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.

6 changes: 6 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ ci-extract-version language tag:
mlt *args:
cargo run --manifest-path {{join(justfile_directory(), 'rust', 'Cargo.toml')}} --package mlt -- "$@"

# Run the mlt CLI tool with the given arguments from current dir.
[no-cd]
[positional-arguments] # avoids shell expansions
mlt-rel *args:
cargo run --release --manifest-path {{join(justfile_directory(), 'rust', 'Cargo.toml')}} --package mlt -- "$@"

# Ensure a command is available
assert-cmd command:
#!/usr/bin/env bash
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ nav:
- Encoding Algorithms: encodings.md
- Specification: specification.md
- Geometry Spec: geometry.md
- Migrating to v2: migrating-to-v2.md

extra:
social:
Expand Down
10 changes: 6 additions & 4 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 @@ -37,8 +38,8 @@ impl<'a> Layer<'a> {
let (input, value) = take(input, size)?;

let layer = match tag {
// For now, we only support tag 0x01 layers, but more will be added soon
1 => Layer::Tag01(Layer01::from_bytes(value, parser)?),
2 => Layer::Tag02(decode_v2_layer(value)?),
tag => Layer::Unknown(Unknown { tag, value }),
};

Expand All @@ -51,7 +52,8 @@ impl<'a> Layer<'a> {
/// `Layer::Tag01(lazy)` and call the individual methods on [`Layer01`].
pub fn decode_all(self, dec: &mut Decoder) -> MltResult<ParsedLayer<'a>> {
match self {
Layer::Tag01(lazy) => Ok(Layer::Tag01(lazy.decode_all(dec)?)),
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
8 changes: 8 additions & 0 deletions rust/mlt-core/src/decoder/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ use crate::{DecodeState, Lazy, Parsed};
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 @@ -26,6 +31,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 Expand Up @@ -116,6 +122,8 @@ pub struct Layer01<'a, S: DecodeState = Lazy> {
pub(crate) layer_order: Vec<crate::decoder::fuzzing::LayerOrdering>,
}

impl StrParse for Layer {}

pub type ParsedLayer01<'a> = Layer01<'a, Parsed>;

impl<'a, S> fmt::Debug for Layer01<'a, S>
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
3 changes: 2 additions & 1 deletion rust/mlt-core/src/utils/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ pub fn assert_empty<T>(result: MltRefResult<T>) -> T {
pub fn into_layer01(layer: Layer) -> Layer01 {
match layer {
Layer::Tag01(layer01) => layer01,
Layer::Unknown(_) => panic!("expected Tag01 layer"),
Layer::Tag02(_) => panic!("expected Tag01 layer, got Tag02"),
Layer::Unknown(_) => panic!("expected Tag01 layer, got Unknown"),
}
}

Expand Down
Loading
Loading