Skip to content

Conversation

@ahocevar
Copy link
Member

This pull request adds wrapX support for vector layers, vector overlays, and the map's replay group. It also ensures that ol.Map#forEachFeatureAtPixel() works when viewing a wrapped world.

@ahocevar ahocevar force-pushed the vector-wrapx branch 5 times, most recently from b6cb1d6 to ffc0145 Compare April 16, 2015 17:25
@ahocevar
Copy link
Member Author

This is now ready for review. cc @elemoine, @tschaub.

@ahocevar ahocevar force-pushed the vector-wrapx branch 2 times, most recently from e90559c to ec110c9 Compare April 16, 2015 19:21
Copy link
Member

Choose a reason for hiding this comment

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

If you rebase on master, I think the 3-way merge will do the right thing (make these changes in examples instead of examples_src).

@ahocevar
Copy link
Member Author

Rebased, 3-way merge did the trick.

@tschaub
Copy link
Member

tschaub commented Apr 19, 2015

@ahocevar - you mentioned on Thursday that you were going to make some changes. Is this ready for review now?

externs/olx.js Outdated
Copy link
Member

Choose a reason for hiding this comment

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

I haven't tried, but is 0° really a problem? Or only -180° and 180°?

@ahocevar
Copy link
Member Author

@tschaub Yes, this is ready for review - and thanks for starting the review.

@ahocevar
Copy link
Member Author

Any more comments on this?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure about this one. The Mollweide projection is global but it doesn't/cannot have an extent.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense. This means I have to remove this assertion and check for extent available elsewhere before doing any wrapping. I can do that.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe you can skip the isGlobal test?

Copy link
Member Author

Choose a reason for hiding this comment

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

When using a projection for transforming coordinates only, you don't need an extent - and you also don't need to set isGlobal. I think the best will be to remove the assertion altogether like you suggested. To avoid checking for the same conditions over and over, I can add a canWrapX function (which returns with a cached value) to ol.proj.Projection.

Copy link
Member

Choose a reason for hiding this comment

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

I was just wondering why wrapX would only work for "global" projections. What makes "global" projections special wrt wrapping the "world"?

Copy link
Member Author

Choose a reason for hiding this comment

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

For "global" projections, we assume that the projection's extent is the extent of the world. So if we wrap e.g. a Swiss projection around its extent, Switzerland will be repeated several times across the globe.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure I completely follow, but it's probably me so can you just ignore me for now :)

I thought someone may want to use wrapX even though his projection is not "global" (i.e. covering the earth).

Copy link
Member

Choose a reason for hiding this comment

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

We could avoid the test by making the offsetX argument non-optional, and passing 0 when no offset is wanted.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will make this change.

@ahocevar
Copy link
Member Author

@elemoine I may have a better approach for map replays: render them on the correct world instead of repeating them. I'll give myself an hour to see if this is feasible and report back here.

@ahocevar
Copy link
Member Author

@elemoine I was able to implement what I had in mind, and I am very happy with the result. I hope you are too - there is no more canvas replay wrapping 😄.

@elemoine
Copy link
Member

Cool. Do you mind explaining how it now works? I don't understand the relation to the frame state focus. And I don't understand how features from feature overlays are now repeated when the viewport spans multiple words. Thanks.

@ahocevar
Copy link
Member Author

Feature overlays are not repeated/wrapped any more. Instead, the frameState's focus is used to determine the world where the feature overlay is rendered. You can see this in action e.g. In the vector-layer.html example: if you zoom out so that multiple worlds are visible and hover over a country, it only gets highlighted under your pointer, and not in other worlds. Same for feature selection in the select-features.html example.

@elemoine
Copy link
Member

Thanks for the explanations @ahocevar! It's much clearer now. I've just added one last comment. Please merge when addressed.

By using the frameState's focus, we can adjust extent and transform and
render it for the world of interest instead of wrapping it and rendering
for every visible world.
@ahocevar
Copy link
Member Author

Thanks for the great review @elemoine and @tschaub!

ahocevar added a commit that referenced this pull request Apr 22, 2015
Add wrapX support for vector layers (canvas renderer only)
@ahocevar ahocevar merged commit 90b736c into openlayers:master Apr 22, 2015
@ahocevar ahocevar deleted the vector-wrapx branch April 22, 2015 07:21
@bartvde
Copy link
Member

bartvde commented Apr 23, 2015

one thing I noticed which might be related to this PR, the zoom box control can behave strangely, sometimes it doesn't show or it shows up in a different world.

@ahocevar
Copy link
Member Author

Another gentle reminder that the Box interaction should draw a dom element and not a feature on a vector overlay...

@bartvde
Copy link
Member

bartvde commented Apr 23, 2015

Right

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