Skip to content

Commit

Permalink
resolve conflict of nusamai/Cargo.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
sato-toshifumi committed Jan 15, 2024
2 parents 6d45717 + e38d1c5 commit e30a1f5
Show file tree
Hide file tree
Showing 356 changed files with 2,299,443 additions and 21,723 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.gml linguist-detectable=false
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ Network Trash Folder
Temporary Items
.apdisk


# emacs buckup files
*~
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
- [`macros`](./nusamai-plateau/citygml/macros/) — パーサ導出用の proc macros
- 変換先形式のためのライブラリ:
- [`nusamai-3dtiles`](./nusamai-3dtiles/) — 3D Tiles
- [`nusamai-mvt`](./nusamai-mvt/) — Mapbox Vector Tile (MVT)
- [`nusamai-mvt`](./nusamai-mvt/) — Mapbox Vector Tiles (MVT)
- [`nusamai-gpkg`](./nusamai-gpkg/) — GeoPackage
- [`nusamai-gltf`](./nusamai-gltf/) — glTF
- [`nusamai-geojson`](./nusamai-geojson/) — GeoJSON
Expand Down
37 changes: 7 additions & 30 deletions app/README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,15 @@
# create-svelte
# app

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
## Development

## Creating a project
Tauri dev:

If you're seeing this, you've probably already done this step. Congrats!

