From 47c1f1908e7a57379b3b3cd9a76c394c1a5fdc89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 21 Aug 2014 10:46:56 +0200 Subject: [PATCH] Remove the ol.geom.RawPolygon type --- src/ol/geom/geometry.js | 10 +--------- src/ol/geom/polygon.js | 6 +++--- src/ol/interaction/drawinteraction.js | 26 +++++++++++++------------- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/ol/geom/geometry.js b/src/ol/geom/geometry.js index 9e33e2dd37..5293ec1e41 100644 --- a/src/ol/geom/geometry.js +++ b/src/ol/geom/geometry.js @@ -203,14 +203,6 @@ ol.geom.Geometry.prototype.transform = function(source, destination) { }; -/** - * Array representation of a polygon. - * @typedef {Array.>} - * @api stable - */ -ol.geom.RawPolygon; - - /** * Array representation of a multipoint. * @typedef {Array.} @@ -229,7 +221,7 @@ ol.geom.RawMultiLineString; /** * Array representation of a multipolygon. - * @typedef {Array.} + * @typedef {Array.>>} * @api stable */ ol.geom.RawMultiPolygon; diff --git a/src/ol/geom/polygon.js b/src/ol/geom/polygon.js index b0f386ce47..4c5b266539 100644 --- a/src/ol/geom/polygon.js +++ b/src/ol/geom/polygon.js @@ -25,7 +25,7 @@ goog.require('ol.geom.flat.simplify'); * * @constructor * @extends {ol.geom.SimpleGeometry} - * @param {ol.geom.RawPolygon} coordinates Coordinates. + * @param {Array.>} coordinates Coordinates. * @param {ol.geom.GeometryLayout=} opt_layout Layout. * @api stable */ @@ -150,7 +150,7 @@ ol.geom.Polygon.prototype.getArea = function() { /** - * @return {ol.geom.RawPolygon} Coordinates. + * @return {Array.>} Coordinates. * @api stable */ ol.geom.Polygon.prototype.getCoordinates = function() { @@ -279,7 +279,7 @@ ol.geom.Polygon.prototype.getType = function() { /** - * @param {ol.geom.RawPolygon} coordinates Coordinates. + * @param {Array.>} coordinates Coordinates. * @param {ol.geom.GeometryLayout=} opt_layout Layout. * @api stable */ diff --git a/src/ol/interaction/drawinteraction.js b/src/ol/interaction/drawinteraction.js index c99cf1be15..03b6f7e476 100644 --- a/src/ol/interaction/drawinteraction.js +++ b/src/ol/interaction/drawinteraction.js @@ -166,10 +166,10 @@ ol.interaction.Draw = function(options) { /** * Sketch polygon. Used when drawing polygon. - * @type {ol.geom.RawPolygon} + * @type {Array.>} * @private */ - this.sketchRawPolygon_ = null; + this.sketchPolygonCoords_ = null; /** * Squared tolerance for handling up events. If the squared distance @@ -331,8 +331,8 @@ ol.interaction.Draw.prototype.atFinish_ = function(event) { goog.asserts.assertInstanceof(geometry, ol.geom.Polygon); potentiallyDone = geometry.getCoordinates()[0].length > this.minPointsPerRing_; - potentiallyFinishCoordinates = [this.sketchRawPolygon_[0][0], - this.sketchRawPolygon_[0][this.sketchRawPolygon_[0].length - 2]]; + potentiallyFinishCoordinates = [this.sketchPolygonCoords_[0][0], + this.sketchPolygonCoords_[0][this.sketchPolygonCoords_[0].length - 2]]; } if (potentiallyDone) { var map = event.map; @@ -388,8 +388,8 @@ ol.interaction.Draw.prototype.startDrawing_ = function(event) { } else if (this.mode_ === ol.interaction.DrawMode.POLYGON) { this.sketchLine_ = new ol.Feature(new ol.geom.LineString([start.slice(), start.slice()])); - this.sketchRawPolygon_ = [[start.slice(), start.slice()]]; - geometry = new ol.geom.Polygon(this.sketchRawPolygon_); + this.sketchPolygonCoords_ = [[start.slice(), start.slice()]]; + geometry = new ol.geom.Polygon(this.sketchPolygonCoords_); } } goog.asserts.assert(goog.isDef(geometry)); @@ -425,7 +425,7 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) { coordinates = geometry.getCoordinates(); } else if (this.mode_ === ol.interaction.DrawMode.POLYGON) { goog.asserts.assertInstanceof(geometry, ol.geom.Polygon); - coordinates = this.sketchRawPolygon_[0]; + coordinates = this.sketchPolygonCoords_[0]; } if (this.atFinish_(event)) { // snap to finish @@ -445,7 +445,7 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) { goog.asserts.assertInstanceof(sketchLineGeom, ol.geom.LineString); sketchLineGeom.setCoordinates(coordinates); goog.asserts.assertInstanceof(geometry, ol.geom.Polygon); - geometry.setCoordinates(this.sketchRawPolygon_); + geometry.setCoordinates(this.sketchPolygonCoords_); } } this.updateSketchFeatures_(); @@ -468,9 +468,9 @@ ol.interaction.Draw.prototype.addToDrawing_ = function(event) { coordinates.push(coordinate.slice()); geometry.setCoordinates(coordinates); } else if (this.mode_ === ol.interaction.DrawMode.POLYGON) { - this.sketchRawPolygon_[0].push(coordinate.slice()); + this.sketchPolygonCoords_[0].push(coordinate.slice()); goog.asserts.assertInstanceof(geometry, ol.geom.Polygon); - geometry.setCoordinates(this.sketchRawPolygon_); + geometry.setCoordinates(this.sketchPolygonCoords_); } this.updateSketchFeatures_(); }; @@ -500,9 +500,9 @@ ol.interaction.Draw.prototype.finishDrawing_ = function(event) { // When we finish drawing a polygon on the last point, // the last coordinate is duplicated as for LineString // we force the replacement by the first point - this.sketchRawPolygon_[0].pop(); - this.sketchRawPolygon_[0].push(this.sketchRawPolygon_[0][0]); - geometry.setCoordinates(this.sketchRawPolygon_); + this.sketchPolygonCoords_[0].pop(); + this.sketchPolygonCoords_[0].push(this.sketchPolygonCoords_[0][0]); + geometry.setCoordinates(this.sketchPolygonCoords_); coordinates = geometry.getCoordinates(); }