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
impl GeoArrowType
Sourcepub fn coord_type(&self) -> Option<CoordType>
pub fn coord_type(&self) -> Option<CoordType>
Get the CoordType of this data type.
WKB and WKT variants will return None.
Sourcepub fn to_data_type(&self) -> DataType
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(_)));Sourcepub fn to_field<N: Into<String>>(&self, name: N, nullable: bool) -> Field
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");Sourcepub fn with_coord_type(self, coord_type: CoordType) -> GeoArrowType
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));Sourcepub fn with_dimension(self, dim: Dimension) -> GeoArrowType
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));Sourcepub fn with_metadata(self, meta: Arc<Metadata>) -> GeoArrowType
pub fn with_metadata(self, meta: Arc<Metadata>) -> GeoArrowType
Applies the provided Metadata onto self.
Sourcepub fn from_extension_field(field: &Field) -> GeoArrowResult<Option<Self>>
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
Errreturn value indicates that the field has a GeoArrow extension name, but it is invalid. This can happen if the field’sDataTypeis not compatible with the allowed types for the given GeoArrow type, or if the GeoArrow metadata is malformed.
Sourcepub fn from_arrow_field(field: &Field) -> GeoArrowResult<Self>
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
impl Clone for GeoArrowType
Source§fn clone(&self) -> GeoArrowType
fn clone(&self) -> GeoArrowType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more