Struct geojson::Geometry [−][src]
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 Value
s.
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: Value
foreign_members: Option<Map<String, JsonValue>>
Foreign Members
Implementations
impl Geometry
[src]
pub fn new(value: Value) -> Self
[src]
Returns a new Geometry
with the specified value
. bbox
and foreign_members
will be
set to None
.
impl Geometry
[src]
pub fn from_json_object(object: Map<String, JsonValue>) -> Result<Self, Error>
[src]
pub fn from_json_value(value: JsonValue) -> Result<Self, Error>
[src]
Trait Implementations
impl Clone for Geometry
[src]
impl Debug for Geometry
[src]
impl<'de> Deserialize<'de> for Geometry
[src]
fn deserialize<D>(deserializer: D) -> Result<Geometry, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Display for Geometry
[src]
impl<'a> From<&'a Geometry> for Map<String, JsonValue>
[src]
impl From<Geometry> for GeoJson
[src]
impl<V> From<V> for Geometry where
V: Into<Value>,
[src]
V: Into<Value>,
impl PartialEq<Geometry> for Geometry
[src]
impl Serialize for Geometry
[src]
impl StructuralPartialEq for Geometry
[src]
impl TryFrom<GeoJson> for Geometry
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(value: GeoJson) -> Result<Self, Self::Error>
[src]
impl TryFrom<Map<String, Value>> for Geometry
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(mut object: Map<String, JsonValue>) -> Result<Self, Self::Error>
[src]
impl TryFrom<Value> for Geometry
[src]
Auto Trait Implementations
impl RefUnwindSafe for Geometry
[src]
impl Send for Geometry
[src]
impl Sync for Geometry
[src]
impl Unpin for Geometry
[src]
impl UnwindSafe for Geometry
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,