Skip to content

Commit

Permalink
Fix(plateau): uro まわりの属性の多重度をいくつか修正 (#269)
Browse files Browse the repository at this point in the history
uro
まわりの多重度が誤っているので修正します(XMLスキーマから多重度を判断できないため、自動生成の結果では適切な多重度度になっていなかった)。
  • Loading branch information
ciscorn authored Feb 11, 2024
1 parent efe0d5b commit b5b5dbc
Show file tree
Hide file tree
Showing 19 changed files with 111 additions and 129 deletions.
2 changes: 1 addition & 1 deletion nusamai-citygml/macros/src/type_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fn modify(ty: &Stereotype, args: &FeatureArgs, input: &mut DeriveInput) -> Resul
fields,
quote! {
#[citygml(geom = #geom_prefix)]
pub geometries: ::nusamai_citygml::GeometryRef
pub geometries: ::nusamai_citygml::GeometryRefs
},
);
pos += 1;
Expand Down
10 changes: 5 additions & 5 deletions nusamai-citygml/src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ pub enum GeometryType {

#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct GeometryRefEntry {
pub struct GeometryRef {
#[serde(rename = "type")]
pub ty: GeometryType,
pub lod: u8,
pub pos: u32,
pub len: u32,
}

pub type GeometryRef = Vec<GeometryRefEntry>;
pub type GeometryRefs = Vec<GeometryRef>;

/// Geometries in a single city object and all its children.
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
Expand All @@ -52,11 +52,11 @@ pub struct GeometryStore {
/// Shared vertex buffer for all geometries
pub vertices: Vec<[f64; 3]>,

/// All polygons, referenced by `GeometryRef`
/// All polygons, referenced by `GeometryRefs`
pub multipolygon: MultiPolygon<'static, 1, u32>,
/// All line-strings, referenced by `GeometryRef`
/// All line-strings, referenced by `GeometryRefs`
pub multilinestring: MultiLineString<'static, 1, u32>,
/// All points, referenced by `GeometryRef`
/// All points, referenced by `GeometryRefs`
pub multipoint: MultiPoint<'static, 1, u32>,

/// Ring ids of the all polygons
Expand Down
11 changes: 8 additions & 3 deletions nusamai-citygml/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::borrow::Cow;

use crate::geometry::GeometryRef;
use crate::geometry::GeometryRefs;
use crate::values::{Code, Date, Point, URI};
use crate::Measure;
use serde::{Deserialize, Serialize};
Expand All @@ -19,8 +19,13 @@ pub struct Object {

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum ObjectStereotype {
Feature { id: String, geometries: GeometryRef },
Object { id: String },
Feature {
id: String,
geometries: GeometryRefs,
},
Object {
id: String,
},
Data,
}

Expand Down
25 changes: 12 additions & 13 deletions nusamai-citygml/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use url::Url;
use crate::appearance::{TexCoordList, TextureAssociation};
use crate::codelist::{self, CodeResolver};
use crate::geometry::{
GeometryCollector, GeometryParseType, GeometryRef, GeometryRefEntry, GeometryStore,
GeometryType,
GeometryCollector, GeometryParseType, GeometryRef, GeometryRefs, GeometryStore, GeometryType,
};
use crate::namespace::{wellknown_prefix_from_nsres, APP_2_NS, GML31_NS};
use crate::{CityGmlAttribute, LocalId, SurfaceSpan};
Expand Down Expand Up @@ -323,7 +322,7 @@ impl<'b, R: BufRead> SubTreeReader<'_, 'b, R> {
/// Expect a geometric attribute of CityGML
pub fn parse_geometric_attr(
&mut self,
geomref: &mut GeometryRef,
geomref: &mut GeometryRefs,
lod: u8,
geomtype: GeometryParseType,
) -> Result<(), ParseError> {
Expand Down Expand Up @@ -353,7 +352,7 @@ impl<'b, R: BufRead> SubTreeReader<'_, 'b, R> {

fn parse_multi_surface_prop(
&mut self,
geomrefs: &mut GeometryRef,
geomrefs: &mut GeometryRefs,
lod: u8,
) -> Result<(), ParseError> {
let mut surface_id = None;
Expand Down Expand Up @@ -388,7 +387,7 @@ impl<'b, R: BufRead> SubTreeReader<'_, 'b, R> {

let poly_end = self.state.geometry_collector.multipolygon.len();
if poly_end - poly_begin > 0 {
geomrefs.push(GeometryRefEntry {
geomrefs.push(GeometryRef {
ty: geomtype,
lod,
pos: poly_begin as u32,
Expand Down Expand Up @@ -423,14 +422,14 @@ impl<'b, R: BufRead> SubTreeReader<'_, 'b, R> {

fn parse_surface_prop(
&mut self,
geomrefs: &mut GeometryRef,
geomrefs: &mut GeometryRefs,
lod: u8,
) -> Result<(), ParseError> {
let poly_begin = self.state.geometry_collector.multipolygon.len();
self.parse_surface()?;
let poly_end = self.state.geometry_collector.multipolygon.len();
if poly_end - poly_begin > 0 {
geomrefs.push(GeometryRefEntry {
geomrefs.push(GeometryRef {
ty: GeometryType::Surface,
lod,
pos: poly_begin as u32,
Expand All @@ -440,7 +439,7 @@ impl<'b, R: BufRead> SubTreeReader<'_, 'b, R> {
Ok(())
}

fn parse_solid_prop(&mut self, geomrefs: &mut GeometryRef, lod: u8) -> Result<(), ParseError> {
fn parse_solid_prop(&mut self, geomrefs: &mut GeometryRefs, lod: u8) -> Result<(), ParseError> {
let poly_begin = self.state.geometry_collector.multipolygon.len();

if expect_start(self.reader, &mut self.state.buf1, GML31_NS, b"Solid")? {
Expand All @@ -450,7 +449,7 @@ impl<'b, R: BufRead> SubTreeReader<'_, 'b, R> {

let poly_end = self.state.geometry_collector.multipolygon.len();
if poly_end - poly_begin > 0 {
geomrefs.push(GeometryRefEntry {
geomrefs.push(GeometryRef {
ty: GeometryType::Solid,
lod,
pos: poly_begin as u32,
Expand All @@ -462,7 +461,7 @@ impl<'b, R: BufRead> SubTreeReader<'_, 'b, R> {

fn parse_geometry_prop(
&mut self,
geomrefs: &mut GeometryRef,
geomrefs: &mut GeometryRefs,
lod: u8,
) -> Result<(), ParseError> {
let mut surface_id = None;
Expand Down Expand Up @@ -525,7 +524,7 @@ impl<'b, R: BufRead> SubTreeReader<'_, 'b, R> {

let poly_end = self.state.geometry_collector.multipolygon.len();
if poly_end - poly_begin > 0 {
geomrefs.push(GeometryRefEntry {
geomrefs.push(GeometryRef {
ty: geomtype,
lod,
pos: poly_begin as u32,
Expand Down Expand Up @@ -560,7 +559,7 @@ impl<'b, R: BufRead> SubTreeReader<'_, 'b, R> {

fn parse_triangulated_prop(
&mut self,
geomrefs: &mut GeometryRef,
geomrefs: &mut GeometryRefs,
lod: u8,
) -> Result<(), ParseError> {
let poly_begin = self.state.geometry_collector.multipolygon.len();
Expand Down Expand Up @@ -595,7 +594,7 @@ impl<'b, R: BufRead> SubTreeReader<'_, 'b, R> {

let poly_end = self.state.geometry_collector.multipolygon.len();
if poly_end - poly_begin > 0 {
geomrefs.push(GeometryRefEntry {
geomrefs.push(GeometryRef {
ty: GeometryType::Triangle,
lod,
pos: poly_begin as u32,
Expand Down
16 changes: 8 additions & 8 deletions nusamai-plateau/src/models/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct Bridge {
pub address: Vec<Address>,

#[citygml(path = b"uro:bridBaseAttribute/uro:ConstructionBaseAttribute")]
pub brid_base_attribute: Vec<uro::ConstructionBaseAttribute>,
pub brid_base_attribute: Option<uro::ConstructionBaseAttribute>,

#[citygml(path = b"uro:bridDataQualityAttribute/uro:ConstructionDataQualityAttribute")]
pub brid_data_quality_attribute: Option<uro::ConstructionDataQualityAttribute>,
Expand All @@ -65,13 +65,13 @@ pub struct Bridge {
pub brid_facility_type_attribute: Vec<uro::FacilityTypeAttribute>,

#[citygml(path = b"uro:bridFunctionalAttribute/uro:BridgeFunctionalAttribute")]
pub brid_functional_attribute: Vec<uro::BridgeFunctionalAttribute>,
pub brid_functional_attribute: Option<uro::BridgeFunctionalAttribute>,

#[citygml(path = b"uro:bridRiskAssessmentAttribute/uro:ConstructionRiskAssessmentAttribute")]
pub brid_risk_assessment_attribute: Vec<uro::ConstructionRiskAssessmentAttribute>,
pub brid_risk_assessment_attribute: Option<uro::ConstructionRiskAssessmentAttribute>,

#[citygml(path = b"uro:bridStructureAttribute/uro:BridgeStructureAttribute")]
pub brid_structure_attribute: Vec<uro::BridgeStructureAttribute>,
pub brid_structure_attribute: Option<uro::BridgeStructureAttribute>,
}

#[citygml_feature(name = "brid:BridgePart")]
Expand Down Expand Up @@ -116,7 +116,7 @@ pub struct BridgePart {
pub address: Vec<Address>,

#[citygml(path = b"uro:bridBaseAttribute/uro:ConstructionBaseAttribute")]
pub brid_base_attribute: Vec<uro::ConstructionBaseAttribute>,
pub brid_base_attribute: Option<uro::ConstructionBaseAttribute>,

#[citygml(path = b"uro:bridDataQualityAttribute/uro:ConstructionDataQualityAttribute")]
pub brid_data_quality_attribute: Option<uro::ConstructionDataQualityAttribute>,
Expand All @@ -137,13 +137,13 @@ pub struct BridgePart {
pub brid_facility_type_attribute: Vec<uro::FacilityTypeAttribute>,

#[citygml(path = b"uro:bridFunctionalAttribute/uro:BridgeFunctionalAttribute")]
pub brid_functional_attribute: Vec<uro::BridgeFunctionalAttribute>,
pub brid_functional_attribute: Option<uro::BridgeFunctionalAttribute>,

#[citygml(path = b"uro:bridRiskAssessmentAttribute/uro:ConstructionRiskAssessmentAttribute")]
pub brid_risk_assessment_attribute: Vec<uro::ConstructionRiskAssessmentAttribute>,
pub brid_risk_assessment_attribute: Option<uro::ConstructionRiskAssessmentAttribute>,

#[citygml(path = b"uro:bridStructureAttribute/uro:BridgeStructureAttribute")]
pub brid_structure_attribute: Vec<uro::BridgeStructureAttribute>,
pub brid_structure_attribute: Option<uro::BridgeStructureAttribute>,
}

#[citygml_feature(name = "brid:BridgeConstructionElement")]
Expand Down
4 changes: 2 additions & 2 deletions nusamai-plateau/src/models/building.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub struct Building {
pub building_disaster_risk_attribute: Vec<uro::BuildingDisasterRiskAttributeProperty>, // -> uro:BuildingDisasterRiskAttribute

#[citygml(path = b"uro:buildingIDAttribute/uro:BuildingIDAttribute")]
pub building_id_attribute: Vec<uro::BuildingIDAttribute>,
pub building_id_attribute: Option<uro::BuildingIDAttribute>,

#[citygml(path = b"uro:ifcBuildingAttribute")]
pub ifc_building_attribute: Vec<uro::IfcAttributeProperty>, // -> uro:IfcAttribute
Expand Down Expand Up @@ -176,7 +176,7 @@ pub struct BuildingPart {
pub building_disaster_risk_attribute: Vec<uro::BuildingDisasterRiskAttributeProperty>, // -> uro:BuildingDisasterRiskAttribute

#[citygml(path = b"uro:buildingIDAttribute/uro:BuildingIDAttribute")]
pub building_id_attribute: Vec<uro::BuildingIDAttribute>,
pub building_id_attribute: Option<uro::BuildingIDAttribute>,

#[citygml(path = b"uro:ifcBuildingAttribute")]
pub ifc_building_attribute: Vec<uro::IfcAttributeProperty>, // -> uro:IfcAttribute
Expand Down
2 changes: 1 addition & 1 deletion nusamai-plateau/src/models/iur/uro/dm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub struct DmAnnotation {
#[citygml_data(name = "uro:DmGeometricAttribute")]
pub struct DmGeometricAttribute {
#[citygml(geom = b"uro")]
pub geometries: nusamai_citygml::GeometryRef,
pub geometries: nusamai_citygml::GeometryRefs,

#[citygml(path = b"uro:dmCode", required)]
pub dm_code: Option<Code>,
Expand Down
2 changes: 1 addition & 1 deletion nusamai-plateau/src/models/iur/uro/transportation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub struct RoadType {
#[citygml_data(name = "uro:RailwayTrackAttribute")]
pub struct RailwayTrackAttribute {
#[citygml(geom = b"uro")]
geometries: nusamai_citygml::GeometryRef,
geometries: nusamai_citygml::GeometryRefs,

#[citygml(path = b"uro:routeName")]
pub route_name: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion nusamai-plateau/src/models/landuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct LandUse {
pub ifc_land_use_attribute: Vec<uro::IfcAttributeProperty>, // -> uro:IfcAttribute

#[citygml(path = b"uro:landUseDetailAttribute/uro:LandUseDetailAttribute")]
pub land_use_detail_attribute: Vec<uro::LandUseDetailAttribute>,
pub land_use_detail_attribute: Option<uro::LandUseDetailAttribute>,

#[citygml(path = b"uro:luseDataQualityAttribute/uro:LandUseDataQualityAttribute")]
pub luse_data_quality_attribute: Option<uro::LandUseDataQualityAttribute>,
Expand Down
12 changes: 6 additions & 6 deletions nusamai-plateau/src/models/transportation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ pub struct Road {
pub road_status: Vec<uro::RoadType>,

#[citygml(path = b"uro:roadStructureAttribute/uro:RoadStructureAttribute")]
pub road_structure_attribute: Vec<uro::RoadStructureAttribute>,
pub road_structure_attribute: Option<uro::RoadStructureAttribute>,

#[citygml(path = b"uro:trafficVolumeAttribute/uro:TrafficVolumeAttribute")]
pub traffic_volume_attribute: Vec<uro::TrafficVolumeAttribute>,
pub traffic_volume_attribute: Option<uro::TrafficVolumeAttribute>,
}

#[citygml_feature(name = "tran:Railway")]
Expand Down Expand Up @@ -77,7 +77,7 @@ pub struct Railway {
pub tran_facility_type_attribute: Vec<uro::FacilityTypeAttribute>,

#[citygml(path = b"uro:railwayRouteAttribute/uro:RailwayRouteAttribute")]
pub railway_route_attribute: Vec<uro::RailwayRouteAttribute>,
pub railway_route_attribute: Option<uro::RailwayRouteAttribute>,
}

#[citygml_feature(name = "tran:Track")]
Expand Down Expand Up @@ -113,7 +113,7 @@ pub struct Track {
pub tran_facility_type_attribute: Vec<uro::FacilityTypeAttribute>,

#[citygml(path = b"uro:trackAttribute/uro:TrackAttribute")]
pub track_attribute: Vec<uro::TrackAttribute>,
pub track_attribute: Option<uro::TrackAttribute>,
}

#[citygml_feature(name = "tran:Square")]
Expand Down Expand Up @@ -149,7 +149,7 @@ pub struct Square {
pub tran_facility_type_attribute: Vec<uro::FacilityTypeAttribute>,

#[citygml(path = b"uro:squareUrbanPlanAttribute")]
pub square_urban_plan_attribute: Vec<uro::SquareUrbanPlanAttributeProperty>, // -> uro:SquareUrbanPlanAttribute
pub square_urban_plan_attribute: Option<uro::SquareUrbanPlanAttributeProperty>, // -> uro:SquareUrbanPlanAttribute
}

/// uro:Waterway (PLATEAU, CityGML 2.x)
Expand Down Expand Up @@ -211,7 +211,7 @@ pub struct TrafficArea {
pub railway_track_attribute: Vec<uro::RailwayTrackAttribute>,

#[citygml(path = b"uro:trafficAreaStructureAttribute/uro:TrafficAreaStructureAttribute")]
pub traffic_area_structure_attribute: Vec<uro::TrafficAreaStructureAttribute>,
pub traffic_area_structure_attribute: Option<uro::TrafficAreaStructureAttribute>,
}

#[citygml_feature(name = "tran:AuxiliaryTrafficArea")]
Expand Down
16 changes: 8 additions & 8 deletions nusamai-plateau/src/models/tunnel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct Tunnel {
pub consists_of_tunnel_part: Vec<TunnelPart>,

#[citygml(path = b"uro:tunBaseAttribute/uro:ConstructionBaseAttribute")]
pub tun_base_attribute: Vec<uro::ConstructionBaseAttribute>,
pub tun_base_attribute: Option<uro::ConstructionBaseAttribute>,

#[citygml(path = b"uro:tunDataQualityAttribute/uro:ConstructionDataQualityAttribute")]
pub tun_data_quality_attribute: Option<uro::ConstructionDataQualityAttribute>,
Expand All @@ -55,13 +55,13 @@ pub struct Tunnel {
pub tun_facility_type_attribute: Vec<uro::FacilityTypeAttribute>,

#[citygml(path = b"uro:tunFunctionalAttribute/uro:TunnelFunctionalAttribute")]
pub tun_functional_attribute: Vec<uro::TunnelFunctionalAttribute>,
pub tun_functional_attribute: Option<uro::TunnelFunctionalAttribute>,

#[citygml(path = b"uro:tunRiskAssessmentAttribute/uro:ConstructionRiskAssessmentAttribute")]
pub tun_risk_assessment_attribute: Vec<uro::ConstructionRiskAssessmentAttribute>,
pub tun_risk_assessment_attribute: Option<uro::ConstructionRiskAssessmentAttribute>,

#[citygml(path = b"uro:tunStructureAttribute/uro:TunnelStructureAttribute")]
pub tun_structure_attribute: Vec<uro::TunnelStructureAttribute>,
pub tun_structure_attribute: Option<uro::TunnelStructureAttribute>,
}

#[citygml_feature(name = "tun:TunnelPart")]
Expand Down Expand Up @@ -97,7 +97,7 @@ pub struct TunnelPart {
pub consists_of_tunnel_part: Vec<TunnelPart>,

#[citygml(path = b"uro:tunBaseAttribute/uro:ConstructionBaseAttribute")]
pub tun_base_attribute: Vec<uro::ConstructionBaseAttribute>,
pub tun_base_attribute: Option<uro::ConstructionBaseAttribute>,

#[citygml(path = b"uro:tunDataQualityAttribute/uro:ConstructionDataQualityAttribute")]
pub tun_data_quality_attribute: Option<uro::ConstructionDataQualityAttribute>,
Expand All @@ -118,13 +118,13 @@ pub struct TunnelPart {
pub tun_facility_type_attribute: Vec<uro::FacilityTypeAttribute>,

#[citygml(path = b"uro:tunFunctionalAttribute/uro:TunnelFunctionalAttribute")]
pub tun_functional_attribute: Vec<uro::TunnelFunctionalAttribute>,
pub tun_functional_attribute: Option<uro::TunnelFunctionalAttribute>,

#[citygml(path = b"uro:tunRiskAssessmentAttribute/uro:ConstructionRiskAssessmentAttribute")]
pub tun_risk_assessment_attribute: Vec<uro::ConstructionRiskAssessmentAttribute>,
pub tun_risk_assessment_attribute: Option<uro::ConstructionRiskAssessmentAttribute>,

#[citygml(path = b"uro:tunStructureAttribute/uro:TunnelStructureAttribute")]
pub tun_structure_attribute: Vec<uro::TunnelStructureAttribute>,
pub tun_structure_attribute: Option<uro::TunnelStructureAttribute>,
}

#[citygml_feature(name = "tun:HollowSpace")]
Expand Down
2 changes: 1 addition & 1 deletion nusamai-plateau/src/models/waterbody.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct WaterBody {
pub flooding_risk_attribute: Vec<uro::WaterBodyFloodingRiskAttributeProperty>, // -> uro:WaterBodyFloodingRiskAttribute

#[citygml(path = b"uro:waterBodyDetailAttribute/uro:WaterBodyDetailAttribute")]
pub water_body_detail_attribute: Vec<uro::WaterBodyDetailAttribute>,
pub water_body_detail_attribute: Option<uro::WaterBodyDetailAttribute>,

#[citygml(path = b"uro:wtrDmAttribute")]
pub wtr_dm_attribute: Vec<uro::DmAttributeProperty>, // -> uro:DmAttribute
Expand Down
Loading

0 comments on commit b5b5dbc

Please sign in to comment.