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 renderBuffer option to ol.layer.Vector #3061

Merged
merged 3 commits into from Dec 19, 2014
Merged

Add a renderBuffer option to ol.layer.Vector #3061

merged 3 commits into from Dec 19, 2014

Conversation

elemoine
Copy link
Member

This PR fixes a the bug reported in #2851 and a renderBuffer option to ol.layer.Vector.

The bug reported in #2851 can be easily reproduced using the icon example. Just move the map north until the icon hits the bottom of the viewport: the icon disappears as soon as the icon position ([0, 0]) is outside the viewport.

This PR fixes the bug by removing the ol.extent.intersects tests in the ReplayGroup's replay functions. This means Replay objects are now unconditionally replayed, even when their envelope does not intersect the viewport extent.

Also, currently, we do not recreate a new ReplayGroup when the extent of the current ReplayGroup contains the viewport extent. This means that we may have rendering issues (symbols/icons not drawn) when the viewport approaches the boundary of tthe ReplayGroup extent.

This PR addresses this problem by using not re-creating the batch only in the case where the ReplayGroup extent equals the viewport extent. But note that we still do not create new ReplayGroup's during animations and interactions.

And, at last, this PR adds a renderBuffer option to ol.layer.Vector that allows specifying the size (in pixels) of the rendering buffer around the viewport extent. The default value is 100 pixels, but larger values can be used when using large icon sizes or line widths. This option is somewhat similar to MapServer's tile_map_edge_buffer.

Please review.

Fixes #2851.

@fredj
Copy link
Member

fredj commented Dec 18, 2014

LGTM, thanks !

@tschaub
Copy link
Member

tschaub commented Dec 18, 2014

This looks great to me. Very nice description of the problem and the solution. I still think we could check for contains since we are always comparing buffered extents - I agree we would have a problem if we only checked to see whether the rendered extent contained the unbuffered frame extent. But as I mention above, given the other conditions, there are few cases where the batch extent contains but does not equal the buffered frame extent.

Interested if I'm missing something, but please merge in any case.

@elemoine
Copy link
Member Author

I changed the commit history. Here the exchange @tschaub and I had on some previous commit:

@tschaub:

Isn't this.renderedExtent_ always buffered? I see how we would have rendering issues if we only recreated the batch when the unbuffered rendered extent didn't contain the buffered frame extent. But I don't immediately see how we'd have problems if we only recreate the batch if the buffered rendered extent doesn't contain the buffered frame extent.

That said, because we're also checking for matching resolution here, I think we could only have a buffered rendered extent that contains but does not equal the buffered frame extent when the viewport size changes. So, while I think we could still be using ol.extent.containsExtent here, it's a minor optimization.

Curious if you see a case where contains would fail (assuming this.renderedExtent_ is never set to an unbuffered frame extent).

@elemoine:

You are totally correct. Previously (in the current master branch) we only recreate the batch if the (buffered) rendered extent does not contain the (unbuffered) viewport extent. But, with my changes, we compare the rendered extent to the buffured viewport extent. So you're absolutely right, I could still use containsExtent rather than equal. And as you said this is a small optimization for the case where the viewport size changed. This may also be a small optimization for the case where the renderBuffer changes (which is not possible at the moment because there is not setter). Anyway good comment, I'll make the change before merging.

https://github.com/elemoine/ol3/commit/567316c8d9fc3fd9c1d2dff933a7b92c95e10106

Only recreate batch when the (buffered) rendered extent contains the **buffered** viewport extent.
elemoine pushed a commit that referenced this pull request Dec 19, 2014
Add a renderBuffer option to ol.layer.Vector
@elemoine elemoine merged commit 85a6de0 into openlayers:master Dec 19, 2014
@elemoine elemoine deleted the render-bug2 branch December 19, 2014 07:58
@tschaub
Copy link
Member

tschaub commented Dec 23, 2014

Unfortunately, it looks like ddc51ee messes with the select interaction when it is configured to respond to mousemove (see #3081).

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.

Icon image disappears when feature is outside visual map area
3 participants