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

Always report skipped feature hits for the original layer #4854

Conversation

ahocevar
Copy link
Member

In the process of getting to the bottom of #4822, it occurred to me why so many iterations of patching the select interaction fixed one issue, only to create another: hit detection of features should return the same features and layers, no matter be features selected or not.

I think this fix makes the affected code easier to read and understand, and turns the select interaction into one that could almost be loved.

Fixes #4822.

@ahocevar ahocevar force-pushed the fix-select-and-everything-that-relies-on-unmanaged-layers-and-skipped-features-this-time-for-real---hopefully branch from fa930d8 to 9f0fefd Compare February 17, 2016 01:51
@ahocevar ahocevar changed the title Hit-detect skipped features, but not on unmanaged layer Always report skipped feature hits for the original layer Feb 17, 2016
@marcjansen
Copy link
Member

Nice branch name 😉

@tschaub
Copy link
Member

tschaub commented Feb 17, 2016

Nice branch name 😉

Agreed.

Other things I like:

  • Net 7 lines removed!
  • And that is with something like 15 test lines added!

Things that make me scared:

  • This code always breaks.
  • This changes a test in a way that makes it seem like applications would break, but I'm so scared of the select interaction that I don't know if this is expected behavior or not.

In summary:

  • Andreas is awesome for his perseverance with the select interaction.
  • I hope that someone else who uses the select interaction can review this.
  • It would be really nice to have a clear understanding of what was broken before and what is fixed now.

@ahocevar
Copy link
Member Author

@tschaub I wrote a blog post about the whole story: http://ahocevar.net/openlayers/2016/02/17/trilogy-of-error.html. I hope it explains the whole evolution of these problems.

@ahocevar
Copy link
Member Author

@tschaub:

This changes a test in a way that makes it seem like applications would break, but I'm so scared of the select interaction that I don't know if this is expected behavior or not.

There is no real need to make this change, so I changed it back to the way it was.

The key change of this pull request is that skipped features are now hit-detected the same way as if they had never been changed on their original layer. This means that they will be hit-detected on their original layer only, even when duplicated on one or more unmanaged layers.

@ahocevar
Copy link
Member Author

It would be really nice to have a clear understanding of what was broken before and what is fixed now.

When a feature is selected, the Select interaction calls ol.Map#skipFeature() with the selected feature, and copies the feature to its internal unmanaged layer. Before this change, an already selected feature was reported by ol.Map#forEachFeatureAtPixel to come from a null layer. After this change, it is still reported to come from the layer that it was selected from. The Select interaction had a lot of code to deal with this change of layers for a selected feature, which could now be removed.

For user created unmanaged layers, nothing changes, because a user cannot call ol.Map#skipFeature().

@ahocevar ahocevar force-pushed the fix-select-and-everything-that-relies-on-unmanaged-layers-and-skipped-features-this-time-for-real---hopefully branch from b2461c2 to 97c5d67 Compare February 17, 2016 07:59
@ahocevar ahocevar force-pushed the fix-select-and-everything-that-relies-on-unmanaged-layers-and-skipped-features-this-time-for-real---hopefully branch from 97c5d67 to 5bc00d8 Compare February 17, 2016 07:59
@ischas
Copy link
Contributor

ischas commented Feb 17, 2016

I wrote a blog post about the whole story: http://ahocevar.net/openlayers/2015/02/17/trilogy-of-error.html.

@ahocevar So if you knew that all one year before (see publishing date), why didn't you fix it earlier? ;-)

@ahocevar
Copy link
Member Author

Thanks @ischas - I shouldn't be writing blog posts at 2am. Updated blog post URL: http://ahocevar.net/openlayers/2016/02/17/trilogy-of-error.html.

@ischas
Copy link
Contributor

ischas commented Feb 17, 2016

@ahocevar 404! First link was good, but the publishing date was wrong! Maybe you must fix the blog post, too.

@ahocevar
Copy link
Member Author

@ischas Took a few seconds to update on the server. Now it's live.

@jonataswalker
Copy link
Contributor

Andreas is awesome for his perseverance with the select interaction.

No doubt. All of us are benefited at his cost.

@bjornharrtell
Copy link
Contributor

Nice work @ahocevar, did some testing with an application of mine that makes good use of the Select interaction here and there and it works as expected.

This also makes #3453 easier to fix so I've rebased that on this PR.

@ahocevar
Copy link
Member Author

Anyone brave enough to review this? @fredj or @tsauerwein maybe?

@fredj
Copy link
Member

fredj commented Feb 22, 2016

LGTM, thanks Andreas

ahocevar added a commit that referenced this pull request Feb 22, 2016
…-relies-on-unmanaged-layers-and-skipped-features-this-time-for-real---hopefully

Always report skipped feature hits for the original layer
@ahocevar ahocevar merged commit 6c7d681 into openlayers:master Feb 22, 2016
@ahocevar ahocevar deleted the fix-select-and-everything-that-relies-on-unmanaged-layers-and-skipped-features-this-time-for-real---hopefully branch February 22, 2016 08:23
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.

Having 2 select interactions active at the same time
7 participants