Transformed

This commit is contained in:
Tim Schaub
2017-12-11 16:29:33 -07:00
parent 1cdb6a66f0
commit 7f47883c48
737 changed files with 22216 additions and 21609 deletions

View File

@@ -1,7 +1,5 @@
goog.require('ol.coordinate');
goog.require('ol.geom.Circle');
import _ol_coordinate_ from '../../../src/ol/coordinate.js';
import _ol_geom_Circle_ from '../../../src/ol/geom/Circle.js';
describe('ol.coordinate', function() {
@@ -15,19 +13,19 @@ describe('ol.coordinate', function() {
});
it('returns a coordinate', function() {
var returnedCoordinate = ol.coordinate.add(coordinate, delta);
var returnedCoordinate = _ol_coordinate_.add(coordinate, delta);
expect(returnedCoordinate).to.be.an('array');
expect(returnedCoordinate).to.have.length(2);
});
it('adds the delta', function() {
var returnedCoordinate = ol.coordinate.add(coordinate, delta);
var returnedCoordinate = _ol_coordinate_.add(coordinate, delta);
expect(returnedCoordinate[0]).to.eql(48.73);
expect(returnedCoordinate[1]).to.eql(10.1);
});
it('modifies in place', function() {
ol.coordinate.add(coordinate, delta);
_ol_coordinate_.add(coordinate, delta);
expect(coordinate[0]).to.eql(48.73);
expect(coordinate[1]).to.eql(10.1);
});
@@ -39,8 +37,8 @@ describe('ol.coordinate', function() {
var bonn2 = [50.73000, 7.10000];
it('compares correctly', function() {
var bonnEqualsBonn = ol.coordinate.equals(bonn1, bonn2);
var bonnEqualsCologne = ol.coordinate.equals(bonn1, cologne);
var bonnEqualsBonn = _ol_coordinate_.equals(bonn1, bonn2);
var bonnEqualsCologne = _ol_coordinate_.equals(bonn1, cologne);
expect(bonnEqualsBonn).to.be(true);
expect(bonnEqualsCologne).to.be(false);
});
@@ -53,12 +51,12 @@ describe('ol.coordinate', function() {
});
it('rounds the values', function() {
var string = ol.coordinate.format(coordinate, '{x} {y}', 0);
var string = _ol_coordinate_.format(coordinate, '{x} {y}', 0);
expect(string).to.eql('7 47');
});
it('handles the optional fractionDigits param', function() {
var string = ol.coordinate.format(coordinate, '{x} {y}', 3);
var string = _ol_coordinate_.format(coordinate, '{x} {y}', 3);
expect(string).to.eql('6.612 46.792');
});
});
@@ -72,7 +70,7 @@ describe('ol.coordinate', function() {
});
it('returns a CoordinateFormatType', function() {
created = ol.coordinate.createStringXY();
created = _ol_coordinate_.createStringXY();
expect(created).to.be.a('function');
formatted = created(coordinate);
@@ -81,7 +79,7 @@ describe('ol.coordinate', function() {
});
it('respects opt_fractionDigits', function() {
created = ol.coordinate.createStringXY(3);
created = _ol_coordinate_.createStringXY(3);
expect(created).to.be.a('function');
formatted = created(coordinate);
@@ -92,13 +90,13 @@ describe('ol.coordinate', function() {
describe('#closestOnCircle', function() {
var center = [5, 10];
var circle = new ol.geom.Circle(center, 10);
var circle = new _ol_geom_Circle_(center, 10);
it('can find the closest point on circle', function() {
expect(ol.coordinate.closestOnCircle([-20, 10], circle))
expect(_ol_coordinate_.closestOnCircle([-20, 10], circle))
.to.eql([-5, 10]);
});
it('can handle coordinate equal circle center', function() {
expect(ol.coordinate.closestOnCircle(center, circle))
expect(_ol_coordinate_.closestOnCircle(center, circle))
.to.eql([15, 10]);
});
});
@@ -108,27 +106,27 @@ describe('ol.coordinate', function() {
function() {
var point = [2, 5];
var segment = [[-5, 0], [10, 0]];
expect(ol.coordinate.closestOnSegment(point, segment))
expect(_ol_coordinate_.closestOnSegment(point, segment))
.to.eql([2, 0]);
});
it('can handle points where the foot of the perpendicular is not closest',
function() {
var point = [0, -6];
var segment = [[-5, 0], [0, -1]];
expect(ol.coordinate.closestOnSegment(point, segment))
expect(_ol_coordinate_.closestOnSegment(point, segment))
.to.eql([0, -1]);
});
});
describe('#format', function() {
it('can deal with undefined coordinate', function() {
expect(ol.coordinate.format()).to.be('');
expect(_ol_coordinate_.format()).to.be('');
});
it('formats a coordinate into a template (default precision is 0)',
function() {
var coord = [7.85, 47.983333];
var template = 'Coordinate is ({x}|{y}).';
var got = ol.coordinate.format(coord, template);
var got = _ol_coordinate_.format(coord, template);
var expected = 'Coordinate is (8|48).';
expect(got).to.be(expected);
});
@@ -136,7 +134,7 @@ describe('ol.coordinate', function() {
function() {
var coord = [7.85, 47.983333];
var template = 'Coordinate is ({x}|{y}).';
var got = ol.coordinate.format(coord, template, 2);
var got = _ol_coordinate_.format(coord, template, 2);
var expected = 'Coordinate is (7.85|47.98).';
expect(got).to.be(expected);
});
@@ -146,14 +144,14 @@ describe('ol.coordinate', function() {
it('can rotate point in place', function() {
var coord = [7.85, 47.983333];
var rotateRadians = Math.PI / 2; // 90 degrees
ol.coordinate.rotate(coord, rotateRadians);
_ol_coordinate_.rotate(coord, rotateRadians);
expect(coord[0].toFixed(6)).to.eql('-47.983333');
expect(coord[1].toFixed(6)).to.eql('7.850000');
});
it('returns the rotated point', function() {
var coord = [7.85, 47.983333];
var rotateRadians = Math.PI / 2; // 90 degrees
var rotated = ol.coordinate.rotate(coord, rotateRadians);
var rotated = _ol_coordinate_.rotate(coord, rotateRadians);
expect(rotated[0].toFixed(7)).to.eql('-47.9833330');
expect(rotated[1].toFixed(7)).to.eql('7.8500000');
});
@@ -163,14 +161,14 @@ describe('ol.coordinate', function() {
it('can scale point in place', function() {
var coord = [7.85, 47.983333];
var scale = 1.2;
ol.coordinate.scale(coord, scale);
_ol_coordinate_.scale(coord, scale);
expect(coord[0].toFixed(7)).to.eql('9.4200000');
expect(coord[1].toFixed(7)).to.eql('57.5799996');
});
it('returns the scaled point', function() {
var coord = [7.85, 47.983333];
var scale = 1.2;
var scaledCoord = ol.coordinate.scale(coord, scale);
var scaledCoord = _ol_coordinate_.scale(coord, scale);
expect(scaledCoord[0].toFixed(7)).to.eql('9.4200000');
expect(scaledCoord[1].toFixed(7)).to.eql('57.5799996');
});
@@ -180,14 +178,14 @@ describe('ol.coordinate', function() {
it('can subtract from point in place', function() {
var coord = [47, 11];
var delta = [1, -1];
ol.coordinate.sub(coord, delta);
_ol_coordinate_.sub(coord, delta);
expect(coord[0]).to.eql(46);
expect(coord[1]).to.eql(12);
});
it('can subtract from point in place', function() {
var coord = [47, 11];
var delta = [1, -1];
var subtracted = ol.coordinate.sub(coord, delta);
var subtracted = _ol_coordinate_.sub(coord, delta);
expect(subtracted[0]).to.eql(46);
expect(subtracted[1]).to.eql(12);
});
@@ -198,14 +196,14 @@ describe('ol.coordinate', function() {
function() {
var point = [2, 5];
var segment = [[-5, 0], [10, 0]];
expect(ol.coordinate.squaredDistanceToSegment(point, segment))
expect(_ol_coordinate_.squaredDistanceToSegment(point, segment))
.to.eql(25);
});
it('can handle points where the foot of the perpendicular is not closest',
function() {
var point = [0, -6];
var segment = [[-5, 0], [0, -1]];
expect(ol.coordinate.squaredDistanceToSegment(point, segment))
expect(_ol_coordinate_.squaredDistanceToSegment(point, segment))
.to.eql(25);
});
@@ -213,19 +211,19 @@ describe('ol.coordinate', function() {
describe('#toStringHDMS', function() {
it('returns the empty string on undefined input', function() {
var got = ol.coordinate.toStringHDMS();
var got = _ol_coordinate_.toStringHDMS();
var expected = '';
expect(got).to.be(expected);
});
it('formats with zero fractional digits as default', function() {
var coord = [7.85, 47.983333];
var got = ol.coordinate.toStringHDMS(coord);
var got = _ol_coordinate_.toStringHDMS(coord);
var expected = '47° 59 00″ N 7° 51 00″ E';
expect(got).to.be(expected);
});
it('formats with given fractional digits, if passed', function() {
var coord = [7.85, 47.983333];
var got = ol.coordinate.toStringHDMS(coord, 3);
var got = _ol_coordinate_.toStringHDMS(coord, 3);
var expected = '47° 58 59.999″ N 7° 51 00.000″ E';
expect(got).to.be(expected);
});
@@ -234,13 +232,13 @@ describe('ol.coordinate', function() {
describe('#toStringXY', function() {
it('formats with zero fractional digits as default', function() {
var coord = [7.85, 47.983333];
var got = ol.coordinate.toStringXY(coord);
var got = _ol_coordinate_.toStringXY(coord);
var expected = '8, 48';
expect(got).to.be(expected);
});
it('formats with given fractional digits, if passed', function() {
var coord = [7.85, 47.983333];
var got = ol.coordinate.toStringXY(coord, 2);
var got = _ol_coordinate_.toStringXY(coord, 2);
var expected = '7.85, 47.98';
expect(got).to.be(expected);
});