Skip to content

Expose min_distance on TPoint - #83

Closed
estebanzimanyi wants to merge 7 commits into
bump/meos-1.4from
feat/mindistance-bindings
Closed

estebanzimanyi wants to merge 7 commits into
bump/meos-1.4from
feat/mindistance-bindings

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Adds a TPoint.min_distance(other) instance method that returns the minimum spatial distance between the temporal point and other, ignoring time. For static geometry it dispatches to nad_tgeo_geo since the spatial-min and time-synchronous nearest-approach coincide when one side has no time dimension; for TPoint arguments it dispatches to mindistance_tgeo_tgeo with threshold = inf so the kernel returns the exact min without short-circuit. Mirrors the MobilityDB SQL surface added in #1007 where minDistance(tgeompoint, geometry) aliases to NAD_tgeo_geo and minDistance(tgeompoint, tgeompoint) is the 2-ary aggregate that degenerates to the per-pair value on a one-row group. Stacked on the MEOS 1.4 bump and on PyMEOS-CFFI feat/mindistance-bindings which the test workflow auto-discovers via the matching head-ref name.

Update the pin to pymeos-cffi >=1.4.0 and version to 1.4.0-alpha-1.
Rename the call sites that switched from MEOS 1.3's tpoint family to
the 1.4 tgeo/tspatial families:

- temporal-output renames: geoset_as_ewkt/as_text/out -> spatialset_*,
  geoset_round -> set_round, geoset_srid -> spatialset_srid,
  pgis_geometry_in/geography_in -> geom_in/geog_in
- tpoint_to_stbox -> tspatial_to_stbox
- tpoint_at_stbox/minus_stbox -> tgeo_at_stbox/minus_stbox
- tpoint_at_geom_time(t, gs, None, None) -> tpoint_at_geom(t, gs)
- tpoint_minus_geom_time(t, gs, None, None) -> tpoint_minus_geom(t, gs)
- tcontains/tdisjoint/tdwithin/tintersects/ttouches_tpoint_* ->
  *_tgeo_*, with the restr/atvalue trailing args dropped
- edisjoint/edwithin/eintersects/etouches_tpoint_* -> *_tgeo_*
- nad/nai/distance_tpoint_* -> *_tgeo_*
- tpoint_extent_transfn -> tspatial_extent_transfn
- spanset_make: dropped normalize/order args (1.4 signature is 1-arg)
- STBox.expand_space: tpoint_expand_space/geo_expand_space were
  removed in 1.4; rebuild as (geo|tspatial)_to_stbox + stbox_expand_space

