pub struct GeoFeature {
pub id: Option<GeoValue>,
pub geometry: Geometry,
pub properties: GeoProperties,
}Expand description
A single geographic feature consisting of an optional id, a Geometry, and GeoProperties.
This mirrors a GeoJSON Feature: geometry holds the spatial data, properties stores
arbitrary typed attributes, and id is optional. GeoFeature provides constructors and
utilities for setting properties and converting geometries, plus serialization to a
GeoJSON-compatible representation.
Fields§
§id: Option<GeoValue>Optional feature identifier. If present, it is emitted as the GeoJSON id field.
geometry: GeometryThe feature’s spatial component.
properties: GeoPropertiesKey–value attributes associated with the feature (emitted as GeoJSON properties).
Implementations§
Source§impl GeoFeature
impl GeoFeature
Sourcepub fn new(geometry: Geometry) -> Self
pub fn new(geometry: Geometry) -> Self
Creates a new GeoFeature with the given geometry, no id, and empty properties.
§Examples
let geom = Geometry::new_example();
let feature = GeoFeature::new(geom);Sourcepub fn set_id(&mut self, id: GeoValue)
pub fn set_id(&mut self, id: GeoValue)
Sets the optional identifier of the feature (serialized as GeoJSON id).
Sourcepub fn set_properties(&mut self, properties: GeoProperties)
pub fn set_properties(&mut self, properties: GeoProperties)
Replaces the entire properties map with the provided GeoProperties.
Sourcepub fn set_property<T>(&mut self, key: String, value: T)
pub fn set_property<T>(&mut self, key: String, value: T)
Inserts or updates a single property value.
Accepts any type T that can be converted into GeoValue (e.g., strings, numbers, booleans).
The key is stored verbatim and will appear in the GeoJSON properties object.
Sourcepub fn to_single_geometry(&mut self)
pub fn to_single_geometry(&mut self)
Converts the inner geometry to its single variant if it is currently a multi-geometry.
If the geometry is already single, this is a no-op.
Sourcepub fn to_multi_geometry(&mut self)
pub fn to_multi_geometry(&mut self)
Converts the inner geometry to its multi variant if it is currently a single-geometry.
If the geometry is already multi, this is a no-op.
Sourcepub fn to_json(&self, precision: Option<u8>) -> JsonObject
pub fn to_json(&self, precision: Option<u8>) -> JsonObject
Serializes the feature into a GeoJSON-compatible JsonObject.
The output object contains type: "Feature", an optional id, a geometry member,
and the properties object. If precision is provided, coordinate values in the
geometry are rounded to that many fractional digits.
Trait Implementations§
Source§impl Clone for GeoFeature
impl Clone for GeoFeature
Source§fn clone(&self) -> GeoFeature
fn clone(&self) -> GeoFeature
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GeoFeature
impl Debug for GeoFeature
Source§impl From<MultiPolygon> for GeoFeature
Creates a GeoFeature from a geo::MultiPolygon<f64> by wrapping it as a Geometry
and initializing id to None and properties to empty.
impl From<MultiPolygon> for GeoFeature
Creates a GeoFeature from a geo::MultiPolygon<f64> by wrapping it as a Geometry
and initializing id to None and properties to empty.
Source§fn from(geometry: MultiPolygon<f64>) -> Self
fn from(geometry: MultiPolygon<f64>) -> Self
Auto Trait Implementations§
impl Freeze for GeoFeature
impl RefUnwindSafe for GeoFeature
impl Send for GeoFeature
impl Sync for GeoFeature
impl Unpin for GeoFeature
impl UnsafeUnpin for GeoFeature
impl UnwindSafe for GeoFeature
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more