Preserve extra dimensions in ol.geom.MultiPoint#closestPointXY

This commit is contained in:
Tom Payne committed 2014-01-20 09:39:09 +01:00
1 parent 2da724572a
commit 52a0263310
2 files changed
+14 -3

No files matched your search

+5 -3
View File
@@ -42,14 +42,16 @@ ol.geom.MultiPoint.prototype.closestPointXY =
}
var flatCoordinates = this.flatCoordinates;
var stride = this.stride;
var i, ii;
var i, ii, j;
for (i = 0, ii = flatCoordinates.length; i < ii; i += stride) {
var squaredDistance = ol.geom.flat.squaredDistance(
x, y, flatCoordinates[i], flatCoordinates[i + 1]);
if (squaredDistance < minSquaredDistance) {
minSquaredDistance = squaredDistance;
closestPoint[0] = flatCoordinates[i];
closestPoint[1] = flatCoordinates[i + 1];
for (j = 0; j < stride; ++j) {
closestPoint[j] = flatCoordinates[i + j];
}
closestPoint.length = stride;
}
}
return minSquaredDistance;