@spacexr/tiles 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/README.md +57 -2
- package/dist/addressing/index.d.ts +16 -0
- package/dist/addressing/index.js +4 -0
- package/dist/addressing/index.js.map +1 -0
- package/dist/bake/index.d.ts +91 -0
- package/dist/bake/index.js +3 -0
- package/dist/bake/index.js.map +1 -0
- package/dist/celestial-dataset-CUIsplKO.d.ts +99 -0
- package/dist/chunk-2HLQXRDD.js +246 -0
- package/dist/chunk-2HLQXRDD.js.map +1 -0
- package/dist/chunk-6YNCRDEE.js +170 -0
- package/dist/chunk-6YNCRDEE.js.map +1 -0
- package/dist/chunk-7AWV2IEK.js +79 -0
- package/dist/chunk-7AWV2IEK.js.map +1 -0
- package/dist/chunk-ESLGXWQR.js +219 -0
- package/dist/chunk-ESLGXWQR.js.map +1 -0
- package/dist/chunk-FB57CZDK.js +312 -0
- package/dist/chunk-FB57CZDK.js.map +1 -0
- package/dist/chunk-GRTG4WNA.js +44 -0
- package/dist/chunk-GRTG4WNA.js.map +1 -0
- package/dist/chunk-HVYN4AIT.js +45 -0
- package/dist/chunk-HVYN4AIT.js.map +1 -0
- package/dist/chunk-IGNRXAW3.js +77 -0
- package/dist/chunk-IGNRXAW3.js.map +1 -0
- package/dist/chunk-QGTREKHS.js +145 -0
- package/dist/chunk-QGTREKHS.js.map +1 -0
- package/dist/chunk-SPDRAY37.js +56 -0
- package/dist/chunk-SPDRAY37.js.map +1 -0
- package/dist/chunk-TA4BEVHL.js +81 -0
- package/dist/chunk-TA4BEVHL.js.map +1 -0
- package/dist/chunk-TGOB5HT5.js +149 -0
- package/dist/chunk-TGOB5HT5.js.map +1 -0
- package/dist/chunk-X6ZJ2PDY.js +104 -0
- package/dist/chunk-X6ZJ2PDY.js.map +1 -0
- package/dist/chunk-XTY4HCPY.js +22 -0
- package/dist/chunk-XTY4HCPY.js.map +1 -0
- package/dist/chunk-Y66PNDG2.js +107 -0
- package/dist/chunk-Y66PNDG2.js.map +1 -0
- package/dist/chunk-YEACOJOC.js +51 -0
- package/dist/chunk-YEACOJOC.js.map +1 -0
- package/dist/cube/index.d.ts +160 -0
- package/dist/cube/index.js +9 -0
- package/dist/cube/index.js.map +1 -0
- package/dist/datasets/index.d.ts +75 -0
- package/dist/datasets/index.js +11 -0
- package/dist/datasets/index.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/mercator/index.d.ts +24 -0
- package/dist/mercator/index.js +8 -0
- package/dist/mercator/index.js.map +1 -0
- package/dist/metrics-HGbzqj6L.d.ts +45 -0
- package/dist/pyramid/index.d.ts +156 -0
- package/dist/pyramid/index.js +4 -0
- package/dist/pyramid/index.js.map +1 -0
- package/dist/raster-registration-CgBxrhDB.d.ts +19 -0
- package/dist/reference-surface-CsTtrNsc.d.ts +49 -0
- package/dist/reprojection/index.d.ts +255 -0
- package/dist/reprojection/index.js +6 -0
- package/dist/reprojection/index.js.map +1 -0
- package/dist/sources/index.d.ts +55 -0
- package/dist/sources/index.js +7 -0
- package/dist/sources/index.js.map +1 -0
- package/dist/surface/index.d.ts +15 -0
- package/dist/surface/index.js +4 -0
- package/dist/surface/index.js.map +1 -0
- package/dist/tile-D-jjIRRA.d.ts +53 -0
- package/dist/tile-address-BkfSftp6.d.ts +66 -0
- package/dist/tile-http-client-BHZOtGX7.d.ts +73 -0
- package/dist/tile-neighbors-LfvV7oiX.d.ts +48 -0
- package/dist/tile-surface-s9Zi6X9_.d.ts +40 -0
- package/dist/tile-topology-B6xHYqPb.d.ts +51 -0
- package/dist/web-mercator-dataset-Dmou8byO.d.ts +125 -0
- package/dist/web-tile-source-DrZDBIm6.d.ts +92 -0
- package/package.json +122 -5
- package/src/addressing/index.ts +8 -0
- package/src/addressing/metrics.ts +48 -0
- package/src/addressing/raster-registration.ts +22 -0
- package/src/addressing/tile-address.ts +130 -0
- package/src/addressing/tile-edge-rotation.ts +13 -0
- package/src/addressing/tile-neighbors.ts +73 -0
- package/src/addressing/tile-surface.ts +44 -0
- package/src/addressing/tile-topology.ts +86 -0
- package/src/addressing/tile.ts +73 -0
- package/src/bake/bake-pyramid.ts +106 -0
- package/src/bake/index.ts +2 -0
- package/src/bake/pyramid-levels.ts +63 -0
- package/src/cube/celestial-dataset.ts +182 -0
- package/src/cube/cube-face.ts +51 -0
- package/src/cube/cube-geometric-error.ts +30 -0
- package/src/cube/cube-mapping.ts +101 -0
- package/src/cube/cube-neighbors.ts +198 -0
- package/src/cube/cube-tile-surface.ts +30 -0
- package/src/cube/index.ts +6 -0
- package/src/datasets/index.ts +1 -0
- package/src/datasets/tile-dataset.ts +121 -0
- package/src/index.ts +9 -0
- package/src/mercator/index.ts +3 -0
- package/src/mercator/web-mercator-dataset.ts +215 -0
- package/src/mercator/web-mercator-tile-metrics.ts +119 -0
- package/src/mercator/web-mercator-tile-surface.ts +52 -0
- package/src/pyramid/index.ts +2 -0
- package/src/pyramid/resident-tiles.ts +81 -0
- package/src/pyramid/tile-pyramid.ts +285 -0
- package/src/reprojection/cube-resampling.ts +159 -0
- package/src/reprojection/index.ts +4 -0
- package/src/reprojection/source-projection.ts +196 -0
- package/src/reprojection/source-tile-matrix.ts +100 -0
- package/src/reprojection/wmts-capabilities.ts +112 -0
- package/src/sources/index.ts +4 -0
- package/src/sources/tile-http-client.ts +154 -0
- package/src/sources/tile-layer-changes.ts +88 -0
- package/src/sources/url-template.ts +96 -0
- package/src/sources/web-tile-source.ts +73 -0
- package/src/surface/directions.ts +27 -0
- package/src/surface/index.ts +2 -0
- package/src/surface/reference-surface.ts +88 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { I as ITileAddress } from './tile-address-BkfSftp6.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Position around a tile, as the SpaceXR `NeighborsIndex`. The values follow the 3 x 3 layout row-major from the
|
|
5
|
+
* north-west, with the tile itself at the centre:
|
|
6
|
+
*
|
|
7
|
+
* ```text
|
|
8
|
+
* NW N NE 0 1 2
|
|
9
|
+
* W C E 3 4 5
|
|
10
|
+
* SW S SE 6 7 8
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
declare enum TileNeighbor {
|
|
14
|
+
NW = 0,
|
|
15
|
+
N = 1,
|
|
16
|
+
NE = 2,
|
|
17
|
+
W = 3,
|
|
18
|
+
C = 4,
|
|
19
|
+
E = 5,
|
|
20
|
+
SW = 6,
|
|
21
|
+
S = 7,
|
|
22
|
+
SE = 8
|
|
23
|
+
}
|
|
24
|
+
/** Neighbours sharing an edge with the tile. */
|
|
25
|
+
type TileEdgeNeighbor = TileNeighbor.N | TileNeighbor.E | TileNeighbor.S | TileNeighbor.W;
|
|
26
|
+
/** Neighbours sharing only a corner with the tile. */
|
|
27
|
+
type TileCornerNeighbor = TileNeighbor.NW | TileNeighbor.NE | TileNeighbor.SE | TileNeighbor.SW;
|
|
28
|
+
/** Edge neighbours, clockwise from the north. */
|
|
29
|
+
declare const TILE_EDGE_NEIGHBORS: readonly TileEdgeNeighbor[];
|
|
30
|
+
/** Corner neighbours, clockwise from the north-west. */
|
|
31
|
+
declare const TILE_CORNER_NEIGHBORS: readonly TileCornerNeighbor[];
|
|
32
|
+
/** The two edges meeting at each corner, north or south first. */
|
|
33
|
+
declare const TILE_CORNER_EDGES: Readonly<Record<TileCornerNeighbor, readonly [TileEdgeNeighbor, TileEdgeNeighbor]>>;
|
|
34
|
+
/** Column and row offsets of each neighbour, in XYZ axes: `x` eastward, `y` southward. */
|
|
35
|
+
declare function tileNeighborOffset(neighbor: TileNeighbor): readonly [number, number];
|
|
36
|
+
interface ITileNeighborOptions {
|
|
37
|
+
/** Wraps columns around the antimeridian, for pyramids covering every longitude. Defaults to false. */
|
|
38
|
+
wrapX?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns the neighbour at the same level of detail, or `undefined` beyond the pyramid. Rows never wrap: there is no
|
|
42
|
+
* tile north of the first row or south of the last one. The face is kept; neighbours across root boundaries are given by the supplied topology.
|
|
43
|
+
*/
|
|
44
|
+
declare function tileNeighborAddress(address: ITileAddress, neighbor: TileNeighbor, options?: ITileNeighborOptions): ITileAddress | undefined;
|
|
45
|
+
/** Returns the nine addresses of {@link TileNeighbor} order, the tile itself at `TileNeighbor.C`. */
|
|
46
|
+
declare function tileNeighborAddresses(address: ITileAddress, options?: ITileNeighborOptions): Array<ITileAddress | undefined>;
|
|
47
|
+
|
|
48
|
+
export { type ITileNeighborOptions as I, TILE_CORNER_EDGES as T, TILE_CORNER_NEIGHBORS as a, TILE_EDGE_NEIGHBORS as b, type TileCornerNeighbor as c, type TileEdgeNeighbor as d, TileNeighbor as e, tileNeighborAddresses as f, tileNeighborOffset as g, tileNeighborAddress as t };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ICartesian3 } from '@spacexr/geodesy';
|
|
2
|
+
import { I as ITileAddress } from './tile-address-BkfSftp6.js';
|
|
3
|
+
|
|
4
|
+
/** How tiles share one shape: tiles of the same `key` are the same shape turned about the `Z` axis by `rotation`. */
|
|
5
|
+
interface ITileShapeFrame {
|
|
6
|
+
/** Identifies the shape among the tiles of a surface. */
|
|
7
|
+
readonly key: string;
|
|
8
|
+
/** Angle about the `Z` axis from the frame of the shape to the body-fixed frame, in radians. */
|
|
9
|
+
readonly rotation: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Places the tiles of a pyramid on a body: the part of a tiling scheme that geometry needs. Positions are Cartesian,
|
|
13
|
+
* in metres, in the body-fixed frame. Tile coordinates `s` and `t` run in `[0, 1]`, `s` along the tile `x` axis and
|
|
14
|
+
* `t` along its `y` axis.
|
|
15
|
+
*/
|
|
16
|
+
interface ITileSurface {
|
|
17
|
+
/**
|
|
18
|
+
* Point of a tile at a height above the reference surface, along {@link up}.
|
|
19
|
+
*
|
|
20
|
+
* @param height - Height in metres. Defaults to 0.
|
|
21
|
+
* @param target - Receives the point.
|
|
22
|
+
* @throws RangeError When the address does not belong to the surface.
|
|
23
|
+
*/
|
|
24
|
+
point(address: ITileAddress, s: number, t: number, height?: number, target?: ICartesian3): ICartesian3;
|
|
25
|
+
/**
|
|
26
|
+
* Unit vector along which heights move a point of the tile.
|
|
27
|
+
*
|
|
28
|
+
* @param target - Receives the vector.
|
|
29
|
+
* @throws RangeError When the address does not belong to the surface.
|
|
30
|
+
*/
|
|
31
|
+
up(address: ITileAddress, s: number, t: number, target?: ICartesian3): ICartesian3;
|
|
32
|
+
/**
|
|
33
|
+
* Shape shared by a tile with others.
|
|
34
|
+
*
|
|
35
|
+
* @throws RangeError When the address does not belong to the surface.
|
|
36
|
+
*/
|
|
37
|
+
shape(address: ITileAddress): ITileShapeFrame;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type { ITileShapeFrame as I, ITileSurface as a };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { I as ITileAddress } from './tile-address-BkfSftp6.js';
|
|
2
|
+
import { e as TileNeighbor } from './tile-neighbors-LfvV7oiX.js';
|
|
3
|
+
|
|
4
|
+
/** Neighbour of a tile, with the quarter turns from the frame of the tile to the frame of the neighbour. */
|
|
5
|
+
interface ITileTopologyNeighbor {
|
|
6
|
+
readonly address: ITileAddress;
|
|
7
|
+
/** 0 when both tiles share a frame; within the pyramid root, 1 to 3 across some face edges. */
|
|
8
|
+
readonly turns: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Area of a tile in another tile, in coordinates of the other tile. A point `(u, v)` of the tile lies at
|
|
12
|
+
* `(west + a * size, north + b * size)`, with `(a, b) = turnedTileCoordinates(u, v, turns)`. The area may lie outside
|
|
13
|
+
* the other tile: only the points the two tiles share are inside it.
|
|
14
|
+
*/
|
|
15
|
+
interface ITileAreaAcross {
|
|
16
|
+
readonly west: number;
|
|
17
|
+
readonly north: number;
|
|
18
|
+
readonly size: number;
|
|
19
|
+
/** Quarter turns from the frame of the tile to the frame of the other tile. */
|
|
20
|
+
readonly turns: number;
|
|
21
|
+
}
|
|
22
|
+
/** How the tiles of a pyramid connect: the part of a tiling scheme that neighbours and junctions need. */
|
|
23
|
+
interface ITileTopology {
|
|
24
|
+
/**
|
|
25
|
+
* Neighbour at the same level, or `undefined` beyond the pyramid or at a corner where only 3 tiles meet.
|
|
26
|
+
*
|
|
27
|
+
* @throws RangeError When the address is invalid.
|
|
28
|
+
*/
|
|
29
|
+
neighbor(address: ITileAddress, position: TileNeighbor): ITileTopologyNeighbor | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Area of a tile in another tile that contains or touches it, for reading the data of a neighbour along a shared
|
|
32
|
+
* edge or corner.
|
|
33
|
+
*
|
|
34
|
+
* @throws RangeError When the two tiles cannot touch.
|
|
35
|
+
*/
|
|
36
|
+
areaIn(address: ITileAddress, other: ITileAddress): ITileAreaAcross;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Coordinates of a point of a tile in a frame turned by quarter turns about the centre of the tile. One turn sends the
|
|
40
|
+
* direction `N` to `E`, so `u`, which grows toward `E`, grows toward `S` in the turned frame.
|
|
41
|
+
*/
|
|
42
|
+
declare function turnedTileCoordinates(u: number, v: number, turns: number): [number, number];
|
|
43
|
+
/** Options of {@link flatTileTopology}. */
|
|
44
|
+
interface IFlatTileTopologyOptions {
|
|
45
|
+
/** Wraps columns around the antimeridian, for pyramids covering every longitude. Defaults to false. */
|
|
46
|
+
wrapX?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/** Topology of a pyramid with one root, such as Web Mercator: neighbours never turn. */
|
|
49
|
+
declare function flatTileTopology(options?: IFlatTileTopologyOptions): ITileTopology;
|
|
50
|
+
|
|
51
|
+
export { type IFlatTileTopologyOptions as I, type ITileAreaAcross as a, type ITileTopology as b, type ITileTopologyNeighbor as c, flatTileTopology as f, turnedTileCoordinates as t };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { GeodeticSystem } from '@spacexr/geodesy';
|
|
2
|
+
import { R as RasterRegistration } from './raster-registration-CgBxrhDB.js';
|
|
3
|
+
import { I as ITileAddress } from './tile-address-BkfSftp6.js';
|
|
4
|
+
import { a as TileHttpClient, I as ITileHttpClientOptions, T as TileFetchResult } from './tile-http-client-BHZOtGX7.js';
|
|
5
|
+
import { W as WebTileSource } from './web-tile-source-DrZDBIm6.js';
|
|
6
|
+
import { b as ITileMetrics, C as CellCoordinateReference, I as ICartesian2, a as IGeographic2 } from './metrics-HGbzqj6L.js';
|
|
7
|
+
|
|
8
|
+
interface IWebMercatorTileMetricsOptions {
|
|
9
|
+
minLOD: number;
|
|
10
|
+
maxLOD: number;
|
|
11
|
+
tileSize?: number;
|
|
12
|
+
cellSize?: number;
|
|
13
|
+
cellCoordinateReference?: CellCoordinateReference;
|
|
14
|
+
overlap?: number;
|
|
15
|
+
}
|
|
16
|
+
/** Immutable EPSG:3857 tile metrics backed by a geodetic ellipsoid. */
|
|
17
|
+
declare class WebMercatorTileMetrics implements ITileMetrics {
|
|
18
|
+
readonly geodeticSystem: GeodeticSystem;
|
|
19
|
+
readonly minLatitude: number;
|
|
20
|
+
readonly maxLatitude = 85.0511287798066;
|
|
21
|
+
readonly minLongitude = -180;
|
|
22
|
+
readonly maxLongitude = 180;
|
|
23
|
+
readonly minLOD: number;
|
|
24
|
+
readonly maxLOD: number;
|
|
25
|
+
readonly tileSize: number;
|
|
26
|
+
readonly cellSize: number;
|
|
27
|
+
readonly cellCoordinateReference: CellCoordinateReference;
|
|
28
|
+
readonly overlap: number;
|
|
29
|
+
constructor(options: IWebMercatorTileMetricsOptions, geodeticSystem: GeodeticSystem);
|
|
30
|
+
mapSize(levelOfDetail: number): number;
|
|
31
|
+
mapScale(latitudeDegrees: number, levelOfDetail: number, pixelsPerUnit: number): number;
|
|
32
|
+
groundResolution(latitudeDegrees: number, levelOfDetail: number): number;
|
|
33
|
+
getLatLonToTileXY(latitudeDegrees: number, longitudeDegrees: number, levelOfDetail: number): ICartesian2;
|
|
34
|
+
getTileXYToLatLon(x: number, y: number, levelOfDetail: number): IGeographic2;
|
|
35
|
+
getLatLonToPointXY(latitudeDegrees: number, longitudeDegrees: number, levelOfDetail: number): ICartesian2;
|
|
36
|
+
getPointXYToLatLon(x: number, y: number, levelOfDetail: number): IGeographic2;
|
|
37
|
+
getTileXYToPointXY(x: number, y: number): ICartesian2;
|
|
38
|
+
getPointXYToTileXY(x: number, y: number): ICartesian2;
|
|
39
|
+
private assertLOD;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Scheme of the Web Mercator datasets of this version of the specification. */
|
|
43
|
+
declare const WEB_MERCATOR_SCHEME = "spacexr-web-mercator/1";
|
|
44
|
+
/** What the tiles of a dataset hold. */
|
|
45
|
+
type TileDatasetContent = "elevation" | "imagery" | "normals";
|
|
46
|
+
/** A rectangle in degrees of longitude and latitude on the reference surface of a dataset. */
|
|
47
|
+
interface IDatasetBounds {
|
|
48
|
+
readonly west: number;
|
|
49
|
+
readonly south: number;
|
|
50
|
+
readonly east: number;
|
|
51
|
+
readonly north: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Descriptor of a Web Mercator (EPSG:3857 tiling, XYZ addressing, `y` from the north) dataset of a tile service: a
|
|
55
|
+
* provider such as an elevation or imagery pyramid is described by this data, never by code.
|
|
56
|
+
*/
|
|
57
|
+
interface IWebMercatorDataset {
|
|
58
|
+
/** This specification and its version: {@link WEB_MERCATOR_SCHEME}. */
|
|
59
|
+
readonly scheme: string;
|
|
60
|
+
/** Catalogue name of the body, such as `Earth`. */
|
|
61
|
+
readonly body: string;
|
|
62
|
+
/** Radii `a`, `b`, `c` of the ellipsoid of revolution the tiles are computed on, in metres: `a` equals `b`. */
|
|
63
|
+
readonly referenceRadii: readonly [number, number, number];
|
|
64
|
+
readonly content: TileDatasetContent;
|
|
65
|
+
/** Tile format: `terrarium` heights, `mapzen-normal` normals, or an image format such as `png`, `jpeg`, `webp`. */
|
|
66
|
+
readonly encoding: string;
|
|
67
|
+
/** Pixels per tile side. */
|
|
68
|
+
readonly tileSize: number;
|
|
69
|
+
/** Levels available inside {@link bounds}, from `minLOD` to `maxLOD`. */
|
|
70
|
+
readonly minLOD: number;
|
|
71
|
+
readonly maxLOD: number;
|
|
72
|
+
/** Where the dataset has tiles; the whole Web Mercator square when absent. A tile outside is never requested. */
|
|
73
|
+
readonly bounds?: IDatasetBounds;
|
|
74
|
+
/** Where the samples of the tiles lie: `area` for images, the usual case. */
|
|
75
|
+
readonly registration: RasterRegistration;
|
|
76
|
+
/** URL template; a relative one is resolved against the URL of its descriptor by {@link loadTileDataset}. */
|
|
77
|
+
readonly tiles: string;
|
|
78
|
+
/** Values of `{s}` in the template, rotated between requests. */
|
|
79
|
+
readonly subdomains?: readonly string[];
|
|
80
|
+
/** Text applications must display with the tiles. */
|
|
81
|
+
readonly attribution: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Checks the JSON value of a Web Mercator dataset descriptor.
|
|
85
|
+
*
|
|
86
|
+
* @throws RangeError When a member is missing or invalid, naming it. A scheme of another version is rejected.
|
|
87
|
+
* @throws TileUrlTemplateError When the URL template uses an unknown variable.
|
|
88
|
+
*/
|
|
89
|
+
declare function parseWebMercatorDataset(value: unknown): IWebMercatorDataset;
|
|
90
|
+
/**
|
|
91
|
+
* The JSON value of a Web Mercator dataset descriptor, as {@link parseWebMercatorDataset} reads it back: the members of
|
|
92
|
+
* the dataset, checked, with `extras` written as given (the parser keeps no member it does not know).
|
|
93
|
+
*
|
|
94
|
+
* @throws RangeError When a member is invalid, as {@link parseWebMercatorDataset} would report it.
|
|
95
|
+
*/
|
|
96
|
+
declare function webMercatorDatasetDescriptor(dataset: Omit<IWebMercatorDataset, "scheme">, extras?: Record<string, unknown>): Record<string, unknown>;
|
|
97
|
+
/** Options of {@link WebMercatorDatasetSource}. */
|
|
98
|
+
interface IWebMercatorDatasetSourceOptions {
|
|
99
|
+
/** Shared client, or options used to create a dedicated one. */
|
|
100
|
+
client?: TileHttpClient | ITileHttpClientOptions;
|
|
101
|
+
/**
|
|
102
|
+
* Geodetic system of the tiles; by default one built from the radii of the descriptor. Give the system of the
|
|
103
|
+
* application when it is the same ellipsoid, so that its metrics compare equal.
|
|
104
|
+
*/
|
|
105
|
+
geodeticSystem?: GeodeticSystem;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Tiles of a Web Mercator dataset over HTTP. Like the cube source of a tile service, it never requests a tile the
|
|
109
|
+
* descriptor does not declare: a level out of range, or a tile outside the bounds, resolves as absent.
|
|
110
|
+
*/
|
|
111
|
+
declare class WebMercatorDatasetSource {
|
|
112
|
+
readonly dataset: IWebMercatorDataset;
|
|
113
|
+
readonly metrics: WebMercatorTileMetrics;
|
|
114
|
+
/** The HTTP source of the tiles, for consumers that take a {@link WebTileSource}. */
|
|
115
|
+
readonly source: WebTileSource;
|
|
116
|
+
/** @param dataset - The descriptor, or its JSON value, checked by {@link parseWebMercatorDataset}. */
|
|
117
|
+
constructor(dataset: IWebMercatorDataset | unknown, options?: IWebMercatorDatasetSourceOptions);
|
|
118
|
+
get attribution(): string;
|
|
119
|
+
/** Whether the dataset declares a tile: its level is in range and it meets the bounds. */
|
|
120
|
+
isAvailable(address: ITileAddress): boolean;
|
|
121
|
+
/** Fetches a tile; a tile the dataset does not declare resolves as absent, like a 404, without any request. */
|
|
122
|
+
fetchTile(address: ITileAddress, signal?: AbortSignal): Promise<TileFetchResult>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export { type IDatasetBounds as I, type TileDatasetContent as T, WEB_MERCATOR_SCHEME as W, type IWebMercatorDataset as a, type IWebMercatorDatasetSourceOptions as b, type IWebMercatorTileMetricsOptions as c, WebMercatorDatasetSource as d, WebMercatorTileMetrics as e, parseWebMercatorDataset as p, webMercatorDatasetDescriptor as w };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { b as ITileMetrics } from './metrics-HGbzqj6L.js';
|
|
2
|
+
import { R as RasterRegistration } from './raster-registration-CgBxrhDB.js';
|
|
3
|
+
import { I as ITileAddress } from './tile-address-BkfSftp6.js';
|
|
4
|
+
import { a as TileHttpClient, I as ITileHttpClientOptions, T as TileFetchResult } from './tile-http-client-BHZOtGX7.js';
|
|
5
|
+
|
|
6
|
+
/** Options used to expand a tile URL template. */
|
|
7
|
+
interface ITileUrlTemplateOptions {
|
|
8
|
+
/** Values substituted for `{s}`. Required when the template contains `{s}`. */
|
|
9
|
+
subdomains?: readonly string[];
|
|
10
|
+
/**
|
|
11
|
+
* Application variables, for example `{format}` or `{accessToken}`.
|
|
12
|
+
* Values are URI-encoded. Built-in variable names cannot be redefined.
|
|
13
|
+
*/
|
|
14
|
+
variables?: Readonly<Record<string, string | number>>;
|
|
15
|
+
}
|
|
16
|
+
/** Raised when a template contains an unknown variable or misses a required option. */
|
|
17
|
+
declare class TileUrlTemplateError extends Error {
|
|
18
|
+
constructor(message: string);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Variables provided for every tile.
|
|
22
|
+
*
|
|
23
|
+
* - `{z}`, `{lod}`, `{level}`: level of detail.
|
|
24
|
+
* - `{x}`: column, growing eastward.
|
|
25
|
+
* - `{y}`: XYZ row, growing southward.
|
|
26
|
+
* - `{-y}`: TMS row, growing northward.
|
|
27
|
+
* - `{quadkey}`: Bing Maps quadkey, within the face.
|
|
28
|
+
* - `{face}`: face of a multi-root pyramid, 0 for single-root pyramids.
|
|
29
|
+
* - `{s}`: subdomain, chosen as `subdomains[(x + y) % subdomains.length]` so a tile always maps to the same host.
|
|
30
|
+
*/
|
|
31
|
+
declare const BUILT_IN_TILE_URL_VARIABLES: readonly string[];
|
|
32
|
+
/** Lists the variable names of a template, without braces, in order of appearance. */
|
|
33
|
+
declare function tileUrlTemplateVariables(template: string): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Checks that every variable of a template can be expanded with the given options.
|
|
36
|
+
*
|
|
37
|
+
* @throws TileUrlTemplateError When a variable is unknown, when `{s}` has no subdomains, or when an
|
|
38
|
+
* application variable redefines a built-in variable.
|
|
39
|
+
*/
|
|
40
|
+
declare function validateTileUrlTemplate(template: string, options?: ITileUrlTemplateOptions): void;
|
|
41
|
+
/**
|
|
42
|
+
* Expands a tile URL template for an XYZ address.
|
|
43
|
+
*
|
|
44
|
+
* @throws TileUrlTemplateError See {@link validateTileUrlTemplate}.
|
|
45
|
+
* @throws RangeError When the address lies outside its pyramid level.
|
|
46
|
+
*/
|
|
47
|
+
declare function expandTileUrlTemplate(template: string, address: ITileAddress, options?: ITileUrlTemplateOptions): string;
|
|
48
|
+
|
|
49
|
+
/** Options of {@link WebTileSource}. */
|
|
50
|
+
interface IWebTileSourceOptions extends ITileUrlTemplateOptions {
|
|
51
|
+
id?: string;
|
|
52
|
+
/** URL template, expanded by {@link expandTileUrlTemplate}. */
|
|
53
|
+
urlTemplate: string;
|
|
54
|
+
/** Addressing, tile size and available levels of the source. */
|
|
55
|
+
metrics: ITileMetrics;
|
|
56
|
+
/** Where the samples of the tiles lie, required: `area` for tiles published as images, whatever they hold. */
|
|
57
|
+
registration: RasterRegistration;
|
|
58
|
+
/** Shared client, or options used to create a dedicated one. */
|
|
59
|
+
client?: TileHttpClient | ITileHttpClientOptions;
|
|
60
|
+
/** Attribution text that applications must display with the tiles. */
|
|
61
|
+
attribution?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Tile pyramid served over HTTP.
|
|
65
|
+
*
|
|
66
|
+
* The template is validated at construction, so a misspelled variable fails immediately instead of producing
|
|
67
|
+
* invalid URLs. Requests outside `[metrics.minLOD, metrics.maxLOD]` are rejected: deeper levels must be derived
|
|
68
|
+
* from an ancestor by the caller.
|
|
69
|
+
*/
|
|
70
|
+
declare class WebTileSource {
|
|
71
|
+
readonly id: string;
|
|
72
|
+
readonly urlTemplate: string;
|
|
73
|
+
readonly metrics: ITileMetrics;
|
|
74
|
+
readonly registration: RasterRegistration;
|
|
75
|
+
readonly attribution: string | undefined;
|
|
76
|
+
readonly client: TileHttpClient;
|
|
77
|
+
private readonly templateOptions;
|
|
78
|
+
/** @throws TypeError When `registration` is missing or unknown. */
|
|
79
|
+
constructor(options: IWebTileSourceOptions);
|
|
80
|
+
/** Returns `true` when the source serves this level of detail. */
|
|
81
|
+
servesLevel(lod: number): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Returns the URL of a tile.
|
|
84
|
+
*
|
|
85
|
+
* @throws RangeError When the level is not served or the address lies outside its level.
|
|
86
|
+
*/
|
|
87
|
+
urlOf(address: ITileAddress): string;
|
|
88
|
+
/** Fetches a tile. See {@link TileHttpClient.fetchTile}. */
|
|
89
|
+
fetchTile(address: ITileAddress, signal?: AbortSignal): Promise<TileFetchResult>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { BUILT_IN_TILE_URL_VARIABLES as B, type ITileUrlTemplateOptions as I, TileUrlTemplateError as T, WebTileSource as W, type IWebTileSourceOptions as a, expandTileUrlTemplate as e, tileUrlTemplateVariables as t, validateTileUrlTemplate as v };
|
package/package.json
CHANGED
|
@@ -1,6 +1,123 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@spacexr/tiles",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Renderer-neutral tiling schemes of a body: tile addressing, neighbours and topologies, Web Mercator and equi-angular cube schemes, reference surfaces, tile pyramids, URL templates, HTTP tile sources and source reprojection.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"author": "Guillaume Pelletier (SpaceXR)",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/pandaGaume/spacexr-tiling.git",
|
|
11
|
+
"directory": "packages/tiles"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/pandaGaume/spacexr-tiling#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/pandaGaume/spacexr-tiling/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"tiles",
|
|
19
|
+
"tiling",
|
|
20
|
+
"xyz",
|
|
21
|
+
"tms",
|
|
22
|
+
"quadkey",
|
|
23
|
+
"web-mercator",
|
|
24
|
+
"cube",
|
|
25
|
+
"equi-angular",
|
|
26
|
+
"spacexr"
|
|
27
|
+
],
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=20.11.0"
|
|
30
|
+
},
|
|
31
|
+
"sideEffects": false,
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"src",
|
|
35
|
+
"LICENSE",
|
|
36
|
+
"README.md"
|
|
37
|
+
],
|
|
38
|
+
"main": "./dist/index.js",
|
|
39
|
+
"module": "./dist/index.js",
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"exports": {
|
|
42
|
+
".": {
|
|
43
|
+
"types": "./dist/index.d.ts",
|
|
44
|
+
"import": "./dist/index.js",
|
|
45
|
+
"default": "./dist/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./addressing": {
|
|
48
|
+
"types": "./dist/addressing/index.d.ts",
|
|
49
|
+
"import": "./dist/addressing/index.js",
|
|
50
|
+
"default": "./dist/addressing/index.js"
|
|
51
|
+
},
|
|
52
|
+
"./bake": {
|
|
53
|
+
"types": "./dist/bake/index.d.ts",
|
|
54
|
+
"import": "./dist/bake/index.js",
|
|
55
|
+
"default": "./dist/bake/index.js"
|
|
56
|
+
},
|
|
57
|
+
"./cube": {
|
|
58
|
+
"types": "./dist/cube/index.d.ts",
|
|
59
|
+
"import": "./dist/cube/index.js",
|
|
60
|
+
"default": "./dist/cube/index.js"
|
|
61
|
+
},
|
|
62
|
+
"./datasets": {
|
|
63
|
+
"types": "./dist/datasets/index.d.ts",
|
|
64
|
+
"import": "./dist/datasets/index.js",
|
|
65
|
+
"default": "./dist/datasets/index.js"
|
|
66
|
+
},
|
|
67
|
+
"./mercator": {
|
|
68
|
+
"types": "./dist/mercator/index.d.ts",
|
|
69
|
+
"import": "./dist/mercator/index.js",
|
|
70
|
+
"default": "./dist/mercator/index.js"
|
|
71
|
+
},
|
|
72
|
+
"./pyramid": {
|
|
73
|
+
"types": "./dist/pyramid/index.d.ts",
|
|
74
|
+
"import": "./dist/pyramid/index.js",
|
|
75
|
+
"default": "./dist/pyramid/index.js"
|
|
76
|
+
},
|
|
77
|
+
"./reprojection": {
|
|
78
|
+
"types": "./dist/reprojection/index.d.ts",
|
|
79
|
+
"import": "./dist/reprojection/index.js",
|
|
80
|
+
"default": "./dist/reprojection/index.js"
|
|
81
|
+
},
|
|
82
|
+
"./sources": {
|
|
83
|
+
"types": "./dist/sources/index.d.ts",
|
|
84
|
+
"import": "./dist/sources/index.js",
|
|
85
|
+
"default": "./dist/sources/index.js"
|
|
86
|
+
},
|
|
87
|
+
"./surface": {
|
|
88
|
+
"types": "./dist/surface/index.d.ts",
|
|
89
|
+
"import": "./dist/surface/index.js",
|
|
90
|
+
"default": "./dist/surface/index.js"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"scripts": {
|
|
94
|
+
"build": "tsup",
|
|
95
|
+
"clean": "rimraf dist coverage",
|
|
96
|
+
"watch": "tsup --watch",
|
|
97
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
98
|
+
"test": "vitest run --coverage.enabled=false",
|
|
99
|
+
"test:watch": "vitest",
|
|
100
|
+
"lint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
101
|
+
"lint:fix": "eslint \"src/**/*.ts\" \"tests/**/*.ts\" --fix",
|
|
102
|
+
"format": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
103
|
+
"format:fix": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
104
|
+
"prepublishOnly": "npm run lint && npm run typecheck && npm run test && npm run build"
|
|
105
|
+
},
|
|
106
|
+
"dependencies": {
|
|
107
|
+
"@spacexr/geodesy": "0.4.0"
|
|
108
|
+
},
|
|
109
|
+
"devDependencies": {
|
|
110
|
+
"@types/node": "^20.11.0",
|
|
111
|
+
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
112
|
+
"@typescript-eslint/parser": "^7.0.0",
|
|
113
|
+
"eslint": "^8.57.0",
|
|
114
|
+
"eslint-config-prettier": "^9.1.0",
|
|
115
|
+
"eslint-plugin-prettier": "^5.5.7",
|
|
116
|
+
"prettier": "^3.9.10",
|
|
117
|
+
"rimraf": "~6.1.4",
|
|
118
|
+
"tslib": "^2.9.1",
|
|
119
|
+
"tsup": "^8.5.1",
|
|
120
|
+
"typescript": "^5.4.0",
|
|
121
|
+
"vitest": "4.1.12"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./metrics";
|
|
2
|
+
export * from "./raster-registration";
|
|
3
|
+
export * from "./tile";
|
|
4
|
+
export * from "./tile-address";
|
|
5
|
+
export * from "./tile-neighbors";
|
|
6
|
+
export * from "./tile-surface";
|
|
7
|
+
export * from "./tile-topology";
|
|
8
|
+
export * from "./tile-edge-rotation";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export enum CellCoordinateReference {
|
|
2
|
+
Center = 0,
|
|
3
|
+
NorthWest = 1,
|
|
4
|
+
NorthEast = 2,
|
|
5
|
+
SouthWest = 3,
|
|
6
|
+
SouthEast = 4,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ICartesian2 {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface IGeographic2 {
|
|
15
|
+
latitude: number;
|
|
16
|
+
longitude: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Describes the addressing, resolution and valid LOD range of a tile source.
|
|
21
|
+
*
|
|
22
|
+
* This is the renderer-neutral counterpart of SpaceXR `ITileMetrics`. Angles
|
|
23
|
+
* are expressed in degrees and sizes in pixels or metres as documented by
|
|
24
|
+
* each method.
|
|
25
|
+
*/
|
|
26
|
+
export interface ITileMetrics {
|
|
27
|
+
readonly minLOD: number;
|
|
28
|
+
readonly maxLOD: number;
|
|
29
|
+
readonly minLatitude: number;
|
|
30
|
+
readonly maxLatitude: number;
|
|
31
|
+
readonly minLongitude: number;
|
|
32
|
+
readonly maxLongitude: number;
|
|
33
|
+
readonly tileSize: number;
|
|
34
|
+
readonly cellSize: number;
|
|
35
|
+
readonly cellCoordinateReference: CellCoordinateReference;
|
|
36
|
+
readonly overlap: number;
|
|
37
|
+
|
|
38
|
+
mapSize(levelOfDetail: number): number;
|
|
39
|
+
mapScale(latitudeDegrees: number, levelOfDetail: number, pixelsPerUnit: number): number;
|
|
40
|
+
groundResolution(latitudeDegrees: number, levelOfDetail: number): number;
|
|
41
|
+
|
|
42
|
+
getLatLonToTileXY(latitudeDegrees: number, longitudeDegrees: number, levelOfDetail: number): ICartesian2;
|
|
43
|
+
getTileXYToLatLon(x: number, y: number, levelOfDetail: number): IGeographic2;
|
|
44
|
+
getLatLonToPointXY(latitudeDegrees: number, longitudeDegrees: number, levelOfDetail: number): ICartesian2;
|
|
45
|
+
getPointXYToLatLon(x: number, y: number, levelOfDetail: number): IGeographic2;
|
|
46
|
+
getTileXYToPointXY(x: number, y: number): ICartesian2;
|
|
47
|
+
getPointXYToTileXY(x: number, y: number): ICartesian2;
|
|
48
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Location of the samples of a raster over the tile extent. It belongs to the data, so every source declares it where
|
|
3
|
+
* its data is imported: there is no default.
|
|
4
|
+
*
|
|
5
|
+
* - `area`: each sample covers one pixel, so sample `i` is centred at `(i + 0.5) / size`. This is how web tiles are
|
|
6
|
+
* published, elevation and imagery alike; two neighbouring tiles never share a sample.
|
|
7
|
+
* - `point`: sample `i` lies at `i / (size - 1)`, so the first and last samples lie on the tile edges, as in the tiles of
|
|
8
|
+
* a multi-root pyramid and in stitched rasters.
|
|
9
|
+
*/
|
|
10
|
+
export type RasterRegistration = "area" | "point";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Checks the registration a source declares, for callers the compiler does not reach: a raster read with the wrong one
|
|
14
|
+
* moves half a pixel without any other sign.
|
|
15
|
+
*
|
|
16
|
+
* @throws TypeError When the registration is missing or unknown.
|
|
17
|
+
*/
|
|
18
|
+
export function assertRasterRegistration(registration: unknown): asserts registration is RasterRegistration {
|
|
19
|
+
if (registration !== "area" && registration !== "point") {
|
|
20
|
+
throw new TypeError(`A source declares its registration, "area" or "point", where its data is imported: got ${String(registration)}.`);
|
|
21
|
+
}
|
|
22
|
+
}
|