Geom

Struct Geom 

Source
pub struct Geom { /* private fields */ }
Expand description

An owned geometry that can represent any OGC Simple Feature type.

This is the main type for working with geometries. It supports:

  • All geometry types: Point, LineString, Polygon, and Multi/Collection variants
  • Parsing from WKT, WKB, GeoJSON, HEX, and GeoBin formats
  • Spatial predicates: intersects, contains, within, covers, touches, etc.
  • Serialization to various output formats

Memory is managed by the TG library and freed when dropped.

Implementations§

Source§

impl Geom

Source

pub fn geom_type(&self) -> GeomType

Source

pub fn rect(&self) -> Rect

Source

pub fn is_empty(&self) -> bool

Source

pub fn new_point(point: Point) -> Result<Self>

Source

pub fn new_point_z(point: Point, z: f64) -> Result<Self>

Source

pub fn new_point_m(point: Point, m: f64) -> Result<Self>

Source

pub fn new_point_zm(point: Point, z: f64, m: f64) -> Result<Self>

Source

pub fn new_point_empty() -> Result<Self>

Source

pub fn new_linestring(line: &Line) -> Result<Self>

Source

pub fn new_linestring_z(line: &Line, extra_coords: &[f64]) -> Result<Self>

Source

pub fn new_linestring_m(line: &Line, extra_coords: &[f64]) -> Result<Self>

Source

pub fn new_linestring_zm(line: &Line, extra_coords: &[f64]) -> Result<Self>

Source

pub fn new_linestring_empty() -> Result<Self>

Source

pub fn new_polygon(poly: &Poly) -> Result<Self>

Source

pub fn new_polygon_z(poly: &Poly, extra_coords: &[f64]) -> Result<Self>

Source

pub fn new_polygon_m(poly: &Poly, extra_coords: &[f64]) -> Result<Self>

Source

pub fn new_polygon_zm(poly: &Poly, extra_coords: &[f64]) -> Result<Self>

Source

pub fn new_polygon_empty() -> Result<Self>

Source

pub fn new_multipoint(points: &[Point]) -> Result<Self>

Source

pub fn new_multipoint_z(points: &[Point], extra_coords: &[f64]) -> Result<Self>

Source

pub fn new_multipoint_m(points: &[Point], extra_coords: &[f64]) -> Result<Self>

Source

pub fn new_multipoint_zm(points: &[Point], extra_coords: &[f64]) -> Result<Self>

Source

pub fn new_multipoint_empty() -> Result<Self>

Source

pub fn new_multilinestring(lines: &[&Line]) -> Result<Self>

Source

pub fn new_multilinestring_z( lines: &[&Line], extra_coords: &[f64], ) -> Result<Self>

Source

pub fn new_multilinestring_m( lines: &[&Line], extra_coords: &[f64], ) -> Result<Self>

Source

pub fn new_multilinestring_zm( lines: &[&Line], extra_coords: &[f64], ) -> Result<Self>

Source

pub fn new_multilinestring_empty() -> Result<Self>

Source

pub fn new_multipolygon(polys: &[&Poly]) -> Result<Self>

Source

pub fn new_multipolygon_z(polys: &[&Poly], extra_coords: &[f64]) -> Result<Self>

Source

pub fn new_multipolygon_m(polys: &[&Poly], extra_coords: &[f64]) -> Result<Self>

Source

pub fn new_multipolygon_zm( polys: &[&Poly], extra_coords: &[f64], ) -> Result<Self>

Source

pub fn new_multipolygon_empty() -> Result<Self>

Source

pub fn new_geometrycollection(geoms: &[&Geom]) -> Result<Self>

Source

pub fn new_geometrycollection_empty() -> Result<Self>

Source

pub unsafe fn from_raw(ptr: *mut tg_geom) -> Option<Self>

§Safety

The pointer must be valid and not owned elsewhere.

Source

pub fn as_ptr(&self) -> *const tg_geom

Source

pub fn into_raw(self) -> *mut tg_geom

Source

pub fn copy(&self) -> Result<Self>

Deep copy.

Source

pub fn clone_ref(&self) -> Result<Self>

Reference-counted clone sharing the underlying data.

Source

pub fn is_feature(&self) -> bool

Source

pub fn is_featurecollection(&self) -> bool

Source

pub fn point(&self) -> Point

Source

pub fn line(&self) -> Option<LineRef<'_>>

Source

pub fn poly(&self) -> Option<PolyRef<'_>>

Source

pub fn num_points(&self) -> usize

Source

pub fn point_at(&self, index: usize) -> Option<Point>

Source

pub fn num_lines(&self) -> usize

Source

pub fn line_at(&self, index: usize) -> Option<LineRef<'_>>

Source

pub fn num_polys(&self) -> usize

Source

pub fn poly_at(&self, index: usize) -> Option<PolyRef<'_>>

Source

pub fn num_geometries(&self) -> usize

Source

pub fn geometry_at(&self, index: usize) -> Option<GeomRef<'_>>

Source

pub fn extra_json(&self) -> Option<&str>

Source

pub fn dims(&self) -> i32

Source

pub fn has_z(&self) -> bool

Source

pub fn has_m(&self) -> bool

Source

pub fn z(&self) -> f64

Source

pub fn m(&self) -> f64

Source

pub fn extra_coords(&self) -> &[f64]

Source

pub fn memsize(&self) -> usize

Source

pub fn fullrect(&self) -> (i32, [f64; 4], [f64; 4])

Returns (dims, min, max).

Source

pub fn error(&self) -> Option<&str>

Source

pub fn equals(&self, other: &Geom) -> bool

Source

pub fn intersects(&self, other: &Geom) -> bool

Source

pub fn disjoint(&self, other: &Geom) -> bool

Source

pub fn contains(&self, other: &Geom) -> bool

Source

pub fn within(&self, other: &Geom) -> bool

Source

pub fn covers(&self, other: &Geom) -> bool

Source

pub fn coveredby(&self, other: &Geom) -> bool

Source

pub fn touches(&self, other: &Geom) -> bool

Source

pub fn intersects_rect(&self, rect: Rect) -> bool

Source

pub fn intersects_xy(&self, x: f64, y: f64) -> bool

Source

pub fn search<F>(&self, rect: Rect, iter: F)
where F: FnMut(GeomRef<'_>, usize) -> bool,

Searches for child geometries intersecting rect. Return true from callback to continue, false to stop.

Source§

impl Geom

Source

pub fn from_geojson(geojson: &str) -> Result<Self>

Source

pub fn from_geojson_ix(geojson: &str, ix: IndexKind) -> Result<Self>

Source

pub fn from_wkt(wkt: &str) -> Result<Self>

Source

pub fn from_wkt_ix(wkt: &str, ix: IndexKind) -> Result<Self>

Source

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

Source

pub fn from_wkb_ix(wkb: &[u8], ix: IndexKind) -> Result<Self>

Source

pub fn from_hex(hex: &str) -> Result<Self>

Source

pub fn from_hex_ix(hex: &str, ix: IndexKind) -> Result<Self>

Source

pub fn from_geobin(geobin: &[u8]) -> Result<Self>

Source

pub fn from_geobin_ix(geobin: &[u8], ix: IndexKind) -> Result<Self>

Source

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

Auto-detect format.

Source

pub fn parse_ix(data: &[u8], ix: IndexKind) -> Result<Self>

Source

pub fn to_geojson(&self) -> String

Source

pub fn to_wkt(&self) -> String

Source

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

Source

pub fn to_hex(&self) -> String

Source

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

Trait Implementations§

Source§

impl Debug for Geom

Source§

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

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

impl Display for Geom

Source§

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

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

impl Drop for Geom

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl PartialEq for Geom

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0§

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 Send for Geom

Source§

impl Sync for Geom

Auto Trait Implementations§

§

impl Freeze for Geom

§

impl RefUnwindSafe for Geom

§

impl Unpin for Geom

§

impl UnwindSafe for Geom

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.