GeoArrowType

Enum GeoArrowType 

Source
pub enum GeoArrowType {
Show 15 variants Point(PointType), LineString(LineStringType), Polygon(PolygonType), MultiPoint(MultiPointType), MultiLineString(MultiLineStringType), MultiPolygon(MultiPolygonType), GeometryCollection(GeometryCollectionType), Rect(BoxType), Geometry(GeometryType), Wkb(WkbType), LargeWkb(WkbType), WkbView(WkbType), Wkt(WktType), LargeWkt(WktType), WktView(WktType),
}
Expand description

Geospatial data types supported by GeoArrow.

The variants of this enum include all possible GeoArrow geometry types, including both “native” and “serialized” encodings.

Each variant uniquely identifies the physical buffer layout for the respective array type.

Variants§

§

Point(PointType)

A Point.

§

LineString(LineStringType)

A LineString.

§

Polygon(PolygonType)

A Polygon.

§

MultiPoint(MultiPointType)

A MultiPoint.

§

MultiLineString(MultiLineStringType)

A MultiLineString.

§

MultiPolygon(MultiPolygonType)

A MultiPolygon.

§

GeometryCollection(GeometryCollectionType)

A GeometryCollection.

§

Rect(BoxType)

A Rect.

§

Geometry(GeometryType)

A Geometry with unknown types or dimensions.

§

Wkb(WkbType)

A WKB stored in a BinaryArray with i32 offsets.

§

LargeWkb(WkbType)

A WKB stored in a LargeBinaryArray with i64 offsets.

§

WkbView(WkbType)

A WKB stored in a BinaryViewArray.

§

Wkt(WktType)

A WKT stored in a StringArray with i32 offsets.

§

LargeWkt(WktType)

A WKT stored in a LargeStringArray with i64 offsets.

§

WktView(WktType)

A WKT stored in a StringViewArray.

Implementations§

Source§

impl GeoArrowType

Source

pub fn coord_type(&self) -> Option<CoordType>

Get the CoordType of this data type.

WKB and WKT variants will return None.

Source

pub fn dimension(&self) -> Option<Dimension>

Get the Dimension of this data type, if it has one.

Geometry and WKB and WKT variants will return None.

Source

pub fn metadata(&self) -> &Arc<Metadata>

Returns the Metadata contained within this type.

Source

pub fn to_data_type(&self) -> DataType

Converts a GeoArrowType into the relevant arrow DataType.

Note that an arrow DataType will lose the accompanying GeoArrow metadata if it is not part of a Field with GeoArrow extension metadata in its field metadata.

§Examples
let point_type = PointType::new(Dimension::XY, Default::default());
let data_type = GeoArrowType::Point(point_type).to_data_type();
assert!(matches!(data_type, DataType::Struct(_)));
Source

pub fn to_field<N: Into<String>>(&self, name: N, nullable: bool) -> Field

Converts this GeoArrowType into an arrow Field, maintaining GeoArrow extension metadata.

§Examples
let point_type = PointType::new(Dimension::XY, Default::default());
let geoarrow_type = GeoArrowType::Point(point_type);
let field = geoarrow_type.to_field("geometry", true);
assert_eq!(field.name(), "geometry");
assert!(field.is_nullable());
assert_eq!(field.metadata()["ARROW:extension:name"], "geoarrow.point");
Source

pub fn with_coord_type(self, coord_type: CoordType) -> GeoArrowType

Applies the provided CoordType onto self.

Rect and WKB and WKT variants will return the same type as they do not have a parameterized coordinate types.

§Examples
let point_type = PointType::new(Dimension::XY, Default::default());
let geoarrow_type = GeoArrowType::Point(point_type);
let new_type = geoarrow_type.with_coord_type(CoordType::Separated);

assert_eq!(new_type.coord_type(), Some(CoordType::Separated));
Source

pub fn with_dimension(self, dim: Dimension) -> GeoArrowType

Applies the provided Dimension onto self.

