Skip to content

Add support for new 1.3 tgeom and tgeog types#3

Open
Davichet-e wants to merge 6 commits intostable-1.3from
geom-geog
Open

Add support for new 1.3 tgeom and tgeog types#3
Davichet-e wants to merge 6 commits intostable-1.3from
geom-geog

Conversation

@Davichet-e
Copy link
Copy Markdown
Member

@Davichet-e Davichet-e commented Mar 22, 2026

Add TGeometry / TGeography types and unify geo temporal API

What changed

New types

MEOS 1.3 exposes tgeometry and tgeography — arbitrary geometry/geography temporals, not restricted to points. This PR adds full Rust support for both:

  • TGeometry / TGeometryInstant / TGeometrySequence / TGeometrySequenceSet
  • TGeography / TGeographyInstant / TGeographySequence / TGeographySequenceSet

All spatial methods (trajectory, length, speed, at_point, distance_to_point, nearest_approach_distance, etc.) are available on both types via TGeoTrait.

Unified trait

TPointTrait<const IS_GEODETIC: bool> is replaced by a single TGeoTrait. The const generic was artificial — MEOS uses the same C functions for geodetic and non-geodetic types everywhere except value serialization, which is now handled internally by the trait's one required method:

pub trait TGeoTrait: Temporal {
    fn geo_to_gserialized(geo: Geometry) -> *mut GSERIALIZED;
}

Macro-driven codegen

All four geo type families are now generated by a single macro call each:

impl_tgeo_type!(TGeomPoint, false, tpointinst_make, tgeompoint_in, tgeompoint_from_mfjson);
impl_tgeo_type!(TGeogPoint, true,  tpointinst_make, tgeogpoint_in, tgeogpoint_from_mfjson);
impl_tgeo_type!(TGeometry,  false, tgeoinst_make,   tgeometry_in,  tgeometry_from_mfjson);
impl_tgeo_type!(TGeography, true,  tgeoinst_make,   tgeography_in, tgeography_from_mfjson);

This collapsed ~600 lines of duplicated boilerplate. Adding a new geo type in the future is one line.

Renamed src/temporal/point/src/temporal/geo/

The directory and module names now reflect that these types are not point-specific.

Migration

  • Replace use meos::TPointTrait with use meos::TGeoTrait
  • All method names are unchanged

Expanded TGeoTrait and STBox API

Wrapped ~80 previously missing MEOS functions:

  • Ever/always spatial relations — ever_equal, ever_intersects, ever_contains, ever_covers, ever_touches, ever_within_distance, and their always_* counterparts, each with both a geometry and a tgeo variant
  • Geometry/STBox restrictions — at_geom, minus_geom, at_stbox, minus_stbox (returning Option<Self::Enum>)
  • Spatial aggregates — centroid, convex_hull, traversed_area
  • Temporal spatial relations — contains, covers, disjoint, touches (returning TBool)
  • nearest_approach_distance_to_stbox, value_n
  • Full set of positional operators on STBox (is_left, is_right, is_above, is_below, is_before, is_after, all is_over_or_*, is_adjacent, overlaps, is_same, is_contained_in)
  • Full set of positional operators on TGeoTrait vs both Self::Enum and STBox

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant