Allow access to right-hand oriented polygon coordinates

This commit is contained in:
Tim Schaub
2015-03-25 16:50:30 -06:00
parent ce36947bdb
commit 7572f27cf9
2 changed files with 44 additions and 2 deletions

View File

@@ -151,12 +151,30 @@ ol.geom.Polygon.prototype.getArea = function() {
/**
* Get the coordinate array for this geometry. This array has the structure
* of a GeoJSON coordinate array for polygons.
*
* @param {boolean=} opt_right Orient coordinates according to the right-hand
* rule (counter-clockwise for exterior and clockwise for interior rings).
* If `false`, coordinates will be oriented according to the left-hand rule
* (clockwise for exterior and counter-clockwise for interior rings).
* By default, coordinate orientation will depend on how the geometry was
* constructed.
* @return {Array.<Array.<ol.Coordinate>>} Coordinates.
* @api stable
*/
ol.geom.Polygon.prototype.getCoordinates = function() {
ol.geom.Polygon.prototype.getCoordinates = function(opt_right) {
var flatCoordinates;
if (goog.isDef(opt_right)) {
flatCoordinates = this.getOrientedFlatCoordinates().slice();
ol.geom.flat.orient.orientLinearRings(
flatCoordinates, 0, this.ends_, this.stride, opt_right);
} else {
flatCoordinates = this.flatCoordinates;
}
return ol.geom.flat.inflate.coordinatess(
this.flatCoordinates, 0, this.ends_, this.stride);
flatCoordinates, 0, this.ends_, this.stride);
};