Track replay group resolution and buffer max extent to capture strokes #1845

Merged
merged 1 commit into from Mar 17, 2014

Projects

None yet

2 participants

@tschaub
Member
tschaub commented Mar 12, 2014

With 36204fa canvas vector rendering is clipped to the extent requested by the layer. This can leave partial strokes rendered for geometry segments that fall just outside the max extent. To avoid this, points are only eliminated if they fall outside of the max extent buffered by the current stroke width * resolution.

@tschaub
Member
tschaub commented Mar 12, 2014

This is now ready for review. The change is subtle, but if you play around with the fractal example you'll occasionally see partial strokes rendered at the edge of the clipped rendering extent. With the change in this branch, this no longer happens.

@twpayne twpayne and 1 other commented on an outdated diff Mar 13, 2014
src/ol/render/canvas/canvasreplay.js
@@ -923,6 +944,16 @@ ol.render.canvas.LineStringReplay.prototype.drawFlatCoordinates_ =
/**
+ * @inheritDoc
+ */
+ol.render.canvas.LineStringReplay.prototype.getBufferedMaxExtent = function() {
+ var width = goog.isDef(this.state_.currentLineWidth) ?
+ this.state_.currentLineWidth + 1 : 0;
@twpayne
twpayne Mar 13, 2014 Contributor

Does this not need to track the maximum line width used in the batch, rather than the current line width?

@tschaub
tschaub Mar 13, 2014 Member

Clear oversight on my part, thanks.

@twpayne twpayne and 1 other commented on an outdated diff Mar 13, 2014
src/ol/render/canvas/canvasreplay.js
@@ -923,6 +944,16 @@ ol.render.canvas.LineStringReplay.prototype.drawFlatCoordinates_ =
/**
+ * @inheritDoc
+ */
+ol.render.canvas.LineStringReplay.prototype.getBufferedMaxExtent = function() {
+ var width = goog.isDef(this.state_.currentLineWidth) ?
+ this.state_.currentLineWidth + 1 : 0;
+ return ol.extent.buffer(this.maxExtent, width * this.resolution / 2);
@twpayne
twpayne Mar 13, 2014 Contributor

If width === 0 then presumably you can return this.maxExtent directly, saving an Array allocation.

@twpayne
Contributor
twpayne commented Mar 17, 2014

Thanks, LGTM.

@tschaub tschaub merged commit f57a054 into openlayers:master Mar 17, 2014

1 check passed

default The Travis CI build passed
Details
@tschaub tschaub deleted the tschaub:buffered branch Mar 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment