Skip to content

Proposal on top of distance-tool - #206

Merged
esgn merged 6 commits into
138/distance-toolfrom
138/distance-tool-experiment
Oct 2, 2026
Merged

esgn merged 6 commits into
138/distance-toolfrom
138/distance-tool-experiment

Conversation

@esgn

@esgn esgn commented Oct 2, 2026

Copy link
Copy Markdown
Member

Description

  • replace node-vincenty with geographiclib-geodesic

Related issues (if applicable)

On top of #183

Motivation

  • node-vincenty (0.0.6, unmaintained, untyped) returns an undefined distance for antipodal or nearly antipodal points,which the wrapper let through. Karney's algorithm always converges; over 40,000 random pairs it differs from Vincenty byat most 0.56 mm. The hand-written node-vincenty types and their tsconfig.test.json entry go away.

Implementation

  • Replace one by the other

Testing

  • Tests passing

TODOs

  • TODO

Checklist

  • The PR is focused and of a reasonable size.
  • The commit history is clean.
  • Relevant documentation has been updated.
  • Relevant tests have been added or updated.

node-vincenty (0.0.6, unmaintained, untyped) returns an undefined distance for antipodal or nearly antipodal points, which the wrapper let through. Karney's algorithm always converges; over 40,000 random pairs it differs from Vincenty by at most 0.56 mm. The hand-written node-vincenty types and their tsconfig.test.json entry go away.

@LionelZoubritzky-IGN LionelZoubritzky-IGN left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved on the principle.
However, the occurences of "vincenty" should be replaced by "karney" to reflect the underlying algorithm change.

esgn added 4 commits October 2, 2026 10:32
The distance tool profiles `direct` and `vincenty` become `spherical` (still the default) and `ellipsoidal`, and the helper's `distanceVincenty` and its `"haversine"`/`"vincenty"` metrics become `ellipsoidalDistance` and `"spherical"`/`"ellipsoidal"`: since the switch to geographiclib, nothing runs Vincenty's formula anymore.
jsts indexes facets in chunks of 6 segments, so a line of 6k+1 vertices ends with a single-vertex chunk whose location carries the last vertex index. getSegment then read a vertex past the end and threw a TypeError, which failed urbanisme and assiette_sup calls whose nearest object is a line reached at its end, and silently nulled distance_to_filter_center. Clamp the index to the last segment.
Comment thread docs/mcp-tools.md Outdated
The result is rounded to the centimeter, so 0.5 cm, not 1 mm. Drop "coûteuse", the cost being a few microseconds, and the default already published by the schema.
@esgn
esgn merged commit 7a1313a into 138/distance-tool Oct 2, 2026
@esgn
esgn deleted the 138/distance-tool-experiment branch October 2, 2026 09:33
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.

2 participants