Skip to content

feat(bindings): asMVTGeom + geoMeasure for tgeompoint#84

Closed
estebanzimanyi wants to merge 1 commit intomainfrom
feat/parity-asmvtgeom-geomeasure
Closed

feat(bindings): asMVTGeom + geoMeasure for tgeompoint#84
estebanzimanyi wants to merge 1 commit intomainfrom
feat/parity-asmvtgeom-geomeasure

Conversation

@estebanzimanyi
Copy link
Copy Markdown
Member

Closes the visualization-essential analytics in `geo/076_tpoint_analytics` so users can encode trajectories for Mapbox Vector Tile rendering and add a measure dimension (M-coord) from a parallel `tfloat`.

New SQL surface (6 scalar registrations)

Signature Returns Routed through
`asMVTGeom(tgeompoint, stbox)` `STRUCT(geom GEOMETRY, times BIGINT[])` `tpoint_as_mvtgeom` (extent=4096, buffer=256, clip=TRUE defaults)
`asMVTGeom(tgeompoint, stbox, integer)` same + custom extent
`asMVTGeom(tgeompoint, stbox, integer, integer)` same + custom extent + buffer
`asMVTGeom(tgeompoint, stbox, integer, integer, boolean)` same full args
`geoMeasure(tgeompoint, tfloat)` `GEOMETRY` `tpoint_tfloat_to_geomeas` (segmentize=FALSE default)
`geoMeasure(tgeompoint, tfloat, boolean)` `GEOMETRY` full args

Implementation notes

asMVTGeom

Output is a single-row composite `STRUCT(geom GEOMETRY, times BIGINT[])` matching MobilityDB's `geom_times` type. MEOS hands back one clipped/projected geometry plus a parallel array of Unix-epoch second timestamps (one per vertex). The exec function:

  • Calls `tpoint_as_mvtgeom(temp, bounds, extent, buffer, clip, &geom, &times, &count)`.
  • Encodes the GSERIALIZED geometry into the struct's `geom` child via `GSerializedToGeometry` (with an `ArenaAllocator` scoped to the result vector).
  • Materialises the int64 timestamp array into the `BIGINT[]` struct child via standard `ListVector` reserve/set patterns.

geoMeasure

Routes `tpoint_tfloat_to_geomeas(tpoint, measure, segmentize, &geom)` and encodes the resulting GSERIALIZED with M-coord via `GSerializedToGeometry`.

Both are scalar functions, no TableFunction infra required.

Tests

  • `test/sql/parity/076_asmvtgeom_geomeasure.test` — 6 assertions covering the `typeof` shape, default-extent and custom-extent encodings, times-array length, and both geoMeasure overloads (with/without segmentize).
  • Full suite: 758 assertions / 14 test cases passing under `TZ=UTC`.

Coverage delta

Per the audit in PR #66:

  • `geo/076_tpoint_analytics` and `geo/076_tgeo_analytics`: `asMVTGeom` and `geoMeasure` were the visualization-blocking gaps. Now covered.

Test plan

  • `cmake --build . --target shell unittest` clean
  • New parity test passes (6/6)
  • Full suite green (758/14)

Closes the visualization-essential analytics in geo/076_tpoint_analytics
so users can both encode trajectories for Mapbox Vector Tile rendering
and add a measure dimension (M-coord) from a parallel tfloat.

New SQL surface (6 registrations):

- asMVTGeom(tgeompoint, stbox bounds[, extent[, buffer[, clip bool]]])
  -> STRUCT(geom geometry, times bigint[])
  4 overloads (default extent=4096, buffer=256, clip=TRUE).
  Routes to MEOS tpoint_as_mvtgeom which clips the trajectory to the
  tile bounds and projects to vector-tile coordinates.

- geoMeasure(tgeompoint, tfloat measure[, segmentize boolean])
  -> geometry
  2 overloads (default segmentize=FALSE).
  Routes to MEOS tpoint_tfloat_to_geomeas which produces an M-coord
  geometry: the trajectory's spatial path with each vertex carrying the
  measure's value at that timestamp.

asMVTGeom output schema is STRUCT(geom GEOMETRY, times BIGINT[]) — single
row per input, with `times` being the array of Unix-epoch seconds for
each vertex of the encoded geometry.

Hooked into LoadInternal via a new RegisterAnalyticsViz method on
TgeompointType.

Test: test/sql/parity/076_asmvtgeom_geomeasure.test (6 assertions
covering the typeof shape, default- and custom-extent encodings,
times-array length, and both geoMeasure overloads).
Full suite: 758 / 14 cases under TZ=UTC.
@estebanzimanyi estebanzimanyi marked this pull request as ready for review May 1, 2026 19:13
@estebanzimanyi
Copy link
Copy Markdown
Member Author

Superseded by the consolidated PR branch consolidate/tgeompoint-ops-parity. All changes from this PR are included in that branch as a single squashed commit. Please review and merge the consolidated branch instead.

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