From 82fa4861e7cefd062aeccee3a1382b8c4844ab9d Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 4 Dec 2013 19:13:49 +0100 Subject: [PATCH] Allow ol.geom.LinearRings to have null coordinates and add setFlatCoordinates --- src/ol/geom/linearring.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/ol/geom/linearring.js b/src/ol/geom/linearring.js index db91862cf4..3fa3bcbbe7 100644 --- a/src/ol/geom/linearring.js +++ b/src/ol/geom/linearring.js @@ -50,8 +50,26 @@ ol.geom.LinearRing.prototype.getType = function() { */ ol.geom.LinearRing.prototype.setCoordinates = function(coordinates, opt_layout) { - this.setLayout(opt_layout, coordinates, 1); - ol.geom.flat.deflateCoordinates( - this.flatCoordinates, 0, coordinates, this.stride); + if (goog.isNull(coordinates)) { + this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null); + } else { + this.setLayout(opt_layout, coordinates, 1); + if (goog.isNull(this.flatCoordinates)) { + this.flatCoordinates = []; + } + this.flatCoordinates.length = ol.geom.flat.deflateCoordinates( + this.flatCoordinates, 0, coordinates, this.stride); + this.dispatchChangeEvent(); + } +}; + + +/** + * @param {ol.geom.GeometryLayout} layout Layout. + * @param {Array.} flatCoordinates Flat coordinates. + */ +ol.geom.LinearRing.prototype.setFlatCoordinates = + function(layout, flatCoordinates) { + this.setFlatCoordinatesInternal(layout, flatCoordinates); this.dispatchChangeEvent(); };