Skip to main content

vortex_spatial/
editions.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4//! The `spatial` edition family.
5//!
6//! Spatial support is opt-in. [`crate::initialize`] registers and enables the edition so the
7//! writer can serialize spatial dtypes and the AABB zone stat registered by the crate.
8
9use vortex_edition::Edition;
10use vortex_edition::EditionDeclaration;
11use vortex_edition::EditionFamily;
12use vortex_edition::EditionId;
13use vortex_edition::EditionMember;
14
15/// The `spatial` family: the geometry dtypes and the AABB zone aggregate.
16pub static FAMILY: EditionFamily = EditionFamily {
17    name: "spatial",
18    origin: "vortex-spatial",
19    doc: "The geometry extension dtypes and the axis-aligned bounding-box zone aggregate. \
20Spatial support is opt-in: a reader built without `vortex-spatial` cannot resolve \
21`vortex.st.*`, so these members are versioned independently of `core` and a session enables \
22this family only by initializing the crate.",
23};
24
25/// The August 2026 draft edition of the `spatial` family.
26pub const SPATIAL_2026_08: EditionId = EditionId::new("spatial", 2026, 8, 0);
27
28/// The declaration of [`SPATIAL_2026_08`] and the components that join the family at it.
29///
30/// A draft: no Vortex release yet guarantees these members forever. The dtype members appear in
31/// file schemas, and the AABB aggregate is recorded in the zone maps of geometry columns.
32pub static DECLARATION: EditionDeclaration = EditionDeclaration {
33    edition: Edition {
34        id: SPATIAL_2026_08,
35        immutable: true,
36        min_library_version: None,
37    },
38    added: &[
39        EditionMember::dtype(&"vortex.st.box"),
40        EditionMember::dtype(&"vortex.st.linestring"),
41        EditionMember::dtype(&"vortex.st.multilinestring"),
42        EditionMember::dtype(&"vortex.st.multipoint"),
43        EditionMember::dtype(&"vortex.st.multipolygon"),
44        EditionMember::dtype(&"vortex.st.point"),
45        EditionMember::dtype(&"vortex.st.polygon"),
46        EditionMember::dtype(&"vortex.st.wkb"),
47        EditionMember::aggregate(&"vortex.st.aabb"),
48    ],
49};
50
51#[cfg(test)]
52mod tests {
53    use vortex_edition::ComponentKind;
54    use vortex_edition::EditionSessionExt;
55    use vortex_edition::test_harness::validate_edition;
56    use vortex_error::VortexResult;
57
58    use super::*;
59
60    #[test]
61    fn spatial_edition_is_valid() -> VortexResult<()> {
62        let session = crate::test_harness::spatial_session();
63        validate_edition(&session.editions(), &SPATIAL_2026_08)
64    }
65
66    /// A spatial session must permit the AABB zone stat it registers, or writing a geometry
67    /// column fails on the aggregate the session itself asked for.
68    #[test]
69    fn initialize_permits_the_aabb_zone_stat() {
70        let session = crate::test_harness::spatial_session();
71        let enabled = session.enabled_component_ids(ComponentKind::Aggregate);
72        assert!(
73            enabled.iter().any(|id| id.as_str() == "vortex.st.aabb"),
74            "spatial session permits {enabled:?}"
75        );
76    }
77
78    #[test]
79    fn initialize_permits_spatial_dtypes() {
80        let session = crate::test_harness::spatial_session();
81        let enabled = session.enabled_component_ids(ComponentKind::DType);
82        assert_eq!(enabled.len(), 8);
83        assert!(enabled.iter().any(|id| id.as_str() == "vortex.st.point"));
84    }
85}