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: a reader without this crate cannot resolve `vortex.st.*`, so
7//! spatial members live in their own family rather than in `core`. [`crate::initialize`]
8//! registers and enables the edition so the writer can serialize spatial dtypes and the AABB
9//! zone stat registered by the crate.
10
11use vortex_edition::Edition;
12use vortex_edition::EditionDeclaration;
13use vortex_edition::EditionId;
14use vortex_edition::EditionMember;
15
16/// The August 2026 draft edition of the `spatial` family.
17pub const SPATIAL_2026_08: EditionId = EditionId::new("spatial", 2026, 8, 0);
18
19/// The declaration of [`SPATIAL_2026_08`] and the components that join the family at it.
20///
21/// A draft: no Vortex release yet guarantees these members forever. The dtype members appear in
22/// file schemas, and the AABB aggregate is recorded in the zone maps of geometry columns.
23pub static DECLARATION: EditionDeclaration = EditionDeclaration {
24    edition: Edition {
25        id: SPATIAL_2026_08,
26        min_vortex_version: None,
27    },
28    added: &[
29        EditionMember::dtype(&"vortex.st.box"),
30        EditionMember::dtype(&"vortex.st.linestring"),
31        EditionMember::dtype(&"vortex.st.multilinestring"),
32        EditionMember::dtype(&"vortex.st.multipoint"),
33        EditionMember::dtype(&"vortex.st.multipolygon"),
34        EditionMember::dtype(&"vortex.st.point"),
35        EditionMember::dtype(&"vortex.st.polygon"),
36        EditionMember::dtype(&"vortex.st.wkb"),
37        EditionMember::aggregate(&"vortex.st.aabb"),
38    ],
39};
40
41#[cfg(test)]
42mod tests {
43    use vortex_edition::ComponentKind;
44    use vortex_edition::EditionError;
45    use vortex_edition::EditionSessionExt;
46    use vortex_edition::test_harness::validate_edition;
47
48    use super::*;
49
50    #[test]
51    fn spatial_edition_is_valid() -> Result<(), EditionError> {
52        let session = crate::test_harness::spatial_session();
53        validate_edition(&session.editions(), &SPATIAL_2026_08)
54    }
55
56    /// A spatial session must permit the AABB zone stat it registers, or writing a geometry
57    /// column fails on the aggregate the session itself asked for.
58    #[test]
59    fn initialize_permits_the_aabb_zone_stat() {
60        let session = crate::test_harness::spatial_session();
61        let enabled = session.enabled_component_ids(ComponentKind::Aggregate);
62        assert!(
63            enabled.iter().any(|id| id.as_str() == "vortex.st.aabb"),
64            "spatial session permits {enabled:?}"
65        );
66    }
67
68    #[test]
69    fn initialize_permits_spatial_dtypes() {
70        let session = crate::test_harness::spatial_session();
71        let enabled = session.enabled_component_ids(ComponentKind::DType);
72        assert_eq!(enabled.len(), 8);
73        assert!(enabled.iter().any(|id| id.as_str() == "vortex.st.point"));
74    }
75}