Preserve extra dimensions in ol.geom.MultiPoint#closestPointXY

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

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;