Skip to content

Commit

Permalink
Publish nusamai-geometry as 'flatgeom' on crates.io. (#546)
Browse files Browse the repository at this point in the history
Close: #536

Publish nusamai-geometry as
[flatgeom](https://crates.io/crates/flatgeom) on crates.io
  • Loading branch information
ciscorn authored May 29, 2024
1 parent 720b2f0 commit 0c6addf
Show file tree
Hide file tree
Showing 50 changed files with 62 additions and 2,114 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,12 @@ PLATEAU の標準仕様に準拠した CityGML 2.0 形式の3D都市モデルは
- アプリケーション:
- [`app`](./app/) — Tauri による GUI 実装
- [`nusamai`](./nusamai/) — アプリケーションバックエンドおよびコマンドライン版の実装
- 基盤・ユーティリティ:
- [`nusamai-geometry`](./nusamai-geometry/) — ジオメトリ型
- [`nusamai-projection`](./nusamai-projection/) — 投影法変換
- データソース:
- [`nusamai-citygml`](./nusamai-plateau/citygml/) — CityGML パーサ実装支援ライブラリ
- [`macros`](./nusamai-plateau/citygml/macros/) — パーサ導出用の proc macros
- [`nusamai-plateau`](./nusamai-plateau/) — PLATEAU 用の CityGML モデルおよびパーサ
- 変換先形式のための支援ライブラリ(本プロジェクトのユースケースと癒着しないように構成)
- 基盤・ユーティリティ(本プロジェクトのユースケースと癒着しないように構成):
- [`nusamai-projection`](./nusamai-projection/) — 投影法変換
- [`nusamai-mvt`](./nusamai-mvt/) — Mapbox Vector Tiles (MVT)
- [`nusamai-gpkg`](./nusamai-gpkg/) — GeoPackage
- [`nusamai-gltf`](./nusamai-gltf/) — glTF
Expand All @@ -109,9 +107,10 @@ PLATEAU の標準仕様に準拠した CityGML 2.0 形式の3D都市モデルは

### 7.1. 外部リポジトリ

- [MIERUNE/cesiumtiles-rs](https://github.com/MIERUNE/cesiumtiles-rs) — 3D TilesのJSONモデルなど
- [MIERUNE/flatgeom-rs](https://github.com/MIERUNE/flatgeom-rs) — シリアライズ/デシリアライズの効率を優先したジオメトリ型
- [MIERUNE/earcut-rs](https://github.com/MIERUNE/earcut-rs) — ポリゴン三角形化アルゴリズムのRust移植
- [MIERUNE/japan-geoid](https://github.com/MIERUNE/japan-geoid) — 日本のジオイドモデル (JGD2011 → WGS 84 の変換)
- [MIERUNE/cesiumtiles-rs](https://github.com/MIERUNE/cesiumtiles-rs) — 3D TilesのJSONモデルなど

## 8. ライセンス

Expand Down
2 changes: 1 addition & 1 deletion app/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.6.1", features = [ "shell-open", "fs-read-dir", "dialog-all"] }
nusamai = { path = "../../nusamai" }
nusamai-geometry = { path = "../../nusamai-geometry" }
flatgeom = "0.0"
nusamai-geojson = { path = "../../nusamai-geojson" }
nusamai-plateau = { path = "../../nusamai-plateau" }
nusamai-citygml = {path = "../../nusamai-citygml" }
Expand Down
4 changes: 2 additions & 2 deletions nusamai-citygml/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ edition = "2021"

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

[dependencies]
ahash = "0.8.11"
chrono = { version = "0.4.35", features = ["serde"], default-features = false }
indexmap = { version = "2.2.6", features = ["serde"] }
log = "0.4.21"
macros = { path = "./macros" }
nusamai-geometry = { path = "../nusamai-geometry", features = ["serde"]}
flatgeom = "0.0"
nusamai-projection = { path = "../nusamai-projection"}
quick-xml = "0.31"
serde = { version = "1.0", features = ["derive"], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion nusamai-citygml/src/geometry.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use nusamai_geometry::{MultiLineString, MultiPoint, MultiPolygon};
use flatgeom::{MultiLineString, MultiPoint, MultiPolygon};
use nusamai_projection::crs::*;

use crate::LocalId;
Expand Down
2 changes: 1 addition & 1 deletion nusamai-czml/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
chrono = { version = "0.4.35", features = ["serde"] }
serde = { version = "1.0.197", features = ["derive"] }
serde_json = { version = "1.0.115", features = ["float_roundtrip"] }
nusamai-geometry = { path = "../nusamai-geometry" }
flatgeom= "0.0"

[dev-dependencies]
glob = "0.3.1"
2 changes: 1 addition & 1 deletion nusamai-czml/src/conversion.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use nusamai_geometry::{MultiPolygon, Polygon};
use flatgeom::{MultiPolygon, Polygon};

use crate::{
models::CzmlPolygon, PositionList, PositionListOfLists, PositionListOfListsProperties,
Expand Down
2 changes: 1 addition & 1 deletion nusamai-geojson/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ edition = "2021"

[dependencies]
geojson = "0.24.1"
nusamai-geometry = { path = "../nusamai-geometry" }
flatgeom= "0.0"
serde_json = { version = "1.0.115", features = ["indexmap"] }
28 changes: 14 additions & 14 deletions nusamai-geojson/src/conversion.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use nusamai_geometry::{
use flatgeom::{
Coord, LineString, LineString3, MultiLineString, MultiLineString3, MultiPoint, MultiPoint3,
MultiPolygon, Polygon,
};

/// Create a GeoJSON Polygon from `nusamai_geometry::MultiPolygon`.
/// Create a GeoJSON Polygon from `flatgeom::MultiPolygon`.
pub fn polygon_to_value<const D: usize>(poly: &Polygon<[f64; D]>) -> geojson::Value {
polygon_to_value_with_mapping(poly, |c| c.to_vec())
}
Expand All @@ -13,7 +13,7 @@ pub fn indexed_polygon_to_value(vertices: &[[f64; 3]], poly_idx: &Polygon<u32>)
polygon_to_value_with_mapping(poly_idx, |idx| vertices[idx as usize].to_vec())
}

/// Create a GeoJSON Polygon from `nusamai_geometry::Polygon` with a mapping function.
/// Create a GeoJSON Polygon from `flatgeom::Polygon` with a mapping function.
pub fn polygon_to_value_with_mapping<T: Coord>(
poly: &Polygon<T>,
mapping: impl Fn(T) -> Vec<f64>,
Expand All @@ -29,7 +29,7 @@ pub fn polygon_to_value_with_mapping<T: Coord>(
geojson::Value::Polygon(coords)
}

/// Create a GeoJSON MultiPolygon from `nusamai_geometry::MultiPolygon`.
/// Create a GeoJSON MultiPolygon from `flatgeom::MultiPolygon`.
pub fn multipolygon_to_value<const D: usize>(mpoly: &MultiPolygon<[f64; D]>) -> geojson::Value {
multipolygon_to_value_with_mapping(mpoly, |c| c.to_vec())
}
Expand All @@ -42,7 +42,7 @@ pub fn indexed_multipolygon_to_value(
multipolygon_to_value_with_mapping(mpoly_idx, |idx| vertices[idx as usize].to_vec())
}

/// Create a GeoJSON MultiPolygon from `nusamai_geometry::MultiPolygon` with a mapping function.
/// Create a GeoJSON MultiPolygon from `flatgeom::MultiPolygon` with a mapping function.
pub fn multipolygon_to_value_with_mapping<T: Coord>(
mpoly: &MultiPolygon<T>,
mapping: impl Fn(T) -> Vec<f64>,
Expand All @@ -62,7 +62,7 @@ pub fn multipolygon_to_value_with_mapping<T: Coord>(
geojson::Value::MultiPolygon(coords)
}

/// Create a GeoJSON LineString from `nusamai_geometry::LineString`.
/// Create a GeoJSON LineString from `flatgeom::LineString`.
pub fn linestring_to_value(ls: &LineString3) -> geojson::Value {
linestring_to_value_with_mapping(ls, |c| c.to_vec())
}
Expand All @@ -75,7 +75,7 @@ pub fn indexed_linestring_to_value(
linestring_to_value_with_mapping(ls_idx, |idx| vertices[idx as usize].to_vec())
}

/// Create a GeoJSON LineString from `nusamai_geometry::LineString` with a mapping function.
/// Create a GeoJSON LineString from `flatgeom::LineString` with a mapping function.
pub fn linestring_to_value_with_mapping<T: Coord>(
ls: &LineString<T>,
mapping: impl Fn(T) -> Vec<f64>,
Expand All @@ -84,7 +84,7 @@ pub fn linestring_to_value_with_mapping<T: Coord>(
geojson::Value::LineString(coords)
}

/// Create a GeoJSON MultiLineString from `nusamai_geometry::MultiLineString`.
/// Create a GeoJSON MultiLineString from `flatgeom::MultiLineString`.
pub fn multilinestring_to_value(mls: &MultiLineString3) -> geojson::Value {
multilinestring_to_value_with_mapping(mls, |c| c.to_vec())
}
Expand All @@ -97,7 +97,7 @@ pub fn indexed_multilinestring_to_value(
multilinestring_to_value_with_mapping(mls_idx, |idx| vertices[idx as usize].to_vec())
}

/// Create a GeoJSON MultiLineString from `nusamai_geometry::MultiLineString` with a mapping function.
/// Create a GeoJSON MultiLineString from `flatgeom::MultiLineString` with a mapping function.
pub fn multilinestring_to_value_with_mapping<T: Coord>(
mls: &MultiLineString<T>,
mapping: impl Fn(T) -> Vec<f64>,
Expand All @@ -114,7 +114,7 @@ pub fn multilinestring_to_value_with_mapping<T: Coord>(
geojson::Value::MultiLineString(coords)
}

/// Create a GeoJSON Point from `nusamai_geometry::Point`.
/// Create a GeoJSON Point from `flatgeom::Point`.
pub fn point_to_value(point: &[f64; 3]) -> geojson::Value {
point_to_value_with_mapping(*point, |c| c.to_vec())
}
Expand All @@ -124,15 +124,15 @@ pub fn indexed_point_to_value(vertices: &[[f64; 3]], point_idx: u32) -> geojson:
point_to_value_with_mapping(point_idx, |idx| vertices[idx as usize].to_vec())
}

/// Create a GeoJSON Point from `nusamai_geometry::Point` with a mapping function.
/// Create a GeoJSON Point from `flatgeom::Point` with a mapping function.
pub fn point_to_value_with_mapping<T: Coord>(
point: T,
mapping: impl Fn(T) -> Vec<f64>,
) -> geojson::Value {
geojson::Value::Point(mapping(point))
}

/// Create a GeoJSON MultiPoint from `nusamai_geometry::Point`.
/// Create a GeoJSON MultiPoint from `flatgeom::Point`.
pub fn multipoint_to_value(mpoint: &MultiPoint3) -> geojson::Value {
multipoint_to_value_with_mapping(mpoint, |c| c.to_vec())
}
Expand All @@ -145,7 +145,7 @@ pub fn indexed_multipoint_to_value(
multipoint_to_value_with_mapping(mpoint_idx, |idx| vertices[idx as usize].to_vec())
}

/// Create a GeoJSON MultiPoint from `nusamai_geometry::MultiPoint` with a mapping function.
/// Create a GeoJSON MultiPoint from `flatgeom::MultiPoint` with a mapping function.
pub fn multipoint_to_value_with_mapping<T: Coord>(
mpoint: &MultiPoint<T>,
mapping: impl Fn(T) -> Vec<f64>,
Expand All @@ -159,7 +159,7 @@ pub fn multipoint_to_value_with_mapping<T: Coord>(

#[cfg(test)]
mod tests {
use nusamai_geometry::{MultiPolygon3, Polygon3};
use flatgeom::{MultiPolygon3, Polygon3};

use super::*;

Expand Down
16 changes: 0 additions & 16 deletions nusamai-geometry/Cargo.toml

This file was deleted.

35 changes: 0 additions & 35 deletions nusamai-geometry/README.md

This file was deleted.

Binary file removed nusamai-geometry/docs/01_linestring.png
Binary file not shown.
Binary file removed nusamai-geometry/docs/02_polygon.png
Binary file not shown.
Binary file removed nusamai-geometry/docs/03_polygon_with_a_hole.png
Binary file not shown.
Binary file not shown.
Binary file removed nusamai-geometry/docs/05_multipolygon.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed nusamai-geometry/docs/nusamai-geometry.key
Binary file not shown.
Loading

0 comments on commit 0c6addf

Please sign in to comment.