11// SPDX-License-Identifier: Apache-2.0
22// SPDX-FileCopyrightText: Copyright the Vortex contributors
33
4- //! Coordinate building blocks for geometry extension types: the `Struct<x, y, [z], [m] >` storage,
4+ //! Coordinate building blocks for geometry extension types: the `Struct<x, y, z?, m? >` storage,
55//! its [`Dimension`], and the decoded [`Coordinate`] value.
6+ //!
7+ //! The coordinate fields, where `?` marks an optional field, are:
8+ //! - `x` — longitude or easting
9+ //! - `y` — latitude or northing
10+ //! - `z?` — elevation
11+ //! - `m?` — measure: an arbitrary per-point value such as distance along a route or a timestamp
612
713use std:: fmt:: Display ;
814use std:: fmt:: Formatter ;
@@ -22,7 +28,7 @@ use vortex_error::VortexResult;
2228use vortex_error:: vortex_bail;
2329use vortex_error:: vortex_err;
2430
25- /// Coordinate dimensions, matching GeoArrow. Field order is fixed: x, y , then z before m .
31+ /// Coordinate dimensions, matching GeoArrow. Field order is fixed: `x`, `y` , then `z` before `m` .
2632#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
2733pub ( crate ) enum Dimension {
2834 /// 2D: `x`, `y`.
@@ -48,7 +54,7 @@ impl Dimension {
4854 }
4955}
5056
51- /// A decoded coordinate. `z`/`m` are `Some` iff the storage dimension includes them.
57+ /// A decoded coordinate. `z? `/`m? ` are `Some` iff the storage dimension includes them.
5258///
5359/// This is the native value produced when unpacking a [`Point`](crate::extension::Point) scalar;
5460/// the rest of the coordinate machinery is crate-internal.
@@ -58,14 +64,14 @@ pub struct Coordinate {
5864 x : f64 ,
5965 /// The y (latitude/northing) ordinate.
6066 y : f64 ,
61- /// The optional z (elevation) ordinate.
67+ /// The optional `z?` (elevation) ordinate.
6268 z : Option < f64 > ,
63- /// The optional m (measure) ordinate.
69+ /// The optional `m?` (measure) ordinate.
6470 m : Option < f64 > ,
6571}
6672
6773impl Coordinate {
68- /// A 2D coordinate (no `z `/`m` ).
74+ /// A 2D coordinate (`z? `/`m?` unset ).
6975 pub fn xy ( x : f64 , y : f64 ) -> Self {
7076 Coordinate {
7177 x,
@@ -85,12 +91,12 @@ impl Coordinate {
8591 self . y
8692 }
8793
88- /// The z (elevation) ordinate, if the dimension includes one.
94+ /// The `z?` (elevation) ordinate, if the dimension includes one.
8995 pub fn z ( & self ) -> Option < f64 > {
9096 self . z
9197 }
9298
93- /// The m (measure) ordinate, if the dimension includes one.
99+ /// The `m?` (measure) ordinate, if the dimension includes one.
94100 pub fn m ( & self ) -> Option < f64 > {
95101 self . m
96102 }
@@ -123,7 +129,7 @@ pub(crate) fn coordinate_dimension(dtype: &DType) -> VortexResult<Dimension> {
123129 Dimension :: from_field_names ( & names)
124130}
125131
126- /// Decode a [`Coordinate`] from a coordinate `Struct<x, y, [z], [m] >` scalar (`z`/`m` read iff
132+ /// Decode a [`Coordinate`] from a coordinate `Struct<x, y, z?, m? >` scalar (`z? `/`m? ` read iff
127133/// present, so the same decoder serves every dimension).
128134pub ( crate ) fn coordinate_from_struct ( scalar : & Scalar ) -> VortexResult < Coordinate > {
129135 let fields = scalar. as_struct ( ) ;
@@ -158,7 +164,7 @@ pub(crate) fn coordinate_from_scalar(scalar: &Scalar) -> VortexResult<Coordinate
158164}
159165
160166/// Canonicalize a point column once and return its flat `x`/`y` `f64` columns. The bulk counterpart
161- /// to [`coordinate_from_scalar`]; distances use only `x`/`y`, so `z`/`m` are ignored.
167+ /// to [`coordinate_from_scalar`]; distances use only `x`/`y`, so `z? `/`m? ` are ignored.
162168pub ( crate ) fn xy_columns (
163169 points : & ArrayRef ,
164170 ctx : & mut ExecutionCtx ,
0 commit comments