From 9bc92b2166ea87cf3f8e3edca702d61d50a78f70 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Tue, 17 Dec 2013 17:46:43 +0100 Subject: [PATCH] Always quantize all polygons --- src/ol/render/canvas/canvasreplay.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ol/render/canvas/canvasreplay.js b/src/ol/render/canvas/canvasreplay.js index 58c62adf41..6ab1f12fcc 100644 --- a/src/ol/render/canvas/canvasreplay.js +++ b/src/ol/render/canvas/canvasreplay.js @@ -14,6 +14,7 @@ goog.require('ol.array'); goog.require('ol.color'); goog.require('ol.extent'); goog.require('ol.geom.flat'); +goog.require('ol.geom.simplify'); goog.require('ol.render.IRender'); goog.require('ol.render.IReplayGroup'); goog.require('ol.render.canvas'); @@ -984,6 +985,18 @@ ol.render.canvas.PolygonReplay.prototype.finish = function() { goog.asserts.assert(!goog.isNull(this.state_)); this.reverseHitDetectionInstructions_(); this.state_ = null; + // We want to preserve topology when drawing polygons. Polygons are + // simplified using quantization and point elimination. However, we might + // have received a mix of quantized and non-quantized geometries, so ensure + // that all are quantized by quantizing all coordinates in the batch. + var tolerance = this.tolerance; + if (tolerance !== 0) { + var coordinates = this.coordinates; + var i, ii; + for (i = 0, ii = coordinates.length; i < ii; ++i) { + coordinates[i] = ol.geom.simplify.snap(coordinates[i], tolerance); + } + } };