pub enum CoordBuffer {
Interleaved(InterleavedCoordBuffer),
Separated(SeparatedCoordBuffer),
}
Expand description
An Arrow representation of an array of coordinates.
As defined in the GeoArrow spec, coordinates can either be interleaved (i.e. a single array of XYXYXY) or separated (i.e. two arrays, one XXX and another YYY).
This CoordBuffer abstracts over an InterleavedCoordBuffer
and a SeparatedCoordBuffer
.
For now all coordinate buffers support only two dimensions.
This is named CoordBuffer
instead of CoordArray
because the buffer does not store its own
validity bitmask. Rather the geometry arrays that build on top of this maintain their own
validity masks.
Variants§
Interleaved(InterleavedCoordBuffer)
Interleaved coordinates
Separated(SeparatedCoordBuffer)
Separated coordinates
Implementations§
Source§impl CoordBuffer
impl CoordBuffer
Sourcepub fn coord_type(&self) -> CoordType
pub fn coord_type(&self) -> CoordType
The underlying coordinate type
Sourcepub fn value(&self, index: usize) -> Coord<'_>
pub fn value(&self, index: usize) -> Coord<'_>
Returns the element at index i
, not considering validity.
§Examples
use geo_traits::CoordTrait;
use geoarrow_array::array::{CoordBuffer, SeparatedCoordBuffer};
use geoarrow_schema::Dimension;
let coords = [
geo_types::coord! { x: 1.0, y: 2.0 },
geo_types::coord! { x: 3.0, y: 4.0 },
];
let coord_buffer = CoordBuffer::from(
SeparatedCoordBuffer::from_coords(coords.iter(), Dimension::XY).unwrap()
);
let coord = coord_buffer.value(0);
assert_eq!(coord.x(), 1.0);
assert_eq!(coord.y(), 2.0);
§Panics
Panics if the value is outside the bounds of the buffer.
Sourcepub unsafe fn value_unchecked(&self, index: usize) -> Coord<'_>
pub unsafe fn value_unchecked(&self, index: usize) -> Coord<'_>
Returns the element at index i
, not considering validity.
§Examples
use geo_traits::CoordTrait;
use geoarrow_array::array::{CoordBuffer, SeparatedCoordBuffer};
use geoarrow_schema::Dimension;
let coords = [
geo_types::coord! { x: 1.0, y: 2.0 },
geo_types::coord! { x: 3.0, y: 4.0 },
];
let coord_buffer = CoordBuffer::from(
SeparatedCoordBuffer::from_coords(coords.iter(), Dimension::XY).unwrap()
);
let coord = unsafe { coord_buffer.value_unchecked(0) };
assert_eq!(coord.x(), 1.0);
assert_eq!(coord.y(), 2.0);
§Safety
Caller is responsible for ensuring that the index is within the bounds of the buffer.
Sourcepub fn into_coord_type(self, coord_type: CoordType) -> Self
pub fn into_coord_type(self, coord_type: CoordType) -> Self
Convert this coordinate array into the given CoordType
This is a no-op if the coord_type matches the existing coord type. Otherwise a full clone of the underlying coordinate buffers will be performed.
Trait Implementations§
Source§impl Clone for CoordBuffer
impl Clone for CoordBuffer
Source§fn clone(&self) -> CoordBuffer
fn clone(&self) -> CoordBuffer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more