geoarrow_array/test/
point.rs1use geo_types::{Point, point};
2use geoarrow_schema::{CoordType, Dimension, PointType};
3use geoarrow_test::raw;
4
5use crate::array::PointArray;
6use crate::builder::PointBuilder;
7
8pub(crate) fn p0() -> Point {
9 point!(
10 x: 0., y: 1.
11 )
12}
13
14pub(crate) fn p1() -> Point {
15 point!(
16 x: 1., y: 2.
17 )
18}
19
20pub(crate) fn p2() -> Point {
21 point!(
22 x: 2., y: 3.
23 )
24}
25
26pub(crate) fn point_array(coord_type: CoordType) -> PointArray {
27 let geoms = [Some(p0()), Some(p1()), None, Some(p2())];
28 let typ = PointType::new(Dimension::XY, Default::default()).with_coord_type(coord_type);
29 PointBuilder::from_nullable_points(geoms.iter().map(|x| x.as_ref()), typ).finish()
30}
31
32pub fn array(coord_type: CoordType, dim: Dimension) -> PointArray {
33 let typ = PointType::new(dim, Default::default()).with_coord_type(coord_type);
34 let geoms = match dim {
35 Dimension::XY => raw::point::xy::geoms(),
36 Dimension::XYZ => raw::point::xyz::geoms(),
37 Dimension::XYM => raw::point::xym::geoms(),
38 Dimension::XYZM => raw::point::xyzm::geoms(),
39 };
40 PointBuilder::from_nullable_points(geoms.iter().map(|x| x.as_ref()), typ).finish()
41}