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
impl Geometry
Sourcepub fn kind(&self) -> GeometryKind
pub fn kind(&self) -> GeometryKind
Get the kind of geometry
Sourcepub fn into_point(self) -> Result<Point<f64>>
pub fn into_point(self) -> Result<Point<f64>>
Convert this geometry into the given type
Sourcepub fn from_point(v: Point<f64>) -> Self
pub fn from_point(v: Point<f64>) -> Self
Create a new geometry from the given type
Sourcepub fn into_line(self) -> Result<LineString<f64>>
pub fn into_line(self) -> Result<LineString<f64>>
Convert this geometry into the given type
Sourcepub fn from_line(v: LineString<f64>) -> Self
pub fn from_line(v: LineString<f64>) -> Self
Create a new geometry from the given type
Sourcepub fn is_polygon(&self) -> bool
pub fn is_polygon(&self) -> bool
Check if this is a of the given type
Sourcepub fn into_polygon(self) -> Result<Polygon<f64>>
pub fn into_polygon(self) -> Result<Polygon<f64>>
Convert this geometry into the given type
Sourcepub fn from_polygon(v: Polygon<f64>) -> Self
pub fn from_polygon(v: Polygon<f64>) -> Self
Create a new geometry from the given type
Sourcepub fn is_multipoint(&self) -> bool
pub fn is_multipoint(&self) -> bool
Check if this is a of the given type
Sourcepub fn into_multipoint(self) -> Result<MultiPoint<f64>>
pub fn into_multipoint(self) -> Result<MultiPoint<f64>>
Convert this geometry into the given type
Sourcepub fn from_multipoint(v: MultiPoint<f64>) -> Self
pub fn from_multipoint(v: MultiPoint<f64>) -> Self
Create a new geometry from the given type
Sourcepub fn is_multiline(&self) -> bool
pub fn is_multiline(&self) -> bool
Check if this is a of the given type
Sourcepub fn into_multiline(self) -> Result<MultiLineString<f64>>
pub fn into_multiline(self) -> Result<MultiLineString<f64>>
Convert this geometry into the given type
Sourcepub fn from_multiline(v: MultiLineString<f64>) -> Self
pub fn from_multiline(v: MultiLineString<f64>) -> Self
Create a new geometry from the given type
Sourcepub fn is_multipolygon(&self) -> bool
pub fn is_multipolygon(&self) -> bool
Check if this is a of the given type
Sourcepub fn into_multipolygon(self) -> Result<MultiPolygon<f64>>
pub fn into_multipolygon(self) -> Result<MultiPolygon<f64>>
Convert this geometry into the given type
Sourcepub fn from_multipolygon(v: MultiPolygon<f64>) -> Self
pub fn from_multipolygon(v: MultiPolygon<f64>) -> Self
Create a new geometry from the given type
Sourcepub fn is_collection(&self) -> bool
pub fn is_collection(&self) -> bool
Check if this is a of the given type
Sourcepub fn into_collection(self) -> Result<Vec<Geometry>>
pub fn into_collection(self) -> Result<Vec<Geometry>>
Convert this geometry into the given type
Sourcepub fn from_collection(v: Vec<Geometry>) -> Self
pub fn from_collection(v: Vec<Geometry>) -> Self
Create a new geometry from the given type
Source§impl Geometry
impl Geometry
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Check if this has valid latitude and longitude points:
- -90 <= lat <= 90
- -180 <= lng <= 180
Sourcepub fn as_coordinates(&self) -> Value
pub fn as_coordinates(&self) -> Value
Get the raw coordinates of this Geometry as an Array
Sourcepub fn try_from_object(object: &Object) -> Option<Geometry>
pub fn try_from_object(object: &Object) -> Option<Geometry>
Try to convert an object into a geometry
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Geometry
impl<'de> Deserialize<'de> for Geometry
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>,
Source§impl FromFlatbuffers for Geometry
impl FromFlatbuffers for Geometry
Source§impl PartialOrd for Geometry
impl PartialOrd for Geometry
Source§impl SurrealValue for Geometry
impl SurrealValue for Geometry
Source§fn into_value(self) -> Value
fn into_value(self) -> Value
Source§impl ToFlatbuffers for Geometry
impl ToFlatbuffers for Geometry
impl StructuralPartialEq for Geometry
Auto Trait Implementations§
impl Freeze for Geometry
impl RefUnwindSafe for Geometry
impl Send for Geometry
impl Sync for Geometry
impl Unpin for Geometry
impl UnsafeUnpin for Geometry
impl UnwindSafe for Geometry
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> 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