Skip to content

feat(parity): th3index — full H3 cell index API#193

Open
estebanzimanyi wants to merge 2 commits into
fix/bump-meos-pinfrom
feat/parity-th3index
Open

feat(parity): th3index — full H3 cell index API#193
estebanzimanyi wants to merge 2 commits into
fix/bump-meos-pinfrom
feat/parity-th3index

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Add the th3index temporal H3 cell-index family on the pinned MEOS H3 surface: the H3INDEX scalar cell type with text I/O, the TH3INDEX temporal type, casts to tgeompoint / tgeogpoint, and the cell-index scalar surface (resolution, validity, parent/child, boundary, neighbors, grid distance). The MEOS port builds with H3 enabled and links the vcpkg h3 library; smoke coverage exercises the H3INDEX text round-trip.

@estebanzimanyi estebanzimanyi force-pushed the feat/parity-th3index branch from 961b2c7 to 8181399 Compare June 5, 2026 18:42
@estebanzimanyi estebanzimanyi force-pushed the feat/parity-th3index branch 2 times, most recently from 504e1ba to dee2e01 Compare June 6, 2026 04:47
@estebanzimanyi estebanzimanyi force-pushed the feat/parity-th3index branch from dee2e01 to 37107d1 Compare June 6, 2026 06:10
@estebanzimanyi estebanzimanyi force-pushed the feat/parity-th3index branch 2 times, most recently from 3ec3ee9 to ade75e5 Compare June 6, 2026 07:15
Wraps Uber's H3 discrete global grid as MobilityDuck SQL types:

- `H3INDEX`  — 64-bit cell id (BIGINT alias).
- `TH3INDEX` — Temporal* of H3 cells (BLOB alias); all four
  subtypes (instant / discrete sequence / step sequence / linear
  sequence / sequence set).

- Inout: text parse / format, asBinary/asEWKB/asHexWKB/asMFJSON,
  fromBinary / fromHexWKB / fromMFJSON.
- Constructors: H3 cell from lat/lng+res, tinstant/tsequence/
  tsequenceset constructors.
- Accessors: subtype/interp/memSize/numInstants/numSequences/
  startInstant/endInstant/start{Timestamp,Value}/end{Value}/
  values/valueAtTimestamp.
- Casts: th3index → tgeompoint / tgeogpoint (each with res),
  th3index → tbigint (deferred; tbigint not yet exposed).
- H3 metric/topology surface: cell area / edge length / unit
  string dispatch, cell→parent / center-child / child-pos / vertex,
  hierarchy, neighbors, geo→cell sets (static geometry → H3 cell
  set), every*/always* comparison predicates, tEq/tNe/tDistance.

- Bump MEOS port pin to `feat/th3index-complete` tip (`beddae670`
  upstream) and enable `-DH3=ON`.
- vcpkg.json: add `h3` as a top-level dependency.
- CMakeLists.txt: `find_package(h3 CONFIG)` plus explicit
  `find_path(h3api.h)` probe — vcpkg's h3 imported target carries
  `include/` only; MEOS source uses `#include <h3api.h>` which
  lives at `include/h3/`, so we publish that subdir as an include
  directory.

The MEOS source at `beddae670` has four standalone-build gaps
visible only with `-DH3=ON`; vcpkg port applies these workarounds
until they land upstream:

1. `meos/include/h3/th3index_internal.h` unconditionally
   `#include <fmgr.h>` (PG-only).  Guarded with `#if !MEOS`,
   mirroring the same idiom in `meos/include/temporal/temporal.h`.
2. `meos/CMakeLists.txt` builds the `h3` OBJECT library but the
   `PROJECT_OBJECTS` list — fed to `add_library(meos ...)` —
   silently omits `h3`.  Without this, libmeos shipped with zero
   H3 symbols even when `H3=ON`.
3. `meos/CMakeLists.txt` install rules carry every other module
   header (`meos_npoint.h` / `meos_pose.h` / `meos_rgeo.h` /
   `meos_cbuffer.h`) but no `install()` for `meos_h3.h`.
4. `meos/src/h3/{h3_geo,th3index_latlng,th3index_metrics}.c` call
   `ensure_srid_is_latlong()` (declared in
   `meos/include/geo/tgeo_spatialfuncs.h`) without including that
   header → implicit-declaration error under `MEOS=1`.

Also: `H3_LIBRARY` and `H3_INCLUDE_DIR` are now passed explicitly
to the MEOS configure (resolving from `${CURRENT_INSTALLED_DIR}/
lib` and `${CURRENT_INSTALLED_DIR}/include/h3`), bypassing MEOS's
own `find_library(NAMES h3)` which does not consult vcpkg's
toolchain on every triplet (notably `arm64-linux-release`).

- Local `h3index_in` / `h3index_out` definitions (in `extern "C"`
  in `src/h3/th3index.cpp`) since MEOS declares these in
  `meos_h3.h` but does not provide a standalone-build definition;
  the wrappers route through h3's own `stringToH3` / `h3ToString`.
- `th3index<->tbigint` cast registrations are deferred until
  MobilityDuck exposes the `tbigint` base type (a separate
  follow-up).

Squash of 61 iteration commits on `feat/parity-th3index`; full
history preserved on `backup/parity-th3index-orig`.
The wasm32-emscripten toolchain ships clang-tidy, so h3's ENABLE_LINTING
pass (default ON when clang-tidy is on PATH) runs during the dependency
build and aborts it: h3 4.3.0's own source trips its WarningsAsErrors
.clang-tidy config (readability-braces-around-statements,
bugprone-narrowing-conversions) and that config carries a stale
AnalyzeTemporaryDtors key newer clang-tidy rejects. An h3 overlay port
pins -DENABLE_LINTING=OFF so the dependency builds on every triplet.
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