@basemaps/shared 6.9.1 → 6.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/build/__test__/api.path.test.js +57 -60
- package/build/__test__/api.test.js +29 -32
- package/build/__test__/env.test.js +9 -12
- package/build/__test__/util.test.js +36 -39
- package/build/__test__/vdom.parse.test.js +18 -21
- package/build/__test__/vdom.test.js +29 -32
- package/build/api.js +6 -10
- package/build/api.path.d.ts.map +1 -1
- package/build/api.path.js +15 -23
- package/build/aws/aws.dynamo.table.d.ts.map +1 -1
- package/build/aws/aws.dynamo.table.js +1 -2
- package/build/cli/__test__/git.tag.test.js +7 -10
- package/build/cli/api.key.js +4 -9
- package/build/cli/git.tag.js +4 -8
- package/build/composite.error.d.ts +1 -7
- package/build/composite.error.d.ts.map +1 -1
- package/build/composite.error.js +1 -13
- package/build/const.d.ts.map +1 -1
- package/build/const.js +3 -6
- package/build/file/__test__/file.local.test.js +33 -22
- package/build/file/__test__/file.operator.test.helper.d.ts.map +1 -1
- package/build/file/__test__/file.operator.test.helper.js +17 -21
- package/build/file/file.config.d.ts.map +1 -1
- package/build/file/file.config.js +2 -7
- package/build/file/index.d.ts +3 -3
- package/build/file/index.d.ts.map +1 -1
- package/build/file/index.js +19 -23
- package/build/index.d.ts +12 -14
- package/build/index.d.ts.map +1 -1
- package/build/index.js +18 -36
- package/build/log.d.ts +0 -3
- package/build/log.d.ts.map +1 -1
- package/build/log.js +6 -16
- package/build/logger.fatal.error.d.ts.map +1 -1
- package/build/logger.fatal.error.js +1 -5
- package/build/proj/__test__/projection.test.js +30 -33
- package/build/proj/__test__/projection.tile.matrix.set.test.js +115 -118
- package/build/proj/__test__/test.util.d.ts.map +1 -1
- package/build/proj/__test__/test.util.js +10 -17
- package/build/proj/citm2000.js +1 -4
- package/build/proj/nztm2000.js +1 -4
- package/build/proj/projection.d.ts +33 -33
- package/build/proj/projection.d.ts.map +1 -1
- package/build/proj/projection.js +47 -52
- package/build/proj/tile.set.name.d.ts.map +1 -1
- package/build/proj/tile.set.name.js +3 -7
- package/build/util.d.ts.map +1 -1
- package/build/util.js +5 -13
- package/build/vdom.d.ts.map +1 -1
- package/build/vdom.js +4 -11
- package/build/vdom.parse.d.ts +1 -1
- package/build/vdom.parse.d.ts.map +1 -1
- package/build/vdom.parse.js +5 -10
- package/package.json +12 -9
- package/build/__test__/aws.init.test.d.ts +0 -2
- package/build/__test__/aws.init.test.d.ts.map +0 -1
- package/build/__test__/aws.init.test.js +0 -9
- package/build/aws/api.key.table.d.ts +0 -29
- package/build/aws/api.key.table.d.ts.map +0 -1
- package/build/aws/api.key.table.js +0 -38
- package/build/aws/credentials.d.ts +0 -21
- package/build/aws/credentials.d.ts.map +0 -1
- package/build/aws/credentials.js +0 -42
- package/build/aws/index.d.ts +0 -16
- package/build/aws/index.d.ts.map +0 -1
- package/build/aws/index.js +0 -38
- package/build/aws/object.cache.d.ts +0 -6
- package/build/aws/object.cache.d.ts.map +0 -1
- package/build/aws/object.cache.js +0 -17
package/build/log.js
CHANGED
|
@@ -1,33 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.LogConfig = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const pino_1 = tslib_1.__importDefault(require("pino"));
|
|
1
|
+
import pino from 'pino';
|
|
2
|
+
import { PrettyTransform } from 'pretty-json-log';
|
|
6
3
|
let currentLog;
|
|
4
|
+
const defaultOpts = { level: 'debug' };
|
|
7
5
|
/**
|
|
8
6
|
* Encapsulate the logger so that it can be swapped out
|
|
9
7
|
*/
|
|
10
|
-
|
|
8
|
+
export const LogConfig = {
|
|
11
9
|
/** Get the currently configured logger */
|
|
12
10
|
get() {
|
|
13
11
|
if (currentLog == null) {
|
|
14
|
-
currentLog =
|
|
12
|
+
currentLog = process.stdout.isTTY ? pino(defaultOpts, PrettyTransform.stream()) : pino(defaultOpts);
|
|
15
13
|
}
|
|
16
14
|
return currentLog;
|
|
17
15
|
},
|
|
18
16
|
set(log) {
|
|
19
17
|
currentLog = log;
|
|
20
18
|
},
|
|
21
|
-
/** Overwrite the logger with a new logger that outputs to the provided stream*/
|
|
22
|
-
setOutputStream(stream) {
|
|
23
|
-
let level = 'debug';
|
|
24
|
-
if (currentLog) {
|
|
25
|
-
level = currentLog.level;
|
|
26
|
-
}
|
|
27
|
-
currentLog = pino_1.default({ level }, stream);
|
|
28
|
-
},
|
|
29
19
|
/** Disable the logger */
|
|
30
20
|
disable() {
|
|
31
|
-
|
|
21
|
+
LogConfig.get().level = 'silent';
|
|
32
22
|
},
|
|
33
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.fatal.error.d.ts","sourceRoot":"","sources":["../src/logger.fatal.error.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"logger.fatal.error.d.ts","sourceRoot":"","sources":["../src/logger.fatal.error.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBACjB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM;CAItD"}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LoggerFatalError = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Utility error to throw expecting that Logger will fatal log its contents
|
|
6
3
|
*/
|
|
7
|
-
class LoggerFatalError extends Error {
|
|
4
|
+
export class LoggerFatalError extends Error {
|
|
8
5
|
constructor(obj, msg) {
|
|
9
6
|
super(msg);
|
|
10
7
|
this.obj = obj;
|
|
11
8
|
}
|
|
12
9
|
}
|
|
13
|
-
exports.LoggerFatalError = LoggerFatalError;
|
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const googleProj = projection_1.Projection.get(geo_1.EpsgCode.Google);
|
|
12
|
-
const nztmProj = projection_1.Projection.get(geo_1.EpsgCode.Nztm2000);
|
|
13
|
-
ospec_1.default('should convert to 2193', () => {
|
|
1
|
+
import { EpsgCode } from '@basemaps/geo';
|
|
2
|
+
import { round } from '@basemaps/test/build/rounding.js';
|
|
3
|
+
import { bboxToPolygon } from '@linzjs/geojson';
|
|
4
|
+
import o from 'ospec';
|
|
5
|
+
import { Projection } from '../projection.js';
|
|
6
|
+
import { qkToNamedBounds } from './test.util.js';
|
|
7
|
+
o.spec('Projection', () => {
|
|
8
|
+
const googleProj = Projection.get(EpsgCode.Google);
|
|
9
|
+
const nztmProj = Projection.get(EpsgCode.Nztm2000);
|
|
10
|
+
o('should convert to 2193', () => {
|
|
14
11
|
if (nztmProj == null) {
|
|
15
12
|
throw new Error('Failed to init proj:2193');
|
|
16
13
|
}
|
|
17
14
|
const output = nztmProj.toWgs84([1180000, 4758000]);
|
|
18
|
-
|
|
15
|
+
o(round(output, 6)).deepEquals([167.454458, -47.197075]);
|
|
19
16
|
const reverse = nztmProj.fromWgs84(output);
|
|
20
|
-
|
|
17
|
+
o(round(reverse, 2)).deepEquals([1180000, 4758000]);
|
|
21
18
|
});
|
|
22
|
-
|
|
23
|
-
const geojson = googleProj.toGeoJson(
|
|
19
|
+
o('toGeoJson', () => {
|
|
20
|
+
const geojson = googleProj.toGeoJson(qkToNamedBounds(['31', '33']));
|
|
24
21
|
const { features } = geojson;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
o(features.length).equals(2);
|
|
23
|
+
o(features[0].properties).deepEquals({ name: '2-3-2' });
|
|
24
|
+
o(features[1].properties).deepEquals({ name: '2-3-3' });
|
|
28
25
|
const { geometry } = features[0];
|
|
29
26
|
const coords = geometry.type === 'Polygon' ? geometry.coordinates : null;
|
|
30
|
-
|
|
27
|
+
o(round(coords[0], 8)).deepEquals([
|
|
31
28
|
[90, -66.51326044],
|
|
32
29
|
[90, 0],
|
|
33
30
|
[180, 0],
|
|
@@ -35,15 +32,15 @@ ospec_1.default.spec('Projection', () => {
|
|
|
35
32
|
[90, -66.51326044],
|
|
36
33
|
]);
|
|
37
34
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const ans =
|
|
35
|
+
o.spec('boundsToGeoJsonFeature', () => {
|
|
36
|
+
o('simple', () => {
|
|
37
|
+
const ans = round(googleProj.boundsToGeoJsonFeature({
|
|
41
38
|
x: -19929885.00696367,
|
|
42
39
|
y: 19871181.369240656,
|
|
43
40
|
width: 48921.969810251147,
|
|
44
41
|
height: 4891.969810251147,
|
|
45
42
|
}, { name: '13-22-33' }));
|
|
46
|
-
|
|
43
|
+
o(ans).deepEquals({
|
|
47
44
|
type: 'Feature',
|
|
48
45
|
geometry: {
|
|
49
46
|
type: 'Polygon',
|
|
@@ -61,9 +58,9 @@ ospec_1.default.spec('Projection', () => {
|
|
|
61
58
|
bbox: [-179.03320312, 84.92054529, -178.59372959, 84.92443459],
|
|
62
59
|
});
|
|
63
60
|
});
|
|
64
|
-
|
|
65
|
-
const ans =
|
|
66
|
-
|
|
61
|
+
o('crosses antimeridian', () => {
|
|
62
|
+
const ans = round(nztmProj.boundsToGeoJsonFeature({ x: 1293760, y: 5412480, width: 1246880, height: 1146880 }, { name: '1-2-1' }), 4);
|
|
63
|
+
o(ans).deepEquals({
|
|
67
64
|
type: 'Feature',
|
|
68
65
|
geometry: {
|
|
69
66
|
type: 'MultiPolygon',
|
|
@@ -93,11 +90,11 @@ ospec_1.default.spec('Projection', () => {
|
|
|
93
90
|
});
|
|
94
91
|
});
|
|
95
92
|
});
|
|
96
|
-
|
|
97
|
-
const poly = [
|
|
98
|
-
|
|
99
|
-
const ans =
|
|
100
|
-
|
|
93
|
+
o('projectMultipolygon', () => {
|
|
94
|
+
const poly = [bboxToPolygon([18494091.86765497, -6051366.655280836, 19986142.659781612, -4016307.214216303])];
|
|
95
|
+
o(googleProj.projectMultipolygon(poly, googleProj)).equals(poly);
|
|
96
|
+
const ans = round(googleProj.projectMultipolygon(poly, nztmProj), 4);
|
|
97
|
+
o(round(ans, 4)).deepEquals([
|
|
101
98
|
[
|
|
102
99
|
[
|
|
103
100
|
[1084733.8967, 4698018.9435],
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const rounding_1 = require("@basemaps/test/build/rounding");
|
|
7
|
-
const ospec_1 = tslib_1.__importDefault(require("ospec"));
|
|
8
|
-
const projection_1 = require("../projection");
|
|
1
|
+
import { Bounds, GoogleTms, Nztm2000QuadTms, Nztm2000Tms, QuadKey } from '@basemaps/geo';
|
|
2
|
+
import { Approx } from '@basemaps/test';
|
|
3
|
+
import { round } from '@basemaps/test/build/rounding.js';
|
|
4
|
+
import o from 'ospec';
|
|
5
|
+
import { Projection } from '../projection.js';
|
|
9
6
|
const TileSize = 256;
|
|
10
7
|
/**
|
|
11
8
|
* Get the raster bounds for a WebMercator zoom level
|
|
@@ -14,130 +11,130 @@ const TileSize = 256;
|
|
|
14
11
|
* @param zoom Web mercator zoom level
|
|
15
12
|
*/
|
|
16
13
|
function getPixelsBoundsFromMeters(extent, zoom) {
|
|
17
|
-
const upperLeftMeters =
|
|
18
|
-
const lowerRightMeters =
|
|
19
|
-
return
|
|
14
|
+
const upperLeftMeters = GoogleTms.sourceToPixels(extent[0], extent[3], zoom);
|
|
15
|
+
const lowerRightMeters = GoogleTms.sourceToPixels(extent[2], extent[1], zoom);
|
|
16
|
+
return Bounds.fromUpperLeftLowerRight(upperLeftMeters, lowerRightMeters);
|
|
20
17
|
}
|
|
21
18
|
/** Convert a XYZ tile into a screen bounding box */
|
|
22
19
|
function getPixelsFromTile(x, y) {
|
|
23
|
-
return new
|
|
20
|
+
return new Bounds(x * TileSize, y * TileSize, TileSize, TileSize);
|
|
24
21
|
}
|
|
25
22
|
function isValidLatLong(x) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
o(x.lat <= 90).equals(true)(`lat: ${x.lat} <= 90`);
|
|
24
|
+
o(x.lat >= -90).equals(true)(`lat: ${x.lat} >= -90`);
|
|
25
|
+
o(x.lon <= 180).equals(true)(`lon: ${x.lon} <= 180`);
|
|
26
|
+
o(x.lon >= -180).equals(true)(`lon: ${x.lon} >= -180`);
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
o.spec('ProjectionTileMatrixSet', () => {
|
|
29
|
+
o('getTiffResZoom', () => {
|
|
30
|
+
o(Projection.getTiffResZoom(GoogleTms, 10)).equals(14);
|
|
31
|
+
o(Projection.getTiffResZoom(GoogleTms, 10, 2)).equals(13);
|
|
32
|
+
o(Projection.getTiffResZoom(GoogleTms, 0.075)).equals(21);
|
|
33
|
+
o(Projection.getTiffResZoom(Nztm2000Tms, 10)).equals(10);
|
|
34
|
+
o(Projection.getTiffResZoom(Nztm2000Tms, 10, 2)).equals(9);
|
|
35
|
+
o(Projection.getTiffResZoom(Nztm2000Tms, 0.075)).equals(16);
|
|
39
36
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
o('getTileSize', async () => {
|
|
38
|
+
o(Projection.getImagePixelWidth(GoogleTms, { x: 0, y: 0, z: 5 }, 10)).equals(16384);
|
|
39
|
+
o(Projection.getImagePixelWidth(GoogleTms, { x: 0, y: 0, z: 13 }, 20)).equals(65536);
|
|
40
|
+
o(Projection.getImagePixelWidth(Nztm2000Tms, { x: 0, y: 0, z: 5 }, 10)).equals(20480);
|
|
41
|
+
o(Projection.getImagePixelWidth(Nztm2000Tms, { x: 0, y: 0, z: 13 }, 16)).equals(5120);
|
|
45
42
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
43
|
+
o('findAlignmentLevels', () => {
|
|
44
|
+
o(Projection.findAlignmentLevels(GoogleTms, { x: 2, y: 0, z: 5 }, 0.075)).equals(15);
|
|
45
|
+
o(Projection.findAlignmentLevels(GoogleTms, { x: 2, y: 0, z: 5 }, 0.5)).equals(13);
|
|
46
|
+
o(Projection.findAlignmentLevels(GoogleTms, { x: 2, y: 0, z: 3 }, 1)).equals(14);
|
|
47
|
+
o(Projection.findAlignmentLevels(GoogleTms, { x: 2, y: 0, z: 8 }, 10)).equals(5);
|
|
48
|
+
o(Projection.findAlignmentLevels(GoogleTms, { x: 2, y: 0, z: 14 }, 10)).equals(0);
|
|
49
|
+
o(Projection.findAlignmentLevels(Nztm2000Tms, { x: 2, y: 0, z: 1 }, 0.075)).equals(14);
|
|
50
|
+
o(Projection.findAlignmentLevels(Nztm2000Tms, { x: 2, y: 0, z: 5 }, 0.5)).equals(8);
|
|
51
|
+
o(Projection.findAlignmentLevels(Nztm2000Tms, { x: 2, y: 0, z: 3 }, 7)).equals(6);
|
|
52
|
+
o(Projection.findAlignmentLevels(Nztm2000Tms, { x: 2, y: 0, z: 8 }, 14)).equals(0);
|
|
56
53
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const center =
|
|
54
|
+
o.spec('tileCenterToLatLon', () => {
|
|
55
|
+
o('should create centers for web mercator', () => {
|
|
56
|
+
const center = Projection.tileCenterToLatLon(GoogleTms, QuadKey.toTile('3120123'));
|
|
60
57
|
isValidLatLong(center);
|
|
61
|
-
|
|
58
|
+
o(round(center, 8)).deepEquals({
|
|
62
59
|
lat: -47.98992167,
|
|
63
60
|
lon: 105.46875,
|
|
64
61
|
});
|
|
65
62
|
});
|
|
66
|
-
|
|
67
|
-
const center =
|
|
63
|
+
o('should create centers for NZTM', () => {
|
|
64
|
+
const center = Projection.tileCenterToLatLon(Nztm2000Tms, { x: 2295, y: 5119, z: 10 });
|
|
68
65
|
isValidLatLong(center);
|
|
69
|
-
const centerB =
|
|
66
|
+
const centerB = Projection.tileCenterToLatLon(Nztm2000Tms, { x: 20, y: 20, z: 10 });
|
|
70
67
|
isValidLatLong(centerB);
|
|
71
68
|
});
|
|
72
|
-
|
|
73
|
-
const center =
|
|
69
|
+
o('should create centers for NZTMQuad', () => {
|
|
70
|
+
const center = Projection.tileCenterToLatLon(Nztm2000QuadTms, { x: 200, y: 500, z: 10 });
|
|
74
71
|
isValidLatLong(center);
|
|
75
|
-
|
|
76
|
-
const centerB =
|
|
72
|
+
o(round(center, 8)).deepEquals({ lat: -35.79628765, lon: 141.39377624 });
|
|
73
|
+
const centerB = Projection.tileCenterToLatLon(Nztm2000QuadTms, { x: 1000, y: 1000, z: 10 });
|
|
77
74
|
isValidLatLong(centerB);
|
|
78
75
|
});
|
|
79
76
|
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
77
|
+
o.spec('wrapLatLon', () => {
|
|
78
|
+
o('should wrap longitude', () => {
|
|
79
|
+
o(Projection.wrapLatLon(0, 1)).deepEquals({ lat: 0, lon: 1 });
|
|
80
|
+
o(Projection.wrapLatLon(0, 181)).deepEquals({ lat: 0, lon: -179 });
|
|
81
|
+
o(Projection.wrapLatLon(0, 271)).deepEquals({ lat: 0, lon: -89 });
|
|
82
|
+
o(Projection.wrapLatLon(0, 361)).deepEquals({ lat: 0, lon: 1 });
|
|
83
|
+
o(Projection.wrapLatLon(0, 631)).deepEquals({ lat: 0, lon: -89 });
|
|
84
|
+
o(Projection.wrapLatLon(0, 721)).deepEquals({ lat: 0, lon: 1 });
|
|
85
|
+
o(Projection.wrapLatLon(0, -1)).deepEquals({ lat: 0, lon: -1 });
|
|
86
|
+
o(Projection.wrapLatLon(0, -181)).deepEquals({ lat: 0, lon: 179 });
|
|
87
|
+
o(Projection.wrapLatLon(0, -271)).deepEquals({ lat: 0, lon: 89 });
|
|
88
|
+
o(Projection.wrapLatLon(0, -361)).deepEquals({ lat: 0, lon: -1 });
|
|
89
|
+
o(Projection.wrapLatLon(0, -631)).deepEquals({ lat: 0, lon: 89 });
|
|
90
|
+
o(Projection.wrapLatLon(0, -721)).deepEquals({ lat: 0, lon: -1 });
|
|
94
91
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
92
|
+
o('should wrap latitude', () => {
|
|
93
|
+
o(Projection.wrapLatLon(1, 0)).deepEquals({ lat: 1, lon: 0 });
|
|
94
|
+
o(Projection.wrapLatLon(91, 0)).deepEquals({ lat: 89, lon: 180 });
|
|
95
|
+
o(Projection.wrapLatLon(181, 0)).deepEquals({ lat: -1, lon: 180 });
|
|
96
|
+
o(Projection.wrapLatLon(271, 0)).deepEquals({ lat: -89, lon: 0 });
|
|
97
|
+
o(Projection.wrapLatLon(361, 0)).deepEquals({ lat: 1, lon: 0 });
|
|
98
|
+
o(Projection.wrapLatLon(631, 0)).deepEquals({ lat: -89, lon: 0 });
|
|
99
|
+
o(Projection.wrapLatLon(721, 0)).deepEquals({ lat: 1, lon: 0 });
|
|
100
|
+
o(Projection.wrapLatLon(-1, 0)).deepEquals({ lat: -1, lon: 0 });
|
|
101
|
+
o(Projection.wrapLatLon(-91, 0)).deepEquals({ lat: -89, lon: 180 });
|
|
102
|
+
o(Projection.wrapLatLon(-181, 0)).deepEquals({ lat: 1, lon: 180 });
|
|
103
|
+
o(Projection.wrapLatLon(-271, 0)).deepEquals({ lat: 89, lon: 0 });
|
|
104
|
+
o(Projection.wrapLatLon(-361, 0)).deepEquals({ lat: -1, lon: 0 });
|
|
105
|
+
o(Projection.wrapLatLon(-631, 0)).deepEquals({ lat: 89, lon: 0 });
|
|
106
|
+
o(Projection.wrapLatLon(-721, 0)).deepEquals({ lat: -1, lon: 0 });
|
|
110
107
|
});
|
|
111
108
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const pt =
|
|
115
|
-
|
|
109
|
+
o.spec('tileToWgs84Bbox', () => {
|
|
110
|
+
o('should handle antimeridian', () => {
|
|
111
|
+
const pt = Projection.tileToWgs84Bbox(Nztm2000Tms, { x: 2, y: 1, z: 1 });
|
|
112
|
+
o(round(pt)).deepEquals([170.05982382, -20.71836222, -179.34441046, -10.28396555]);
|
|
116
113
|
});
|
|
117
|
-
|
|
118
|
-
const pt =
|
|
119
|
-
|
|
114
|
+
o('should convert base tiles', () => {
|
|
115
|
+
const pt = Projection.tileToWgs84Bbox(GoogleTms, { x: 0, y: 0, z: 0 });
|
|
116
|
+
o(round(pt)).deepEquals([-180, -85.05112878, 180, 85.05112878]);
|
|
120
117
|
});
|
|
121
118
|
});
|
|
122
|
-
|
|
119
|
+
o.spec('TilingBounds', () => {
|
|
123
120
|
// Approximate bounding box of new zealand
|
|
124
121
|
const tifBoundingBox = [18494091.86765497, -6051366.655280836, 19986142.659781612, -4016307.214216303];
|
|
125
|
-
const expectedBaseSize =
|
|
126
|
-
|
|
122
|
+
const expectedBaseSize = Bounds.fromJson({ width: 9.53125, height: 13, y: 153.65625, x: 246.14062500000006 });
|
|
123
|
+
o('should tile 0,0,0', () => {
|
|
127
124
|
const bounds = getPixelsBoundsFromMeters(tifBoundingBox, 0);
|
|
128
|
-
|
|
125
|
+
Approx.bounds(bounds, expectedBaseSize);
|
|
129
126
|
const screenBounds = getPixelsFromTile(0, 0);
|
|
130
127
|
const intersection = bounds.intersection(screenBounds);
|
|
131
|
-
|
|
128
|
+
Approx.bounds(intersection, expectedBaseSize);
|
|
132
129
|
});
|
|
133
|
-
|
|
130
|
+
o('should tile 1,1,1', () => {
|
|
134
131
|
const [x, y, z] = [1, 1, 1];
|
|
135
132
|
const bounds = getPixelsBoundsFromMeters(tifBoundingBox, z);
|
|
136
133
|
const expectedBaseSizeScaled = expectedBaseSize.scale(2, 2);
|
|
137
|
-
|
|
134
|
+
Approx.bounds(bounds, expectedBaseSizeScaled);
|
|
138
135
|
const screenBounds = getPixelsFromTile(x, y);
|
|
139
136
|
const intersection = bounds.intersection(screenBounds);
|
|
140
|
-
|
|
137
|
+
Approx.bounds(intersection, expectedBaseSizeScaled);
|
|
141
138
|
});
|
|
142
139
|
/**
|
|
143
140
|
* XYZ tiles 15,9,4 & 15,10,4 provide a top/bottom tiles for this bounding box
|
|
@@ -149,15 +146,15 @@ ospec_1.default.spec('ProjectionTileMatrixSet', () => {
|
|
|
149
146
|
* | XXX | 10
|
|
150
147
|
* |-------|
|
|
151
148
|
*/
|
|
152
|
-
|
|
149
|
+
o('should tile [15, 9, 4] & [15, 10, 4]', () => {
|
|
153
150
|
const [x, z] = [15, 4];
|
|
154
151
|
const bounds = getPixelsBoundsFromMeters(tifBoundingBox, z);
|
|
155
152
|
const expectedBaseSizeScaled = expectedBaseSize.scale(2 ** z, 2 ** z);
|
|
156
|
-
|
|
153
|
+
Approx.bounds(bounds, expectedBaseSizeScaled);
|
|
157
154
|
const screenBounds9 = getPixelsFromTile(x, 9);
|
|
158
155
|
const screenBounds10 = getPixelsFromTile(x, 10);
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
o(screenBounds9.toJson()).deepEquals({ width: 256, height: 256, y: 2304, x: 3840 });
|
|
157
|
+
o(screenBounds10.toJson()).deepEquals({ width: 256, height: 256, y: 2560, x: 3840 });
|
|
161
158
|
const intersection9 = bounds.intersection(screenBounds9);
|
|
162
159
|
const intersection10 = bounds.intersection(screenBounds10);
|
|
163
160
|
if (intersection9 == null || intersection10 == null) {
|
|
@@ -165,12 +162,12 @@ ospec_1.default.spec('ProjectionTileMatrixSet', () => {
|
|
|
165
162
|
}
|
|
166
163
|
// the image is split in two so the intersection should combine into the total height of the image
|
|
167
164
|
const totalIntersectionHeight = intersection9.height + intersection10.height;
|
|
168
|
-
|
|
165
|
+
o(totalIntersectionHeight).equals(bounds.height);
|
|
169
166
|
// The image is not split horizontally so the width should be the same for both intersections
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
167
|
+
o(intersection9.width).equals(bounds.width);
|
|
168
|
+
o(intersection10.width).equals(bounds.width);
|
|
169
|
+
Approx.equal(intersection9.height, 101.5, 'height');
|
|
170
|
+
Approx.equal(intersection10.height, 106.5, 'height');
|
|
174
171
|
});
|
|
175
172
|
/**
|
|
176
173
|
* XYZ tiles [30, 19, 5], [31, 19, 5], [30, 20, 5], [31, 20, 5]
|
|
@@ -183,16 +180,16 @@ ospec_1.default.spec('ProjectionTileMatrixSet', () => {
|
|
|
183
180
|
* | XXXXX|XXXX | 20
|
|
184
181
|
* |-------|-------|
|
|
185
182
|
*/
|
|
186
|
-
|
|
183
|
+
o('should tile [30, 19, 5], [31, 19, 5], [30, 20, 5], [31, 20, 5]', () => {
|
|
187
184
|
const z = 5;
|
|
188
|
-
const tileBounds = new
|
|
185
|
+
const tileBounds = new Bounds(30, 19, 1, 1);
|
|
189
186
|
const bounds = getPixelsBoundsFromMeters(tifBoundingBox, z);
|
|
190
187
|
const expectedBaseSizeScaled = expectedBaseSize.scale(2 ** z, 2 ** z);
|
|
191
|
-
|
|
188
|
+
Approx.bounds(bounds, expectedBaseSizeScaled);
|
|
192
189
|
const screenTopLeft = getPixelsFromTile(tileBounds.x, tileBounds.y);
|
|
193
190
|
const screenTopRight = getPixelsFromTile(tileBounds.right, tileBounds.y);
|
|
194
|
-
|
|
195
|
-
|
|
191
|
+
o(screenTopLeft.toJson()).deepEquals({ width: 256, height: 256, y: 4864, x: 7680 });
|
|
192
|
+
o(screenTopRight.toJson()).deepEquals({ width: 256, height: 256, y: 4864, x: 7936 });
|
|
196
193
|
const intersectionTopLeft = bounds.intersection(screenTopLeft);
|
|
197
194
|
const intersectionTopRight = bounds.intersection(screenTopRight);
|
|
198
195
|
if (intersectionTopLeft == null || intersectionTopRight == null) {
|
|
@@ -200,13 +197,13 @@ ospec_1.default.spec('ProjectionTileMatrixSet', () => {
|
|
|
200
197
|
}
|
|
201
198
|
// the image is split in two so the intersection should combine into the total width of the image
|
|
202
199
|
const totalTopIntersectionWidth = intersectionTopLeft.width + intersectionTopRight.width;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
200
|
+
o(totalTopIntersectionWidth).equals(bounds.width);
|
|
201
|
+
o(intersectionTopLeft.height).equals(203);
|
|
202
|
+
o(intersectionTopRight.height).equals(203);
|
|
206
203
|
const screenBottomLeft = getPixelsFromTile(tileBounds.x, tileBounds.bottom);
|
|
207
204
|
const screenBottomRight = getPixelsFromTile(tileBounds.right, tileBounds.bottom);
|
|
208
|
-
|
|
209
|
-
|
|
205
|
+
o(screenBottomLeft.toJson()).deepEquals({ width: 256, height: 256, y: 5120, x: 7680 });
|
|
206
|
+
o(screenBottomRight.toJson()).deepEquals({ width: 256, height: 256, y: 5120, x: 7936 });
|
|
210
207
|
const intersectionBottomLeft = bounds.intersection(screenBottomLeft);
|
|
211
208
|
const intersectionBottomRight = bounds.intersection(screenBottomRight);
|
|
212
209
|
if (intersectionBottomLeft == null || intersectionBottomRight == null) {
|
|
@@ -214,13 +211,13 @@ ospec_1.default.spec('ProjectionTileMatrixSet', () => {
|
|
|
214
211
|
}
|
|
215
212
|
// the image is split in two so the intersection should combine into the total width of the image
|
|
216
213
|
const totalBottomIntersectionWidth = intersectionBottomLeft.width + intersectionBottomRight.width;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
214
|
+
o(totalBottomIntersectionWidth).equals(bounds.width);
|
|
215
|
+
Approx.equal(intersectionBottomLeft.height, 213, 'height');
|
|
216
|
+
Approx.equal(intersectionBottomRight.height, 213, 'height');
|
|
220
217
|
const totalLeftIntersectionHeight = intersectionTopLeft.height + intersectionBottomLeft.height;
|
|
221
218
|
const totalRightIntersectionHeight = intersectionTopRight.height + intersectionBottomRight.height;
|
|
222
|
-
|
|
223
|
-
|
|
219
|
+
o(totalLeftIntersectionHeight).equals(bounds.height);
|
|
220
|
+
o(totalRightIntersectionHeight).equals(bounds.height);
|
|
224
221
|
});
|
|
225
222
|
});
|
|
226
223
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.util.d.ts","sourceRoot":"","sources":["../../../src/proj/__test__/test.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,aAAa,EAAE,IAAI,EAAkB,WAAW,EAAE,MAAM,eAAe,CAAC;AAEpG,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,CAGjE;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,GAAG,gBAAsC,GAAG,WAAW,EAAE,CAEpH;AAED,wBAAgB,YAAY,
|
|
1
|
+
{"version":3,"file":"test.util.d.ts","sourceRoot":"","sources":["../../../src/proj/__test__/test.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,aAAa,EAAE,IAAI,EAAkB,WAAW,EAAE,MAAM,eAAe,CAAC;AAEpG,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,CAGjE;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,GAAG,gBAAsC,GAAG,WAAW,EAAE,CAEpH;AAED,wBAAgB,YAAY,CAC1B,WAAW,EAAE,IAAI,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,SAAI,EACV,GAAG,gBAAsC,GACxC,WAAW,EAAE,CAef"}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const geo_1 = require("@basemaps/geo");
|
|
5
|
-
function qkToName(qk) {
|
|
6
|
-
return geo_1.TileMatrixSet.tileToName(geo_1.QuadKey.toTile(qk));
|
|
1
|
+
import { EpsgCode, QuadKey, TileMatrixSet, TileMatrixSets } from '@basemaps/geo';
|
|
2
|
+
export function qkToName(qk) {
|
|
3
|
+
return TileMatrixSet.tileToName(QuadKey.toTile(qk));
|
|
7
4
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return quadKeys.map((qk) => ({ name: qkToName(qk), ...tms.tileToSourceBounds(geo_1.QuadKey.toTile(qk)) }));
|
|
5
|
+
export function qkToNamedBounds(quadKeys) {
|
|
6
|
+
const tms = TileMatrixSets.get(EpsgCode.Google);
|
|
7
|
+
return quadKeys.map((qk) => ({ name: qkToName(qk), ...tms.tileToSourceBounds(QuadKey.toTile(qk)) }));
|
|
12
8
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return tileNames.map((name) => ({ name, ...tms.tileToSourceBounds(geo_1.TileMatrixSet.nameToTile(name)) }));
|
|
9
|
+
export function tileNamesToNamedBounds(tileNames, tms = TileMatrixSets.get(EpsgCode.Google)) {
|
|
10
|
+
return tileNames.map((name) => ({ name, ...tms.tileToSourceBounds(TileMatrixSet.nameToTile(name)) }));
|
|
16
11
|
}
|
|
17
|
-
|
|
18
|
-
function genTileNames(topLeftTile, xTotal, yTotal = 1, tms = geo_1.TileMatrixSets.get(geo_1.EpsgCode.Google)) {
|
|
12
|
+
export function genTileNames(topLeftTile, xTotal, yTotal = 1, tms = TileMatrixSets.get(EpsgCode.Google)) {
|
|
19
13
|
const bounds = [];
|
|
20
14
|
yTotal += topLeftTile.y;
|
|
21
15
|
xTotal += topLeftTile.x;
|
|
@@ -24,9 +18,8 @@ function genTileNames(topLeftTile, xTotal, yTotal = 1, tms = geo_1.TileMatrixSet
|
|
|
24
18
|
tile.y = y;
|
|
25
19
|
for (let x = topLeftTile.x; x < xTotal; ++x) {
|
|
26
20
|
tile.x = x;
|
|
27
|
-
bounds.push({ name:
|
|
21
|
+
bounds.push({ name: TileMatrixSet.tileToName(tile), ...tms.tileToSourceBounds(tile) });
|
|
28
22
|
}
|
|
29
23
|
}
|
|
30
24
|
return bounds;
|
|
31
25
|
}
|
|
32
|
-
exports.genTileNames = genTileNames;
|
package/build/proj/citm2000.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Citm2000 = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Well known text for NZGD2000 / Chatham Islands TM 2000
|
|
6
3
|
*
|
|
7
4
|
* @see https://epsg.io/3793
|
|
8
5
|
*/
|
|
9
|
-
|
|
6
|
+
export const Citm2000 = `PROJCS["NZGD2000 / Chatham Islands TM 2000",
|
|
10
7
|
GEOGCS["NZGD2000",
|
|
11
8
|
DATUM["New_Zealand_Geodetic_Datum_2000",
|
|
12
9
|
SPHEROID["GRS 1980",6378137,298.257222101,
|
package/build/proj/nztm2000.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Nztm2000 = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Well known text for NZGD2000
|
|
6
3
|
*
|
|
7
4
|
* @see https://epsg.io/2193
|
|
8
5
|
*/
|
|
9
|
-
|
|
6
|
+
export const Nztm2000 = `PROJCS["NZGD2000 / New Zealand Transverse Mercator 2000",
|
|
10
7
|
GEOGCS["NZGD2000",
|
|
11
8
|
DATUM["New_Zealand_Geodetic_Datum_2000",
|
|
12
9
|
SPHEROID["GRS 1980",6378137,298.257222101,
|