Skip to content

Commit

Permalink
follow tinymvt API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ciscorn committed Oct 24, 2024
1 parent 0a8804e commit 0f6ed49
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
6 changes: 2 additions & 4 deletions nusamai/src/sink/mvt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,14 +433,12 @@ fn make_tile(default_detail: i32, serialized_feats: &[Vec<u8>]) -> Result<Vec<u8
}

let mut id = None;
let mut tags: Vec<u32> = Vec::new();

let layer = if let object::Value::Object(obj) = &feature.properties {
let layer = layers.entry_ref(obj.typename.as_ref()).or_default();

// Encode attributes as MVT tags
for (key, value) in &obj.attributes {
convert_properties(&mut tags, &mut layer.tags_enc, key, value);
convert_properties(&mut layer.tags_enc, key, value);
}

// Make a MVT feature id (u64) by hashing the original feature id string.
Expand All @@ -457,7 +455,7 @@ fn make_tile(default_detail: i32, serialized_feats: &[Vec<u8>]) -> Result<Vec<u8

layer.features.push(vector_tile::tile::Feature {
id,
tags,
tags: layer.tags_enc.flush_tags(),
r#type: Some(vector_tile::tile::GeomType::Polygon as i32),
geometry,
});
Expand Down
27 changes: 11 additions & 16 deletions nusamai/src/sink/mvt/tags.rs
Original file line number Diff line number Diff line change
@@ -1,42 +1,37 @@
use nusamai_citygml::object;
use tinymvt::tag::TagsEncoder;

pub fn convert_properties(
tags: &mut Vec<u32>,
tags_enc: &mut TagsEncoder,
name: &str,
tree: &object::Value,
) {
pub fn convert_properties(tags_enc: &mut TagsEncoder, name: &str, tree: &object::Value) {
match &tree {
nusamai_citygml::Value::String(v) => {
tags.extend(tags_enc.add(name, v.clone().into()));
tags_enc.add(name, v.clone().into());
}
nusamai_citygml::Value::Code(v) => {
tags.extend(tags_enc.add(name, v.value().into()));
tags_enc.add(name, v.value().into());
}
nusamai_citygml::Value::Integer(v) => {
tags.extend(tags_enc.add(name, (*v).into()));
tags_enc.add(name, (*v).into());
}
nusamai_citygml::Value::NonNegativeInteger(v) => {
tags.extend(tags_enc.add(name, (*v).into()));
tags_enc.add(name, (*v).into());
}
nusamai_citygml::Value::Double(v) => {
tags.extend(tags_enc.add(name, (*v).into()));
tags_enc.add(name, (*v).into());
}
nusamai_citygml::Value::Measure(v) => {
tags.extend(tags_enc.add(name, v.value().into()));
tags_enc.add(name, v.value().into());
}
nusamai_citygml::Value::Boolean(v) => {
tags.extend(tags_enc.add(name, (*v).into()));
tags_enc.add(name, (*v).into());

Check warning on line 25 in nusamai/src/sink/mvt/tags.rs

View check run for this annotation

Codecov / codecov/patch

nusamai/src/sink/mvt/tags.rs#L25

Added line #L25 was not covered by tests
}
nusamai_citygml::Value::Uri(v) => {
tags.extend(tags_enc.add(name, v.value().to_string().into()));
tags_enc.add(name, v.value().to_string().into());

Check warning on line 28 in nusamai/src/sink/mvt/tags.rs

View check run for this annotation

Codecov / codecov/patch

nusamai/src/sink/mvt/tags.rs#L28

Added line #L28 was not covered by tests
}
nusamai_citygml::Value::Date(v) => {
tags.extend(tags_enc.add(name, v.to_string().into()));
tags_enc.add(name, v.to_string().into());
}
nusamai_citygml::Value::Point(v) => {
tags.extend(tags_enc.add(name, format!("{:?}", v).into())); // FIXME
tags_enc.add(name, format!("{:?}", v).into()); // FIXME

Check warning on line 34 in nusamai/src/sink/mvt/tags.rs

View check run for this annotation

Codecov / codecov/patch

nusamai/src/sink/mvt/tags.rs#L34

Added line #L34 was not covered by tests
}
nusamai_citygml::Value::Array(_arr) => {
// ignore non-root attributes
Expand Down

0 comments on commit 0f6ed49

Please sign in to comment.