Skip to content

Ol10 geometry copy - #6830

Draft
meyerlor wants to merge 4 commits into
3liz:masterfrom
meyerlor:ol10-geometry-copy
Draft

Ol10 geometry copy#6830
meyerlor wants to merge 4 commits into
3liz:masterfrom
meyerlor:ol10-geometry-copy

Conversation

@meyerlor

Copy link
Copy Markdown
Collaborator

Migrate Copy/Paste geometry to OL10

  • Bind clicks to mainLizmap.map (OL10) in edition context; keep the OL2
    click handler for non-edition flows.
  • Toggle mainLizmap.digitizing.toolSelected = deactivate / restore to
    pause drawing while copy mode is active, instead of poking the now
    removed OL2 mainLizmap.edition.drawControl.

Without this PR the button rendered by the OL10
digitizing toolbar would still call into the OL2 paths and silently fail
on click.

* Replace OpenLayers.Control.Snapping with the OL10 Snap interaction.
* Render snap features as a solid orange overlay while snapping is active.
* Drop the manual refresh button: getSnappingData() now runs automatically
  on moveend and on layer-tree visibility changes (the
  snapLayersRefreshable state and snapping.refreshable event are gone,
  no consumers remained).
* OL10 Snap exposes a single vertex flag and a single pixelTolerance, so
  snap_vertices is OR-ed with snap_intersections and pixelTolerance is
  max(snap_vertices_tolerance, snap_segments_tolerance). Worth flagging
  for projects that configure vertex vs intersection independently.
* Public reorderSnapInteraction() lets future callers re-add the Snap
  interaction so OL processes it before any recently-added Draw / Modify
  / Translate. No-op when snap is inactive.

Tests:
* snap.spec.js: remove three WFS 1.1.0 / SRSNAME / datum-shift tests that
  exercised the OL2 snap WFS path (replaced by OL10 GeoJSON parsing).
  Strip refresh-button click / disabled-state assertions from the snap
  panel test now that refresh is automatic.

This PR ships the snap infrastructure but does not visibly engage with
the OL2 edition Draw / Modify yet. Snapping starts to actually snap once
the follow-up OL10 edition migration lands.
@github-actions github-actions Bot added this to the 3.11.0 milestone May 14, 2026
@meyerlor
meyerlor force-pushed the ol10-geometry-copy branch 9 times, most recently from 8acad39 to b725f3f Compare May 15, 2026 08:09
meyerlor added 3 commits May 15, 2026 11:17
* Replace OpenLayers.Control.DrawFeature / ModifyFeature / SelectFeature
  with OL10 Draw, Modify and Select interactions. The OL2 vector edit
  layer becomes an OL10 VectorLayer / VectorSource on mainLizmap.map.
* Auto-activate Modify after a feature is drawn, including for point
  layers. Feature highlights use the OL10 draw layer.
* Route WMS extent / size queries through the OL10 view. Required
  because the OL10 map is now the source of truth for the visible
  viewport during edition.
* New modules/Edition.js owns the WKT bridge between the digitizing
  module and the hidden geometry form field, and emits user-facing
  toasts via #lizmap-editing-message (the legacy #lizmap-edition-message
  is still used for save-success / error toasts).
* Duplicate toast dispatches removed from legacy/edition.js so the
  "Edit vertices" / "Draw on the map" toast no longer appears twice.
* For point edition the digitizing toolbar is hidden; drawing begins
  automatically on click.
* New baseline locale keys: edition.toolbar.redraw plus four
  digitizing.toolbar.<tool>.help keys (edit / split / rotate / scaling).
* Remove ~120 lines of dead OL2 split helpers from legacy/edition.js
  (afterReshapeSpliting, beforeFeatureSpliting, afterFeatureSpliting and
  their editCtrls.reshape / editCtrls.featsplit entries).

Builds on the snapping migration. The new digitizing module calls
mainLizmap.snapping.reorderSnapInteraction() after adding interactions,
so the OL10 Snap follows each new Draw / Modify / Translate.

Tests:
* 9 spec files updated for OL10 map / interactions (clickOnMapLegacy
  → clickOnMap, mapOl2 → map, #map → #newOlMap, waitForFunction guards
  for Select/Modify).
* edition-form.spec.js: "must allow modification without creation"
  now expects #lizmap-editing-message (the new id) for the on-form
  edit-vertices toast.
