diff --git a/src/ol/geom/multipolygon.js b/src/ol/geom/multipolygon.js index eca4120f3c..186e5ac2c2 100644 --- a/src/ol/geom/multipolygon.js +++ b/src/ol/geom/multipolygon.js @@ -22,6 +22,18 @@ ol.geom.MultiPolygon = function(coordinates, opt_layout) { */ this.endss_ = []; + /** + * @private + * @type {number} + */ + this.interiorPointsRevision_ = -1; + + /** + * @private + * @type {Array.} + */ + this.interiorPoints_ = null; + this.setCoordinates(coordinates, opt_layout); }; @@ -58,10 +70,14 @@ ol.geom.MultiPolygon.prototype.getEndss = function() { * @return {Array.} Interior points. */ ol.geom.MultiPolygon.prototype.getInteriorPoints = function() { - var ys = ol.geom.flat.linearRingssMidYs( - this.flatCoordinates, 0, this.endss_, this.stride); - return ol.geom.flat.linearRingssGetInteriorPoints( - this.flatCoordinates, 0, this.endss_, this.stride, ys); + if (this.interiorPointsRevision_ != this.revision) { + var ys = ol.geom.flat.linearRingssMidYs( + this.flatCoordinates, 0, this.endss_, this.stride); + this.interiorPoints_ = ol.geom.flat.linearRingssGetInteriorPoints( + this.flatCoordinates, 0, this.endss_, this.stride, ys); + this.interiorPointsRevision_ = this.revision; + } + return this.interiorPoints_; };