Trait geoarrow::trait_::GeometryArrayTrait
source · pub trait GeometryArrayTrait: Debug + Send + Sync {
Show 18 methods
// Required methods
fn as_any(&self) -> &dyn Any;
fn data_type(&self) -> &GeoDataType;
fn storage_type(&self) -> DataType;
fn extension_field(&self) -> Arc<Field>;
fn extension_name(&self) -> &str;
fn into_array_ref(self) -> ArrayRef;
fn to_array_ref(&self) -> ArrayRef;
fn coord_type(&self) -> CoordType;
fn len(&self) -> usize;
fn validity(&self) -> Option<&NullBuffer>;
fn metadata(&self) -> Arc<ArrayMetadata>;
fn as_ref(&self) -> &dyn GeometryArrayTrait;
// Provided methods
fn is_empty(&self) -> bool { ... }
fn nulls(&self) -> Option<&NullBuffer> { ... }
fn logical_nulls(&self) -> Option<NullBuffer> { ... }
fn null_count(&self) -> usize { ... }
fn is_null(&self, i: usize) -> bool { ... }
fn is_valid(&self, i: usize) -> bool { ... }
}
Expand description
A trait of common methods that all geometry arrays in this crate implement.
This trait is often used for downcasting. If you have a dynamically-typed Arc<dyn GeometryArrayTrait>
, to downcast into a strongly-typed chunked array use as_any
with the
data_type
method to discern which chunked array type to pass to downcast_ref
.
Required Methods§
sourcefn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Returns the array as Any
so that it can be
downcasted to a specific implementation.
Example:
//use geoarrow::datatypes::GeoDataType;
//use geoarrow::array::PointArray;
//use geoarrow::GeometryArrayTrait;
//use geo::point;
//let point = point!(x: 1., y: 2.);
//let point_array: PointArray = vec![point].into();
//let geometry_array = Arc::new(point_array) as Arc<dyn GeometryArrayTrait>;
let id = Int32Array::from(vec![1, 2, 3, 4, 5]);
let batch = RecordBatch::try_new(
Arc::new(Schema::new(vec![Field::new("id", DataType::Int32, false)])),
vec![Arc::new(id)]
).unwrap();
let int32array = batch
.column(0)
.as_any()
.downcast_ref::<Int32Array>()
.expect("Failed to downcast");
sourcefn data_type(&self) -> &GeoDataType
fn data_type(&self) -> &GeoDataType
Returns a reference to the GeoDataType
of this array.
Example:
use geoarrow::datatypes::GeoDataType;
use geoarrow::array::PointArray;
use geoarrow::GeometryArrayTrait;
use geo::point;
let point = point!(x: 1., y: 2.);
let point_array: PointArray = vec![point].as_slice().into();
assert!(matches!(point_array.data_type(), GeoDataType::Point(_)));
sourcefn storage_type(&self) -> DataType
fn storage_type(&self) -> DataType
Get the logical DataType of this array.
sourcefn extension_field(&self) -> Arc<Field>
fn extension_field(&self) -> Arc<Field>
Get the extension type of this array, as defined by the GeoArrow specification.
Always returns DataType::Extension
.
sourcefn extension_name(&self) -> &str
fn extension_name(&self) -> &str
Get the extension name of this array.
sourcefn into_array_ref(self) -> ArrayRef
fn into_array_ref(self) -> ArrayRef
fn to_array_ref(&self) -> ArrayRef
sourcefn coord_type(&self) -> CoordType
fn coord_type(&self) -> CoordType
Get the coordinate type of this geometry array, either interleaved or separated.
sourcefn validity(&self) -> Option<&NullBuffer>
fn validity(&self) -> Option<&NullBuffer>
Access the array’s validity. Every array has an optional NullBuffer
that, when available
specifies whether the array slot is valid or not (null). When the validity is None
, all
slots are valid.
fn metadata(&self) -> Arc<ArrayMetadata>
fn as_ref(&self) -> &dyn GeometryArrayTrait
Provided Methods§
fn nulls(&self) -> Option<&NullBuffer>
fn logical_nulls(&self) -> Option<NullBuffer>
sourcefn null_count(&self) -> usize
fn null_count(&self) -> usize
The number of null slots in this array.
Implementation
This is O(1)
since the number of null elements is pre-computed.
Trait Implementations§
source§impl AffineOps<&[AffineTransform]> for &dyn GeometryArrayTrait
impl AffineOps<&[AffineTransform]> for &dyn GeometryArrayTrait
type Output = Result<Arc<dyn GeometryArrayTrait>, GeoArrowError>
source§fn affine_transform(&self, transform: &[AffineTransform]) -> Self::Output
fn affine_transform(&self, transform: &[AffineTransform]) -> Self::Output
transform
immutably, outputting a new geometry.source§impl AffineOps<&AffineTransform> for &dyn GeometryArrayTrait
impl AffineOps<&AffineTransform> for &dyn GeometryArrayTrait
type Output = Result<Arc<dyn GeometryArrayTrait>, GeoArrowError>
source§fn affine_transform(&self, transform: &AffineTransform) -> Self::Output
fn affine_transform(&self, transform: &AffineTransform) -> Self::Output
transform
immutably, outputting a new geometry.source§impl Area for &dyn GeometryArrayTrait
impl Area for &dyn GeometryArrayTrait
type Output = Result<PrimitiveArray<Float64Type>, GeoArrowError>
fn area(&self) -> Self::Output
source§impl Area for &dyn GeometryArrayTrait
impl Area for &dyn GeometryArrayTrait
type Output = Result<PrimitiveArray<Float64Type>, GeoArrowError>
fn signed_area(&self) -> Self::Output
fn unsigned_area(&self) -> Self::Output
source§impl AsGeometryArray for &dyn GeometryArrayTrait
impl AsGeometryArray for &dyn GeometryArrayTrait
source§fn as_point_opt(&self) -> Option<&PointArray>
fn as_point_opt(&self) -> Option<&PointArray>
PointArray
returning None
if not possiblesource§fn as_line_string_opt(&self) -> Option<&LineStringArray<i32>>
fn as_line_string_opt(&self) -> Option<&LineStringArray<i32>>
source§fn as_large_line_string_opt(&self) -> Option<&LineStringArray<i64>>
fn as_large_line_string_opt(&self) -> Option<&LineStringArray<i64>>
source§fn as_polygon_opt(&self) -> Option<&PolygonArray<i32>>
fn as_polygon_opt(&self) -> Option<&PolygonArray<i32>>
source§fn as_large_polygon_opt(&self) -> Option<&PolygonArray<i64>>
fn as_large_polygon_opt(&self) -> Option<&PolygonArray<i64>>
source§fn as_multi_point_opt(&self) -> Option<&MultiPointArray<i32>>
fn as_multi_point_opt(&self) -> Option<&MultiPointArray<i32>>
source§fn as_large_multi_point_opt(&self) -> Option<&MultiPointArray<i64>>
fn as_large_multi_point_opt(&self) -> Option<&MultiPointArray<i64>>
source§fn as_multi_line_string_opt(&self) -> Option<&MultiLineStringArray<i32>>
fn as_multi_line_string_opt(&self) -> Option<&MultiLineStringArray<i32>>
source§fn as_large_multi_line_string_opt(&self) -> Option<&MultiLineStringArray<i64>>
fn as_large_multi_line_string_opt(&self) -> Option<&MultiLineStringArray<i64>>
source§fn as_multi_polygon_opt(&self) -> Option<&MultiPolygonArray<i32>>
fn as_multi_polygon_opt(&self) -> Option<&MultiPolygonArray<i32>>
source§fn as_large_multi_polygon_opt(&self) -> Option<&MultiPolygonArray<i64>>
fn as_large_multi_polygon_opt(&self) -> Option<&MultiPolygonArray<i64>>
source§fn as_mixed_opt(&self) -> Option<&MixedGeometryArray<i32>>
fn as_mixed_opt(&self) -> Option<&MixedGeometryArray<i32>>
source§fn as_large_mixed_opt(&self) -> Option<&MixedGeometryArray<i64>>
fn as_large_mixed_opt(&self) -> Option<&MixedGeometryArray<i64>>
source§fn as_geometry_collection_opt(&self) -> Option<&GeometryCollectionArray<i32>>
fn as_geometry_collection_opt(&self) -> Option<&GeometryCollectionArray<i32>>
source§fn as_large_geometry_collection_opt(
&self
) -> Option<&GeometryCollectionArray<i64>>
fn as_large_geometry_collection_opt( &self ) -> Option<&GeometryCollectionArray<i64>>
source§fn as_rect_opt(&self) -> Option<&RectArray>
fn as_rect_opt(&self) -> Option<&RectArray>
RectArray
returning None
if not possiblesource§fn as_point(&self) -> &PointArray
fn as_point(&self) -> &PointArray
PointArray
panicking if not possiblesource§fn as_line_string(&self) -> &LineStringArray<i32>
fn as_line_string(&self) -> &LineStringArray<i32>
LineStringArray
with i32
offsets panicking if not possiblesource§fn as_large_line_string(&self) -> &LineStringArray<i64>
fn as_large_line_string(&self) -> &LineStringArray<i64>
LineStringArray
with i64
offsets panicking if not possiblesource§fn as_polygon(&self) -> &PolygonArray<i32>
fn as_polygon(&self) -> &PolygonArray<i32>
PolygonArray
with i32
offsets panicking if not possiblesource§fn as_large_polygon(&self) -> &PolygonArray<i64>
fn as_large_polygon(&self) -> &PolygonArray<i64>
PolygonArray
with i64
offsets panicking if not possiblesource§fn as_multi_point(&self) -> &MultiPointArray<i32>
fn as_multi_point(&self) -> &MultiPointArray<i32>
MultiPointArray
with i32
offsets panicking if not possiblesource§fn as_large_multi_point(&self) -> &MultiPointArray<i64>
fn as_large_multi_point(&self) -> &MultiPointArray<i64>
MultiPointArray
with i64
offsets panicking if not possiblesource§fn as_multi_line_string(&self) -> &MultiLineStringArray<i32>
fn as_multi_line_string(&self) -> &MultiLineStringArray<i32>
MultiLineStringArray
with i32
offsets panicking if not possiblesource§fn as_large_multi_line_string(&self) -> &MultiLineStringArray<i64>
fn as_large_multi_line_string(&self) -> &MultiLineStringArray<i64>
MultiLineStringArray
with i64
offsets panicking if not possiblesource§fn as_multi_polygon(&self) -> &MultiPolygonArray<i32>
fn as_multi_polygon(&self) -> &MultiPolygonArray<i32>
MultiPolygonArray
with i32
offsets panicking if not possiblesource§fn as_large_multi_polygon(&self) -> &MultiPolygonArray<i64>
fn as_large_multi_polygon(&self) -> &MultiPolygonArray<i64>
MultiPolygonArray
with i64
offsets panicking if not possiblesource§fn as_mixed(&self) -> &MixedGeometryArray<i32>
fn as_mixed(&self) -> &MixedGeometryArray<i32>
MixedGeometryArray
with i32
offsets panicking if not possiblesource§fn as_large_mixed(&self) -> &MixedGeometryArray<i64>
fn as_large_mixed(&self) -> &MixedGeometryArray<i64>
MixedGeometryArray
with i64
offsets panicking if not possiblesource§fn as_geometry_collection(&self) -> &GeometryCollectionArray<i32>
fn as_geometry_collection(&self) -> &GeometryCollectionArray<i32>
GeometryCollectionArray
with i32
offsets panicking if not possiblesource§fn as_large_geometry_collection(&self) -> &GeometryCollectionArray<i64>
fn as_large_geometry_collection(&self) -> &GeometryCollectionArray<i64>
GeometryCollectionArray
with i64
offsets panicking if not possiblesource§fn as_wkb(&self) -> &WKBArray<i32>
fn as_wkb(&self) -> &WKBArray<i32>
WKBArray
with i32
offsets panicking if not possiblesource§impl BoundingRect for &dyn GeometryArrayTrait
impl BoundingRect for &dyn GeometryArrayTrait
type Output = Result<RectArray, GeoArrowError>
source§fn bounding_rect(&self) -> Self::Output
fn bounding_rect(&self) -> Self::Output
source§impl Cast for &dyn GeometryArrayTrait
impl Cast for &dyn GeometryArrayTrait
type Output = Result<Arc<dyn GeometryArrayTrait>, GeoArrowError>
fn cast(&self, to_type: &GeoDataType) -> Self::Output
source§impl Center for &dyn GeometryArrayTrait
impl Center for &dyn GeometryArrayTrait
type Output = Result<PointArray, GeoArrowError>
fn center(&self) -> Self::Output
source§impl Centroid for &dyn GeometryArrayTrait
impl Centroid for &dyn GeometryArrayTrait
type Output = Result<PointArray, GeoArrowError>
source§impl ChaikinSmoothing for &dyn GeometryArrayTrait
impl ChaikinSmoothing for &dyn GeometryArrayTrait
type Output = Result<Arc<dyn GeometryArrayTrait>, GeoArrowError>
source§fn chaikin_smoothing(&self, n_iterations: u32) -> Self::Output
fn chaikin_smoothing(&self, n_iterations: u32) -> Self::Output
n_iterations
times.