Skip to content

Commit

Permalink
Merge branch 'main' into feature/generic-attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
ciscorn committed Jan 4, 2024
2 parents 5f396e7 + 648f112 commit b7186eb
Show file tree
Hide file tree
Showing 7 changed files with 559,217 additions and 26 deletions.
4 changes: 2 additions & 2 deletions nusamai-citygml/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
use crate::geometry::{self, GeometryRef};
use crate::values::{Code, Point, URI};
use crate::Measure;
use crate::Measure;
use chrono::NaiveDate;
use serde::{Deserialize, Serialize};
use std::iter;

pub type Map = indexmap::IndexMap<String, Value>;

Expand Down Expand Up @@ -122,7 +122,7 @@ mod tests {
let value = obj.to_attribute_json();
assert_eq!(value, json!(true));

let obj = Value::URI(URI::new("http://example.com".into()));
let obj = Value::URI(URI::new("http://example.com"));
let value = obj.to_attribute_json();
assert_eq!(value, json!("http://example.com"));

Expand Down
47 changes: 41 additions & 6 deletions nusamai-citygml/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,9 @@ impl<R: BufRead> SubTreeReader<'_, '_, R> {
MultiSurface => self.parse_multi_surface_prop(geomref, lod)?,
Geometry => self.parse_geometry_prop(geomref, lod)?, // FIXME: not only surfaces
Triangulated => self.parse_triangulated_prop(geomref, lod)?, // FIXME
_ => {
return Err(ParseError::SchemaViolation(format!(
"Unsupported geometry type: lod={}, geomtype={:?}",
lod, &geomtype
)));
}
Point => todo!(),
MultiPoint => todo!(),
MultiCurve => todo!(),
}

self.state
Expand Down Expand Up @@ -769,3 +766,41 @@ fn expect_end<R: BufRead>(reader: &mut NsReader<R>, buf: &mut Vec<u8>) -> Result
}
}
}

#[cfg(test)]
mod tests {
use super::*;

fn parse(doc: &str, f: impl Fn(&mut SubTreeReader<std::io::Cursor<&str>>)) {
let mut reader = quick_xml::NsReader::from_reader(std::io::Cursor::new(doc));
let mut citygml_reader = CityGMLReader::new(ParseContext::default());
let mut subtree_reader = citygml_reader
.start_root(&mut reader)
.expect("Failed to start root");
f(&mut subtree_reader);
}

#[test]
fn parse_text() {
parse(
r#"
<foo>bar</foo>
"#,
|sr| {
assert_eq!(sr.parse_text().unwrap(), "bar");
},
);
}

#[test]
fn parse_text_invalid() {
parse(
r#"
<foo><unexpected></unexpected></foo>
"#,
|sr| {
sr.parse_text().expect_err("error expected");
},
);
}
}
2 changes: 2 additions & 0 deletions nusamai-citygml/src/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub use chrono::NaiveDate;
use serde::{Deserialize, Serialize};
use std::io::BufRead;

// type aliases
// type aliases
pub type Date = chrono::NaiveDate;
pub type Length = Measure; // Length is almost same as Measure
Expand All @@ -13,6 +14,7 @@ pub type GYearMonth = String; // TODO?
pub type MeasureOrNullList = String; // TODO?
pub type BuildingLODType = String; // TODO?
pub type DoubleList = String; // TODO?
pub type LODType = u64; // TODO?

