1 | import LngLat from './lng_lat';
|
2 | import MercatorCoordinate, {mercatorScale} from './mercator_coordinate';
|
3 |
|
4 | describe('LngLat', () => {
|
5 | test('#constructor', () => {
|
6 | expect(new MercatorCoordinate(0, 0) instanceof MercatorCoordinate).toBeTruthy();
|
7 | expect(new MercatorCoordinate(0, 0, 0) instanceof MercatorCoordinate).toBeTruthy();
|
8 | });
|
9 |
|
10 | test('#fromLngLat', () => {
|
11 | const nullIsland = new LngLat(0, 0);
|
12 | expect(MercatorCoordinate.fromLngLat(nullIsland)).toEqual({x: 0.5, y: 0.5, z: 0});
|
13 | });
|
14 |
|
15 | test('#toLngLat', () => {
|
16 | const dc = new LngLat(-77, 39);
|
17 | expect(MercatorCoordinate.fromLngLat(dc, 500).toLngLat()).toEqual({lng: -77, lat: 39});
|
18 | });
|
19 |
|
20 | test('#toAltitude', () => {
|
21 | const dc = new LngLat(-77, 39);
|
22 | expect(MercatorCoordinate.fromLngLat(dc, 500).toAltitude()).toBe(500);
|
23 | });
|
24 |
|
25 | test('#mercatorScale', () => {
|
26 | expect(mercatorScale(0)).toBe(1);
|
27 | expect(mercatorScale(45)).toBe(1.414213562373095);
|
28 | });
|
29 |
|
30 | test('#meterInMercatorCoordinateUnits', () => {
|
31 | const nullIsland = new LngLat(0, 0);
|
32 | expect(MercatorCoordinate.fromLngLat(nullIsland).meterInMercatorCoordinateUnits()).toBe(2.4981121214570498e-8);
|
33 | });
|
34 | });
|