Fewer function calls during bounds calculation
This commit is contained in:
@@ -99,23 +99,30 @@ ol.geom.LineString.prototype.getCount = function() {
|
|||||||
*/
|
*/
|
||||||
ol.geom.LineString.prototype.getBounds = function() {
|
ol.geom.LineString.prototype.getBounds = function() {
|
||||||
if (goog.isNull(this.bounds_)) {
|
if (goog.isNull(this.bounds_)) {
|
||||||
var minX,
|
var minX, minY = minX = Number.POSITIVE_INFINITY,
|
||||||
minY = minX = Number.POSITIVE_INFINITY,
|
maxX, maxY = maxX = Number.NEGATIVE_INFINITY,
|
||||||
maxX,
|
dimension = this.dimension,
|
||||||
maxY = maxX = Number.NEGATIVE_INFINITY,
|
|
||||||
vertices = this.vertices,
|
vertices = this.vertices,
|
||||||
id = this.sharedId_,
|
id = this.sharedId_,
|
||||||
count = vertices.getCount(id),
|
count = vertices.getCount(id),
|
||||||
dimension = this.dimension,
|
start = vertices.getStart(id),
|
||||||
|
end = start + (count * dimension),
|
||||||
|
coordinates = vertices.coordinates,
|
||||||
x, y, i;
|
x, y, i;
|
||||||
|
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = start; i < end; i += dimension) {
|
||||||
x = vertices.get(id, i, 0);
|
x = coordinates[i];
|
||||||
y = vertices.get(id, i, 1);
|
y = coordinates[i + 1];
|
||||||
minX = Math.min(minX, x);
|
if (x < minX) {
|
||||||
minY = Math.min(minY, y);
|
minX = x;
|
||||||
maxX = Math.max(maxX, x);
|
} else if (x > maxX) {
|
||||||
maxY = Math.max(maxY, y);
|
maxX = x;
|
||||||
|
}
|
||||||
|
if (y < minY) {
|
||||||
|
minY = y;
|
||||||
|
} else if (y > maxY) {
|
||||||
|
maxY = y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.bounds_ = new ol.Extent(minX, minY, maxX, maxY);
|
this.bounds_ = new ol.Extent(minX, minY, maxX, maxY);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user