Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions specta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ bevy_ecs = ["dep:bevy_ecs"]
bevy_input = ["dep:bevy_input", "dep:bevy_ecs", "dep:glam"]
# [camino](https://docs.rs/camino) crate
camino = ["dep:camino"]
## [geojson](https://docs.rs/geojson) crate
geojson = ["dep:geojson", "serde_json"]

[lints]
workspace = true
Expand Down Expand Up @@ -119,6 +121,7 @@ bevy_ecs = { version = "0.17.3", optional = true, default-features = false, feat
bevy_input = { version = "0.17.3", optional = true, default-features = false, features = ["std", "bevy_reflect"] }
jiff = { version = "0.2", optional = true, default-features = false }
camino = { version = "1.2.1", optional = true, default-features = false }
geojson = { version = "0.24", optional = true, default-features = false }

[dev-dependencies]
serde = { version = "1.0.228", features = ["derive"] } # TODO: Can we remove this?
55 changes: 55 additions & 0 deletions specta/src/type/legacy_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,3 +563,58 @@ impl_as!(
camino::Utf8Path as String
camino::Utf8PathBuf as String
);

#[cfg(feature = "geojson")]
const _: () = {
use geojson::{Feature, FeatureCollection, Geometry, Value};

#[derive(Type)]
#[specta(rename = "GeoJsonValue", untagged, remote = Value, crate = crate, collect = false)]
#[allow(dead_code)]
pub enum GeoJsonValue {
Point(geojson::PointType),
MultiPoint(Vec<geojson::PointType>),
LineString(geojson::LineStringType),
MultiLineString(Vec<geojson::LineStringType>),
Polygon(geojson::PolygonType),
MultiPolygon(Vec<geojson::PolygonType>),
GeometryCollection(Vec<Geometry>),
}

#[derive(Type)]
#[specta(rename = "GeoJsonGeometry", remote = Geometry, crate = crate, collect = false)]
#[allow(dead_code)]
pub struct GeoJsonGeometry {
pub bbox: Option<geojson::Bbox>,
pub value: Value,
pub foreign_members: Option<geojson::JsonObject>,
}

#[derive(Type)]
#[specta(rename = "GeoJsonFeature", remote = Feature, crate = crate, collect = false)]
#[allow(dead_code)]
pub struct GeoJsonFeature {
pub bbox: Option<geojson::Bbox>,
pub geometry: Option<Geometry>,
pub id: Option<geojson::feature::Id>,
pub properties: Option<geojson::JsonObject>,
pub foreign_members: Option<geojson::JsonObject>,
}

#[derive(Type)]
#[specta(rename = "GeoJsonFeatureCollection", remote = FeatureCollection, crate = crate, collect = false)]
#[allow(dead_code)]
pub struct GeoJsonFeatureCollection {
pub bbox: Option<geojson::Bbox>,
pub features: Vec<Feature>,
pub foreign_members: Option<geojson::JsonObject>,
}

#[derive(Type)]
#[specta(rename = "GeoJsonFeatureId", untagged, remote = geojson::feature::Id, crate = crate, collect = false)]
#[allow(dead_code)]
pub enum GeoJsonFeatureId {
String(String),
Number(serde_json::Number),
}
};
Loading