pub struct FeatureCollection {
pub bbox: Option<Bbox>,
pub features: Vec<Feature>,
pub foreign_members: Option<JsonObject>,
}Expand description
Feature Collection Object
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 = feature_collection.to_string();
assert_eq!(serialized, r#"{"type":"FeatureCollection","features":[]}"#);Deserializing a GeoJSON string into a FeatureCollection:
use geojson::{FeatureCollection, Feature, Geometry};
let geojson_str = r#"
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-1.0, -2.0]
}
}
]
}"#;
let feature_collection = geojson_str
.parse::<FeatureCollection>()
.expect("valid FeatureCollection GeoJSON");
let expected = FeatureCollection::new([
Feature::from(Geometry::new_point([-1.0, -2.0]))
]);
assert_eq!(feature_collection, expected);Collect from an iterator:
use geojson::{Feature, FeatureCollection, Geometry};
let fc: FeatureCollection = (0..10)
.map(|idx| -> Feature {
let c = idx as f64;
Geometry::new_point([1.0 * c, 2.0 * c, 3.0 * c]).into()
})
.collect();
assert_eq!(fc.features.len(), 10);Fields§
§bbox: Option<Bbox>Bounding Box
features: Vec<Feature>§foreign_members: Option<JsonObject>Foreign Members
GeoJSON Format Specification § 6
See the crate-level foreign members documentation for details, including limitations on key names.
Implementations§
Source§impl FeatureCollection
impl FeatureCollection
Sourcepub fn new(features: impl IntoIterator<Item = Feature>) -> Self
pub fn new(features: impl IntoIterator<Item = Feature>) -> Self
Construct a FeatureCollection from an iterator of Features (or things that can be turned Into a Feature)
Trait Implementations§
Source§impl Clone for FeatureCollection
impl Clone for FeatureCollection
Source§fn clone(&self) -> FeatureCollection
fn clone(&self) -> FeatureCollection
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FeatureCollection
impl Debug for FeatureCollection
Source§impl Default for FeatureCollection
impl Default for FeatureCollection
Source§fn default() -> FeatureCollection
fn default() -> FeatureCollection
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for FeatureCollection
impl<'de> Deserialize<'de> for FeatureCollection
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for FeatureCollection
impl Display for FeatureCollection
Source§impl<T> From<&GeometryCollection<T>> for FeatureCollectionwhere
T: CoordFloat,
Available on crate feature geo-types only.
impl<T> From<&GeometryCollection<T>> for FeatureCollectionwhere
T: CoordFloat,
Available on crate feature
geo-types only.Source§fn from(geometry_collection: &GeometryCollection<T>) -> Self
fn from(geometry_collection: &GeometryCollection<T>) -> Self
Converts to this type from the input type.
Source§impl From<FeatureCollection> for GeoJson
impl From<FeatureCollection> for GeoJson
Source§fn from(feature_collection: FeatureCollection) -> GeoJson
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.
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§impl FromStr for FeatureCollection
impl FromStr for FeatureCollection
Source§impl IntoIterator for FeatureCollection
impl IntoIterator for FeatureCollection
Source§impl<'a> IntoIterator for &'a FeatureCollection
impl<'a> IntoIterator for &'a FeatureCollection
Source§impl PartialEq for FeatureCollection
impl PartialEq for FeatureCollection
Source§fn eq(&self, other: &FeatureCollection) -> bool
fn eq(&self, other: &FeatureCollection) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for FeatureCollection
impl Serialize for FeatureCollection
impl StructuralPartialEq for FeatureCollection
Source§impl<T> TryFrom<FeatureCollection> for Geometry<T>where
T: CoordFloat,
Available on crate feature geo-types only.
impl<T> TryFrom<FeatureCollection> for Geometry<T>where
T: CoordFloat,
Available on crate feature
geo-types only.Auto Trait Implementations§
impl Freeze for FeatureCollection
impl RefUnwindSafe for FeatureCollection
impl Send for FeatureCollection
impl Sync for FeatureCollection
impl Unpin for FeatureCollection
impl UnsafeUnpin for FeatureCollection
impl UnwindSafe for FeatureCollection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more