@developmentseed/morecantile 0.1.0 → 0.2.0-beta.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.
Files changed (49) hide show
  1. package/dist/index.d.ts +4 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +2 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/transform.d.ts +53 -0
  6. package/dist/transform.d.ts.map +1 -0
  7. package/dist/transform.js +69 -0
  8. package/dist/transform.js.map +1 -0
  9. package/dist/types/index.d.ts +5 -0
  10. package/dist/types/index.d.ts.map +1 -0
  11. package/dist/types/index.js +2 -0
  12. package/dist/types/index.js.map +1 -0
  13. package/dist/types/spec/2DBoundingBox.d.ts +17 -0
  14. package/dist/types/spec/2DBoundingBox.d.ts.map +1 -0
  15. package/dist/types/spec/2DBoundingBox.js +5 -0
  16. package/dist/types/spec/2DBoundingBox.js.map +1 -0
  17. package/dist/types/spec/2DPoint.d.ts +8 -0
  18. package/dist/types/spec/2DPoint.d.ts.map +1 -0
  19. package/dist/types/spec/2DPoint.js +5 -0
  20. package/dist/types/spec/2DPoint.js.map +1 -0
  21. package/dist/types/spec/crs.d.ts +20 -0
  22. package/dist/types/spec/crs.d.ts.map +1 -0
  23. package/dist/types/spec/crs.js +5 -0
  24. package/dist/types/spec/crs.js.map +1 -0
  25. package/dist/types/spec/index.d.ts +8 -0
  26. package/dist/types/spec/index.d.ts.map +1 -0
  27. package/dist/types/spec/index.js +11 -0
  28. package/dist/types/spec/index.js.map +1 -0
  29. package/dist/types/spec/projJSON.d.ts +3 -0
  30. package/dist/types/spec/projJSON.d.ts.map +1 -0
  31. package/dist/types/spec/projJSON.js +5 -0
  32. package/dist/types/spec/projJSON.js.map +1 -0
  33. package/dist/types/spec/tileMatrix.d.ts +58 -0
  34. package/dist/types/spec/tileMatrix.d.ts.map +1 -0
  35. package/dist/types/spec/tileMatrix.js +5 -0
  36. package/dist/types/spec/tileMatrix.js.map +1 -0
  37. package/dist/types/spec/tileMatrixSet.d.ts +44 -0
  38. package/dist/types/spec/tileMatrixSet.d.ts.map +1 -0
  39. package/dist/types/spec/tileMatrixSet.js +5 -0
  40. package/dist/types/spec/tileMatrixSet.js.map +1 -0
  41. package/dist/types/spec/variableMatrixWidth.d.ts +19 -0
  42. package/dist/types/spec/variableMatrixWidth.d.ts.map +1 -0
  43. package/dist/types/spec/variableMatrixWidth.js +5 -0
  44. package/dist/types/spec/variableMatrixWidth.js.map +1 -0
  45. package/dist/utils.d.ts +18 -0
  46. package/dist/utils.d.ts.map +1 -0
  47. package/dist/utils.js +38 -0
  48. package/dist/utils.js.map +1 -0
  49. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,2 +1,5 @@
