From 9edf63fdb87705259300df5d6839932cc5152dfd Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 4 Mar 2013 20:21:08 +0100 Subject: [PATCH] Proper bounds --- src/ol/geom/linestring.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ol/geom/linestring.js b/src/ol/geom/linestring.js index 79017c7cdc..822af57277 100644 --- a/src/ol/geom/linestring.js +++ b/src/ol/geom/linestring.js @@ -99,18 +99,20 @@ ol.geom.LineString.prototype.getCount = function() { */ ol.geom.LineString.prototype.getBounds = function() { if (goog.isNull(this.bounds_)) { - var minX, minY = minX = Number.POSITIVE_INFINITY, - maxX, maxY = maxX = Number.NEGATIVE_INFINITY, - dimension = this.dimension, + var dimension = this.dimension, vertices = this.vertices, id = this.sharedId_, count = vertices.getCount(id), start = vertices.getStart(id), end = start + (count * dimension), coordinates = vertices.coordinates, + minX, maxX, + minY, maxY, x, y, i; - for (i = start; i < end; i += dimension) { + minX = maxX = coordinates[start]; + minY = maxY = coordinates[start + 1]; + for (i = start + dimension; i < end; i += dimension) { x = coordinates[i]; y = coordinates[i + 1]; if (x < minX) {