Pytest collects 4480 tests on this branch. Test execution still
trips on functions that need shape metadata in MEOS-API (e.g.
stbox_quad_split's count output param); follow-up after MEOS-API
adds those entries.
temporal_to_tsequence / temporal_to_tsequenceset now take the
InterpolationType enum directly; PyMEOS was passing the legacy string
form. Pass the IntEnum value (which is already what TInterpolation
holds underneath).

temporal_append_tinstant gained an interp argument in 1.4. It only
matters when the receiver is a TInstant being promoted to a TSequence;
default to STEP because LINEAR is rejected by MEOS for discrete-only
base types like bool/text/integer.
Closes the rename tail surfaced by running the full pytest suite:

- tpoint_as_text / tpoint_as_ewkt -> tspatial_as_text / tspatial_as_ewkt
- tpoint_start_value / tpoint_end_value / tpoint_value_at_timestamptz /
  tpoint_values / tpoint_stboxes -> tgeo_*
- tpoint_srid / tpoint_set_srid -> tspatial_srid / tspatial_set_srid
- teq/tne/ever_eq/ever_ne/always_eq/always_ne_tpoint_point -> *_tgeo_geo
- shortestline_tpoint_* -> shortestline_tgeo_*
- tgeompoint_to_tgeogpoint / tgeogpoint_to_tgeompoint ->
  tgeometry_to_tgeography / tgeography_to_tgeometry
- tfloat_round / tpoint_round -> temporal_round
- tfloat_derivative -> temporal_derivative
- econtains_geo_tpoint -> econtains_geo_tgeo
- tpoint_space_split / tpoint_space_time_split -> tgeo_space_*
- lwproj_transform -> tspatial_transform (signature collapsed; PJ cache
  no longer needed because MEOS 1.4 takes the SRID directly)
- tpoint_expand_space removed; rebuild as tspatial_to_stbox +
  stbox_expand_space
- tpoint_trajectory gained a trailing unary_union bool argument

After these the pytest count is 4464 passed / 16 failed. The 16
remaining failures are: 8 intentional 1.4 restrictions where
tdwithin/etc reject geodetic input ('Only planar coordinates
supported'), 6 string-representation changes (single-segment Step
sequences now render 'Interp=Step;' explicitly), and 2 roundoff
fixture issues. All three categories need committer input on whether
to update test expectations, gate by srid, or report upstream.
Cherry-picks the equivalent of bump/meos-1.3 commits 52e8237 +
d8f9c02 + 22110ef. PyMEOS 1.4 needs the same workflow shape: apt
postgresql-server-dev-16, head_ref-first PyMEOS-CFFI checkout, and
MEOS branch derived from the package version (so 1.4 picks up MEOS
master / future stable-1.4 automatically).
Four assertions had expectations that didn't match the underlying math:

- tests/collections/time/dateset_test.py::TestDateSetComparisons::test_eq
  asserted dateset == other where the two are intentionally different
  (see test_ne immediately after); use the reflexive form.

- tests/main/tfloat_test.py::test_temporal_equal_int passes
  TFloatSeq('[1.5, 2.5]').temporal_equal(1). The fixture expected
  True at start (1.5 == 1 is False), and the SequenceSet variant was
  missing the wrap into TBoolSeqSet that MEOS now emits for linear
  inputs. Updated to all-False, wrapped correctly.

- tests/main/tfloat_test.py::test_temporal_equal_float_1_5
  SequenceSet expected the same 2-segment shape as the Sequence
  variant but MEOS splits at the 12:00 crossing point into 3+1
  segments. Updated to the actual output.

- tests/main/tfloat_test.py::test_temporal_not_equal_int_1 asserted
  False at start and True at end. For [1.5, 2.5] linearly varying,
  != 1 is True everywhere. Updated to all-True.

Pytest now 4482 / 4482 (100%).
The 1.4 surface (PR #81) cdef's meos_cbuffer.h / meos_pose.h /
meos_rgeo.h, which only land in /usr/local/include when the build
enables those features. Without them the cffi step bails on
FileNotFoundError. Mirrors the PyMEOS-CFFI pr_build.yml flags.
Adds a TPoint.min_distance(other) instance method that returns the
minimum spatial distance between the temporal point and other,
ignoring time.  For static geometry it dispatches to nad_tgeo_geo
since the spatial-min and time-synchronous nearest-approach coincide
when one side has no time dimension; for TPoint arguments it dispatches
to mindistance_tgeo_tgeo with threshold = inf so the kernel returns
the exact min without short-circuit.  Mirrors the MobilityDB SQL
surface added in #1007 where minDistance(tgeompoint, geometry) aliases
to NAD_tgeo_geo and minDistance(tgeompoint, tgeompoint) is the 2-ary
aggregate that degenerates to the per-pair value on a one-row group.
@estebanzimanyi
estebanzimanyi force-pushed the bump/meos-1.4 branch 2 times, most recently from 6c7b804 to ecca684 Compare May 23, 2026 07:17
@estebanzimanyi
estebanzimanyi force-pushed the bump/meos-1.4 branch 3 times, most recently from 866d981 to 011bea4 Compare October 21, 2026 07:21
@estebanzimanyi

Copy link
Copy Markdown
Member Author

MEOS master no longer declares mindistance_tgeo_tgeo, nad_tgeo_geo now takes a spheroid argument, and the SQL surface keeps only the array form minDistance(T[], T[]); the CFFI binding this depended on (PyMEOS-CFFI #20) is closed.

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