pub struct Geometry {
pub bbox: Option<Bbox>,
pub value: Value,
pub foreign_members: Option<Map<String, JsonValue>>,
}Expand description
Geometry Objects
GeoJSON Format Specification § 3.1
Examples
Constructing a Geometry:
use geojson::{Geometry, Value};
let geometry = Geometry::new(Value::Point(vec![7.428959, 1.513394]));Geometries can be created from Values.
let geometry1: Geometry = Value::Point(vec![7.428959, 1.513394]).into();Serializing a Geometry to a GeoJSON string:
use geojson::{GeoJson, Geometry, Value};
use serde_json;
let geometry = Geometry::new(Value::Point(vec![7.428959, 1.513394]));
let geojson_string = geometry.to_string();
assert_eq!(
"{\"coordinates\":[7.428959,1.513394],\"type\":\"Point\"}",
geojson_string,
);Deserializing a GeoJSON string into a Geometry:
use geojson::{GeoJson, Geometry, Value};
let geojson_str = "{\"coordinates\":[7.428959,1.513394],\"type\":\"Point\"}";
let geometry = match geojson_str.parse::<GeoJson>() {
Ok(GeoJson::Geometry(g)) => g,
_ => return,
};
assert_eq!(
Geometry::new(Value::Point(vec![7.428959, 1.513394]),),
geometry,
);Fields
bbox: Option<Bbox>Bounding Box
value: Valueforeign_members: Option<Map<String, JsonValue>>Foreign Members
Implementations
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Geometry
impl<'de> Deserialize<'de> for Geometry
sourcefn deserialize<D>(deserializer: D) -> Result<Geometry, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Geometry, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<T> TryFrom<Geometry> for Geometry<T> where
T: CoordFloat,
This is supported on crate feature geo-types only.
impl<T> TryFrom<Geometry> for Geometry<T> where
T: CoordFloat,
This is supported on crate feature
geo-types only.impl StructuralPartialEq for Geometry
Auto Trait Implementations
impl RefUnwindSafe for Geometry
impl Send for Geometry
impl Sync for Geometry
impl Unpin for Geometry
impl UnwindSafe for Geometry
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more