Skip to main content

Geometry

Enum Geometry 

Source
pub enum Geometry {
    Point(Coord),
    LineString(Vec<Coord>),
    Polygon {
        exterior: Ring,
        interiors: Vec<Ring>,
    },
    MultiPoint(Vec<Coord>),
    MultiLineString(Vec<Vec<Coord>>),
    MultiPolygon(Vec<(Ring, Vec<Ring>)>),
    GeometryCollection(Vec<Geometry>),
}
Expand description

The canonical geometry type covering all OGC Simple Features.

Variants§

§

Point(Coord)

Single point geometry.

§

LineString(Vec<Coord>)

Connected path of vertices.

§

Polygon

Polygon with one exterior ring and zero or more interior rings.

Fields

§exterior: Ring

Exterior boundary ring.

§interiors: Vec<Ring>

Interior hole rings.

§

MultiPoint(Vec<Coord>)

Set of points.

§

MultiLineString(Vec<Vec<Coord>>)

Set of line strings.

§

MultiPolygon(Vec<(Ring, Vec<Ring>)>)

Set of polygons.

§

GeometryCollection(Vec<Geometry>)

Heterogeneous set of geometries.

Implementations§

Source§

impl Geometry

Source

pub fn point(x: f64, y: f64) -> Self

Constructs a 2D point geometry.

Source

pub fn point_z(x: f64, y: f64, z: f64) -> Self

Constructs a 3D point geometry.

Source

pub fn line_string(coords: Vec<Coord>) -> Self

Constructs a line string geometry.

Source

pub fn polygon(exterior: Vec<Coord>, interiors: Vec<Vec<Coord>>) -> Self

Constructs a polygon geometry from exterior and interior coordinate rings.

Source

pub fn multi_point(pts: Vec<Coord>) -> Self

Constructs a multipoint geometry.

Source

pub fn multi_line_string(lines: Vec<Vec<Coord>>) -> Self

Constructs a multilinestring geometry.

Source

pub fn multi_polygon(polys: Vec<(Vec<Coord>, Vec<Vec<Coord>>)>) -> Self

Constructs a multipolygon geometry.

Source

pub fn geom_type(&self) -> GeometryType

Returns the geometry type discriminator.

Source

pub fn has_z(&self) -> bool

Returns true if any coordinate in the geometry has a Z value.

Source

pub fn is_empty(&self) -> bool

Returns true if geometry has no coordinates/components.

Source

pub fn all_coords(&self) -> Vec<&Coord>

Returns flattened coordinate references across all nested components.

Source

pub fn bbox(&self) -> Option<BBox>

Computes an axis-aligned bounding box for the geometry.

Source

pub fn to_wkt(&self) -> String

Serializes geometry to WKT text (diagnostic output).

Source

pub fn to_wkb(&self) -> Vec<u8>

Encode to ISO WKB (little-endian).

Source

pub fn from_wkb(data: &[u8]) -> Result<Self>

Decode from ISO WKB.

Source

pub fn to_gpkg_wkb(&self, srs_id: i32) -> Vec<u8>

Encode to GeoPackage WKB (GP header + ISO WKB + optional XY envelope).

Source

pub fn from_gpkg_wkb(data: &[u8]) -> Result<(Self, i32)>

Decode from GeoPackage WKB. Returns (geometry, srs_id).

Trait Implementations§

Source§

impl Clone for Geometry

Source§

fn clone(&self) -> Geometry

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Geometry

Source§

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

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

impl PartialEq for Geometry

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Geometry

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.