@basemaps/shared 6.7.0 → 6.11.0
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 +61 -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 +19 -19
- 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 +14 -23
- package/build/index.d.ts +13 -14
- package/build/index.d.ts.map +1 -1
- package/build/index.js +18 -35
- 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 +130 -78
- 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 +44 -33
- package/build/proj/projection.d.ts.map +1 -1
- package/build/proj/projection.js +84 -53
- 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 -8
- 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 -18
- 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
|
@@ -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,75 +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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
function isValidLatLong(x) {
|
|
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`);
|
|
27
|
+
}
|
|
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);
|
|
36
|
+
});
|
|
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);
|
|
33
42
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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);
|
|
39
53
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
o.spec('tileCenterToLatLon', () => {
|
|
55
|
+
o('should create centers for web mercator', () => {
|
|
56
|
+
const center = Projection.tileCenterToLatLon(GoogleTms, QuadKey.toTile('3120123'));
|
|
57
|
+
isValidLatLong(center);
|
|
58
|
+
o(round(center, 8)).deepEquals({
|
|
59
|
+
lat: -47.98992167,
|
|
60
|
+
lon: 105.46875,
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
o('should create centers for NZTM', () => {
|
|
64
|
+
const center = Projection.tileCenterToLatLon(Nztm2000Tms, { x: 2295, y: 5119, z: 10 });
|
|
65
|
+
isValidLatLong(center);
|
|
66
|
+
const centerB = Projection.tileCenterToLatLon(Nztm2000Tms, { x: 20, y: 20, z: 10 });
|
|
67
|
+
isValidLatLong(centerB);
|
|
68
|
+
});
|
|
69
|
+
o('should create centers for NZTMQuad', () => {
|
|
70
|
+
const center = Projection.tileCenterToLatLon(Nztm2000QuadTms, { x: 200, y: 500, z: 10 });
|
|
71
|
+
isValidLatLong(center);
|
|
72
|
+
o(round(center, 8)).deepEquals({ lat: -35.79628765, lon: 141.39377624 });
|
|
73
|
+
const centerB = Projection.tileCenterToLatLon(Nztm2000QuadTms, { x: 1000, y: 1000, z: 10 });
|
|
74
|
+
isValidLatLong(centerB);
|
|
75
|
+
});
|
|
50
76
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
lat:
|
|
54
|
-
lon:
|
|
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 });
|
|
91
|
+
});
|
|
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 });
|
|
55
107
|
});
|
|
56
108
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const pt =
|
|
60
|
-
|
|
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]);
|
|
61
113
|
});
|
|
62
|
-
|
|
63
|
-
const pt =
|
|
64
|
-
|
|
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]);
|
|
65
117
|
});
|
|
66
118
|
});
|
|
67
|
-
|
|
119
|
+
o.spec('TilingBounds', () => {
|
|
68
120
|
// Approximate bounding box of new zealand
|
|
69
121
|
const tifBoundingBox = [18494091.86765497, -6051366.655280836, 19986142.659781612, -4016307.214216303];
|
|
70
|
-
const expectedBaseSize =
|
|
71
|
-
|
|
122
|
+
const expectedBaseSize = Bounds.fromJson({ width: 9.53125, height: 13, y: 153.65625, x: 246.14062500000006 });
|
|
123
|
+
o('should tile 0,0,0', () => {
|
|
72
124
|
const bounds = getPixelsBoundsFromMeters(tifBoundingBox, 0);
|
|
73
|
-
|
|
125
|
+
Approx.bounds(bounds, expectedBaseSize);
|
|
74
126
|
const screenBounds = getPixelsFromTile(0, 0);
|
|
75
127
|
const intersection = bounds.intersection(screenBounds);
|
|
76
|
-
|
|
128
|
+
Approx.bounds(intersection, expectedBaseSize);
|
|
77
129
|
});
|
|
78
|
-
|
|
130
|
+
o('should tile 1,1,1', () => {
|
|
79
131
|
const [x, y, z] = [1, 1, 1];
|
|
80
132
|
const bounds = getPixelsBoundsFromMeters(tifBoundingBox, z);
|
|
81
133
|
const expectedBaseSizeScaled = expectedBaseSize.scale(2, 2);
|
|
82
|
-
|
|
134
|
+
Approx.bounds(bounds, expectedBaseSizeScaled);
|
|
83
135
|
const screenBounds = getPixelsFromTile(x, y);
|
|
84
136
|
const intersection = bounds.intersection(screenBounds);
|
|
85
|
-
|
|
137
|
+
Approx.bounds(intersection, expectedBaseSizeScaled);
|
|
86
138
|
});
|
|
87
139
|
/**
|
|
88
140
|
* XYZ tiles 15,9,4 & 15,10,4 provide a top/bottom tiles for this bounding box
|
|
@@ -94,15 +146,15 @@ ospec_1.default.spec('ProjectionTileMatrixSet', () => {
|
|
|
94
146
|
* | XXX | 10
|
|
95
147
|
* |-------|
|
|
96
148
|
*/
|
|
97
|
-
|
|
149
|
+
o('should tile [15, 9, 4] & [15, 10, 4]', () => {
|
|
98
150
|
const [x, z] = [15, 4];
|
|
99
151
|
const bounds = getPixelsBoundsFromMeters(tifBoundingBox, z);
|
|
100
152
|
const expectedBaseSizeScaled = expectedBaseSize.scale(2 ** z, 2 ** z);
|
|
101
|
-
|
|
153
|
+
Approx.bounds(bounds, expectedBaseSizeScaled);
|
|
102
154
|
const screenBounds9 = getPixelsFromTile(x, 9);
|
|
103
155
|
const screenBounds10 = getPixelsFromTile(x, 10);
|
|
104
|
-
|
|
105
|
-
|
|
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 });
|
|
106
158
|
const intersection9 = bounds.intersection(screenBounds9);
|
|
107
159
|
const intersection10 = bounds.intersection(screenBounds10);
|
|
108
160
|
if (intersection9 == null || intersection10 == null) {
|
|
@@ -110,12 +162,12 @@ ospec_1.default.spec('ProjectionTileMatrixSet', () => {
|
|
|
110
162
|
}
|
|
111
163
|
// the image is split in two so the intersection should combine into the total height of the image
|
|
112
164
|
const totalIntersectionHeight = intersection9.height + intersection10.height;
|
|
113
|
-
|
|
165
|
+
o(totalIntersectionHeight).equals(bounds.height);
|
|
114
166
|
// The image is not split horizontally so the width should be the same for both intersections
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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');
|
|
119
171
|
});
|
|
120
172
|
/**
|
|
121
173
|
* XYZ tiles [30, 19, 5], [31, 19, 5], [30, 20, 5], [31, 20, 5]
|
|
@@ -128,16 +180,16 @@ ospec_1.default.spec('ProjectionTileMatrixSet', () => {
|
|
|
128
180
|
* | XXXXX|XXXX | 20
|
|
129
181
|
* |-------|-------|
|
|
130
182
|
*/
|
|
131
|
-
|
|
183
|
+
o('should tile [30, 19, 5], [31, 19, 5], [30, 20, 5], [31, 20, 5]', () => {
|
|
132
184
|
const z = 5;
|
|
133
|
-
const tileBounds = new
|
|
185
|
+
const tileBounds = new Bounds(30, 19, 1, 1);
|
|
134
186
|
const bounds = getPixelsBoundsFromMeters(tifBoundingBox, z);
|
|
135
187
|
const expectedBaseSizeScaled = expectedBaseSize.scale(2 ** z, 2 ** z);
|
|
136
|
-
|
|
188
|
+
Approx.bounds(bounds, expectedBaseSizeScaled);
|
|
137
189
|
const screenTopLeft = getPixelsFromTile(tileBounds.x, tileBounds.y);
|
|
138
190
|
const screenTopRight = getPixelsFromTile(tileBounds.right, tileBounds.y);
|
|
139
|
-
|
|
140
|
-
|
|
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 });
|
|
141
193
|
const intersectionTopLeft = bounds.intersection(screenTopLeft);
|
|
142
194
|
const intersectionTopRight = bounds.intersection(screenTopRight);
|
|
143
195
|
if (intersectionTopLeft == null || intersectionTopRight == null) {
|
|
@@ -145,13 +197,13 @@ ospec_1.default.spec('ProjectionTileMatrixSet', () => {
|
|
|
145
197
|
}
|
|
146
198
|
// the image is split in two so the intersection should combine into the total width of the image
|
|
147
199
|
const totalTopIntersectionWidth = intersectionTopLeft.width + intersectionTopRight.width;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
200
|
+
o(totalTopIntersectionWidth).equals(bounds.width);
|
|
201
|
+
o(intersectionTopLeft.height).equals(203);
|
|
202
|
+
o(intersectionTopRight.height).equals(203);
|
|
151
203
|
const screenBottomLeft = getPixelsFromTile(tileBounds.x, tileBounds.bottom);
|
|
152
204
|
const screenBottomRight = getPixelsFromTile(tileBounds.right, tileBounds.bottom);
|
|
153
|
-
|
|
154
|
-
|
|
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 });
|
|
155
207
|
const intersectionBottomLeft = bounds.intersection(screenBottomLeft);
|
|
156
208
|
const intersectionBottomRight = bounds.intersection(screenBottomRight);
|
|
157
209
|
if (intersectionBottomLeft == null || intersectionBottomRight == null) {
|
|
@@ -159,13 +211,13 @@ ospec_1.default.spec('ProjectionTileMatrixSet', () => {
|
|
|
159
211
|
}
|
|
160
212
|
// the image is split in two so the intersection should combine into the total width of the image
|
|
161
213
|
const totalBottomIntersectionWidth = intersectionBottomLeft.width + intersectionBottomRight.width;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
214
|
+
o(totalBottomIntersectionWidth).equals(bounds.width);
|
|
215
|
+
Approx.equal(intersectionBottomLeft.height, 213, 'height');
|
|
216
|
+
Approx.equal(intersectionBottomRight.height, 213, 'height');
|
|
165
217
|
const totalLeftIntersectionHeight = intersectionTopLeft.height + intersectionBottomLeft.height;
|
|
166
218
|
const totalRightIntersectionHeight = intersectionTopRight.height + intersectionBottomRight.height;
|
|
167
|
-
|
|
168
|
-
|
|
219
|
+
o(totalLeftIntersectionHeight).equals(bounds.height);
|
|
220
|
+
o(totalRightIntersectionHeight).equals(bounds.height);
|
|
169
221
|
});
|
|
170
222
|
});
|
|
171
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,
|
|
@@ -27,11 +27,11 @@ export declare class Projection {
|
|
|
27
27
|
*/
|
|
28
28
|
static tryGet(unk?: Epsg | EpsgCode | TileMatrixSet): Projection | null;
|
|
29
29
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
* Project the points in a MultiPolygon array to the `targetProjection`.
|
|
31
|
+
|
|
32
|
+
* @return if multipoly is not projected return it verbatim otherwise creates a new multi
|
|
33
|
+
* polygon
|
|
34
|
+
*/
|
|
35
35
|
projectMultipolygon(multipoly: Position[][][], targetProjection: Projection): Position[][][];
|
|
36
36
|
/**
|
|
37
37
|
* Convert source `[x, y]` coordinates to `[lon, lat]`
|
|
@@ -42,34 +42,34 @@ export declare class Projection {
|
|
|
42
42
|
*/
|
|
43
43
|
get fromWgs84(): (coordinates: Position) => Position;
|
|
44
44
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
* Convert a source Bounds to GeoJSON WGS84 BoundingBox. In particular if the bounds crosses the
|
|
46
|
+
* anti-meridian then the east component will be less than the west component.
|
|
47
|
+
|
|
48
|
+
* @param source
|
|
49
|
+
* @returns [west, south, east, north]
|
|
50
|
+
*/
|
|
51
51
|
boundsToWgs84BoundingBox(source: BoundingBox): BBox;
|
|
52
52
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
* Convert a source bounds to a WSG84 GeoJSON Feature
|
|
54
|
+
|
|
55
|
+
* @param bounds in source epsg
|
|
56
|
+
* @param properties any properties to include in the feature such as name
|
|
57
|
+
|
|
58
|
+
* @returns If `bounds` crosses the antimeridian then and east and west pair of non crossing
|
|
59
|
+
* polygons will be returned; otherwise a single Polygon will be returned.
|
|
60
|
+
*/
|
|
61
61
|
boundsToGeoJsonFeature(bounds: BoundingBox, properties?: {}): BBoxFeature;
|
|
62
62
|
/** Convert a tile covering to a GeoJSON FeatureCollection */
|
|
63
63
|
toGeoJson(files: NamedBounds[]): BBoxFeatureCollection;
|
|
64
64
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
* Find the closest zoom level to `gsd` (Ground Sampling Distance meters per pixel) that is at
|
|
66
|
+
* least as good as `gsd`.
|
|
67
|
+
|
|
68
|
+
* @param gsd
|
|
69
|
+
|
|
70
|
+
* @param blockFactor How many time bigger the blockSize is compared to tileSize. Leave as 1 to
|
|
71
|
+
* not take into account.
|
|
72
|
+
*/
|
|
73
73
|
static getTiffResZoom(tms: TileMatrixSet, gsd: number, blockFactor?: number): number;
|
|
74
74
|
/** Convert a tile to the wgs84 bounds */
|
|
75
75
|
static tileToWgs84Bbox(tms: TileMatrixSet, tile: Tile): BBox;
|
|
@@ -77,6 +77,17 @@ export declare class Projection {
|
|
|
77
77
|
* return the `lat`, `lon` of a Tile's center
|
|
78
78
|
*/
|
|
79
79
|
static tileCenterToLatLon(tms: TileMatrixSet, tile: Tile): LatLon;
|
|
80
|
+
/**
|
|
81
|
+
* Reused from : https://github.com/pelias/api/blob/6a7751f35882698eb885b93635656ec0c2941633/sanitizer/wrap.js
|
|
82
|
+
*
|
|
83
|
+
* Normalize co-ordinates that lie outside of the normal ranges.
|
|
84
|
+
*
|
|
85
|
+
* longitude wrapping simply requires adding +- 360 to the value until it comes in to range.
|
|
86
|
+
* for the latitude values we need to flip the longitude whenever the latitude
|
|
87
|
+
* crosses a pole.
|
|
88
|
+
*
|
|
89
|
+
*/
|
|
90
|
+
static wrapLatLon(lat: number, lon: number): LatLon;
|
|
80
91
|
/**
|
|
81
92
|
* Find the number of alignment levels required to render the tile. Min 1
|
|
82
93
|
*
|
|
@@ -85,12 +96,12 @@ export declare class Projection {
|
|
|
85
96
|
*/
|
|
86
97
|
static findAlignmentLevels(tms: TileMatrixSet, tile: Tile, gsd: number): number;
|
|
87
98
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
* Return the expected width in pixels of an image at the tile resolution. Uses
|
|
100
|
+
* `this.blockFactor` for HiDPI tiles.
|
|
101
|
+
|
|
102
|
+
* @param tile
|
|
103
|
+
* @param targetZoom The desired zoom level for the imagery
|
|
104
|
+
*/
|
|
94
105
|
static getImagePixelWidth(tms: TileMatrixSet, tile: Tile, targetZoom: number): number;
|
|
95
106
|
}
|
|
96
107
|
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../src/proj/projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,
|
|
1
|
+
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../src/proj/projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EACL,IAAI,EACJ,WAAW,EACX,qBAAqB,EAKtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAUnC,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAUD,qBAAa,UAAU;IACrB,IAAI,EAAE,IAAI,CAAC;IAEX,8CAA8C;IAC9C,OAAO,CAAC,UAAU,CAAkB;IAEpC;;OAEG;IACH,OAAO;IAaP;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,GAAG,QAAQ,GAAG,aAAa,GAAG,UAAU;IAMjE;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,GAAG,QAAQ,GAAG,aAAa,GAAG,UAAU,GAAG,IAAI;IAYvE;;;;;SAKK;IACL,mBAAmB,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,gBAAgB,EAAE,UAAU,GAAG,QAAQ,EAAE,EAAE,EAAE;IAS5F;;OAEG;IACH,IAAI,OAAO,IAAI,CAAC,WAAW,EAAE,QAAQ,KAAK,QAAQ,CAEjD;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,CAAC,WAAW,EAAE,QAAQ,KAAK,QAAQ,CAEnD;IAED;;;;;;SAMK;IACL,wBAAwB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAOnD;;;;;;;;SAQK;IACL,sBAAsB,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,KAAK,GAAG,WAAW;IAezE,6DAA6D;IAC7D,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,qBAAqB;IAOtD;;;;;;;;SAQK;IACL,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,SAAI,GAAG,MAAM;IAU/E,yCAAyC;IACzC,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI;IAY5D;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM;IAOjE;;;;;;;;;OASG;IACH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IA8BnD;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAI/E;;;;;;SAMK;IACL,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;CAKtF"}
|