impl CityGMLElement for String {
const ELEMENT_TYPE: ElementType = ElementType::BasicType;
Expand Down
81 changes: 66 additions & 15 deletions nusamai-plateau/src/models/relief.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
use nusamai_citygml::{citygml_feature, citygml_property, CityGMLElement};
use super::iur::uro;
use nusamai_citygml::{citygml_feature, citygml_property, CityGMLElement, LODType};

#[citygml_feature(name = "dem:ReliefFeature")]
pub struct ReliefFeature {
#[citygml(path = b"dem:lod")]
lod: Option<u64>,
#[citygml(path = b"dem:lod", required)]
pub lod: Option<LODType>,

#[citygml(path = b"dem:reliefComponent")]
relief_component: Vec<ReliefComponent>,
#[citygml(path = b"dem:reliefComponent", required)]
pub relief_component: Vec<ReliefComponentProperty>, // -> dem:_ReliefComponent
}

#[citygml_property(name = "dem:ReliefComponentProperty")]
pub enum ReliefComponent {
#[citygml_property(name = "dem:_ReliefComponentProperty")]
pub enum ReliefComponentProperty {
#[citygml(path = b"dem:BreaklineRelief")]
BreaklineRelief(BreaklineRelief),
#[citygml(path = b"dem:MassPointRelief")]
Expand All @@ -21,22 +22,72 @@ pub enum ReliefComponent {
TINRelief(TINRelief),
}

#[citygml_feature(name = "dem:TinRelief")]
pub struct TINRelief {
// ...
}

#[citygml_feature(name = "dem:BreaklineRelief")]
pub struct BreaklineRelief {
// ...
#[citygml(path = b"dem:lod", required)]
pub lod: Option<LODType>,

/* TODO:
#[citygml(path = b"dem:extent/gml:Polygon")]
pub extent: Option<Polygon>,
*/
#[citygml(path = b"uro:demDmAttribute")]
pub dem_dm_attribute: Vec<uro::DmAttributeProperty>,
/* TODO:
#[citygml(path = b"dem:ridgeOrValleyLines/gml:MultiCurve")]
pub ridge_or_valley_lines: Option<MultiCurve>,
#[citygml(path = b"dem:breaklines/gml:MultiCurve")]
pub breaklines: Option<MultiCurve>,
*/
}

#[citygml_feature(name = "dem:MassPointRelief")]
pub struct MassPointRelief {
// ...
#[citygml(path = b"dem:lod", required)]
pub lod: Option<LODType>,

// #[citygml(path = b"dem:extent/gml:Polygon")]
// pub extent: Option<Polygon>,
//
#[citygml(path = b"uro:demDmAttribute")]
pub dem_dm_attribute: Vec<uro::DmAttributeProperty>,
/* TODO:
#[citygml(path = b"dem:reliefPoints/gml:MultiPoint", required)]
pub relief_points: Option<MultiPoint>,
*/
}

#[citygml_feature(name = "dem:RasterRelief")]
pub struct RasterRelief {
// ...
#[citygml(path = b"dem:lod", required)]
pub lod: Option<LODType>,

/* TODO:
#[citygml(path = b"dem:extent/gml:Polygon")]
pub extent: Option<Polygon>,
*/
#[citygml(path = b"uro:demDmAttribute")]
pub dem_dm_attribute: Vec<uro::DmAttributeProperty>,
/* TODO:
#[citygml(path = b"dem:grid/gml:RectifiedGridCoverage", required)]
pub grid: Option<RectifiedGridCoverage>,
*/
}

#[citygml_feature(name = "dem:TINRelief")]
pub struct TINRelief {
#[citygml(path = b"dem:lod", required)]
pub lod: Option<LODType>,

/* TODO:
#[citygml(path = b"dem:extent/gml:Polygon")]
pub extent: Option<Polygon>,
*/
#[citygml(path = b"uro:demDmAttribute")]
pub dem_dm_attribute: Vec<uro::DmAttributeProperty>,
/* TODO:
#[citygml(path = b"dem:tin", required)]
pub tin: Option<tinProperty>, // -> gml:TriangulatedSurface
*/
}
6 changes: 3 additions & 3 deletions nusamai-plateau/tests/data/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
テスト用データ出典

- `53393680_bldg_6697_lod4.2_op.gml`: [3D都市モデル(Project PLATEAU)東京都23区 ポートシティ竹芝 建築物モデル(LOD4)(2022年度)](https://www.geospatial.jp/ckan/dataset/plateau-tokyo23ku-2023-lod4)
- `53391597_frn_6697_op.gml`: [3D都市モデル(Project PLATEAU)川崎市(2022年度)](https://www.geospatial.jp/ckan/dataset/plateau-14130-kawasaki-shi-2022)
- `52385608_tran_6697_op.gml`:[3D都市モデル(Project PLATEAU)沼津市(2021年度)](https://www.geospatial.jp/ckan/dataset/plateau-22203-numazu-shi-2021)
- [3D都市モデル(Project PLATEAU)東京都23区 ポートシティ竹芝 建築物モデル(LOD4)(2022年度)](https://www.geospatial.jp/ckan/dataset/plateau-tokyo23ku-2023-lod4)
- [3D都市モデル(Project PLATEAU)川崎市(2022年度)](https://www.geospatial.jp/ckan/dataset/plateau-14130-kawasaki-shi-2022)
- [3D都市モデル(Project PLATEAU)沼津市(2021年度)](https://www.geospatial.jp/ckan/dataset/plateau-22203-numazu-shi-2021)


Project PLATEAUのサイトポリシーに従って、どなたでも、複製、公衆送信、翻訳・変形等の翻案等、自由に利用できます。商用利用も可能です。 (https://www.mlit.go.jp/plateau/site-policy/)
Loading

0 comments on commit b7186eb

Please sign in to comment.