pub struct SeparatedCoordBuffer { /* private fields */ }
Expand description
An array of coordinates stored in separate buffers of the same length.
This stores all coordinates in separated fashion as multiple underlying buffers: e.g. xxx
and
yyy
for 2D coordinates.
Implementations§
Source§impl SeparatedCoordBuffer
impl SeparatedCoordBuffer
Sourcepub const COORD_TYPE: CoordType = CoordType::Separated
pub const COORD_TYPE: CoordType = CoordType::Separated
The underlying coordinate type
Sourcepub fn from_array(
buffers: [ScalarBuffer<f64>; 4],
dim: Dimension,
) -> GeoArrowResult<Self>
pub fn from_array( buffers: [ScalarBuffer<f64>; 4], dim: Dimension, ) -> GeoArrowResult<Self>
Construct a new SeparatedCoordBuffer from an array of existing buffers.
The number of valid buffers in the array must match the dimension size. E.g. if the dim
is Dimension::XY
, then only the first two buffers must have non-zero length, and the last
two buffers in the array can have length zero.
Sourcepub fn from_vec(
buffers: Vec<ScalarBuffer<f64>>,
dim: Dimension,
) -> GeoArrowResult<Self>
pub fn from_vec( buffers: Vec<ScalarBuffer<f64>>, dim: Dimension, ) -> GeoArrowResult<Self>
Construct a new SeparatedCoordBuffer from a Vec
of existing buffers.
All buffers within buffers
must have the same length, and the length of buffers
must
equal the dimension size.
Sourcepub fn raw_buffers(&self) -> &[ScalarBuffer<f64>; 4]
pub fn raw_buffers(&self) -> &[ScalarBuffer<f64>; 4]
Access the underlying coordinate buffers.
Note that not all four buffers may be valid. Only so many buffers have defined meaning as there are dimensions, so for an XY buffer, only the first two buffers have defined meaning, and the last two may be any buffer, or empty.
Sourcepub fn buffers(&self) -> Vec<ScalarBuffer<f64>>
pub fn buffers(&self) -> Vec<ScalarBuffer<f64>>
Access the underlying coordinate buffers.
In comparison to raw_buffers, all of the returned buffers are valid.
Sourcepub fn value(&self, index: usize) -> SeparatedCoord<'_>
pub fn value(&self, index: usize) -> SeparatedCoord<'_>
Returns the element at index i
, not considering validity.
§Examples
use geo_traits::CoordTrait;
use geoarrow_array::array::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 = 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) -> SeparatedCoord<'_>
pub unsafe fn value_unchecked(&self, index: usize) -> SeparatedCoord<'_>
Returns the element at index i
, not considering validity.
§Examples
use geo_traits::CoordTrait;
use geoarrow_array::array::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 = 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 from_coords<'a>(
coords: impl ExactSizeIterator<Item = &'a (impl CoordTrait<T = f64> + 'a)>,
dim: Dimension,
) -> GeoArrowResult<Self>
pub fn from_coords<'a>( coords: impl ExactSizeIterator<Item = &'a (impl CoordTrait<T = f64> + 'a)>, dim: Dimension, ) -> GeoArrowResult<Self>
Construct from an iterator of coordinates
Trait Implementations§
Source§impl Clone for SeparatedCoordBuffer
impl Clone for SeparatedCoordBuffer
Source§fn clone(&self) -> SeparatedCoordBuffer
fn clone(&self) -> SeparatedCoordBuffer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more