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        min_library_version: None,
36    },
37    added: &[
38        EditionMember::dtype(&"vortex.st.box"),
39        EditionMember::dtype(&"vortex.st.linestring"),
40        EditionMember::dtype(&"vortex.st.multilinestring"),
41        EditionMember::dtype(&"vortex.st.multipoint"),
42        EditionMember::dtype(&"vortex.st.multipolygon"),
43        EditionMember::dtype(&"vortex.st.point"),
44        EditionMember::dtype(&"vortex.st.polygon"),
45        EditionMember::dtype(&"vortex.st.wkb"),
46        EditionMember::aggregate(&"vortex.st.aabb"),
47    ],
48};
49
50#[cfg(test)]
51mod tests {
52    use vortex_edition::ComponentKind;
53    use vortex_edition::EditionSessionExt;
54    use vortex_edition::test_harness::validate_edition;
55    use vortex_error::VortexResult;
56
57    use super::*;
58
59    #[test]
60    fn spatial_edition_is_valid() -> VortexResult<()> {
61        let session = crate::test_harness::spatial_session();
62        validate_edition(&session.editions(), &SPATIAL_2026_08)
63    }
64
65    /// A spatial session must permit the AABB zone stat it registers, or writing a geometry
66    /// column fails on the aggregate the session itself asked for.
67    #[test]
68    fn initialize_permits_the_aabb_zone_stat() {
69        let session = crate::test_harness::spatial_session();
70        let enabled = session.enabled_component_ids(ComponentKind::Aggregate);
71        assert!(
72            enabled.iter().any(|id| id.as_str() == "vortex.st.aabb"),
73            "spatial session permits {enabled:?}"
74        );
75    }
76
77    #[test]
78    fn initialize_permits_spatial_dtypes() {
79        let session = crate::test_harness::spatial_session();
80        let enabled = session.enabled_component_ids(ComponentKind::DType);
81        assert_eq!(enabled.len(), 8);
82        assert!(enabled.iter().any(|id| id.as_str() == "vortex.st.point"));
83    }
84}