Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to delete vertices with the Modify interaction #1283

Merged
merged 3 commits into from
Mar 28, 2014

Conversation

ahocevar
Copy link
Member

After this change, vertices can be deleted by simply clicking on
them. This is the same behaviour as e.g. in geojson.io.

@ahocevar
Copy link
Member Author

ahocevar commented Dec 2, 2013

cc @oterral - I heard you'll be porting the editing tools to the vector-api branch.

@oterral
Copy link
Contributor

oterral commented Dec 4, 2013

Thx @ahocevar I'll try to integrate that in the vector-api

@tschaub
Copy link
Member

tschaub commented Dec 10, 2013

I think this is nice behavior, but I'm seeing some assertion errors when trying to delete shared vertices. I haven't narrowed it down to an easily repeatable sequence, but I periodically see assertion errors with this stack:

Uncaught AssertionError: Assertion failed asserts.js:103
goog.asserts.doAssertFailure_ asserts.js:103
goog.asserts.assert asserts.js:118
ol.structs.RBush.remove rbush.js:593
ol.interaction.Modify.removeVertex_ modifyinteraction.js:504
ol.interaction.Modify.handleClick_ modifyinteraction.js:459
ol.interaction.Modify.handleMapBrowserEvent modifyinteraction.js:441
ol.Map.handleMapBrowserEvent map.js:765
goog.events.EventTarget.fireListeners eventtarget.js:284
goog.events.EventTarget.dispatchEventInternal_ eventtarget.js:380
goog.events.EventTarget.dispatchEvent eventtarget.js:198
ol.MapBrowserEventHandler.relayEvent_ mapbrowserevent.js:474
goog.events.fireListener events.js:730
goog.events.handleBrowserEvent_ events.js:851

And here is a picture:

delete

@ahocevar
Copy link
Member Author

Thanks for spotting this @tschaub. I'll investigate this further and try to come up with a fix.

@ahocevar
Copy link
Member Author

Note to /self: double-check iterator variable name in nested loop.

@tschaub: The issue should be fixed now.

@ahocevar
Copy link
Member Author

@tschaub, the above was only part of the fix. Looks like there is a 2nd issue. Working on that one now.

@ahocevar
Copy link
Member Author

@tschaub The "issue" shown in the picture is unrelated to the failing assertion. The picture shows what happens when a vertex is deleted from multiple geometries where neighboring segments have different vertices on each geometry. Regarding the assertion, it seems like an issue with RBush's extent lookup. But so far I have been unable to nail it down. Doing more research now.

@tschaub
Copy link
Member

tschaub commented Dec 11, 2013

The "issue" shown in the picture is unrelated to the failing assertion

Right, I just included the picture to show you where I was editing. I didn't mean to imply that the picture itself demonstrated the issue. Apologies for the confusion.

@ahocevar
Copy link
Member Author

No worries @tschaub - the picture helped indeed to find a way to consistently reproduce the RBush problem.

@ahocevar
Copy link
Member Author

For what it's worth, now that #1373 is fixed, vertex deletion works as expected again.

@ahocevar
Copy link
Member Author

This needs to be ported to the new Modify interaction. I'll be doing this shortly.

@ahocevar
Copy link
Member Author

Updated. Thanks for any review.

@oterral
Copy link
Contributor

oterral commented Mar 27, 2014

Tested on safari/chrome mac. Works great!!!

@tschaub
Copy link
Member

tschaub commented Mar 27, 2014

I'm wondering if it makes sense to require a more explicit action for vertex deletion. No ideas at the moment, but I'm concerned that people might inadvertently delete points when they are trying to do something else. For example, if you are working with small features and are trying to select a feature adjacent to an already selected feature, you can end up deleting points instead of selecting the new feature (this is related to the comments in #1914).

Part of this could be ameliorated by a smaller pixelTolerance in the modify interaction (10 pixels makes accidental deletes on selection less frequent for me).

Any thoughts @ahocevar?

@ahocevar
Copy link
Member Author

I think reducing the pixelTolerance to 10 pixels makes sense, but I want to test on mobile hidpi devices first to see how this affects usability.

As an alternative to this, we could introduce a delete modifier (Meta/Alt key?). But that might raise usability issues too.

If we add an undo functionality, accidental vertex deletion should not be a problem any more.

@tschaub
Copy link
Member

tschaub commented Mar 27, 2014

A lower tolerance plus a promise of undo in the future is probably enough. We could also add support for a delete condition in the future, but leave the default always.

After this change, vertices can be deleted by simply clicking on
them. This is the same behaviour as e.g. in geojson.io.
@ahocevar
Copy link
Member Author

Ticket for undo created: #1919.

ahocevar added a commit that referenced this pull request Mar 28, 2014
Add a way to delete vertices with the Modify interaction
@ahocevar ahocevar merged commit 37eea93 into openlayers:master Mar 28, 2014
@ahocevar ahocevar deleted the delete-vertex branch March 28, 2014 11:39
* @type {ol.Coordinate}
* @private
*/
this.lastVertexCoordinate_;
Copy link
Member

Choose a reason for hiding this comment

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

The property should be initialized (to null).

@elemoine
Copy link
Member

Sorry for the post-merge review. I just added a comment regarding the initialization of the lastVertexCoordinate_ property. Thanks.

@ahocevar
Copy link
Member Author

ahocevar commented Apr 1, 2014

@elemoine lastVertexCoordinate_ is removed with 66fecc8e6a14b37661d76dae26e310a56a0bbfae, which is part of #1914.

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.

4 participants