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§
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.
Prefer using AsGeoArrowArray
instead of calling this
method and manually downcasting.
Sourcefn data_type(&self) -> GeoArrowType
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));
Sourcefn into_array_ref(self) -> ArrayRef
fn into_array_ref(self) -> ArrayRef
Converts this array into an Arc
ed 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();
Sourcefn to_array_ref(&self) -> ArrayRef
fn to_array_ref(&self) -> ArrayRef
Converts this array into an Arc
ed 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();
Sourcefn len(&self) -> usize
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);
Sourcefn logical_nulls(&self) -> Option<NullBuffer>
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.
Sourcefn logical_null_count(&self) -> usize
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);
Sourcefn is_null(&self, i: usize) -> bool
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()
.
Sourcefn slice(&self, offset: usize, length: usize) -> Arc<dyn GeoArrowArray>
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()
.
Sourcefn with_metadata(self, metadata: Arc<Metadata>) -> Arc<dyn GeoArrowArray>
fn with_metadata(self, metadata: Arc<Metadata>) -> Arc<dyn GeoArrowArray>
Change the Metadata
of this array.
Provided Methods§
Sourcefn is_empty(&self) -> bool
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());
Sourcefn is_valid(&self, i: usize) -> bool
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 + '_
impl AsGeoArrowArray for dyn GeoArrowArray + '_
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>
fn as_line_string_opt(&self) -> Option<&LineStringArray>
Source§fn as_polygon_opt(&self) -> Option<&PolygonArray>
fn as_polygon_opt(&self) -> Option<&PolygonArray>
Source§fn as_multi_point_opt(&self) -> Option<&MultiPointArray>
fn as_multi_point_opt(&self) -> Option<&MultiPointArray>
Source§fn as_multi_line_string_opt(&self) -> Option<&MultiLineStringArray>
fn as_multi_line_string_opt(&self) -> Option<&MultiLineStringArray>
Source§fn as_multi_polygon_opt(&self) -> Option<&MultiPolygonArray>
fn as_multi_polygon_opt(&self) -> Option<&MultiPolygonArray>
Source§fn as_geometry_collection_opt(&self) -> Option<&GeometryCollectionArray>
fn as_geometry_collection_opt(&self) -> Option<&GeometryCollectionArray>
Source§fn as_rect_opt(&self) -> Option<&RectArray>
fn as_rect_opt(&self) -> Option<&RectArray>
RectArray
returning None
if not possibleSource§fn as_geometry_opt(&self) -> Option<&GeometryArray>
fn as_geometry_opt(&self) -> Option<&GeometryArray>
GeometryArray
returning None
if not possibleSource§fn as_wkb_opt<O: OffsetSizeTrait>(&self) -> Option<&GenericWkbArray<O>>
fn as_wkb_opt<O: OffsetSizeTrait>(&self) -> Option<&GenericWkbArray<O>>
Source§fn as_wkb_view_opt(&self) -> Option<&WkbViewArray>
fn as_wkb_view_opt(&self) -> Option<&WkbViewArray>
WkbViewArray
returning None
if not possibleSource§fn as_wkt_opt<O: OffsetSizeTrait>(&self) -> Option<&GenericWktArray<O>>
fn as_wkt_opt<O: OffsetSizeTrait>(&self) -> Option<&GenericWktArray<O>>
Source§fn as_wkt_view_opt(&self) -> Option<&WktViewArray>
fn as_wkt_view_opt(&self) -> Option<&WktViewArray>
WktViewArray
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
fn as_line_string(&self) -> &LineStringArray
LineStringArray
with i32
offsets panicking if not possibleSource§fn as_polygon(&self) -> &PolygonArray
fn as_polygon(&self) -> &PolygonArray
PolygonArray
with i32
offsets panicking if not possibleSource§fn as_multi_point(&self) -> &MultiPointArray
fn as_multi_point(&self) -> &MultiPointArray
MultiPointArray
with i32
offsets panicking if not possibleSource§fn as_multi_line_string(&self) -> &MultiLineStringArray
fn as_multi_line_string(&self) -> &MultiLineStringArray
MultiLineStringArray
with i32
offsets panicking if not possibleSource§fn as_multi_polygon(&self) -> &MultiPolygonArray
fn as_multi_polygon(&self) -> &MultiPolygonArray
MultiPolygonArray
with i32
offsets panicking if not possibleSource§fn as_geometry_collection(&self) -> &GeometryCollectionArray
fn as_geometry_collection(&self) -> &GeometryCollectionArray
GeometryCollectionArray
with i32
offsets panicking if not possibleSource§fn as_geometry(&self) -> &GeometryArray
fn as_geometry(&self) -> &GeometryArray
GeometryArray
panicking if not possibleSource§fn as_wkb<O: OffsetSizeTrait>(&self) -> &GenericWkbArray<O>
fn as_wkb<O: OffsetSizeTrait>(&self) -> &GenericWkbArray<O>
GenericWkbArray
with O
offsets panicking if not possibleSource§fn as_wkb_view(&self) -> &WkbViewArray
fn as_wkb_view(&self) -> &WkbViewArray
WkbViewArray
panicking if not possibleSource§fn as_wkt<O: OffsetSizeTrait>(&self) -> &GenericWktArray<O>
fn as_wkt<O: OffsetSizeTrait>(&self) -> &GenericWktArray<O>
GenericWktArray
with O
offsets panicking if not possibleSource§fn as_wkt_view(&self) -> &WktViewArray
fn as_wkt_view(&self) -> &WktViewArray
WktViewArray
panicking if not possible