pub struct FeatureCollection {
    pub bbox: Option<Bbox>,
    pub features: Vec<Feature>,
    pub foreign_members: Option<JsonObject>,
}
Expand description

Feature Collection Objects

GeoJSON Format Specification § 3.3

Examples

Serialization:

use geojson::FeatureCollection;
use geojson::GeoJson;

let feature_collection = FeatureCollection {
    bbox: None,
    features: vec![],
    foreign_members: None,
};

let serialized = GeoJson::from(feature_collection).to_string();

assert_eq!(
    serialized,
    "{\"features\":[],\"type\":\"FeatureCollection\"}"
);

Collect from an iterator:

use geojson::{Feature, FeatureCollection, Value};

let fc: FeatureCollection = (0..10)
    .map(|idx| -> Feature {
        let c = idx as f64;
        Value::Point(vec![1.0 * c, 2.0 * c, 3.0 * c]).into()
    })
    .collect();
assert_eq!(fc.features.len(), 10);

Fields§

§bbox: Option<Bbox>§features: Vec<Feature>§foreign_members: Option<JsonObject>

Implementations§

Trait Implementations§

source§

impl Clone for FeatureCollection

source§

fn clone(&self) -> FeatureCollection

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for FeatureCollection

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for FeatureCollection

source§

fn deserialize<D>(deserializer: D) -> Result<FeatureCollection, D::Error>where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for FeatureCollection

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a FeatureCollection> for JsonObject

source§

fn from(fc: &'a FeatureCollection) -> JsonObject

Converts to this type from the input type.
source§

impl<'a, T> From<&'a GeometryCollection<T>> for FeatureCollectionwhere T: CoordFloat,

Available on crate feature geo-types only.
source§

fn from(geometry_collection: &GeometryCollection<T>) -> Self

Converts to this type from the input type.
source§

impl From<FeatureCollection> for GeoJson

source§

fn from(feature_collection: FeatureCollection) -> GeoJson

Converts to this type from the input type.
source§

impl FromIterator<Feature> for FeatureCollection

Create a FeatureCollection using the collect method on an iterator of Features. If every item contains a bounding-box of the same dimension, then the output has a bounding-box of the union of them. Otherwise, the output will not have a bounding-box.

source§

fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl FromStr for FeatureCollection

§

type Err = Error

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
source§

impl<'a> IntoIterator for &'a FeatureCollection

§

type Item = &'a Feature

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, Feature>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl IntoIterator for FeatureCollection

§

type Item = Feature

The type of the elements being iterated over.
§

type IntoIter = IntoIter<Feature, Global>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl PartialEq<FeatureCollection> for FeatureCollection

source§

fn eq(&self, other: &FeatureCollection) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for FeatureCollection

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T> TryFrom<FeatureCollection> for Geometry<T>where T: CoordFloat,

Available on crate feature geo-types only.
§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(val: FeatureCollection) -> Result<Geometry<T>>

Performs the conversion.
source§

impl TryFrom<GeoJson> for FeatureCollection

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(value: GeoJson) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<Map<String, Value>> for FeatureCollection

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(object: JsonObject) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<Value> for FeatureCollection

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(value: JsonValue) -> Result<Self>

Performs the conversion.
source§

impl StructuralPartialEq for FeatureCollection

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,