Skip to content

Commit 874c171

Browse files
docs: replace z?/m? notation with Struct<x, y[, z][, m]> to avoid nullability confusion
In Vortex DType display syntax a ? suffix means nullable, so z: f64? read as a nullable field when the optional z/m fields are required to be non-nullable f64 when present. Use usage-string brackets for optional fields and anchor the storage shape to the four GeoArrow dimensions XY, XYZ, XYM, XYZM. Signed-off-by: "Nemo Yu" <zhenghong@spiraldb.com>
1 parent ed9a1e8 commit 874c171

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

vortex-geo/src/extension/coordinate.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

4-
//! Coordinate building blocks for geometry extension types: the
5-
//! `Struct<x: f64, y: f64, z?: f64, m?: f64>` storage, its [`Dimension`], and the decoded
6-
//! [`Coordinate`] value.
4+
//! Coordinate building blocks for geometry extension types: the `Struct<x, y[, z][, m]>` storage
5+
//! of non-nullable `f64` fields, its [`Dimension`], and the decoded [`Coordinate`] value.
76
//!
8-
//! The coordinate fields, where `?` marks an optional field, are:
7+
//! The coordinate fields are:
98
//! - `x` — longitude or easting
109
//! - `y` — latitude or northing
11-
//! - `z?` — elevation
12-
//! - `m?` — measure: an arbitrary per-point value such as distance along a route or a timestamp
10+
//! - `z` (optional) — elevation
11+
//! - `m` (optional) — measure: an arbitrary per-point value such as distance along a route or a
12+
//! timestamp
1313
1414
use std::fmt::Display;
1515
use std::fmt::Formatter;
@@ -65,7 +65,7 @@ impl Dimension {
6565
}
6666
}
6767

68-
/// A decoded coordinate. `z?`/`m?` are `Some` iff the storage dimension includes them.
68+
/// A decoded coordinate. `z`/`m` are `Some` iff the storage dimension includes them.
6969
///
7070
/// This is the native value produced when unpacking a [`Point`](crate::extension::Point) scalar;
7171
/// the rest of the coordinate machinery is crate-internal.
@@ -75,14 +75,14 @@ pub struct Coordinate {
7575
pub x: f64,
7676
/// The y (latitude/northing) ordinate.
7777
pub y: f64,
78-
/// The optional `z?` (elevation) ordinate.
78+
/// The optional `z` (elevation) ordinate.
7979
pub z: Option<f64>,
80-
/// The optional `m?` (measure) ordinate.
80+
/// The optional `m` (measure) ordinate.
8181
pub m: Option<f64>,
8282
}
8383

8484
impl Coordinate {
85-
/// A 2D coordinate (`z?`/`m?` unset).
85+
/// A 2D coordinate (`z`/`m` unset).
8686
pub fn xy(x: f64, y: f64) -> Self {
8787
Coordinate {
8888
x,
@@ -122,7 +122,7 @@ pub(crate) fn coordinate_dimension(dtype: &DType) -> VortexResult<Dimension> {
122122
Dimension::from_field_names(fields.names())
123123
}
124124

125-
/// Decode a [`Coordinate`] from a coordinate `Struct<x, y, z?, m?>` scalar (`z?`/`m?` read iff
125+
/// Decode a [`Coordinate`] from a coordinate `Struct<x, y[, z][, m]>` scalar (`z`/`m` read iff
126126
/// present, so the same decoder serves every dimension).
127127
pub(crate) fn coordinate_from_struct(scalar: &Scalar) -> VortexResult<Coordinate> {
128128
let fields = scalar.as_struct();
@@ -157,7 +157,7 @@ pub(crate) fn coordinate_from_scalar(scalar: &Scalar) -> VortexResult<Coordinate
157157
}
158158

159159
/// Validated, executed `x`/`y` columns of a point array. The bulk counterpart to [`Coordinate`];
160-
/// `z?`/`m?` are not executed.
160+
/// `z`/`m` are not executed.
161161
pub(crate) struct ParsedCoordinates {
162162
/// The flat `f64` `x` column.
163163
pub(crate) xs: PrimitiveArray,
@@ -213,7 +213,7 @@ mod tests {
213213
use crate::extension::GeoMetadata;
214214
use crate::extension::Point;
215215

216-
/// Display emits WKT, including `z?`/`m?` when present.
216+
/// Display emits WKT, including `z`/`m` when present.
217217
#[test]
218218
fn display_is_wkt() {
219219
let coordinate = |z, m| Coordinate {

vortex-geo/src/extension/point.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

44
//! The [`Point`] geometry extension type (`vortex.geo.point`): a location stored columnarly as
5-
//! `Struct<x, y, z?, m?>` of `f64`, tagged with [`GeoMetadata`] (CRS). `z?` is an optional
6-
//! elevation and `m?` an optional measure — an arbitrary per-point value such as distance along a
7-
//! route or a timestamp.
5+
//! `Struct<x, y[, z][, m]>` of non-nullable `f64` — the four GeoArrow dimensions XY, XYZ, XYM,
6+
//! XYZM — tagged with [`GeoMetadata`] (CRS). `z` is an optional elevation and `m` an optional
7+
//! measure: an arbitrary per-point value such as distance along a route or a timestamp.
88
99
use prost::Message;
1010
use vortex_array::dtype::extension::ExtDType;
@@ -19,7 +19,7 @@ use super::coordinate::Coordinate;
1919
use super::coordinate::coordinate_dimension;
2020
use super::coordinate::coordinate_from_struct;
2121

22-
/// A single location: `geoarrow.point`, stored as `Struct<x: f64, y: f64, z: f64?, m: f64?>`.
22+
/// A single location: `geoarrow.point`, stored as `Struct<x, y[, z][, m]>` of non-nullable `f64`.
2323
#[derive(Debug, Clone, Default, PartialEq, Eq, Hash)]
2424
pub struct Point;
2525

@@ -99,7 +99,7 @@ mod tests {
9999
}
100100

101101
/// `Point` accepts every GeoArrow dimension; the canonical field names round-trip to their
102-
/// dimension, so a `z?`/`m?` swap or a mislabel would be caught.
102+
/// dimension, so a `z`/`m` swap or a mislabel would be caught.
103103
#[test]
104104
fn point_validates_every_dimension() -> VortexResult<()> {
105105
let cases = [

vortex-geo/src/scalar_fn/distance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn euclidean_distance(ax: f64, ay: f64, bx: f64, by: f64) -> f64 {
3535
}
3636

3737
/// Straight-line (Euclidean) distance between two point operands — "planar" distance in GIS terms
38-
/// (e.g. PostGIS `ST_Distance`). No geodesic correction, and `z?`/`m?` are ignored.
38+
/// (e.g. PostGIS `ST_Distance`). No geodesic correction, and `z`/`m` are ignored.
3939
///
4040
/// The operands are two point columns of equal length; either (or both) may be constant, in which
4141
/// case the constant query point is decoded once and broadcast.

0 commit comments

Comments
 (0)