Geometry and WKB and WKT variants will return the same type as they do not have a parameterized dimension.

§Examples
let point_type = PointType::new(Dimension::XY, Default::default());
let geoarrow_type = GeoArrowType::Point(point_type);
let new_type = geoarrow_type.with_dimension(Dimension::XYZ);

assert_eq!(new_type.dimension(), Some(Dimension::XYZ));
Source

pub fn with_metadata(self, meta: Arc<Metadata>) -> GeoArrowType

Applies the provided Metadata onto self.

Source

pub fn from_extension_field(field: &Field) -> GeoArrowResult<Option<Self>>

Create a new GeoArrowType from an Arrow Field, requiring GeoArrow metadata to be set.

If the field does not have at least a GeoArrow extension name, an error will be returned.

Create a new GeoArrowType from an Arrow Field.

This method requires GeoArrow metadata to be correctly set. If you wish to allow data type coercion without GeoArrow metadata, use GeoArrowType::from_arrow_field instead.

  • An Ok(Some(_)) return value indicates that the field has valid GeoArrow extension metadata, and thus was able to match to a specific GeoArrow type.
  • An Ok(None) return value indicates that the field either does not have any Arrow extension name or the extension name is not a GeoArrow extension name.
  • An Err return value indicates that the field has a GeoArrow extension name, but it is invalid. This can happen if the field’s DataType is not compatible with the allowed types for the given GeoArrow type, or if the GeoArrow metadata is malformed.
Source

pub fn from_arrow_field(field: &Field) -> GeoArrowResult<Self>

Create a new GeoArrowType from an Arrow Field, inferring the GeoArrow type if GeoArrow metadata is not present.

This will first try GeoArrowType::from_extension_field, and if that fails, will try to infer the GeoArrow type from the field’s DataType. This only works for Point, WKB, and WKT types, as those are the only types that can be unambiguously inferred from an Arrow DataType.

Trait Implementations§

Source§

impl Clone for GeoArrowType

Source§

fn clone(&self) -> GeoArrowType

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 GeoArrowType

Source§

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

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

impl From<BoxType> for GeoArrowType

Source§

fn from(value: BoxType) -> Self

Converts to this type from the input type.
Source§

impl From<GeoArrowType> for DataType

Source§

fn from(value: GeoArrowType) -> Self

Converts to this type from the input type.
Source§

impl From<GeometryCollectionType> for GeoArrowType

Source§

fn from(value: GeometryCollectionType) -> Self

Converts to this type from the input type.
Source§

impl From<GeometryType> for GeoArrowType

Source§

fn from(value: GeometryType) -> Self

Converts to this type from the input type.
Source§

impl From<LineStringType> for GeoArrowType

Source§

fn from(value: LineStringType) -> Self

Converts to this type from the input type.
Source§

impl From<MultiLineStringType> for GeoArrowType

Source§

fn from(value: MultiLineStringType) -> Self

Converts to this type from the input type.
Source§

impl From<MultiPointType> for GeoArrowType

Source§

fn from(value: MultiPointType) -> Self

Converts to this type from the input type.
Source§

impl From<MultiPolygonType> for GeoArrowType

Source§

fn from(value: MultiPolygonType) -> Self

Converts to this type from the input type.
Source§

impl From<PointType> for GeoArrowType

Source§

fn from(value: PointType) -> Self

Converts to this type from the input type.
Source§

impl From<PolygonType> for GeoArrowType

Source§

fn from(value: PolygonType) -> Self

Converts to this type from the input type.
Source§

impl Hash for GeoArrowType

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 GeoArrowType

Source§

fn eq(&self, other: &GeoArrowType) -> 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 TryFrom<&Field> for GeoArrowType

Source§

type Error = GeoArrowError

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

fn try_from(field: &Field) -> GeoArrowResult<Self>

Performs the conversion.
Source§

impl Eq for GeoArrowType

Source§

impl StructuralPartialEq for GeoArrowType

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.