pub trait GeometryArrayTrait<'a>: Debug + Send + Sync {
Show 19 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 with_coords(self, coords: CoordBuffer) -> Self; fn coord_type(&self) -> CoordType; fn into_coord_type(self, coord_type: CoordType) -> Self; fn len(&self) -> usize; fn validity(&self) -> Option<&NullBuffer>; fn slice(&self, offset: usize, length: usize) -> Self; fn owned_slice(&self, offset: usize, length: usize) -> Self; // 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.

Required Methods§

source

fn as_any(&self) -> &dyn Any

Returns the array as Any so that it can be downcasted to a specific implementation.

Example:
//use geoarrow2::datatypes::GeoDataType;
//use geoarrow2::array::PointArray;
//use geoarrow2::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");
source

fn data_type(&self) -> &GeoDataType

Returns a reference to the DataType of this array.

Example:
use geoarrow2::datatypes::GeoDataType;
use geoarrow2::array::PointArray;
use geoarrow2::GeometryArrayTrait;
use geo::point;

let point = point!(x: 1., y: 2.);
let point_array: PointArray = vec![point].into();

assert!(matches!(point_array.data_type(), GeoDataType::Point(_)));
source

fn storage_type(&self) -> DataType

Get the logical DataType of this array.

source

fn extension_field(&self) -> Arc<Field>

Get the extension type of this array, as defined by the GeoArrow specification.

Always returns DataType::Extension.

source

fn extension_name(&self) -> &str

Get the extension name of this array.

source

fn into_array_ref(self) -> ArrayRef

Convert this array into an arced arrow array.

Implementation

This is O(1).

source

fn with_coords(self, coords: CoordBuffer) -> Self

Create a new array with replaced coordinates

This is useful if you want to apply an operation to every coordinate in unison, such as a reprojection or a scaling operation, with no regards to each individual geometry

source

fn coord_type(&self) -> CoordType

Get the coordinate type of this geometry array, either interleaved or separated.

source

fn into_coord_type(self, coord_type: CoordType) -> Self

Cast the coordinate buffer of this geometry array to the given coordinate type.

source

fn len(&self) -> usize

The number of geometries contained in this array.

source

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.

source

fn slice(&self, offset: usize, length: usize) -> Self

Returns a zero-copy slice of this array with the indicated offset and length.

Panic

This function panics iff offset + length > self.len().

source

fn owned_slice(&self, offset: usize, length: usize) -> Self

A slice that fully copies the contents of the underlying buffer

Provided Methods§

source

fn is_empty(&self) -> bool

Returns true if the array is empty.

source

fn nulls(&self) -> Option<&NullBuffer>

source

fn logical_nulls(&self) -> Option<NullBuffer>

source

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.

source

fn is_null(&self, i: usize) -> bool

Returns whether slot i is null.

Panic

Panics iff i >= self.len().

source

fn is_valid(&self, i: usize) -> bool

Returns whether slot i is valid.

Panic

Panics iff i >= self.len().

Object Safety§

This trait is not object safe.

Implementors§