Skip to content

feat(bindings): tgeometry parity — full cross-type surface#89

Closed
estebanzimanyi wants to merge 3 commits into
mainfrom
feat/parity-tgeometry-foundations
Closed

feat(bindings): tgeometry parity — full cross-type surface#89
estebanzimanyi wants to merge 3 commits into
mainfrom
feat/parity-tgeometry-foundations

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Summary

First PR in the tgeometry parity sweep. Mirrors the temporal-generic portion of the tgeompoint surface (50+ new overloads) so users can do basic accessing, restricting, modifying, and comparing on tgeometry values.

Category Functions
Accessors valueSet, valueN, valueAtTimestamp, getTime, duration, lowerInc, upperInc, numInstants, instants, numSequences, sequences, startSequence, endSequence, sequenceN, numTimestamps, timestamps, startTimestamp, endTimestamp, timestampN, segments
Time-domain restrict atTime / minusTime over (timestamptz, tstzset, tstzspan, tstzspanset); beforeTimestamp, afterTimestamp
Value restrict atValues / minusValues over (geometry, geomset)
Spatial restrict atGeometry, minusGeometry, minusStbox
Modifiers shiftTime, scaleTime, shiftScaleTime, appendInstant, appendSequence, insert, update, deleteTime over multiple time-argument shapes
Comparison temporal_eq / ne / lt / le / gt / ge / cmp + the matching =, <>, <, <=, >, >= operators

Implementation note

Most MEOS C functions reached here are subtype-agnostic — they take Temporal * and don't care whether the underlying value is a point, polygon, or any other geometry. So the registrations reuse the existing generic TemporalFunctions::* handlers that tgeompoint.cpp already uses, with the LogicalType swapped from TGEOMPOINT()TGEOMETRY() and the value type from POINT → GEOMETRY().

The spatial-restrict functions (atGeometry / minusGeometry / minusStbox) reuse the TgeompointFunctions::Tgeo_* handlers — those are already named for the generic tgeo case (call MEOS's tgeo_at_geom / tgeo_minus_geom / tgeo_minus_stbox).

Out of scope (planned follow-ups)

  • tgeometry × geometry comparison + distance + spatial-rels + temporal-spatial-rels (the bigger 060 / 064 / 070 / 072 SQL files; ~400 SQL functions/operators total).
  • tgeometry tile family + analytics + aggregates + GiST / SP-GiST.
  • tgeography parity (entirely separate type registration; does not currently exist in MobilityDuck).

Test plan

  • test/sql/parity/040_tgeometry_foundations.test — 19 assertions covering each category.
  • No regression in any other parity test.

🤖 Generated with Claude Code

estebanzimanyi and others added 2 commits May 1, 2026 08:57
… / modifiers / comparison

Mirrors the temporal-generic portion of the tgeompoint surface for
tgeometry. Most MEOS C functions reached here are subtype-agnostic
(they take Temporal *), so the registrations reuse the same generic
TemporalFunctions::* handlers that tgeompoint uses, with TGEOMPOINT()
swapped for TGEOMETRY() and the value type swapped from POINT to
GEOMETRY.

Functions added (~50 overloads on top of the existing 22):

- Accessors: valueSet, valueN, valueAtTimestamp, getTime, duration,
  lowerInc, upperInc, numInstants, instants, numSequences, sequences,
  startSequence, endSequence, sequenceN, numTimestamps, timestamps,
  startTimestamp, endTimestamp, timestampN, segments
- Time-domain restrict: atTime / minusTime over (timestamptz, tstzset,
  tstzspan, tstzspanset); beforeTimestamp / afterTimestamp
- Value restrict: atValues / minusValues over (geometry, geomset)
- Spatial restrict: atGeometry, minusGeometry, minusStbox (reusing the
  tgeompoint-side Tgeo_* handlers — they already operate on Temporal *)
- Modifiers: shiftTime, scaleTime, shiftScaleTime, appendInstant,
  appendSequence, insert, update, deleteTime over multiple time
  argument shapes
- Comparison: temporal_eq / ne / lt / le / gt / ge / cmp + the matching
  =, <>, <, <=, >, >= operators

Out of scope for this PR (planned follow-ups):

- tgeometry comparison ops with geometry arg, distance / spatialrels
  / temporal-spatialrels (the bigger 060 / 064 / 070 / 072 SQL files)
- tgeometry tile family + analytics + aggregates + GiST / SP-GiST
- tgeography parity (entirely separate type registration)

Test: 040_tgeometry_foundations.test — 19 assertions covering each
category. Geometry values are emitted in EWKB-hex display rather than
WKT, mirroring how tgeompoint test outputs are compared.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ps / spatial-rels / temporal-rels / distance)

