Skip to content

feat(editable-layers): EditModeCoordinateSystem abstraction aligned with deck.gl COORDINATE_SYSTEM#516

Open
Copilot wants to merge 3 commits intomasterfrom
copilot/start-work-on-issue-496
Open

feat(editable-layers): EditModeCoordinateSystem abstraction aligned with deck.gl COORDINATE_SYSTEM#516
Copilot wants to merge 3 commits intomasterfrom
copilot/start-work-on-issue-496

Conversation

Copy link
Contributor

Copilot AI commented Feb 20, 2026

All editable-layers edit modes hard-code turf.js (WGS84 geodesic) math, making them unusable with OrthographicView or any non-geographic coordinate system. This PR introduces an EditModeCoordinateSystem interface, integrates it with deck.gl's own COORDINATE_SYSTEM constants, and migrates key modes to use it, decoupling editing logic from geographic assumptions.

New: EditModeCoordinateSystem interface + implementations

The interface is named EditModeCoordinateSystem (not CoordinateSystem) to avoid collision with deck.gl's own CoordinateSystem type (-1 | 0 | 1 | 2 | 3 from @deck.gl/core), which describes rendering projection. EditModeCoordinateSystem describes geometric math for edit modes.

Four geometric primitives, consistent bearing convention (compass: 0°=north, CW, [-180°, 180°]):

export interface EditModeCoordinateSystem {
  distance(a: Position, b: Position): number;
  bearing(a: Position, b: Position): number;
  destination(origin: Position, distance: number, bearing: number): Position;
  midpoint(a: Position, b: Position): Position;
}

// WGS84 — wraps turf.js, default/existing behavior unchanged
export const geoCoordinateSystem = new GeoCoordinateSystem();

// Euclidean — Pythagorean distance, atan2 bearing, trig destination
export const cartesianCoordinateSystem = new CartesianCoordinateSystem();

Integration with deck.gl COORDINATE_SYSTEM

A new fromDeckCoordinateSystem() utility maps deck.gl's COORDINATE_SYSTEM enum to the correct math implementation:

deck.gl constant Math used
COORDINATE_SYSTEM.LNGLAT / DEFAULT / LNGLAT_OFFSETS GeoCoordinateSystem
COORDINATE_SYSTEM.CARTESIAN / METER_OFFSETS CartesianCoordinateSystem

EditableGeoJsonLayer.getModeProps() now automatically derives coordinateSystem from the layer's own this.props.coordinateSystem (the standard deck.gl layer prop) via fromDeckCoordinateSystem(). Users just set coordinateSystem={COORDINATE_SYSTEM.CARTESIAN} on the layer and edit modes automatically use Euclidean math — no separate configuration needed.

ModeProps extended

type ModeProps<TData> = {
  // ...existing fields
  coordinateSystem?: EditModeCoordinateSystem; // auto-derived from layer's coordinateSystem prop
};

Modes migrated

  • translateFromCenter — removes @turf/rhumb-bearing/distance/destination in favour of the coordinate system abstraction
  • TranslateMode — uses props.coordinateSystem for drag distance/bearing and translateFromCenter
  • MeasureDistanceMode — uses props.coordinateSystem for segment distance and midpoint tooltips

Exports

EditModeCoordinateSystem, GeoCoordinateSystem, CartesianCoordinateSystem, geoCoordinateSystem, cartesianCoordinateSystem, getEditModeCoordinateSystem, fromDeckCoordinateSystem are all exported from the package root.

Remaining modes (RotateMode, ScaleMode, circle/measurement modes) still call turf directly; follow-up PRs can migrate them one-by-one using the same pattern.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Initiate work on proposal based on feedback from issue #496 feat(editable-layers): CoordinateSystem abstraction layer for non-geographic editing Feb 20, 2026
@charlieforward9 charlieforward9 added this to the 9.3-release milestone Feb 20, 2026
@charlieforward9
Copy link
Collaborator

@copilot It feels like we are not using enough from https://deck.gl/docs/developer-guide/coordinate-systems - this should be better shared

@charlieforward9 charlieforward9 linked an issue Feb 20, 2026 that may be closed by this pull request
@charlieforward9 charlieforward9 marked this pull request as ready for review February 20, 2026 22:00
Copy link
Contributor Author

Copilot AI commented Feb 20, 2026

@copilot It feels like we are not using enough from https://deck.gl/docs/developer-guide/coordinate-systems - this should be better shared

Done in commit 4533e6d.

Three changes align with deck.gl's coordinate system:

  1. Renamed CoordinateSystemEditModeCoordinateSystem to avoid the name collision with @deck.gl/core's own CoordinateSystem type (-1 | 0 | 1 | 2 | 3).

  2. Added fromDeckCoordinateSystem() that maps deck.gl's COORDINATE_SYSTEM enum directly to the right math implementation:

    • COORDINATE_SYSTEM.CARTESIAN / METER_OFFSETSCartesianCoordinateSystem
    • COORDINATE_SYSTEM.LNGLAT / LNGLAT_OFFSETS / DEFAULTGeoCoordinateSystem
  3. EditableGeoJsonLayer.getModeProps() now auto-derives coordinateSystem from this.props.coordinateSystem (the standard deck.gl layer prop) via fromDeckCoordinateSystem(). So users just set coordinateSystem={COORDINATE_SYSTEM.CARTESIAN} on the layer and edit modes automatically use Euclidean math — no separate configuration needed.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • deck.gl
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title feat(editable-layers): CoordinateSystem abstraction layer for non-geographic editing feat(editable-layers): EditModeCoordinateSystem abstraction aligned with deck.gl COORDINATE_SYSTEM Feb 20, 2026
@charlieforward9 charlieforward9 linked an issue Feb 23, 2026 that may be closed by this pull request
8 tasks
@charlieforward9

This comment was marked as resolved.

This comment was marked as resolved.

Copilot AI and others added 3 commits February 28, 2026 15:41
…-geographic editing

Co-authored-by: charlieforward9 <62311337+charlieforward9@users.noreply.github.com>
…ORDINATE_SYSTEM constants

Co-authored-by: charlieforward9 <62311337+charlieforward9@users.noreply.github.com>
@charlieforward9 charlieforward9 force-pushed the copilot/start-work-on-issue-496 branch from 4533e6d to 2a10d9d Compare February 28, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: Non-geospatial coordinate support for editable-layers [Bug] Non-standard FeatureCollection type in editable-layers

2 participants