ol/geom/flat/closest export

This commit is contained in:
raiyni
2018-02-13 08:44:09 -06:00
parent 4575569238
commit 9fc09db89c
7 changed files with 59 additions and 61 deletions

View File

@@ -1,4 +1,4 @@
import _ol_geom_flat_closest_ from '../../../../../src/ol/geom/flat/closest.js';
import {assignClosestPoint, maxSquaredDelta} from '../../../../../src/ol/geom/flat/closest.js';
describe('ol.geom.flat.closest', function() {
@@ -10,7 +10,7 @@ describe('ol.geom.flat.closest', function() {
describe('ol.geom.flat.closest.getMaxSquaredDelta', function() {
it('returns the expected value in simple cases', function() {
expect(_ol_geom_flat_closest_.getMaxSquaredDelta(
expect(maxSquaredDelta(
flatCoordinates, 0, flatCoordinates.length, 2, 0)).to.be(9);
});
@@ -19,23 +19,23 @@ describe('ol.geom.flat.closest', function() {
describe('ol.geom.flat.closest.getClosestPoint', function() {
it('returns the expected value', function() {
const maxDelta = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
const maxDelta = Math.sqrt(maxSquaredDelta(
flatCoordinates, 0, flatCoordinates.length, 2, 0));
expect(maxDelta).to.be(3);
const closestPoint = [NaN, NaN];
expect(_ol_geom_flat_closest_.getClosestPoint(
expect(assignClosestPoint(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 0, 0, closestPoint, Infinity)).to.be(0);
expect(closestPoint).to.eql([0, 0]);
expect(_ol_geom_flat_closest_.getClosestPoint(
expect(assignClosestPoint(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 4, 1, closestPoint, Infinity)).to.be(1);
expect(closestPoint).to.eql([4, 0]);
expect(_ol_geom_flat_closest_.getClosestPoint(
expect(assignClosestPoint(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 5, 2, closestPoint, Infinity)).to.be(4);
expect(closestPoint).to.eql([5, 0]);
expect(_ol_geom_flat_closest_.getClosestPoint(
expect(assignClosestPoint(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 10, 100, closestPoint, Infinity)).to.be(10000);
expect(closestPoint).to.eql([10, 0]);
@@ -78,7 +78,7 @@ describe('ol.geom.flat.closest', function() {
describe('ol.geom.closet.maSquaredDelta', function() {
it('returns the expected value', function() {
expect(_ol_geom_flat_closest_.getMaxSquaredDelta(
expect(maxSquaredDelta(
flatCoordinates, 0, flatCoordinates.length, 2, 0)).
to.roughlyEqual(1389.1058, 1e-9);
});
@@ -88,21 +88,21 @@ describe('ol.geom.flat.closest', function() {
describe('ol.geom.flat.closest.getClosestPoint', function() {
it('returns the expected value', function() {
const maxDelta = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
const maxDelta = Math.sqrt(maxSquaredDelta(
flatCoordinates, 0, flatCoordinates.length, 2, 0));
expect(maxDelta).to.roughlyEqual(Math.sqrt(1389.1058), 1e-9);
const closestPoint = [NaN, NaN];
expect(_ol_geom_flat_closest_.getClosestPoint(
expect(assignClosestPoint(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 0, 0, closestPoint, Infinity)).
to.roughlyEqual(110902.405, 1e-9);
expect(closestPoint).to.eql([292.41, 159.37]);
expect(_ol_geom_flat_closest_.getClosestPoint(
expect(assignClosestPoint(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 500, 500, closestPoint, Infinity)).
to.roughlyEqual(106407.905, 1e-9);
expect(closestPoint).to.eql([671.55, 222.55]);
expect(_ol_geom_flat_closest_.getClosestPoint(
expect(assignClosestPoint(
flatCoordinates, 0, flatCoordinates.length, 2,
maxDelta, false, 1000, 500, closestPoint, Infinity)).
to.roughlyEqual(18229.4425, 1e-9);
@@ -121,11 +121,11 @@ describe('ol.geom.flat.closest', function() {
describe('ol.geom.flat.closest.getClosestPoint', function() {
it('interpolates M coordinates', function() {
const maxDelta = Math.sqrt(_ol_geom_flat_closest_.getMaxSquaredDelta(
const maxDelta = Math.sqrt(maxSquaredDelta(
flatCoordinates, 0, flatCoordinates.length, stride, 0));
expect(maxDelta).to.roughlyEqual(Math.sqrt(8), 1e-9);
const closestPoint = [NaN, NaN];
expect(_ol_geom_flat_closest_.getClosestPoint(
expect(assignClosestPoint(
flatCoordinates, 0, flatCoordinates.length, stride,
maxDelta, false, 1, 1, closestPoint, Infinity)).
to.roughlyEqual(0, 1e-9);