Skip to content

Support for travel time / isochrone elements - #147

Merged
rclark merged 4 commits into
mainfrom
rclark/isochrone-types
Oct 15, 2026
Merged

rclark merged 4 commits into
mainfrom
rclark/isochrone-types

Conversation

@rclark

@rclark rclark commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Extensions can now create a Polygon from a travel time. Passing isochrone: { origin, mode, minutes } instead of coordinates makes Felt compute the reachable area and use it as the shape. The new "isochrone" tool works with setTool and setToolSettings.

The isochrone form is a separate type, IsochronePolygonElementCreate, so PolygonElementCreate still requires coordinates. A Polygon with both or neither is rejected.

Also updates the linking steps in DEVELOPING.md for pnpm.

Test plan

  1. With this branch linked into the Felt app, on a map whose plan includes travel time, create a Polygon with isochrone: { origin, mode: "driving", minutes: 15 }. Observe a shape around the origin.
  2. Update its minutes to 30. Observe that the shape grows.
  3. Select the "isochrone" tool with setTool and click the map. Observe an isochrone, and an onElementCreateEnd event for it.

@dnomadb dnomadb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good. Nothing breaks at runtime: tsc, vitest and the full npm run check pass on the branch, with no drift in the generated docs or API report. The app half in felt/felt#22386 lines up: the mode names map correctly, the tool settings round-trip, and setTool already accepts "isochrone". Two type-level suggestions, neither blocking:

1. The types accept a Polygon with both coordinates and isochrone, but the runtime rejects it (src/modules/elements/types.ts)

This compiles, because both union members share type: "Polygon" and the excess-property check allows keys from either:

const both: ElementCreate = { type: "Polygon", coordinates: ring, isochrone: iso };
const upd: PolygonElementUpdate = { id, type: "Polygon", coordinates: ring, isochrone: iso };

The "both" test has no @ts-expect-error, while the "neither" test does. Extensions and agents only find out when createElement rejects, and llms-full.txt doesn't state the either/or rule for create. Adding isochrone?: never to PolygonElementCreate and coordinates?: never to IsochronePolygonElementCreate would make the rule visible in the types. The same could apply to the update type.

2. Narrowing an ElementCreate to "Polygon" no longer gives access to .coordinates, in a minor release

if (e.type === "Polygon") e.coordinates;
// TS2339: Property 'coordinates' does not exist on type 'IsochronePolygonElementCreate'

felt/felt#22386 already had to work around this in mappers/Polygon.ts, and external consumers that switch on ElementCreate will hit the same error. The ?: never change above also fixes this, since e.coordinates becomes readable again as LngLatTuple[][] | undefined. Otherwise, it's worth noting the break in the changeset.

Smaller things:

  • PolygonElementUpdate.coordinates doesn't say what happens to isochrone when you set coordinates on an isochrone polygon. Does reading it back still return the old travel time alongside a hand-drawn shape?
  • { type: "Polygon" } fails with "…not both", which reads as if the caller passed both.

🤖 Generated with Claude Code

rclark and others added 2 commits October 14, 2026 10:53
…ile time

PolygonElementUpdate now refuses an isochrone, and the new IsochronePolygonElementUpdate refuses coordinates. The tests check each polygon error message exactly and cover the update rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rclark
rclark merged commit 7b69a0f into main Oct 15, 2026
4 checks passed
@rclark
rclark deleted the rclark/isochrone-types branch October 15, 2026 19:17
rclark added a commit that referenced this pull request Oct 15, 2026
* adds isochrone polygons & tool

* update for pnpm

* address review comments

* Reject polygon updates with both coordinates and an isochrone at compile time

PolygonElementUpdate now refuses an isochrone, and the new IsochronePolygonElementUpdate refuses coordinates. The tests check each polygon error message exactly and cover the update rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 7b69a0f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants