Add ol.geom.Geometry#getSimplifiedGeometry
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
@exportSymbol ol.geom.Geometry
|
@exportSymbol ol.geom.Geometry
|
||||||
@exportProperty ol.geom.Geometry.prototype.getExtent
|
@exportProperty ol.geom.Geometry.prototype.getExtent
|
||||||
@exportProperty ol.geom.Geometry.prototype.getLayout
|
@exportProperty ol.geom.Geometry.prototype.getLayout
|
||||||
|
@exportProperty ol.geom.Geometry.prototype.getSimplifiedGeometry
|
||||||
@exportProperty ol.geom.Geometry.prototype.transform
|
@exportProperty ol.geom.Geometry.prototype.transform
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ goog.provide('ol.geom.Geometry');
|
|||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
goog.require('goog.functions');
|
goog.require('goog.functions');
|
||||||
|
goog.require('goog.object');
|
||||||
goog.require('ol.Observable');
|
goog.require('ol.Observable');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.geom.flat');
|
goog.require('ol.geom.flat');
|
||||||
@@ -80,6 +81,18 @@ ol.geom.Geometry = function() {
|
|||||||
*/
|
*/
|
||||||
this.extentRevision = -1;
|
this.extentRevision = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Object.<string, ol.geom.Geometry>}
|
||||||
|
*/
|
||||||
|
this.simplifiedGeometryCache_ = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.simplifiedGeometryRevision_ = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.geom.Geometry, ol.Observable);
|
goog.inherits(ol.geom.Geometry, ol.Observable);
|
||||||
|
|
||||||
@@ -187,6 +200,41 @@ ol.geom.Geometry.prototype.getRevision = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} squaredTolerance Squared tolerance.
|
||||||
|
* @return {ol.geom.Geometry} Simplified geometry.
|
||||||
|
*/
|
||||||
|
ol.geom.Geometry.prototype.getSimplifiedGeometry = function(squaredTolerance) {
|
||||||
|
if (this.simplifiedGeometryRevision_ != this.revision) {
|
||||||
|
goog.object.clear(this.simplifiedGeometryCache_);
|
||||||
|
this.simplifiedGeometryRevision_ = this.revision;
|
||||||
|
}
|
||||||
|
if (squaredTolerance < 0) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
var key = squaredTolerance.toString();
|
||||||
|
if (this.simplifiedGeometryCache_.hasOwnProperty(key)) {
|
||||||
|
return this.simplifiedGeometryCache_[key];
|
||||||
|
} else {
|
||||||
|
var simplifiedGeometry =
|
||||||
|
this.getSimplifiedGeometryInternal(squaredTolerance);
|
||||||
|
this.simplifiedGeometryCache_[key] = simplifiedGeometry;
|
||||||
|
return simplifiedGeometry;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} squaredTolerance Squared tolerance.
|
||||||
|
* @return {ol.geom.Geometry} Simplified geometry.
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
ol.geom.Geometry.prototype.getSimplifiedGeometryInternal =
|
||||||
|
function(squaredTolerance) {
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {number} Stride.
|
* @return {number} Stride.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user