Skip to main content

Geometry

Enum Geometry 

Source
pub enum Geometry {
    Point(Point<f64>),
    Line(LineString<f64>),
    Polygon(Polygon<f64>),
    MultiPoint(MultiPoint<f64>),
    MultiLine(MultiLineString<f64>),
    MultiPolygon(MultiPolygon<f64>),
    Collection(Vec<Geometry>),
}
Expand description

Represents geometric shapes in SurrealDB

Geometry types support various geometric shapes including points, lines, polygons, and their multi-variants. This is useful for spatial data and geographic applications.

The types used internally originate from the geo crate.

Variants§

§

Point(Point<f64>)

A single point in 2D space

§

Line(LineString<f64>)

A line consisting of multiple connected points

§

Polygon(Polygon<f64>)

A polygon with an exterior boundary and optional interior holes

§

MultiPoint(MultiPoint<f64>)

Multiple points

§

MultiLine(MultiLineString<f64>)

Multiple lines

§

MultiPolygon(MultiPolygon<f64>)

Multiple polygons

§

Collection(Vec<Geometry>)

A collection of different geometry types

Implementations§

Source§

impl Geometry

Source

pub fn kind(&self) -> GeometryKind

Get the kind of geometry

Source

pub fn is_point(&self) -> bool

Check if this is a of the given type

Source

pub fn into_point(self) -> Result<Point<f64>>

Convert this geometry into the given type

Source

pub fn from_point(v: Point<f64>) -> Self

Create a new geometry from the given type

Source

pub fn is_line(&self) -> bool

Check if this is a of the given type

Source

pub fn into_line(self) -> Result<LineString<f64>>

Convert this geometry into the given type

Source

pub fn from_line(v: LineString<f64>) -> Self

Create a new geometry from the given type

Source

pub fn is_polygon(&self) -> bool

Check if this is a of the given type

Source

pub fn into_polygon(self) -> Result<Polygon<f64>>

Convert this geometry into the given type

Source

pub fn from_polygon(v: Polygon<f64>) -> Self

Create a new geometry from the given type

Source

pub fn is_multipoint(&self) -> bool

Check if this is a of the given type

Source

pub fn into_multipoint(self) -> Result<MultiPoint<f64>>

Convert this geometry into the given type

Source

pub fn from_multipoint(v: MultiPoint<f64>) -> Self

Create a new geometry from the given type

Source

pub fn is_multiline(&self) -> bool

Check if this is a of the given type

Source

pub fn into_multiline(self) -> Result<MultiLineString<f64>>

Convert this geometry into the given type

Source

pub fn from_multiline(v: MultiLineString<f64>) -> Self

Create a new geometry from the given type

Source

pub fn is_multipolygon(&self) -> bool

Check if this is a of the given type

Source

pub fn into_multipolygon(self) -> Result<MultiPolygon<f64>>

Convert this geometry into the given type

Source

pub fn from_multipolygon(v: MultiPolygon<f64>) -> Self

Create a new geometry from the given type

Source

pub fn is_collection(&self) -> bool

Check if this is a of the given type

Source

pub fn into_collection(self) -> Result<Vec<Geometry>>

Convert this geometry into the given type

Source

pub fn from_collection(v: Vec<Geometry>) -> Self

Create a new geometry from the given type

Source§

impl Geometry

Source

pub fn is_valid(&self) -> bool

Check if this has valid latitude and longitude points:

  • -90 <= lat <= 90
  • -180 <= lng <= 180
Source

pub fn as_type(&self) -> &'static str

Get the type of this Geometry as text

Source

pub fn as_coordinates(&self) -> Value

Get the raw coordinates of this Geometry as an Array

Source

pub fn as_object(&self) -> Object

Convert this geometry into an object

Source

pub fn try_from_object(object: &Object) -> Option<Geometry>

Try to convert an object into a geometry

Trait Implementations§

Source§

impl Clone for Geometry

Source§

fn clone(&self) -> Geometry

Returns a duplicate 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 Geometry

Source§

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

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

impl<'de> Deserialize<'de> for Geometry

Source§

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 Geometry

Source§

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

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

impl FromFlatbuffers for Geometry

Source§

type Input<'a> = Geometry<'a>

The input type from the flatbuffers builder
Source§

fn from_fb(input: Self::Input<'_>) -> Result<Self>

Convert a flatbuffers builder type to a type.
Source§

impl Hash for Geometry

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. 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 · 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 PartialOrd for Geometry

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Geometry

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 SurrealValue for Geometry

Source§

fn kind_of() -> Kind

Returns the kind that represents this type
Source§

fn is_value(value: &Value) -> bool

Checks if the given value can be converted to this type
Source§

fn into_value(self) -> Value

Converts this type into a SurrealDB value
Source§

fn from_value(value: Value) -> Result<Self, Error>

Attempts to convert a SurrealDB value into this type
Source§

impl ToFlatbuffers for Geometry

Source§

type Output<'bldr> = WIPOffset<Geometry<'bldr>>

The output type for the flatbuffers builder
Source§

fn to_fb<'bldr>( &self, builder: &mut FlatBufferBuilder<'bldr>, ) -> Result<Self::Output<'bldr>>

Convert the type to a flatbuffers builder type.
Source§

impl ToSql for Geometry

Source§

fn fmt_sql(&self, f: &mut String, _fmt: SqlFormat)

Format the type to a SQL string.
Source§

fn to_sql(&self) -> String

Convert the type to a SQL string.
Source§

fn to_sql_pretty(&self) -> String

Convert the type to a pretty-printed SQL string with indentation.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool

Source§

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