pub enum Geometry {
MultiPoint {
lod: Option<String>,
boundaries: Ring,
common: GeometryCommon,
},
MultiLineString {
lod: Option<String>,
boundaries: Vec<Ring>,
common: GeometryCommon,
},
MultiSurface {
lod: Option<String>,
boundaries: Vec<Surface>,
common: GeometryCommon,
},
CompositeSurface {
lod: Option<String>,
boundaries: Vec<Surface>,
common: GeometryCommon,
},
Solid {
lod: Option<String>,
boundaries: Vec<Shell>,
common: GeometryCommon,
},
MultiSolid {
lod: Option<String>,
boundaries: Vec<Vec<Shell>>,
common: GeometryCommon,
},
CompositeSolid {
lod: Option<String>,
boundaries: Vec<Vec<Shell>>,
common: GeometryCommon,
},
GeometryInstance {
boundaries: Ring,
template: usize,
transformation_matrix: [f64; 16],
},
}Expand description
A CityJSON geometry object.
The nesting depth of boundaries is part of the type: a MultiSurface
whose boundaries are nested one level too deep does not deserialize, where
previously it decoded happily into an untyped serde_json::Value and left
every consumer to guess the depth.
Variants§
MultiPoint
MultiLineString
MultiSurface
CompositeSurface
Solid
MultiSolid
CompositeSolid
GeometryInstance
Implementations§
Source§impl Geometry
impl Geometry
Sourcepub fn from_json_value(v: Value) -> Result<Geometry>
pub fn from_json_value(v: Value) -> Result<Geometry>
Parse a geometry, reporting a wrong boundaries depth in terms of the
geometry type rather than in terms of serde’s innards.
serde_json::from_value::<Geometry> works just as well and is what
#[derive(Deserialize)] gives every containing type; the only thing
this adds is a readable error. Deserializing a deeply nested Vec
otherwise fails with “invalid type: integer, expected a sequence”,
which says neither which geometry was at fault nor what depth it
wanted.
pub fn geometry_type(&self) -> GeometryType
Sourcepub fn lod(&self) -> Option<&str>
pub fn lod(&self) -> Option<&str>
The lod of this geometry; a Geometry::GeometryInstance has none.
Sourcepub fn common(&self) -> Option<&GeometryCommon>
pub fn common(&self) -> Option<&GeometryCommon>
The semantics/material/texture members, if this variant has them.
A Geometry::GeometryInstance carries none: its appearance lives on
the template it refers to.