Extends the foundational tgeometry surface from the previous commit
with the cross-type predicate family that mirrors what MobilityDB
ships in 060 / 062 / 070 / 072 / 064_tgeo_*.in.sql:

  Box predicates (named function + operator):
    temporal_overlaps  / &&    over (tgeometry × stbox / tstzspan / tgeometry)
    temporal_contains  / @>    over the same cross-product
    temporal_contained / <@
    temporal_same      / ~=
    temporal_adjacent  / -|-

  Position predicates (16 names — left / right / below / above / front /
  back / before / after and their over-* variants) over (tgeometry ×
  stbox / tgeometry); the four time-axis ones (before / after /
  overbefore / overafter) also accept tstzspan.

  Spatial relationships:
    eContains / aContains          (tgeometry, geometry, tgeometry)
    eDisjoint / aDisjoint          commutative (geo, tgeo) reuses (tgeo, geo)
    eIntersects / aIntersects      same
    eTouches / aTouches            same
    eDwithin / aDwithin            with float distance argument

  Temporal spatial relationships (return tbool):
    tContains, tDisjoint, tIntersects, tTouches over (geo, tgeo) /
    (tgeo, geo) / (tgeo, tgeo); tDwithin with float distance.

  Distance:
    tdistance(tgeometry, geometry|tgeometry) -> tfloat
    <-> operator equivalents.

The MEOS exports reached here all take Temporal * (subtype-agnostic),
so this file is purely registration glue — templated executors decode
the input blobs, call the MEOS function, and re-encode the result.

Test 040_tgeometry_parity.test grew from 19 to 33 assertions and was
renamed from 040_tgeometry_foundations.test to reflect the broader
scope.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@estebanzimanyi estebanzimanyi changed the title feat(bindings): tgeometry foundational surface — accessors / restrict / modifiers / comparison feat(bindings): tgeometry parity — full cross-type surface May 1, 2026
…orm / coercions / centroid / convexHull / traversedArea

Adds the spatial-functions surface from MobilityDB's
056_tgeo_spatialfuncs.in.sql for tgeometry:

  SRID(tgeometry)               -> integer
  setSRID(tgeometry, integer)   -> tgeometry
  transform(tgeometry, integer) -> tgeometry
  stbox(tgeometry)              -> stbox

  tgeompoint(tgeometry)  -> tgeompoint
  tgeometry(tgeompoint)  -> tgeometry

  centroid(tgeometry)               -> tgeometry  (temporal centroid path)
  convexHull(tgeometry)             -> geometry
  traversedArea(tgeometry [, bool]) -> geometry

All MEOS exports reached here (tspatial_srid / tspatial_set_srid /
tspatial_transform / tspatial_to_stbox / tgeometry_to_tgeompoint /
tgeompoint_to_tgeometry / tgeo_centroid / tgeo_convex_hull /
tgeo_traversed_area) take a Temporal *, so the new exec helpers in
tgeometry_ops.cpp follow the same decode/call/encode pattern as the
predicate executors above.

Tests: 040_tgeometry_parity.test grew from 33 to 39 assertions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@estebanzimanyi

Copy link
Copy Markdown
Member Author

Superseded by PR #90 — the cumulative tgeometry parity PR which packages this work plus its prerequisites (#85 / #86 / #87 / #88) and the deferred categories (aggregates / tile / analytics) into one review unit.

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