```bash
# create a new project in the current directory
npm create svelte@latest

# create a new project in my-app
npm create svelte@latest my-app
```console
RUST_BACKTRACE=1 npx tauri dev
```

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
Tauri build:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

To create a production version of your app:

```bash
npm run build
npx tauri build
```

You can preview the production build with `npm run preview`.

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
6 changes: 3 additions & 3 deletions app/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use std::sync::{Arc, Mutex};
use nusamai::pipeline::Canceller;
use nusamai::sink::DataSinkProvider;
use nusamai::sink::{
geojson::GeoJsonSinkProvider, gpkg::GpkgSinkProvider, serde::SerdeSinkProvider,
tiling2d::Tiling2DSinkProvider,
geojson::GeoJsonSinkProvider, gpkg::GpkgSinkProvider, mvt::MVTSinkProvider,
serde::SerdeSinkProvider,
};
use nusamai::source::citygml::CityGMLSourceProvider;
use nusamai::source::DataSourceProvider;
Expand Down Expand Up @@ -52,7 +52,7 @@ fn run(input_path: String, output_path: String, filetype: String) {
"GeoJSON" => Box::new(GeoJsonSinkProvider {}),
"GeoPackage" => Box::new(GpkgSinkProvider {}),
"Serde" => Box::new(SerdeSinkProvider {}),
"Tiling2D" => Box::new(Tiling2DSinkProvider {}),
"Vector Tiles" => Box::new(MVTSinkProvider {}),
_ => {
log::error!("Unknown filetype: {}", filetype);
return;
Expand Down
2 changes: 1 addition & 1 deletion app/src/lib/settings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const fileTypeOptions = ['GeoJSON', 'GeoPackage', 'Serde', 'Tiling2D'];
const fileTypeOptions = ['GeoJSON', 'GeoPackage', 'Serde', 'Vector Tiles'];

const crsOptions = [
{ value: 'EPSG:6678', label: 'JGD2011 / Japan Plane Rectangular CS X' },
Expand Down
2 changes: 1 addition & 1 deletion nusamai-citygml/macros/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct FooBarFeature {
id: Option<String>,

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

#[citygml(path = b"gml:description")]
description: Option<String>,
Expand Down
41 changes: 36 additions & 5 deletions nusamai-citygml/macros/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ fn generate_citygml_impl_for_struct(
});
};

add_arm(0, b"lod0Point", "Point"); // only in CityGML 2.0
add_arm(0, b"lod0RoofEdge", "MultiSurface"); // only in CityGML 2.0
add_arm(0, b"lod0FootPrint", "MultiSurface"); // only in CityGML 2.0
add_arm(0, b"lod0Point", "Point");
add_arm(0, b"lod0MultiCurve", "MultiCurve");
add_arm(2, b"lod2MultiCurve", "MultiCurve");
add_arm(3, b"lod3MultiCurve", "MultiCurve");
Expand All @@ -196,7 +194,33 @@ fn generate_citygml_impl_for_struct(
add_arm(2, b"lod2Geometry", "Geometry"); // only in CityGML 2.0
add_arm(3, b"lod3Geometry", "Geometry"); // only in CityGML 2.0
add_arm(4, b"lod4Geometry", "Geometry"); // only in CityGML 2.0
add_arm(0, b"tin", "Triangulated");

// only in CityGML 2.0
match &prefix.value()[..] {
b"bldg" => {
add_arm(0, b"lod0RoofEdge", "MultiSurface");
add_arm(0, b"lod0FootPrint", "MultiSurface");
}
b"tran" => {
add_arm( 0, b"lod0Network", "MultiCurve");
}
b"uro" => {
if typename.as_str() == "uro:RailwayTrackAttribute" {
add_arm(2, b"lod2Network", "MultiCurve");
add_arm(3, b"lod3Network", "MultiCurve");
}
}
b"wtr" => {
add_arm( 2, b"lod2Surface", "Surface");
add_arm( 3, b"lod3Surface", "Surface");
}
b"dem" => {
add_arm( 0, b"tin", "Triangulated");
}
// lod*TerrainIntersection
// lod*ImplicitRepresentation
_ => {}
}

geom_into_object_expr = quote! {
Some(self.#field_ident)
Expand All @@ -213,6 +237,13 @@ fn generate_citygml_impl_for_struct(
b"gen:stringAttribute" => <#field_ty as CityGMLElement>::parse(&mut self.#field_ident, st),
b"gen:uriAttribute" => <#field_ty as CityGMLElement>::parse(&mut self.#field_ident, st),
});
into_object_stmts.push(
quote! {
if let Some(v) = self.#field_ident.into_object() {
attributes.insert("gen:genericAttribute".into(), v);
}
}
);
Ok(())
} else {
Err(meta.error("unrecognized argument"))
Expand Down Expand Up @@ -276,7 +307,7 @@ fn generate_citygml_impl_for_struct(
true => quote! { Ok(()) },
false => quote! {
Err(::nusamai_citygml::ParseError::SchemaViolation(
format!("unexpected element: {}", String::from_utf8_lossy(st.current_path())),
format!("unexpected element: {}", String::from_utf8_lossy(st.current_absolute_path())),
))
},
};
Expand Down
22 changes: 21 additions & 1 deletion nusamai-citygml/macros/src/type_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,30 @@ fn modify(ty: &StereoType, args: &FeatureArgs, input: &mut DeriveInput) -> Resul
// for #[citygml_feature]

let prefix = args.prefix.as_ref().unwrap();

// temporary hack
let geom_prefix = match args.name.as_ref().unwrap().value().as_str() {
"uro:UndergroundBuilding" => LitByteStr::new(b"bldg", prefix.span()),
"uro:Waterway" => LitByteStr::new(b"tran", prefix.span()),
"uro:Appurtenance" => LitByteStr::new(b"frn", prefix.span()),
"uro:Manhole" => LitByteStr::new(b"frn", prefix.span()),
"uro:Handhole" => LitByteStr::new(b"frn", prefix.span()),
"uro:Pipe" => LitByteStr::new(b"frn", prefix.span()),
"uro:WaterPipe" => LitByteStr::new(b"frn", prefix.span()),
"uro:SewerPipe" => LitByteStr::new(b"frn", prefix.span()),
"uro:OilGasChemicalsPipe" => LitByteStr::new(b"frn", prefix.span()),
"uro:ThermalPipe" => LitByteStr::new(b"frn", prefix.span()),
"uro:Cable" => LitByteStr::new(b"frn", prefix.span()),
"uro:ElectricityCable" => LitByteStr::new(b"frn", prefix.span()),
"uro:TelecommunicationsCable" => LitByteStr::new(b"frn", prefix.span()),
"uro:Duct" => LitByteStr::new(b"frn", prefix.span()),
_ => prefix.clone(),
};

add_named_field(
fields,
quote! {
#[citygml(geom = #prefix)]
#[citygml(geom = #geom_prefix)]
pub geometries: nusamai_citygml::GeometryRef
},
);
Expand Down
3 changes: 2 additions & 1 deletion nusamai-citygml/src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub enum GeometryParseType {
MultiSurface,
MultiCurve,
MultiPoint,
Surface,
Point,
Triangulated,
}
Expand All @@ -25,7 +26,7 @@ pub enum GeometryType {
}

#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[derive(Debug, PartialEq)]
#[derive(Debug, Clone, PartialEq)]
pub struct GeometryRefEntry {
#[serde(rename = "type")]
pub ty: GeometryType,
Expand Down
12 changes: 7 additions & 5 deletions nusamai-citygml/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ pub struct CityObject {
pub geometries: geometry::GeometryStore,
}

#[derive(Debug, Serialize, Deserialize, PartialEq)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Feature {
pub typename: Cow<'static, str>,
pub id: Option<String>,
pub attributes: Map,
pub geometries: Option<GeometryRef>,
}

#[derive(Debug, Serialize, Deserialize, PartialEq)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Data {
pub typename: Cow<'static, str>,
pub attributes: Map,
}

/// Nodes for the "Object" representation of the city object.
#[derive(Debug, Serialize, Deserialize, PartialEq)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum Value {
String(String),
Code(Code),
Expand All @@ -57,7 +57,9 @@ impl Value {
Code(c) => serde_json::Value::String(c.value().to_owned()),
Integer(i) => serde_json::Value::Number((*i).into()),
Double(d) => serde_json::Value::Number(serde_json::Number::from_f64(*d).unwrap()),
Measure(m) => serde_json::Value::Number(serde_json::Number::from_f64(m.value).unwrap()),
Measure(m) => {
serde_json::Value::Number(serde_json::Number::from_f64(m.value()).unwrap())
}
Boolean(b) => serde_json::Value::Bool(*b),
URI(u) => serde_json::Value::String(u.value().clone()),
Date(d) => serde_json::Value::String(d.to_string()), // ISO 8601
Expand Down Expand Up @@ -115,7 +117,7 @@ mod tests {
let obj = Value::Double(1.0);
assert_eq!(obj.to_attribute_json(), json!(1.0));

let obj = Value::Measure(Measure { value: 1.0 });
let obj = Value::Measure(Measure::new(1.0));
assert_eq!(obj.to_attribute_json(), json!(1.0));

let obj = Value::Boolean(true);
Expand Down
67 changes: 48 additions & 19 deletions nusamai-citygml/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,22 @@ impl<R: BufRead> SubTreeReader<'_, '_, R> {
match geomtype {
Solid => self.parse_solid_prop(geomref, lod)?,
MultiSurface => self.parse_multi_surface_prop(geomref, lod)?,
Surface => self.parse_surface_prop(geomref, lod)?, // FIXME
Geometry => self.parse_geometry_prop(geomref, lod)?, // FIXME: not only surfaces
Triangulated => self.parse_triangulated_prop(geomref, lod)?, // FIXME
Point => todo!(), // FIXME
MultiPoint => todo!(), // FIXME
MultiCurve => todo!(), // FIXME
Point => todo!(), // FIXME
MultiPoint => todo!(), // FIXME
MultiCurve => {
log::warn!("CompositeCurve is not supported yet.");
self.skip_current_element()?;
return Ok(());
} // FIXME
}

self.state
.path_buf
.truncate(self.state.path_stack_indices.pop().unwrap());

Ok(())
}

Expand Down Expand Up @@ -349,6 +355,25 @@ impl<R: BufRead> SubTreeReader<'_, '_, R> {
Ok(())
}

fn parse_surface_prop(
&mut self,
geomrefs: &mut GeometryRef,
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 {
ty: GeometryType::Surface,
lod,
pos: poly_begin as u32,
len: (poly_end - poly_begin) as u32,
});
}
Ok(())
}

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

Expand Down Expand Up @@ -394,25 +419,29 @@ impl<R: BufRead> SubTreeReader<'_, '_, R> {
GeometryType::Surface
}
(Bound(GML31_NS), b"OrientableSurface") => todo!(),
(Bound(GML31_NS), b"Polygon") => todo!(),
(Bound(GML31_NS), b"Polygon") => {
self.parse_polygon()?;
GeometryType::Surface
}
(Bound(GML31_NS), b"TriangulatedSurface") => todo!(),
(Bound(GML31_NS), b"Tin") => todo!(),
(Bound(GML31_NS), b"LineString") => {
// FIXME, TODO
log::warn!("LineString is not supported yet.");
self.skip_current_element()?; // FIXME, TODO
GeometryType::Curve
} // FIXME:
(Bound(GML31_NS), b"MultiCurve") => {
(
Bound(GML31_NS),
b"Point" | b"CompositeCurve" | b"MultiCurve" | b"LineString",
) => {
// FIXME, TODO
log::warn!("MultiCurve is not supported yet.");
self.skip_current_element()?; // FIXME, TODO
log::warn!(
"Point|CompositeCurve|MultiCurve|LineString is not supported yet."
);
self.reader
.read_to_end_into(start.name(), &mut self.state.buf2)?;

GeometryType::Curve
} // FIXME:
_ => {
return Err(ParseError::SchemaViolation(format!(
"Unexpected element <{}>",
String::from_utf8_lossy(localname.as_ref())
"Unexpected geometry elements <{}>",
String::from_utf8_lossy(start.name().as_ref())
)))
}
};
Expand Down Expand Up @@ -489,7 +518,7 @@ impl<R: BufRead> SubTreeReader<'_, '_, R> {

fn parse_solid(&mut self) -> Result<(), ParseError> {
if expect_start(self.reader, &mut self.state.buf1, GML31_NS, b"exterior")? {
self.parse_surface_prop()?;
self.parse_surface()?;
expect_end(self.reader, &mut self.state.buf1)?;
}
Ok(())
Expand Down Expand Up @@ -541,7 +570,7 @@ impl<R: BufRead> SubTreeReader<'_, '_, R> {
Ok(Event::Start(start)) => {
let (nsres, localname) = self.reader.resolve_element(start.name());
match (nsres, localname.as_ref()) {
(Bound(GML31_NS), b"surfaceMember") => self.parse_surface_prop()?,
(Bound(GML31_NS), b"surfaceMember") => self.parse_surface()?,
_ => return Err(ParseError::SchemaViolation("Unexpected element".into())),
}
}
Expand All @@ -563,7 +592,7 @@ impl<R: BufRead> SubTreeReader<'_, '_, R> {
Ok(Event::Start(start)) => {
let (nsres, localname) = self.reader.resolve_element(start.name());
match (nsres, localname.as_ref()) {
(Bound(GML31_NS), b"surfaceMember") => self.parse_surface_prop()?,
(Bound(GML31_NS), b"surfaceMember") => self.parse_surface()?,
_ => {
return Err(ParseError::SchemaViolation(format!(
"Unexpected element <{}>",
Expand All @@ -584,7 +613,7 @@ impl<R: BufRead> SubTreeReader<'_, '_, R> {
}
}

fn parse_surface_prop(&mut self) -> Result<(), ParseError> {
fn parse_surface(&mut self) -> Result<(), ParseError> {
loop {
match self.reader.read_event_into(&mut self.state.buf1) {
Ok(Event::Start(start)) => {
Expand Down
Loading

0 comments on commit e30a1f5

Please sign in to comment.