Ticket #954 (closed feature: fixed)

Opened 6 years ago

Last modified 4 years ago

Snapping while digitizing vectors

Reported by: jachym Owned by:
Priority: minor Milestone: 2.8 Release
Component: Control Version: 2.4
Keywords: Cc:
State: Complete

Description (last modified by tschaub) (diff)

Add a configurable snapping agent. The agent can be configured to listen for edits on a source layer and will look for eligible features on any number of target layers. Separate node, edge, and vertex tolerances can be configured. Snapping precedence is configurable (default is node, vertex, edge).

Attachments

Point.js-diff Download (7.3 KB) - added by jachym 6 years ago.
Snapping while digitization
snapping.patch Download (57.4 KB) - added by elemoine 5 years ago.
snapping_control.patch Download (46.4 KB) - added by tschaub 4 years ago.
add a snapping agent

Change History

Changed 6 years ago by jachym

Snapping while digitization

  Changed 5 years ago by euzuro

  • milestone set to 2.7 Release

from a cursory reading, this seems like kind of a cool patch. does this maybe already work in vectors in trunk? why hasn't this ticket gotten any traction?

I'm putting it into 2.7 now just to force someone to comment on it, move it, or close it.

  Changed 5 years ago by pgiraud

I would like to inform you that there is also some work done by Frederic Junod on snapping too. It's available in a sandbox.  http://dev.openlayers.org/sandbox/camptocamp/feature/examples/modify-feature.html

The approach is different but this already works. I remember that Fred wanted to separate this into several tickets. The first one is at  http://trac.openlayers.org/ticket/1192

  Changed 5 years ago by crschmidt

  • milestone changed from 2.7 Release to 2.8 Release

Changed 5 years ago by elemoine

  Changed 5 years ago by fredj

The up to date version is now: browser:/sandbox/camptocamp/snapping

  Changed 4 years ago by tschaub

(In [8605]) Add a snapping agent for snapping vertices to nodes, vertices, or edges while editing vector features (creating new sketches or modifying existing features). Provides configuration options for multiple target layers with (optional) specific tolerance values for each target and each snap type. Implemented as an independent control. (see #954)

  Changed 4 years ago by tschaub

See the snapping proposal page? for a bit of detail on a proposal for an alternate implementation (and the draft control).

  Changed 4 years ago by openlayers

This looks awesome.

One thing to add might be the ability to snap in freehand mode as well (as it seems this is not supported in the sandbox example). This would allow for easier 'tracing' of existing adjacent geometries.

-dane

  Changed 4 years ago by tschaub

(In [8631]) Call the modify callback when adding new points. For the snapping control, this allows snapping while in freehand mode (see #954).

Changed 4 years ago by tschaub

add a snapping agent

  Changed 4 years ago by tschaub

  • owner tschaub deleted
  • state set to Review
  • component changed from Handler.Point to Control
  • description modified (diff)

Depends on #1966.

  Changed 4 years ago by tschaub

Tests pass and example works in FF 3, IE 6, IE 7, Safari 3, Opera 9.6. Thanks for any review.

follow-up: ↓ 13   Changed 4 years ago by ahocevar

  • state changed from Review to Commit

Tim, this is great work. The only thing I'd like to add is that in the example, you don't add the control to the map. I see that addToMap is not required for the snapping control, so it may be ok. On the other hand, users may wonder why this control works without adding it to the map.

Anyway, that's minor. Feel free to decide whether or not to change the example in that way. This is good to commit.

  Changed 4 years ago by fredj

Thanks for all your work Tim !

in reply to: ↑ 11   Changed 4 years ago by tschaub

Replying to ahocevar:

Tim, this is great work. The only thing I'd like to add is that in the example, you don't add the control to the map. I see that addToMap is not required for the snapping control, so it may be ok. On the other hand, users may wonder why this control works without adding it to the map. Anyway, that's minor. Feel free to decide whether or not to change the example in that way. This is good to commit.

Thanks for the review. I'll happily commit.

Adding a control to the map calls control.draw. This creates an element node (control.div) and sets a "selectstart" listener on that element. When the map is destroyed, the controls are destroyed, but the listener on the control.div is never cleaned up. This leaked on unpatched IE6 (at least). I know the right thing to do is patch this - but I also don't really see the point in having the extra element node created.

When this control is activated, a number of listeners are registered on a number of layers. These are only application events (not browser events). When the map is destroyed, the layers are destroyed and their events instances are destroyed (this essentially just removes some arrays of functions - again, this control is not dealing specifically with browser events on element nodes).

Anyway, I'm happy to change the example if people want consistency. I'd also like to come up with an alternative to controls that create needless element nodes.

  Changed 4 years ago by tschaub

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [8951]) Adding a snapping agent for snapping geometry components to existing components while editing. r=ahocevar (closes #954)

Note: See TracTickets for help on using tickets.