Skip to content

Commit

Permalink
feat: sync repository (#25)
Browse files Browse the repository at this point in the history
* feat: sync repository
  • Loading branch information
miseyu authored Oct 9, 2024
1 parent 1b9070b commit 280cba9
Show file tree
Hide file tree
Showing 59 changed files with 2,152 additions and 2,427 deletions.
32 changes: 4 additions & 28 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,13 @@ members = [
resolver = "2"

[workspace.package]
authors = ["MIERUNE Inc. <[email protected]>", "Re:Earth Flow Contributors"]
edition = "2021"
license = "MIT"
repository = "https://github.com/reearth/plateau-gis-converter"
rust-version = "1.81"
version = "0.1.0"
authors = ["MIERUNE Inc. <[email protected]>"]
version = "0.0.0-alpha.0"

[profile.dev]
opt-level = 0

[profile.debug-fast]
debug = true
incremental = false
inherits = "release"
panic = "unwind"
strip = "none"
[profile.dev.package."*"]
opt-level = 3

[profile.release-lto]
codegen-units = 8
inherits = "release"
lto = "fat"

[workspace.dependencies]
ahash = "0.8.11"
chrono = "0.4.38"
indexmap = "2.5.0"
log = "0.4.22"
once_cell = "1.20.1"
quick-xml = "0.36.2"
regex = "1.11.0"
serde = "1.0.210"
serde_json = "1.0.128"
thiserror = "1.0.64"
url = "2.5.2"
33 changes: 14 additions & 19 deletions nusamai-citygml/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
[package]
edition = "2021"
name = "nusamai-citygml"

authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
version.workspace = true

[features]
default = ["serde"]
serde = ["dep:serde", "nusamai-geometry/serde", "serde_json"]
serde = ["dep:serde", "flatgeom/serde", "serde_json"]

[dependencies]
ahash.workspace = true
chrono = { workspace = true, features = ["serde"] }
indexmap = { workspace = true, features = ["serde"] }
log.workspace = true
ahash = "0.8.11"
chrono = { version = "0.4.35", features = ["serde"], default-features = false }
flatgeom = "0.0.2"
indexmap = { version = "2.2.6", features = ["serde"] }
log = "0.4.21"
macros = { path = "./macros" }
nusamai-geometry = { path = "../nusamai-geometry", features = ["serde"] }
nusamai-projection = { path = "../nusamai-projection" }
once_cell.workspace = true
quick-xml.workspace = true
regex.workspace = true
serde = { workspace = true, features = ["derive"], optional = true }
serde_json = { workspace = true, features = ["indexmap"], optional = true }
thiserror.workspace = true
url = { workspace = true, features = ["serde"] }
once_cell = "1.20.2"
quick-xml = "0.36.2"
regex = "1.11.0"
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { version = "1.0.115", features = ["indexmap"], optional = true }
thiserror = "1.0"
url = { version = "2.5.0", features = ["serde"] }
9 changes: 2 additions & 7 deletions nusamai-citygml/macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
[package]
name = "macros"

authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
version.workspace = true
version = "0.1.0"
edition = "2021"

[lib]
proc-macro = true
Expand Down
3 changes: 1 addition & 2 deletions nusamai-citygml/macros/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,10 @@ fn generate_citygml_impl_for_struct(
c.extend(name);
let path = LitByteStr::new(&c, prefix.span());
let geomtype = format_ident!("{}", geomtype);
let name = std::str::from_utf8(&c).unwrap();
let hash = hash(&c);

child_arms.push(quote! {
(#hash, #path) => st.parse_geometric_attr(#lod, #name, ::nusamai_citygml::geometry::GeometryParseType::#geomtype),
(#hash, #path) => st.parse_geometric_attr(&mut self.#field_ident, #lod, ::nusamai_citygml::geometry::GeometryParseType::#geomtype),
});
};

Expand Down
25 changes: 21 additions & 4 deletions nusamai-citygml/src/geometry.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use nusamai_geometry::{MultiLineString, MultiPoint, MultiPolygon};
use flatgeom::{MultiLineString, MultiPoint, MultiPolygon};
use nusamai_projection::crs::*;

use crate::LocalId;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// URI prefix for EPSG codes
const CRS_URI_EPSG_PREFIX: &str = "http://www.opengis.net/def/crs/EPSG/0/";

#[derive(Debug, Clone, Copy)]
pub enum GeometryParseType {
Geometry,
Solid,
Expand Down Expand Up @@ -98,6 +101,7 @@ pub struct SurfaceSpan {
#[derive(Default)]
pub(crate) struct GeometryCollector {
pub vertices: indexmap::IndexSet<[u64; 3], ahash::RandomState>,
pub geometry_crs_uri: Option<String>,
pub multipolygon: MultiPolygon<'static, u32>,
pub multilinestring: MultiLineString<'static, u32>,
pub multipoint: MultiPoint<'static, u32>,
Expand Down Expand Up @@ -139,7 +143,7 @@ impl GeometryCollector {
}));
}

pub fn into_geometries(self) -> GeometryStore {
pub fn into_geometries(self, envelope_crs_uri: Option<String>) -> GeometryStore {
let mut vertices = Vec::with_capacity(self.vertices.len());
for vbits in &self.vertices {
vertices.push([
Expand All @@ -149,8 +153,21 @@ impl GeometryCollector {
]);
}

let crs_uri = envelope_crs_uri.unwrap_or(self.geometry_crs_uri.unwrap_or_default());

let epsg = if crs_uri.starts_with(CRS_URI_EPSG_PREFIX) {
if let Some(stripped) = crs_uri.strip_prefix(CRS_URI_EPSG_PREFIX) {
stripped.parse::<EpsgCode>().ok()
} else {
None
}
} else {
None
}
.unwrap_or(EPSG_JGD2011_GEOGRAPHIC_3D);

GeometryStore {
epsg: EPSG_JGD2011_GEOGRAPHIC_3D,
epsg,
vertices,
multipolygon: self.multipolygon,
multilinestring: self.multilinestring,
Expand Down
5 changes: 3 additions & 2 deletions nusamai-citygml/src/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ mod tests {
"#;

let mut reader = NsReader::from_str(data);
reader.config_mut().trim_text(true);
reader.config_mut().expand_empty_elements = true;
let config = reader.config_mut();
config.trim_text(true);
config.expand_empty_elements = true;
loop {
match reader.read_resolved_event() {
Ok((ns, Event::Start(ref e))) => {
Expand Down
Loading

0 comments on commit 280cba9

Please sign in to comment.