Trait GeoArrowArray

Source
pub trait GeoArrowArray:
    Debug
    + Send
    + Sync {
    // Required methods
    fn as_any(&self) -> &dyn Any;
    fn data_type(&self) -> GeoArrowType;
    fn into_array_ref(self) -> ArrayRef;
    fn to_array_ref(&self) -> ArrayRef;
    fn len(&self) -> usize;
    fn logical_nulls(&self) -> Option<NullBuffer>;
    fn logical_null_count(&self) -> usize;
    fn is_null(&self, i: usize) -> bool;
    fn slice(&self, offset: usize, length: usize) -> Arc<dyn GeoArrowArray>;
    fn with_metadata(self, metadata: Arc<Metadata>) -> Arc<dyn GeoArrowArray>;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn is_valid(&self, i: usize) -> bool { ... }
}
Expand description

A base trait for all GeoArrow arrays.

This is a geospatial corollary to the upstream Array trait.

Required Methods§

Source

fn as_any(&self) -> &dyn Any

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

Prefer using AsGeoArrowArray instead of calling this method and manually downcasting.

Source

fn data_type(&self) -> GeoArrowType

Returns the GeoArrowType of this array.

§Examples
let point = geo_types::point!(x: 1., y: 2.);
let point_type = PointType::new(Dimension::XY, Default::default());
let point_array = PointBuilder::from_points([point].iter(), point_type.clone()).finish();
assert_eq!(point_array.data_type(), GeoArrowType::Point(point_type));
Source

fn into_array_ref(self) -> ArrayRef

Converts this array into an Arced arrow array, consuming the original array.

This is O(1).

Note that this will omit any spatial extension information. You must separately store the spatial information in a Field derived from Self::data_type.

§Examples
let point = geo_types::point!(x: 1., y: 2.);
let point_type = PointType::new(Dimension::XY, Default::default());
let point_array = PointBuilder::from_points([point].iter(), point_type.clone()).finish();
let array_ref: ArrayRef = point_array.into_array_ref();
Source

fn to_array_ref(&self) -> ArrayRef

Converts this array into an Arced arrow array.

This is O(1).

Note that this will omit any spatial extension information. You must separately store the spatial information in a Field derived from Self::data_type.

§Examples
let point = geo_types::point!(x: 1., y: 2.);
let point_type = PointType::new(Dimension::XY, Default::default());
let point_array = PointBuilder::from_points([point].iter(), point_type.clone()).finish();
let array_ref: ArrayRef = point_array.to_array_ref();
Source

fn len(&self) -> usize

The number of geometries contained in this array.

§Examples
let point = geo_types::point!(x: 1., y: 2.);
let point_type = PointType::new(Dimension::XY, Default::default());
let point_array = PointBuilder::from_points([point].iter(), point_type.clone()).finish();
assert_eq!(point_array.len(), 1);
Source

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

