feat(bindings): tgeometry parity — full cross-type surface#89
Closed
estebanzimanyi wants to merge 3 commits into
Closed
feat(bindings): tgeometry parity — full cross-type surface#89estebanzimanyi wants to merge 3 commits into
estebanzimanyi wants to merge 3 commits into
Conversation
… / 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>
…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>
2 tasks
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First PR in the
tgeometryparity sweep. Mirrors the temporal-generic portion of thetgeompointsurface (50+ new overloads) so users can do basic accessing, restricting, modifying, and comparing ontgeometryvalues.valueSet,valueN,valueAtTimestamp,getTime,duration,lowerInc,upperInc,numInstants,instants,numSequences,sequences,startSequence,endSequence,sequenceN,numTimestamps,timestamps,startTimestamp,endTimestamp,timestampN,segmentsatTime/minusTimeover(timestamptz, tstzset, tstzspan, tstzspanset);beforeTimestamp,afterTimestampatValues/minusValuesover(geometry, geomset)atGeometry,minusGeometry,minusStboxshiftTime,scaleTime,shiftScaleTime,appendInstant,appendSequence,insert,update,deleteTimeover multiple time-argument shapestemporal_eq/ne/lt/le/gt/ge/cmp+ the matching=,<>,<,<=,>,>=operatorsImplementation 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 genericTemporalFunctions::*handlers thattgeompoint.cppalready uses, with the LogicalType swapped fromTGEOMPOINT()→TGEOMETRY()and the value type from POINT →GEOMETRY().The spatial-restrict functions (
atGeometry/minusGeometry/minusStbox) reuse theTgeompointFunctions::Tgeo_*handlers — those are already named for the generic tgeo case (call MEOS'stgeo_at_geom/tgeo_minus_geom/tgeo_minus_stbox).Out of scope (planned follow-ups)
tgeometry×geometrycomparison + distance + spatial-rels + temporal-spatial-rels (the bigger 060 / 064 / 070 / 072 SQL files; ~400 SQL functions/operators total).tgeometrytile family + analytics + aggregates + GiST / SP-GiST.tgeographyparity (entirely separate type registration; does not currently exist in MobilityDuck).Test plan
test/sql/parity/040_tgeometry_foundations.test— 19 assertions covering each category.🤖 Generated with Claude Code