Add ol.geom.Polygon#getSimplifiedGeometryInternal

This commit is contained in:
Tom Payne
2013-12-06 15:01:43 +01:00
parent 956bff0fe2
commit e560192c0f
2 changed files with 47 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ goog.provide('ol.geom.Polygon');
goog.require('ol.geom.Geometry');
goog.require('ol.geom.LinearRing');
goog.require('ol.geom.flat');
goog.require('ol.geom.simplify');
@@ -104,6 +105,23 @@ ol.geom.Polygon.prototype.getLinearRings = function() {
};
/**
* @inheritDoc
*/
ol.geom.Polygon.prototype.getSimplifiedGeometryInternal =
function(squaredTolerance) {
var simplifiedFlatCoordinates = [];
var simplifiedEnds = [];
simplifiedFlatCoordinates.length = ol.geom.simplify.douglasPeuckers(
this.flatCoordinates, 0, this.ends_, this.stride, squaredTolerance,
simplifiedFlatCoordinates, 0, simplifiedEnds);
var simplifiedPolygon = new ol.geom.Polygon(null);
simplifiedPolygon.setFlatCoordinates(
ol.geom.GeometryLayout.XY, simplifiedFlatCoordinates, simplifiedEnds);
return simplifiedPolygon;
};
/**
* @inheritDoc
*/