Linearly interpolate extra dimensions in ol.geom.flat.closestPoint

This commit is contained in:
Tom Payne
2014-01-20 09:24:41 +01:00
parent 5bee477734
commit 6f0f42040c
3 changed files with 72 additions and 30 deletions

View File

@@ -113,6 +113,33 @@ describe('ol.geom.closest', function() {
});
describe('with multi-dimensional data', function() {
var flatCoordinates = [0, 0, 10, -10, 2, 2, 30, -20];
var stride = 4;
describe('ol.geom.closest.getClosestPoint', function() {
it('interpolates M coordinates', function() {
var maxDelta = Math.sqrt(ol.geom.closest.getMaxSquaredDelta(
flatCoordinates, 0, flatCoordinates.length, stride, 0));
expect(maxDelta).to.roughlyEqual(Math.sqrt(8), 1e-9);
var closestPoint = [NaN, NaN];
expect(ol.geom.closest.getClosestPoint(
flatCoordinates, 0, flatCoordinates.length, stride,
maxDelta, false, 1, 1, closestPoint, Infinity)).
to.roughlyEqual(0, 1e-9);
expect(closestPoint).to.have.length(stride);
expect(closestPoint[0]).to.be(1);
expect(closestPoint[1]).to.be(1);
expect(closestPoint[2]).to.be(20);
expect(closestPoint[3]).to.be(-15);
});
});
});
});