Returns a potentially computed `NullBuffer`` that represents the logical null values of this array, if any.

Logical nulls represent the values that are null in the array, regardless of the underlying physical arrow representation.

For most array types, this is equivalent to the “physical” nulls returned by Array::nulls. However it is different for union arrays, including our GeometryArray and GeometryCollectionArray types, because the unions aren’t encoded in a single null buffer.

Source

fn logical_null_count(&self) -> usize

Returns the number of null slots in this array.

This is O(1) since the number of null elements is pre-computed.

§Examples
let point = geo_types::point!(x: 1., y: 2.);
let point_type = PointType::new(Dimension::XY, Default::default());
let point_array =
    PointBuilder::from_nullable_points([Some(&point), None].into_iter(), point_type.clone()).finish();
assert_eq!(point_array.logical_null_count(), 1);
Source

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

Returns whether slot i is null.

§Examples
let point = geo_types::point!(x: 1., y: 2.);

let point_type = PointType::new(Dimension::XY, Default::default());
let point_array =
    PointBuilder::from_nullable_points([Some(&point), None].into_iter(), point_type.clone()).finish();
assert!(point_array.is_null(1));
§Panics

Panics iff i >= self.len().

Source

fn slice(&self, offset: usize, length: usize) -> Arc<dyn GeoArrowArray>

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

§Examples
let point1 = geo_types::point!(x: 1., y: 2.);
let point2 = geo_types::point!(x: 3., y: 4.);

let point_type = PointType::new(Dimension::XY, Default::default());
let point_array =
    Arc::new(PointBuilder::from_points([point1, point2].iter(), point_type.clone()).finish())
        as Arc<dyn GeoArrowArray>;
let sliced_array = point_array.slice(1, 1);
assert_eq!(sliced_array.len(), 1);
§Panics

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

Source

fn with_metadata(self, metadata: Arc<Metadata>) -> Arc<dyn GeoArrowArray>

Change the Metadata of this array.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true if the array is empty.

§Examples
let point = geo_types::point!(x: 1., y: 2.);
let point_type = PointType::new(Dimension::XY, Default::default());
let point_array = PointBuilder::from_points([point].iter(), point_type.clone()).finish();
assert!(!point_array.is_empty());
Source

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

Returns whether slot i is valid.

§Examples
let point = geo_types::point!(x: 1., y: 2.);

let point_type = PointType::new(Dimension::XY, Default::default());
let point_array =
    PointBuilder::from_nullable_points([Some(&point), None].into_iter(), point_type.clone()).finish();
assert!(point_array.is_valid(0));
§Panics

Panics iff i >= self.len().

Trait Implementations§

Source§

impl AsGeoArrowArray for dyn GeoArrowArray + '_

Source§

fn as_point_opt(&self) -> Option<&PointArray>

Downcast this to a PointArray returning None if not possible
Source§

fn as_line_string_opt(&self) -> Option<&LineStringArray>

Downcast this to a LineStringArray with i32 offsets returning None if not possible
Source§

fn as_polygon_opt(&self) -> Option<&PolygonArray>

Downcast this to a PolygonArray with i32 offsets returning None if not possible
Source§

fn as_multi_point_opt(&self) -> Option<&MultiPointArray>

Downcast this to a MultiPointArray with i32 offsets returning None if not possible
Source§

fn as_multi_line_string_opt(&self) -> Option<&MultiLineStringArray>

Downcast this to a MultiLineStringArray with i32 offsets returning None if not possible
Source§

fn as_multi_polygon_opt(&self) -> Option<&MultiPolygonArray>

Downcast this to a MultiPolygonArray with i32 offsets returning None if not possible
Source§

fn as_geometry_collection_opt(&self) -> Option<&GeometryCollectionArray>

Downcast this to a GeometryCollectionArray with i32 offsets returning None if not possible
Source§

fn as_rect_opt(&self) -> Option<&RectArray>

Downcast this to a RectArray returning None if not possible
Source§

fn as_geometry_opt(&self) -> Option<&GeometryArray>

Downcast this to a GeometryArray returning None if not possible
Source§

fn as_wkb_opt<O: OffsetSizeTrait>(&self) -> Option<&GenericWkbArray<O>>

Downcast this to a GenericWkbArray with O offsets returning None if not possible
Source§

fn as_wkb_view_opt(&self) -> Option<&WkbViewArray>

Downcast this to a WkbViewArray returning None if not possible
Source§

fn as_wkt_opt<O: OffsetSizeTrait>(&self) -> Option<&GenericWktArray<O>>

Downcast this to a GenericWktArray with O offsets returning None if not possible
Source§

fn as_wkt_view_opt(&self) -> Option<&WktViewArray>

Downcast this to a WktViewArray returning None if not possible
Source§

fn as_point(&self) -> &PointArray

Downcast this to a PointArray panicking if not possible
Source§

fn as_line_string(&self) -> &LineStringArray

Downcast this to a LineStringArray with i32 offsets panicking if not possible
Source§

fn as_polygon(&self) -> &PolygonArray

Downcast this to a PolygonArray with i32 offsets panicking if not possible
Source§

fn as_multi_point(&self) -> &MultiPointArray

Downcast this to a MultiPointArray with i32 offsets panicking if not possible
Source§

fn as_multi_line_string(&self) -> &MultiLineStringArray

Downcast this to a MultiLineStringArray with i32 offsets panicking if not possible
Source§

fn as_multi_polygon(&self) -> &MultiPolygonArray

Downcast this to a MultiPolygonArray with i32 offsets panicking if not possible
Source§

fn as_geometry_collection(&self) -> &GeometryCollectionArray

Downcast this to a GeometryCollectionArray with i32 offsets panicking if not possible
Source§

fn as_rect(&self) -> &RectArray

Downcast this to a RectArray panicking if not possible
Source§

fn as_geometry(&self) -> &GeometryArray

Downcast this to a GeometryArray panicking if not possible
Source§

fn as_wkb<O: OffsetSizeTrait>(&self) -> &GenericWkbArray<O>

Downcast this to a GenericWkbArray with O offsets panicking if not possible
Source§

fn as_wkb_view(&self) -> &WkbViewArray

Downcast this to a WkbViewArray panicking if not possible
Source§

fn as_wkt<O: OffsetSizeTrait>(&self) -> &GenericWktArray<O>

Downcast this to a GenericWktArray with O offsets panicking if not possible
Source§

fn as_wkt_view(&self) -> &WktViewArray

Downcast this to a WktViewArray panicking if not possible

Implementors§