1
- export {};
1
+ export type { Affine } from "./transform";
2
+ export { matrixTransform, tileTransform } from "./transform";
3
+ export type { BoundingBox, CRS, TileMatrix, TileMatrixSet, } from "./types/index";
4
+ export { metersPerUnit } from "./utils";
2
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7D,YAAY,EACV,WAAW,EACX,GAAG,EACH,UAAU,EACV,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
- export {};
1
+ export { matrixTransform, tileTransform } from "./transform";
2
+ export { metersPerUnit } from "./utils";
2
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAO7D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { TileMatrix } from "./types/index.js";
2
+ /**
3
+ * A 2-D affine transform as a six-element tuple in row-major order:
4
+ *
5
+ * x_crs = a * col_px + b * row_px + c
6
+ * y_crs = d * col_px + e * row_px + f
7
+ *
8
+ * For the north-up, axis-aligned grids produced by OGC TileMatrices,
9
+ * b and d are always zero, but the type does not enforce that.
10
+ *
11
+ * Note: the meaning of the two output axes depends on the
12
+ * `orderedAxes` field of the parent TileMatrixSet, which these
13
+ * helpers do not consult. Axis 0 of pointOfOrigin is axis 0 of the
14
+ * transform output, whatever that axis happens to be.
15
+ */
16
+ export type Affine = [
17
+ a: number,
18
+ b: number,
19
+ c: number,
20
+ d: number,
21
+ e: number,
22
+ f: number
23
+ ];
24
+ /**
25
+ * Construct a single affine transform that maps pixel coordinates
26
+ * within *any* tile of the matrix to CRS coordinates.
27
+ *
28
+ * Returns `null` when the matrix declares `variableMatrixWidths`,
29
+ * because coalesced rows have a different X pixel size than the rest
30
+ * and cannot be described by one transform. Use {@link tileTransform}
31
+ * in that case.
32
+ *
33
+ * Pixel (0, 0) is the top-left corner of tile (0, 0). The column
34
+ * pixel index runs across the full matrix:
35
+ * globalPixelCol = col * tileWidth + pixelWithinTile_x
36
+ * globalPixelRow = row * tileHeight + pixelWithinTile_y
37
+ */
38
+ export declare function matrixTransform(matrix: TileMatrix): Affine | null;
39
+ /**
40
+ * Construct an affine transform for a single tile identified by its
41
+ * column and row indices within the matrix. Pixel (0, 0) is the
42
+ * top-left corner of *this* tile.
43
+ *
44
+ * This is always possible: even when `variableMatrixWidths` is
45
+ * present, each individual tile is a plain rectangular pixel grid
46
+ * with a well-defined, axis-aligned footprint. Coalescence only
47
+ * stretches the tile in X; Y is unaffected.
48
+ */
49
+ export declare function tileTransform(matrix: TileMatrix, tile: {
50
+ col: number;
51
+ row: number;
52
+ }): Affine;
53
+ //# sourceMappingURL=transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;CACV,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAgBjE;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACjC,MAAM,CAiBR"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Construct a single affine transform that maps pixel coordinates
3
+ * within *any* tile of the matrix to CRS coordinates.
4
+ *
5
+ * Returns `null` when the matrix declares `variableMatrixWidths`,
6
+ * because coalesced rows have a different X pixel size than the rest
7
+ * and cannot be described by one transform. Use {@link tileTransform}
8
+ * in that case.
9
+ *
10
+ * Pixel (0, 0) is the top-left corner of tile (0, 0). The column
11
+ * pixel index runs across the full matrix:
12
+ * globalPixelCol = col * tileWidth + pixelWithinTile_x
13
+ * globalPixelRow = row * tileHeight + pixelWithinTile_y
14
+ */
15
+ export function matrixTransform(matrix) {
16
+ if (matrix.variableMatrixWidths && matrix.variableMatrixWidths.length > 0) {
17
+ return null;
18
+ }
19
+ const [originX, originY] = matrix.pointOfOrigin;
20
+ const ySign = matrix.cornerOfOrigin === "bottomLeft" ? 1 : -1;
21
+ return [
22
+ matrix.cellSize, // a: x per pixel-col
23
+ 0, // b
24
+ originX, // c: x origin
25
+ 0, // d
26
+ ySign * matrix.cellSize, // e: y per pixel-row
27
+ originY, // f: y origin
28
+ ];
29
+ }
30
+ /**
31
+ * Construct an affine transform for a single tile identified by its
32
+ * column and row indices within the matrix. Pixel (0, 0) is the
33
+ * top-left corner of *this* tile.
34
+ *
35
+ * This is always possible: even when `variableMatrixWidths` is
36
+ * present, each individual tile is a plain rectangular pixel grid
37
+ * with a well-defined, axis-aligned footprint. Coalescence only
38
+ * stretches the tile in X; Y is unaffected.
39
+ */
40
+ export function tileTransform(matrix, tile) {
41
+ const coalesce = coalesceForRow(matrix, tile.row);
42
+ const [originX, originY] = matrix.pointOfOrigin;
43
+ const ySign = matrix.cornerOfOrigin === "bottomLeft" ? 1 : -1;
44
+ const tileSpanX = coalesce * matrix.cellSize * matrix.tileWidth;
45
+ const tileSpanY = matrix.cellSize * matrix.tileHeight;
46
+ return [
47
+ coalesce * matrix.cellSize, // a: x per pixel-col (stretched by coalesce)
48
+ 0, // b
49
+ originX + tile.col * tileSpanX, // c: x origin of this tile
50
+ 0, // d
51
+ ySign * matrix.cellSize, // e: y per pixel-row (unchanged)
52
+ originY + ySign * tile.row * tileSpanY, // f: y origin of this tile
53
+ ];
54
+ }
55
+ /**
56
+ * Return the coalesce factor for a given row, or 1 if the row is not
57
+ * coalesced (or the matrix has no variableMatrixWidths at all).
58
+ */
59
+ function coalesceForRow(matrix, row) {
60
+ if (!matrix.variableMatrixWidths)
61
+ return 1;
62
+ for (const vmw of matrix.variableMatrixWidths) {
63
+ if (row >= vmw.minTileRow && row <= vmw.maxTileRow) {
64
+ return vmw.coalesce;
65
+ }
66
+ }
67
+ return 1;
68
+ }
69
+ //# sourceMappingURL=transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.js","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe,CAAC,MAAkB;IAChD,IAAI,MAAM,CAAC,oBAAoB,IAAI,MAAM,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1E,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,aAAa,CAAC;IAChD,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9D,OAAO;QACL,MAAM,CAAC,QAAQ,EAAE,qBAAqB;QACtC,CAAC,EAAE,IAAI;QACP,OAAO,EAAE,cAAc;QACvB,CAAC,EAAE,IAAI;QACP,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,qBAAqB;QAC9C,OAAO,EAAE,cAAc;KACxB,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAkB,EAClB,IAAkC;IAElC,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAElD,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,aAAa,CAAC;IAChD,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9D,MAAM,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC;IAChE,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC;IAEtD,OAAO;QACL,QAAQ,GAAG,MAAM,CAAC,QAAQ,EAAE,6CAA6C;QACzE,CAAC,EAAE,IAAI;QACP,OAAO,GAAG,IAAI,CAAC,GAAG,GAAG,SAAS,EAAE,2BAA2B;QAC3D,CAAC,EAAE,IAAI;QACP,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,iCAAiC;QAC1D,OAAO,GAAG,KAAK,GAAG,IAAI,CAAC,GAAG,GAAG,SAAS,EAAE,2BAA2B;KACpE,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,cAAc,CAAC,MAAkB,EAAE,GAAW;IACrD,IAAI,CAAC,MAAM,CAAC,oBAAoB;QAAE,OAAO,CAAC,CAAC;IAE3C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,oBAAoB,EAAE,CAAC;QAC9C,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;YACnD,OAAO,GAAG,CAAC,QAAQ,CAAC;QACtB,CAAC;IACH,CAAC;IAED,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,5 @@
1
+ export type { DBoundingBox as BoundingBox } from "./spec/2DBoundingBox";
2
+ export type { CRS } from "./spec/crs";
3
+ export type { TileMatrix } from "./spec/tileMatrix";
4
+ export type { TileMatrixSetDefinition as TileMatrixSet } from "./spec/tileMatrixSet";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,IAAI,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxE,YAAY,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,uBAAuB,IAAI,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import type { DPoint } from "./2DPoint.js";
2
+ import type { CRS } from "./crs.js";
3
+ /**
4
+ * Minimum bounding rectangle surrounding a 2D resource in the CRS indicated elsewhere
5
+ */
6
+ export interface DBoundingBox {
7
+ lowerLeft: DPoint;
8
+ upperRight: DPoint;
9
+ crs?: CRS;
10
+ /**
11
+ * @minItems 2
12
+ * @maxItems 2
13
+ */
14
+ orderedAxes?: [string, string];
15
+ [k: string]: unknown;
16
+ }
17
+ //# sourceMappingURL=2DBoundingBox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"2DBoundingBox.d.ts","sourceRoot":"","sources":["../../../src/types/spec/2DBoundingBox.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB"}
@@ -0,0 +1,5 @@
1
+ /* This file was automatically generated from OGC TMS 2.0 JSON Schema. */
2
+ /* DO NOT MODIFY IT BY HAND. Instead, modify the source JSON Schema file */
3
+ /* and run `pnpm run generate-types` to regenerate. */
4
+ export {};
5
+ //# sourceMappingURL=2DBoundingBox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"2DBoundingBox.js","sourceRoot":"","sources":["../../../src/types/spec/2DBoundingBox.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,0EAA0E"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A 2D Point in the CRS indicated elsewhere
3
+ *
4
+ * @minItems 2
5
+ * @maxItems 2
6
+ */
7
+ export type DPoint = [number, number];
8
+ //# sourceMappingURL=2DPoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"2DPoint.d.ts","sourceRoot":"","sources":["../../../src/types/spec/2DPoint.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /* This file was automatically generated from OGC TMS 2.0 JSON Schema. */
2
+ /* DO NOT MODIFY IT BY HAND. Instead, modify the source JSON Schema file */
3
+ /* and run `pnpm run generate-types` to regenerate. */
4
+ export {};
5
+ //# sourceMappingURL=2DPoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"2DPoint.js","sourceRoot":"","sources":["../../../src/types/spec/2DPoint.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,0EAA0E"}
@@ -0,0 +1,20 @@
1
+ import type { ProjJSON } from "./projJSON.js";
2
+ export type CRS = string | ({
3
+ /**
4
+ * Reference to one coordinate reference system (CRS)
5
+ */
6
+ uri: string;
7
+ [k: string]: unknown;
8
+ } | {
9
+ wkt: ProjJSON;
10
+ [k: string]: unknown;
11
+ } | {
12
+ /**
13
+ * A reference system data structure as defined in the MD_ReferenceSystem of the ISO 19115
14
+ */
15
+ referenceSystem: {
16
+ [k: string]: unknown;
17
+ };
18
+ [k: string]: unknown;
19
+ });
20
+ //# sourceMappingURL=crs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crs.d.ts","sourceRoot":"","sources":["../../../src/types/spec/crs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,MAAM,GAAG,GACX,MAAM,GACN,CACI;IACE;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB,GACD;IACE,GAAG,EAAE,QAAQ,CAAC;IACd,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB,GACD;IACE;;OAEG;IACH,eAAe,EAAE;QACf,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KACtB,CAAC;IACF,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB,CACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ /* This file was automatically generated from OGC TMS 2.0 JSON Schema. */
2
+ /* DO NOT MODIFY IT BY HAND. Instead, modify the source JSON Schema file */
3
+ /* and run `pnpm run generate-types` to regenerate. */
4
+ export {};
5
+ //# sourceMappingURL=crs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crs.js","sourceRoot":"","sources":["../../../src/types/spec/crs.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,0EAA0E"}
@@ -0,0 +1,8 @@
1
+ export * from "./2DBoundingBox.js";
2
+ export * from "./2DPoint.js";
3
+ export * from "./crs.js";
4
+ export * from "./projJSON.js";
5
+ export * from "./tileMatrix.js";
6
+ export * from "./tileMatrixSet.js";
7
+ export * from "./variableMatrixWidth.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/spec/index.ts"],"names":[],"mappings":"AAIA,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,11 @@
1
+ /* This file was automatically generated from OGC TMS 2.0 JSON Schema. */
2
+ /* DO NOT MODIFY IT BY HAND. Instead, modify the source JSON Schema file */
3
+ /* and run `pnpm run generate-types` to regenerate. */
4
+ export * from "./2DBoundingBox.js";
5
+ export * from "./2DPoint.js";
6
+ export * from "./crs.js";
7
+ export * from "./projJSON.js";
8
+ export * from "./tileMatrix.js";
9
+ export * from "./tileMatrixSet.js";
10
+ export * from "./variableMatrixWidth.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/spec/index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,0EAA0E;AAE1E,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Opaque type for PROJ JSON coordinate reference system definitions. */
2
+ export type ProjJSON = Record<string, unknown>;
3
+ //# sourceMappingURL=projJSON.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projJSON.d.ts","sourceRoot":"","sources":["../../../src/types/spec/projJSON.ts"],"names":[],"mappings":"AAIA,yEAAyE;AACzE,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /* This file was automatically generated from OGC TMS 2.0 JSON Schema. */
2
+ /* DO NOT MODIFY IT BY HAND. Instead, modify the source JSON Schema file */
3
+ /* and run `pnpm run generate-types` to regenerate. */
4
+ export {};
5
+ //# sourceMappingURL=projJSON.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projJSON.js","sourceRoot":"","sources":["../../../src/types/spec/projJSON.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,0EAA0E"}
@@ -0,0 +1,58 @@
1
+ import type { DPoint } from "./2DPoint.js";
2
+ import type { VariableMatrixWidth } from "./variableMatrixWidth.js";
3
+ /**
4
+ * A tile matrix, usually corresponding to a particular zoom level of a TileMatrixSet.
5
+ */
6
+ export interface TileMatrix {
7
+ /**
8
+ * Title of this tile matrix, normally used for display to a human
9
+ */
10
+ title?: string;
11
+ /**
12
+ * Brief narrative description of this tile matrix set, normally available for display to a human
13
+ */
14
+ description?: string;
15
+ /**
16
+ * Unordered list of one or more commonly used or formalized word(s) or phrase(s) used to describe this dataset
17
+ */
18
+ keywords?: string[];
19
+ /**
20
+ * Identifier selecting one of the scales defined in the TileMatrixSet and representing the scaleDenominator the tile. Implementation of 'identifier'
21
+ */
22
+ id: string;
23
+ /**
24
+ * Scale denominator of this tile matrix
25
+ */
26
+ scaleDenominator: number;
27
+ /**
28
+ * Cell size of this tile matrix
29
+ */
30
+ cellSize: number;
31
+ /**
32
+ * The corner of the tile matrix (_topLeft_ or _bottomLeft_) used as the origin for numbering tile rows and columns. This corner is also a corner of the (0, 0) tile.
33
+ */
34
+ cornerOfOrigin?: "topLeft" | "bottomLeft";
35
+ pointOfOrigin: DPoint;
36
+ /**
37
+ * Width of each tile of this tile matrix in pixels
38
+ */
39
+ tileWidth: number;
40
+ /**
41
+ * Height of each tile of this tile matrix in pixels
42
+ */
43
+ tileHeight: number;
44
+ /**
45
+ * Width of the matrix (number of tiles in width)
46
+ */
47
+ matrixHeight: number;
48
+ /**
49
+ * Height of the matrix (number of tiles in height)
50
+ */
51
+ matrixWidth: number;
52
+ /**
53
+ * Describes the rows that has variable matrix width
54
+ */
55
+ variableMatrixWidths?: VariableMatrixWidth[];
56
+ [k: string]: unknown;
57
+ }
58
+ //# sourceMappingURL=tileMatrix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tileMatrix.d.ts","sourceRoot":"","sources":["../../../src/types/spec/tileMatrix.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC7C,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB"}
@@ -0,0 +1,5 @@
1
+ /* This file was automatically generated from OGC TMS 2.0 JSON Schema. */
2
+ /* DO NOT MODIFY IT BY HAND. Instead, modify the source JSON Schema file */
3
+ /* and run `pnpm run generate-types` to regenerate. */
4
+ export {};
5
+ //# sourceMappingURL=tileMatrix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tileMatrix.js","sourceRoot":"","sources":["../../../src/types/spec/tileMatrix.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,0EAA0E"}
@@ -0,0 +1,44 @@
1
+ import type { DBoundingBox } from "./2DBoundingBox.js";
2
+ import type { CRS } from "./crs.js";
3
+ import type { TileMatrix } from "./tileMatrix.js";
4
+ /**
5
+ * A definition of a tile matrix set following the Tile Matrix Set standard. For tileset metadata, such a description (in `tileMatrixSet` property) is only required for offline use, as an alternative to a link with a `http://www.opengis.net/def/rel/ogc/1.0/tiling-scheme` relation type.
6
+ */
7
+ export interface TileMatrixSetDefinition {
8
+ /**
9
+ * Title of this tile matrix set, normally used for display to a human
10
+ */
11
+ title?: string;
12
+ /**
13
+ * Brief narrative description of this tile matrix set, normally available for display to a human
14
+ */
15
+ description?: string;
16
+ /**
17
+ * Unordered list of one or more commonly used or formalized word(s) or phrase(s) used to describe this tile matrix set
18
+ */
19
+ keywords?: string[];
20
+ /**
21
+ * Tile matrix set identifier. Implementation of 'identifier'
22
+ */
23
+ id?: string;
24
+ /**
25
+ * Reference to an official source for this tileMatrixSet
26
+ */
27
+ uri?: string;
28
+ /**
29
+ * @minItems 1
30
+ */
31
+ orderedAxes?: [string, ...string[]];
32
+ crs: CRS;
33
+ /**
34
+ * Reference to a well-known scale set
35
+ */
36
+ wellKnownScaleSet?: string;
37
+ boundingBox?: DBoundingBox;
38
+ /**
39
+ * Describes scale levels and its tile matrices
40
+ */
41
+ tileMatrices: TileMatrix[];
42
+ [k: string]: unknown;
43
+ }
44
+ //# sourceMappingURL=tileMatrixSet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tileMatrixSet.d.ts","sourceRoot":"","sources":["../../../src/types/spec/tileMatrixSet.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IACpC,GAAG,EAAE,GAAG,CAAC;IACT;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B;;OAEG;IACH,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB"}
@@ -0,0 +1,5 @@
1
+ /* This file was automatically generated from OGC TMS 2.0 JSON Schema. */
2
+ /* DO NOT MODIFY IT BY HAND. Instead, modify the source JSON Schema file */
3
+ /* and run `pnpm run generate-types` to regenerate. */
4
+ export {};
5
+ //# sourceMappingURL=tileMatrixSet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tileMatrixSet.js","sourceRoot":"","sources":["../../../src/types/spec/tileMatrixSet.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,0EAA0E"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Variable Matrix Width data structure
3
+ */
4
+ export interface VariableMatrixWidth {
5
+ /**
6
+ * Number of tiles in width that coalesce in a single tile for these rows
7
+ */
8
+ coalesce: number;
9
+ /**
10
+ * First tile row where the coalescence factor applies for this tilematrix
11
+ */
12
+ minTileRow: number;
13
+ /**
14
+ * Last tile row where the coalescence factor applies for this tilematrix
15
+ */
16
+ maxTileRow: number;
17
+ [k: string]: unknown;
18
+ }
19
+ //# sourceMappingURL=variableMatrixWidth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variableMatrixWidth.d.ts","sourceRoot":"","sources":["../../../src/types/spec/variableMatrixWidth.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB"}
@@ -0,0 +1,5 @@
1
+ /* This file was automatically generated from OGC TMS 2.0 JSON Schema. */
2
+ /* DO NOT MODIFY IT BY HAND. Instead, modify the source JSON Schema file */
3
+ /* and run `pnpm run generate-types` to regenerate. */
4
+ export {};
5
+ //# sourceMappingURL=variableMatrixWidth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variableMatrixWidth.js","sourceRoot":"","sources":["../../../src/types/spec/variableMatrixWidth.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,0EAA0E"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Coefficient to convert the coordinate reference system (CRS)
3
+ * units into meters (metersPerUnit).
4
+ *
5
+ * From note g in http://docs.opengeospatial.org/is/17-083r2/17-083r2.html#table_2:
6
+ *
7
+ * > If the CRS uses meters as units of measure for the horizontal dimensions,
8
+ * > then metersPerUnit=1; if it has degrees, then metersPerUnit=2pa/360
9
+ * > (a is the Earth maximum radius of the ellipsoid).
10
+ *
11
+ * @param unit - The unit of the CRS.
12
+ * @param semiMajorAxis - The semi-major axis of the ellipsoid, required if unit is 'degree'.
13
+ * @returns The meters per unit conversion factor.
14
+ */
15
+ export declare function metersPerUnit(unit: "m" | "metre" | "meter" | "meters" | "foot" | "us survey foot" | "degree", { semiMajorAxis }: {
16
+ semiMajorAxis?: number;
17
+ }): number;
18
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,wBAAgB,aAAa,CAC3B,IAAI,EACA,GAAG,GACH,OAAO,GACP,OAAO,GACP,QAAQ,GACR,MAAM,GACN,gBAAgB,GAChB,QAAQ,EACZ,EAAE,aAAa,EAAE,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5C,MAAM,CA4BR"}
package/dist/utils.js ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Coefficient to convert the coordinate reference system (CRS)
3
+ * units into meters (metersPerUnit).
4
+ *
5
+ * From note g in http://docs.opengeospatial.org/is/17-083r2/17-083r2.html#table_2:
6
+ *
7
+ * > If the CRS uses meters as units of measure for the horizontal dimensions,
8
+ * > then metersPerUnit=1; if it has degrees, then metersPerUnit=2pa/360
9
+ * > (a is the Earth maximum radius of the ellipsoid).
10
+ *
11
+ * @param unit - The unit of the CRS.
12
+ * @param semiMajorAxis - The semi-major axis of the ellipsoid, required if unit is 'degree'.
13
+ * @returns The meters per unit conversion factor.
14
+ */
15
+ // https://github.com/developmentseed/morecantile/blob/7c95a11c491303700d6e33e9c1607f2719584dec/morecantile/utils.py#L67-L90
16
+ export function metersPerUnit(unit, { semiMajorAxis }) {
17
+ unit = unit.toLowerCase();
18
+ switch (unit) {
19
+ case "m":
20
+ case "metre":
21
+ case "meter":
22
+ case "meters":
23
+ return 1;
24
+ case "foot":
25
+ return 0.3048;
26
+ case "us survey foot":
27
+ return 1200 / 3937;
28
+ }
29
+ if (unit === "degree") {
30
+ // 2 * π * ellipsoid semi-major-axis / 360
31
+ if (semiMajorAxis === undefined) {
32
+ throw new Error("CRS with degrees unit requires ellipsoid semi-major-axis");
33
+ }
34
+ return (2 * Math.PI * semiMajorAxis) / 360;
35
+ }
36
+ throw new Error(`Unsupported CRS units: ${unit} when computing metersPerUnit.`);
37
+ }
38
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,4HAA4H;AAC5H,MAAM,UAAU,aAAa,CAC3B,IAOY,EACZ,EAAE,aAAa,EAA8B;IAE7C,IAAI,GAAG,IAAI,CAAC,WAAW,EAAiB,CAAC;IACzC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,GAAG,CAAC;QACT,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,CAAC,CAAC;QACX,KAAK,MAAM;YACT,OAAO,MAAM,CAAC;QAChB,KAAK,gBAAgB;YACnB,OAAO,IAAI,GAAG,IAAI,CAAC;IACvB,CAAC;IAED,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,0CAA0C;QAC1C,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CACb,0DAA0D,CAC3D,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,aAAa,CAAC,GAAG,GAAG,CAAC;IAC7C,CAAC;IAED,MAAM,IAAI,KAAK,CACb,0BAA0B,IAAI,gCAAgC,CAC/D,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@developmentseed/morecantile",
3
- "version": "0.1.0",
3
+ "version": "0.2.0-beta.1",
4
4
  "description": "TypeScript port of Morecantile for working with OGC TileMatrixSet grids",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",