Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,041 changes: 1,041 additions & 0 deletions docs/migrating-to-v2.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ nav:
- Implementation Status: implementation-status.md
- Encoding Algorithms: encodings.md
- Specification: specification.md
- Migrating to v2: migrating-to-v2.md

extra:
social:
Expand Down
7 changes: 5 additions & 2 deletions rust/mlt-core/src/decoder/layer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::codecs::varint::parse_varint;
use crate::decoder::{Layer01, Unknown};
use crate::utils::{parse_u8, take};
use crate::v2::decode_v2_layer;
use crate::{DecodeState, Decoder, Layer, MltError, MltRefResult, MltResult, ParsedLayer, Parser};

impl<'a, S: DecodeState> Layer<'a, S> {
Expand All @@ -9,7 +10,7 @@ impl<'a, S: DecodeState> Layer<'a, S> {
pub fn as_layer01(&self) -> Option<&Layer01<'a, S>> {
match self {
Self::Tag01(l) => Some(l),
Self::Unknown(_) => None,
_ => None,
}
}

Expand All @@ -18,7 +19,7 @@ impl<'a, S: DecodeState> Layer<'a, S> {
pub fn into_layer01(self) -> Option<Layer01<'a, S>> {
match self {
Self::Tag01(l) => Some(l),
Self::Unknown(_) => None,
_ => None,
}
}
}
Expand All @@ -38,6 +39,7 @@ impl<'a> Layer<'a> {

let layer = match tag {
1 => Layer::Tag01(Layer01::from_bytes(value, parser)?),
2 => Layer::Tag02(decode_v2_layer(value)?),
tag => Layer::Unknown(Unknown { tag, value }),
};

Expand All @@ -51,6 +53,7 @@ impl<'a> Layer<'a> {
pub fn decode_all(self, dec: &mut Decoder) -> MltResult<ParsedLayer<'a>> {
match self {
Layer::Tag01(v) => Ok(Layer::Tag01(v.decode_all(dec)?)),
Layer::Tag02(v) => Ok(Layer::Tag02(v)),
Layer::Unknown(u) => Ok(Layer::Unknown(u)),
}
}
Expand Down
6 changes: 6 additions & 0 deletions rust/mlt-core/src/decoder/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ impl From<Extent> for NonZeroU32 {
pub enum Layer<'a, S: DecodeState = Lazy> {
/// MVT-compatible layer (tag = 1)
Tag01(Layer01<'a, S>),
/// Experimental v2 layer (tag = 2), decoded eagerly to owned row-oriented form.
///
/// Unlike `Tag01`, this variant is always fully decoded when parsed: the
/// `S` type parameter is ignored and the data is stored as a [`TileLayer01`].
Tag02(TileLayer01),
/// Unknown layer with tag, size, and value
Unknown(Unknown<'a>),
}
Expand All @@ -53,6 +58,7 @@ where
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Tag01(l) => f.debug_tuple("Tag01").field(l).finish(),
Self::Tag02(t) => f.debug_tuple("Tag02").field(t).finish(),
Self::Unknown(u) => f.debug_tuple("Unknown").field(u).finish(),
}
}
Expand Down
1 change: 1 addition & 0 deletions rust/mlt-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub(crate) mod decoder;
pub mod encoder;
pub(crate) mod errors;
pub(crate) mod utils;
pub mod v2;

pub use convert::{geojson, mvt};
pub use decoder::{
Expand Down
1 change: 1 addition & 0 deletions rust/mlt-core/src/utils/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub fn assert_empty<T>(result: MltRefResult<T>) -> T {
pub fn into_layer01(layer: Layer) -> Layer01 {
match layer {
Layer::Tag01(v) => v,
Layer::Tag02(_) => panic!("expected Tag01 layer, got Tag02"),
Layer::Unknown(v) => panic!("expected Tag01 layer, got Tag{:02x}", v.tag),
}
}
Expand Down
Loading
Loading