Skip to content

Commit

Permalink
models: i-URまわりの整理など (#80)
Browse files Browse the repository at this point in the history
i-UR 関係のモデルのモジュールなどを少し整理する。一旦 #70 に対してマージする。
  • Loading branch information
ciscorn authored Dec 18, 2023
1 parent 02371d1 commit d6af1a9
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 29 deletions.
6 changes: 4 additions & 2 deletions nusamai-plateau/citygml/src/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use crate::CityGMLElement;
pub use chrono::NaiveDate;
use std::io::BufRead;

pub type Date = chrono::NaiveDate;

impl CityGMLElement for String {
#[inline]
fn parse<R: BufRead>(&mut self, st: &mut SubTreeReader<R>) -> Result<(), ParseError> {
Expand Down Expand Up @@ -166,11 +168,11 @@ impl CityGMLElement for Measure {
}
}

impl CityGMLElement for NaiveDate {
impl CityGMLElement for Date {
#[inline]
fn parse<R: BufRead>(&mut self, st: &mut SubTreeReader<R>) -> Result<(), ParseError> {
let text = st.parse_text()?;
match NaiveDate::parse_from_str(text, "%Y-%m-%d") {
match Date::parse_from_str(text, "%Y-%m-%d") {
Ok(v) => {
*self = v;
Ok(())
Expand Down
38 changes: 26 additions & 12 deletions nusamai-plateau/src/models/cityfurniture.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use super::iur::city_furniture::{CityFurnitureDataQualityAttribute, CityFurnitureDetailAttribute};
use super::iur::urban_object::{
DmAttribute, FacilityAttribute, FacilityIdAttribute, FacilityTypeAttribute,
};
use citygml::{CityGMLElement, Code, GeometryRef};
use super::iur::uro;
use citygml::{CityGMLElement, Code, Date, GeometryRef};

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Default, Debug, CityGMLElement)]
Expand All @@ -13,6 +10,21 @@ pub struct CityFurniture {
#[citygml(path = b"@gml:id")]
id: Option<String>,

#[citygml(path = b"gml:identifier")]
identifier: Option<String>,

#[citygml(path = b"gml:name")]
name: Option<String>,

#[citygml(path = b"gml:description")]
description: Option<String>,

#[citygml(path = b"core:creationDate")]
creation_date: Option<Date>,

#[citygml(path = b"core:terminationDate")]
termination_date: Option<Date>,

#[citygml(path = b"frn:class")]
pub class: Option<Code>,

Expand All @@ -23,20 +35,22 @@ pub struct CityFurniture {
pub usage: Vec<Code>,

#[citygml(path = b"uro:cityFurnitureDetailAttribute")]
pub city_furniture_detail_attribute: Vec<CityFurnitureDetailAttribute>,
pub city_furniture_detail_attribute: Vec<uro::CityFurnitureDetailAttribute>,

#[citygml(path = b"uro:cityFurnitureDataQualityAttribute/uro:CityFurnitureDataQualityAttribute")]
pub city_furniture_data_quality_attribute: Option<CityFurnitureDataQualityAttribute>,
#[citygml(
path = b"uro:cityFurnitureDataQualityAttribute/uro:CityFurnitureDataQualityAttribute"
)]
pub city_furniture_data_quality_attribute: Option<uro::CityFurnitureDataQualityAttribute>,

#[citygml(path = b"uro:frnFacilityTypeAttribute")]
pub frn_facility_type_attribute: Vec<FacilityTypeAttribute>,
pub frn_facility_type_attribute: Vec<uro::FacilityTypeAttribute>,

#[citygml(path = b"uro:frnFacilityIdAttribute")]
pub frn_facility_id_attribute: Option<FacilityIdAttribute>,
pub frn_facility_id_attribute: Option<uro::FacilityIdAttribute>,

#[citygml(path = b"uro:frnFacilityAttribute")]
pub frn_facility_attribute: Vec<FacilityAttribute>,
pub frn_facility_attribute: Vec<uro::FacilityAttribute>,

#[citygml(path = b"uro:frnDmAttribute")]
pub frn_dm_attribute: Vec<DmAttribute>,
pub frn_dm_attribute: Vec<uro::DmAttribute>,
}
11 changes: 4 additions & 7 deletions nusamai-plateau/src/models/iur/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
pub mod landslide;
pub mod underground_building;
pub mod utility_network;
pub mod city_furniture;
pub mod urban_object;
//! i-UR (i-Urban Revitalization) Urban Planning ADE
//!
pub use landslide::SedimentDisasterProneArea;
pub use underground_building::UndergroundBuilding;
pub mod urf;
pub mod uro;
File renamed without changes.
5 changes: 5 additions & 0 deletions nusamai-plateau/src/models/iur/urf/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//! Urban Object Module
mod landslide;

pub use landslide::*;
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ pub struct CityFurnitureDataQualityAttribute {
pub appearance_src_desc: Vec<Code>,

#[citygml(path = b"uro:lodType")]
pub lod_type: Option<String>, // uro:CityFurnitureLODType(enumerations)
pub lod_type: Option<String>, // TODO: uro:CityFurnitureLODType(enumerations)
}
File renamed without changes.
13 changes: 13 additions & 0 deletions nusamai-plateau/src/models/iur/uro/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//! Urban Object Module
mod city_furniture;
mod common;
mod other_construction;
mod underground_building;
mod utility_network;

pub use city_furniture::*;
pub use common::*;
pub use other_construction::*;
pub use underground_building::*;
// pub use utility_network::*;
12 changes: 5 additions & 7 deletions nusamai-plateau/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pub mod cityobjectgroup;
pub mod generics;
pub mod iur;
pub mod landuse;
pub mod other_construction;
pub mod relief;
pub mod transportation;
pub mod tunnel;
Expand All @@ -17,10 +16,9 @@ pub use building::Building;
pub use cityfurniture::CityFurniture;
pub use cityobjectgroup::CityObjectGroup;
pub use generics::GenericCityObject;
pub use iur::landslide::SedimentDisasterProneArea;
pub use iur::underground_building::UndergroundBuilding;
pub use iur::urf;
pub use iur::uro;
pub use landuse::LandUse;
pub use other_construction::OtherConstruction;
pub use relief::ReliefFeature;
pub use transportation::{Railway, Road, Square, Track, Waterway};
pub use tunnel::Tunnel;
Expand Down Expand Up @@ -77,14 +75,14 @@ pub enum CityObject {
// i-UR urban objects
//
#[citygml(path = b"uro:OtherConstruction")]
OtherConstruction(OtherConstruction),
OtherConstruction(uro::OtherConstruction),
#[citygml(path = b"uro:UndergroundBuilding")]
UndergroundBuilding(UndergroundBuilding),
UndergroundBuilding(uro::UndergroundBuilding),
//
// i-UR urban functions
//
#[citygml(path = b"urf:SedimentDisasterProneArea")]
SedimentDisasterProneArea(SedimentDisasterProneArea),
SedimentDisasterProneArea(urf::SedimentDisasterProneArea),
//
// and more ...
}

0 comments on commit d6af1a9

Please sign in to comment.