* editing-copy-paste-geometry.spec.js: mark the 11 interaction tests
  test.fixme(). They cover behaviour that needs the OL10 GeometryCopy
  port (lands in the follow-up Copy/Paste PR).
* draw.spec.js: mark "Length and angle constraints" test.fixme() —
  the distance/angle constraint feature is deferred to a follow-up PR.

Deferred to follow-up PRs: reshape, parallel offset, move (in edition),
distance/angle drawing constraints, split-with-server-save (the
digitizing-split button is therefore hidden in edition context for now,
remains available in draw context), ReverseGeom port, draw.spec.js
new-tool tests and pages/drawpage.js new-tool locators.
* Replace OpenLayers.Control.DrawFeature / ModifyFeature / SelectFeature
  with OL10 Draw, Modify and Select interactions. The OL2 vector edit
  layer becomes an OL10 VectorLayer / VectorSource on mainLizmap.map.
* Auto-activate Modify after a feature is drawn, including for point
  layers. Feature highlights use the OL10 draw layer.
* Route WMS extent / size queries through the OL10 view. Required
  because the OL10 map is now the source of truth for the visible
  viewport during edition.
* New modules/Edition.js owns the WKT bridge between the digitizing
  module and the hidden geometry form field, and emits user-facing
  toasts via #lizmap-editing-message (the legacy #lizmap-edition-message
  is still used for save-success / error toasts).
* Duplicate toast dispatches removed from legacy/edition.js so the
  "Edit vertices" / "Draw on the map" toast no longer appears twice.
* For point edition the digitizing toolbar is hidden; drawing begins
  automatically on click.
* New baseline locale keys: edition.toolbar.redraw plus four
  digitizing.toolbar.<tool>.help keys (edit / split / rotate / scaling).
* Remove ~120 lines of dead OL2 split helpers from legacy/edition.js
  (afterReshapeSpliting, beforeFeatureSpliting, afterFeatureSpliting and
  their editCtrls.reshape / editCtrls.featsplit entries).

Builds on the snapping migration. The new digitizing module calls
mainLizmap.snapping.reorderSnapInteraction() after adding interactions,
so the OL10 Snap follows each new Draw / Modify / Translate.

Tests:
* 9 spec files updated for OL10 map / interactions (clickOnMapLegacy
  → clickOnMap, mapOl2 → map, #map → #newOlMap, waitForFunction guards
  for Select/Modify).
* edition-form.spec.js: "must allow modification without creation"
  now expects #lizmap-editing-message (the new id) for the on-form
  edit-vertices toast.
* editing-copy-paste-geometry.spec.js: mark the 11 interaction tests
  test.fixme(). They cover behaviour that needs the OL10 GeometryCopy
  port (lands in the follow-up Copy/Paste PR).
* draw.spec.js: mark "Length and angle constraints" test.fixme() —
  the distance/angle constraint feature is deferred to a follow-up PR.

Deferred to follow-up PRs: reshape, parallel offset, move (in edition),
distance/angle drawing constraints, split-with-server-save (the
digitizing-split button is therefore hidden in edition context for now,
remains available in draw context), ReverseGeom port, draw.spec.js
new-tool tests and pages/drawpage.js new-tool locators.
* Bind clicks to mainLizmap.map (OL10) in edition context; keep the OL2
  click handler for non-edition flows.
* Toggle mainLizmap.digitizing.toolSelected = deactivate / restore to
  pause drawing while copy mode is active, instead of poking the now
  removed OL2 mainLizmap.edition.drawControl.

Without this PR the <lizmap-paste-geom> button rendered by the OL10
digitizing toolbar would still call into the OL2 paths and silently fail
on click.

Tests:
* Un-fixme the 13 editing-copy-paste-geometry.spec.js tests that the
  edition-baseline PR marked test.fixme(). They cover the OL10 Copy/Paste
  flow this PR enables.
@meyerlor
meyerlor force-pushed the ol10-geometry-copy branch from b725f3f to 1b54cb9 Compare May 15, 2026 09:18
@github-actions

Copy link
Copy Markdown

The Lizmap project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 2 months and is being automatically marked as "stale".
If there is no further activity on this pull request, it will be closed in two weeks.

@github-actions github-actions Bot added the stale This ticket might be closed soon label Jul 15, 2026
@3liz-bot 3liz-bot removed the stale This ticket might be closed soon label Jul 16, 2026
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