Add ol.geom.LineString#getFlatMidpoint
This commit is contained in:
@@ -20,6 +20,18 @@ ol.geom.LineString = function(coordinates, opt_layout) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Coordinate}
|
||||
*/
|
||||
this.flatMidpoint_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.flatMidpointRevision_ = -1;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
@@ -88,6 +100,20 @@ ol.geom.LineString.prototype.getLength = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {Array.<number>} Flat midpoint.
|
||||
*/
|
||||
ol.geom.LineString.prototype.getFlatMidpoint = function() {
|
||||
if (this.flatMidpointRevision_ != this.getRevision()) {
|
||||
this.flatMidpoint_ = ol.geom.flat.lineStringInterpolate(
|
||||
this.flatCoordinates, 0, this.flatCoordinates.length, this.stride,
|
||||
0.5, this.flatMidpoint_);
|
||||
this.flatMidpointRevision_ = this.getRevision();
|
||||
}
|
||||
return this.flatMidpoint_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user