@basemaps/landing 6.27.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 +1097 -0
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/build/__test__/config.debug.test.d.ts +2 -0
- package/build/__test__/config.debug.test.d.ts.map +1 -0
- package/build/__test__/config.debug.test.js +28 -0
- package/build/__test__/config.test.d.ts +2 -0
- package/build/__test__/config.test.d.ts.map +1 -0
- package/build/__test__/config.test.js +8 -0
- package/build/__test__/geojson.test.d.ts +2 -0
- package/build/__test__/geojson.test.d.ts.map +1 -0
- package/build/__test__/geojson.test.js +42 -0
- package/build/__test__/map.config.test.d.ts +2 -0
- package/build/__test__/map.config.test.d.ts.map +1 -0
- package/build/__test__/map.config.test.js +103 -0
- package/build/__test__/tile.matrix.test.d.ts +2 -0
- package/build/__test__/tile.matrix.test.d.ts.map +1 -0
- package/build/__test__/tile.matrix.test.js +29 -0
- package/build/attribution.d.ts +48 -0
- package/build/attribution.d.ts.map +1 -0
- package/build/attribution.js +137 -0
- package/build/components/copyable.d.ts +14 -0
- package/build/components/copyable.d.ts.map +1 -0
- package/build/components/copyable.js +26 -0
- package/build/components/debug.d.ts +34 -0
- package/build/components/debug.d.ts.map +1 -0
- package/build/components/debug.js +309 -0
- package/build/components/layer.switcher.dropdown.d.ts +21 -0
- package/build/components/layer.switcher.dropdown.d.ts.map +1 -0
- package/build/components/layer.switcher.dropdown.js +68 -0
- package/build/components/layout.footer.d.ts +8 -0
- package/build/components/layout.footer.d.ts.map +1 -0
- package/build/components/layout.footer.js +23 -0
- package/build/components/layout.header.d.ts +23 -0
- package/build/components/layout.header.d.ts.map +1 -0
- package/build/components/layout.header.js +98 -0
- package/build/components/link.d.ts +17 -0
- package/build/components/link.d.ts.map +1 -0
- package/build/components/link.js +12 -0
- package/build/components/map.d.ts +31 -0
- package/build/components/map.d.ts.map +1 -0
- package/build/components/map.js +136 -0
- package/build/components/map.switcher.d.ts +21 -0
- package/build/components/map.switcher.d.ts.map +1 -0
- package/build/components/map.switcher.js +78 -0
- package/build/config.d.ts +15 -0
- package/build/config.d.ts.map +1 -0
- package/build/config.debug.d.ts +22 -0
- package/build/config.debug.d.ts.map +1 -0
- package/build/config.debug.js +62 -0
- package/build/config.js +43 -0
- package/build/config.map.d.ts +51 -0
- package/build/config.map.d.ts.map +1 -0
- package/build/config.map.js +179 -0
- package/build/global.d.ts +9 -0
- package/build/global.d.ts.map +1 -0
- package/build/global.js +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +21 -0
- package/build/split.d.ts +11 -0
- package/build/split.d.ts.map +1 -0
- package/build/split.js +45 -0
- package/build/tile.matrix.d.ts +23 -0
- package/build/tile.matrix.d.ts.map +1 -0
- package/build/tile.matrix.js +77 -0
- package/build/url.d.ts +37 -0
- package/build/url.d.ts.map +1 -0
- package/build/url.js +78 -0
- package/build/webp.d.ts +3 -0
- package/build/webp.d.ts.map +1 -0
- package/build/webp.js +32 -0
- package/package.json +107 -0
package/build/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { Component, Fragment, render } from 'preact';
|
|
3
|
+
import { Footer } from './components/layout.footer.js';
|
|
4
|
+
import { Header } from './components/layout.header.js';
|
|
5
|
+
import { Basemaps } from './components/map.js';
|
|
6
|
+
import { WindowUrl } from './url.js';
|
|
7
|
+
import { isWebpSupported } from './webp.js';
|
|
8
|
+
class Page extends Component {
|
|
9
|
+
render() {
|
|
10
|
+
return (_jsxs(Fragment, { children: [_jsx(Header, {}), _jsx(Basemaps, {}), _jsx(Footer, {})] }));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
document.addEventListener('DOMContentLoaded', async () => {
|
|
14
|
+
const canUseWebp = await isWebpSupported();
|
|
15
|
+
if (await canUseWebp)
|
|
16
|
+
WindowUrl.ImageFormat = 'webp';
|
|
17
|
+
const mainEl = document.getElementById('main');
|
|
18
|
+
if (mainEl == null)
|
|
19
|
+
throw new Error('Missing #main');
|
|
20
|
+
render(_jsx(Page, {}), mainEl);
|
|
21
|
+
});
|
package/build/split.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare enum SplitTreatment {
|
|
2
|
+
LayerSwitcherButton = "layer-switcher-button"
|
|
3
|
+
}
|
|
4
|
+
export declare const SplitIo: {
|
|
5
|
+
client: Promise<import("@splitsoftware/splitio/types/splitio").IClient | null> | null;
|
|
6
|
+
_client: import("@splitsoftware/splitio/types/splitio").IClient | null;
|
|
7
|
+
getClient(): Promise<SplitIO.IClient | null>;
|
|
8
|
+
getClientSync(): SplitIO.IClient | null;
|
|
9
|
+
getTreatment(key: SplitTreatment): string | null;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=split.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split.d.ts","sourceRoot":"","sources":["../src/split.ts"],"names":[],"mappings":"AAGA,oBAAY,cAAc;IACxB,mBAAmB,0BAA0B;CAC9C;AAED,eAAO,MAAM,OAAO;;;iBAIL,QAAQ,QAAQ,OAAO,GAAG,IAAI,CAAC;qBAwB3B,QAAQ,OAAO,GAAG,IAAI;sBAMrB,cAAc,GAAG,MAAM,GAAG,IAAI;CAKjD,CAAC"}
|
package/build/split.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { SplitFactory } from '@splitsoftware/splitio';
|
|
2
|
+
import { Config } from './config';
|
|
3
|
+
export var SplitTreatment;
|
|
4
|
+
(function (SplitTreatment) {
|
|
5
|
+
SplitTreatment["LayerSwitcherButton"] = "layer-switcher-button";
|
|
6
|
+
})(SplitTreatment || (SplitTreatment = {}));
|
|
7
|
+
export const SplitIo = {
|
|
8
|
+
client: null,
|
|
9
|
+
_client: null,
|
|
10
|
+
getClient() {
|
|
11
|
+
if (this.client != null)
|
|
12
|
+
return this.client;
|
|
13
|
+
if (Config.SplitApiKey === '') {
|
|
14
|
+
this.client = Promise.resolve(null);
|
|
15
|
+
return this.client;
|
|
16
|
+
}
|
|
17
|
+
const factory = SplitFactory({
|
|
18
|
+
core: {
|
|
19
|
+
authorizationKey: Config.SplitApiKey,
|
|
20
|
+
key: Config.ApiKey,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
this.client = new Promise((resolve) => {
|
|
24
|
+
const client = factory.client();
|
|
25
|
+
client.on(client.Event.SDK_READY, () => {
|
|
26
|
+
SplitIo._client = client;
|
|
27
|
+
resolve(client);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
return this.client;
|
|
31
|
+
},
|
|
32
|
+
getClientSync() {
|
|
33
|
+
if (this._client)
|
|
34
|
+
return this._client;
|
|
35
|
+
this.getClient();
|
|
36
|
+
return null;
|
|
37
|
+
},
|
|
38
|
+
getTreatment(key) {
|
|
39
|
+
const client = SplitIo.getClientSync();
|
|
40
|
+
if (client == null)
|
|
41
|
+
return null;
|
|
42
|
+
return client.getTreatment(key);
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
window.splitIo = SplitIo;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TileMatrixSet } from '@basemaps/geo';
|
|
2
|
+
import { Style } from 'maplibre-gl';
|
|
3
|
+
import { MapLocation } from './url.js';
|
|
4
|
+
export declare class TileGrid {
|
|
5
|
+
tileMatrix: TileMatrixSet;
|
|
6
|
+
extraZoomLevels: number;
|
|
7
|
+
constructor(tileMatrix: TileMatrixSet, extraZoomLevels?: number);
|
|
8
|
+
getStyle(layerId: string, style?: string | null): Style | string;
|
|
9
|
+
}
|
|
10
|
+
export declare function getTileGrid(id: string): TileGrid;
|
|
11
|
+
/**
|
|
12
|
+
* Transform the location coordinate between maplibre and another tileMatrix.
|
|
13
|
+
*
|
|
14
|
+
* One of the tileMatrix or targetTileMatrix has to be GoogleTms
|
|
15
|
+
*/
|
|
16
|
+
export declare function locationTransform(location: MapLocation, tileMatrix: TileMatrixSet, targetTileMatrix: TileMatrixSet): MapLocation;
|
|
17
|
+
/**
|
|
18
|
+
* Project a geojson object into the target tile matrix with use with maplibre
|
|
19
|
+
*
|
|
20
|
+
* *Warning* This will overwrite the existing object
|
|
21
|
+
*/
|
|
22
|
+
export declare function projectGeoJson(g: GeoJSON.FeatureCollection, targetTileMatrix: TileMatrixSet): void;
|
|
23
|
+
//# sourceMappingURL=tile.matrix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tile.matrix.d.ts","sourceRoot":"","sources":["../src/tile.matrix.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,aAAa,EAAE,MAAM,eAAe,CAAC;AAEvF,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAA4B,MAAM,UAAU,CAAC;AAEjE,qBAAa,QAAQ;IACnB,UAAU,EAAE,aAAa,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;gBACZ,UAAU,EAAE,aAAa,EAAE,eAAe,SAAI;IAK1D,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM;CAgBjE;AAQD,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,CAKhD;AAKD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,WAAW,EACrB,UAAU,EAAE,aAAa,EACzB,gBAAgB,EAAE,aAAa,GAC9B,WAAW,CAgBb;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,GAAG,IAAI,CAgBlG"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { GoogleTms, Nztm2000QuadTms, Nztm2000Tms } from '@basemaps/geo';
|
|
2
|
+
import { Projection } from '@basemaps/shared/build/proj/projection.js';
|
|
3
|
+
import { WindowUrl } from './url.js';
|
|
4
|
+
export class TileGrid {
|
|
5
|
+
constructor(tileMatrix, extraZoomLevels = 0) {
|
|
6
|
+
this.tileMatrix = tileMatrix;
|
|
7
|
+
this.extraZoomLevels = extraZoomLevels;
|
|
8
|
+
}
|
|
9
|
+
getStyle(layerId, style) {
|
|
10
|
+
if (layerId === 'topographic') {
|
|
11
|
+
return WindowUrl.toTileUrl("style" /* TileVectorStyle */, this.tileMatrix, layerId, style);
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
version: 8,
|
|
15
|
+
sources: {
|
|
16
|
+
basemaps: {
|
|
17
|
+
type: 'raster',
|
|
18
|
+
tiles: [WindowUrl.toTileUrl("raster" /* TileRaster */, this.tileMatrix, layerId)],
|
|
19
|
+
tileSize: 256,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
layers: [{ id: 'LINZ Raster Basemaps', type: 'raster', source: 'basemaps' }],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const Nztm2000TileGrid = new TileGrid(Nztm2000Tms, 2);
|
|
27
|
+
const Nztm2000QuadTileGrid = new TileGrid(Nztm2000QuadTms);
|
|
28
|
+
const GoogleTileGrid = new TileGrid(GoogleTms);
|
|
29
|
+
const Grids = [Nztm2000TileGrid, Nztm2000QuadTileGrid, GoogleTileGrid];
|
|
30
|
+
export function getTileGrid(id) {
|
|
31
|
+
for (const g of Grids) {
|
|
32
|
+
if (id === g.tileMatrix.identifier)
|
|
33
|
+
return g;
|
|
34
|
+
}
|
|
35
|
+
return GoogleTileGrid;
|
|
36
|
+
}
|
|
37
|
+
function isGoogle(tms) {
|
|
38
|
+
return tms.identifier === GoogleTms.identifier;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Transform the location coordinate between maplibre and another tileMatrix.
|
|
42
|
+
*
|
|
43
|
+
* One of the tileMatrix or targetTileMatrix has to be GoogleTms
|
|
44
|
+
*/
|
|
45
|
+
export function locationTransform(location, tileMatrix, targetTileMatrix) {
|
|
46
|
+
if (tileMatrix.identifier === targetTileMatrix.identifier)
|
|
47
|
+
return location;
|
|
48
|
+
if (!isGoogle(tileMatrix) && !isGoogle(targetTileMatrix)) {
|
|
49
|
+
throw new Error('Either tileMatrix or targetTileMatrix must be GoogleTms');
|
|
50
|
+
}
|
|
51
|
+
// Transform the source to the the tile it would be rendered on
|
|
52
|
+
const coords = Projection.get(tileMatrix).fromWgs84([location.lon, location.lat]);
|
|
53
|
+
const point = tileMatrix.sourceToPixels(coords[0], coords[1], Math.round(location.zoom));
|
|
54
|
+
const tile = { x: point.x / tileMatrix.tileSize, y: point.y / tileMatrix.tileSize, z: Math.round(location.zoom) };
|
|
55
|
+
// Translate the tile location into the target tile matrix
|
|
56
|
+
const source = targetTileMatrix.tileToSource(tile);
|
|
57
|
+
const lonLat = Projection.get(targetTileMatrix).toWgs84([source.x, source.y]);
|
|
58
|
+
return { lon: Math.round(lonLat[0] * 1e8) / 1e8, lat: Math.round(lonLat[1] * 1e8) / 1e8, zoom: location.zoom };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Project a geojson object into the target tile matrix with use with maplibre
|
|
62
|
+
*
|
|
63
|
+
* *Warning* This will overwrite the existing object
|
|
64
|
+
*/
|
|
65
|
+
export function projectGeoJson(g, targetTileMatrix) {
|
|
66
|
+
for (const f of g.features) {
|
|
67
|
+
if (f.geometry.type !== 'Polygon')
|
|
68
|
+
throw new Error('Only polygons supported');
|
|
69
|
+
for (const poly of f.geometry.coordinates) {
|
|
70
|
+
for (const coord of poly) {
|
|
71
|
+
const output = locationTransform({ lat: coord[1], lon: coord[0], zoom: targetTileMatrix.maxZoom }, targetTileMatrix, GoogleTms);
|
|
72
|
+
coord[0] = output.lon;
|
|
73
|
+
coord[1] = output.lat;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
package/build/url.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TileMatrixSet } from '@basemaps/geo';
|
|
2
|
+
export interface LonLat {
|
|
3
|
+
lat: number;
|
|
4
|
+
lon: number;
|
|
5
|
+
}
|
|
6
|
+
export interface MapLocation extends LonLat {
|
|
7
|
+
zoom: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const enum MapOptionType {
|
|
10
|
+
TileRaster = "raster",
|
|
11
|
+
TileVectorStyle = "style",
|
|
12
|
+
TileVectorXyz = "vector-xyz",
|
|
13
|
+
TileWmts = "tile-wmts",
|
|
14
|
+
Wmts = "wmts",
|
|
15
|
+
Attribution = "attribution"
|
|
16
|
+
}
|
|
17
|
+
export declare const WindowUrl: {
|
|
18
|
+
ImageFormat: string;
|
|
19
|
+
/**
|
|
20
|
+
* Encode a location into the window.hash
|
|
21
|
+
* Google uses ${lat},${lon},z${zoom}
|
|
22
|
+
* TODO do we want to follow this
|
|
23
|
+
*/
|
|
24
|
+
toHash(loc: MapLocation): string;
|
|
25
|
+
/**
|
|
26
|
+
* Support parsing of zooms with `z14` or `14z`
|
|
27
|
+
* @param zoom string to parse zoom from
|
|
28
|
+
*/
|
|
29
|
+
parseZoom(zoom: string | null): number;
|
|
30
|
+
/** Parse a location from window.hash if it exists */
|
|
31
|
+
fromHash(str: string): Partial<MapLocation>;
|
|
32
|
+
baseUrl(): string;
|
|
33
|
+
toBaseWmts(): string;
|
|
34
|
+
toImageryUrl(layerId: string, imageryType: string): string;
|
|
35
|
+
toTileUrl(urlType: MapOptionType, tileMatrix: TileMatrixSet, layerId: string, style?: string | null | undefined): string;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../src/url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAkB,MAAM,eAAe,CAAC;AAG9D,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAY,SAAQ,MAAM;IACzC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,0BAAkB,aAAa;IAC7B,UAAU,WAAW;IACrB,eAAe,UAAU;IACzB,aAAa,eAAe;IAC5B,QAAQ,cAAc;IACtB,IAAI,SAAS;IACb,WAAW,gBAAgB;CAC5B;AAED,eAAO,MAAM,SAAS;;IAGpB;;;;OAIG;gBACS,WAAW,GAAG,MAAM;IAIhC;;;OAGG;oBACa,MAAM,GAAG,IAAI,GAAG,MAAM;IAOtC,qDAAqD;kBACvC,MAAM,GAAG,QAAQ,WAAW,CAAC;eAmBhC,MAAM;kBAOH,MAAM;0BAKE,MAAM,eAAe,MAAM,GAAG,MAAM;uBAIvC,aAAa,cAAc,aAAa,WAAW,MAAM,sCAA0B,MAAM;CAkB7G,CAAC"}
|
package/build/url.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { TileMatrixSets } from '@basemaps/geo';
|
|
2
|
+
import { Config } from './config.js';
|
|
3
|
+
export const WindowUrl = {
|
|
4
|
+
ImageFormat: 'png',
|
|
5
|
+
/**
|
|
6
|
+
* Encode a location into the window.hash
|
|
7
|
+
* Google uses ${lat},${lon},z${zoom}
|
|
8
|
+
* TODO do we want to follow this
|
|
9
|
+
*/
|
|
10
|
+
toHash(loc) {
|
|
11
|
+
return `#@${loc.lat.toFixed(7)},${loc.lon.toFixed(7)},z${loc.zoom}`;
|
|
12
|
+
},
|
|
13
|
+
/**
|
|
14
|
+
* Support parsing of zooms with `z14` or `14z`
|
|
15
|
+
* @param zoom string to parse zoom from
|
|
16
|
+
*/
|
|
17
|
+
parseZoom(zoom) {
|
|
18
|
+
if (zoom == null || zoom === '')
|
|
19
|
+
return NaN;
|
|
20
|
+
if (zoom.startsWith('z'))
|
|
21
|
+
return parseFloat(zoom.slice(1));
|
|
22
|
+
if (zoom.endsWith('z'))
|
|
23
|
+
return parseFloat(zoom);
|
|
24
|
+
return NaN;
|
|
25
|
+
},
|
|
26
|
+
/** Parse a location from window.hash if it exists */
|
|
27
|
+
fromHash(str) {
|
|
28
|
+
const output = {};
|
|
29
|
+
const hash = str.replace('#@', '');
|
|
30
|
+
const [latS, lonS, zoomS] = hash.split(',');
|
|
31
|
+
const lat = parseFloat(latS);
|
|
32
|
+
const lon = parseFloat(lonS);
|
|
33
|
+
if (!isNaN(lat) && !isNaN(lon)) {
|
|
34
|
+
output.lat = lat;
|
|
35
|
+
output.lon = lon;
|
|
36
|
+
}
|
|
37
|
+
const newZoom = WindowUrl.parseZoom(zoomS);
|
|
38
|
+
if (!isNaN(newZoom)) {
|
|
39
|
+
output.zoom = newZoom;
|
|
40
|
+
}
|
|
41
|
+
return output;
|
|
42
|
+
},
|
|
43
|
+
baseUrl() {
|
|
44
|
+
const baseUrl = Config.BaseUrl;
|
|
45
|
+
if (baseUrl === '')
|
|
46
|
+
return window.location.origin;
|
|
47
|
+
if (!baseUrl.startsWith('http'))
|
|
48
|
+
throw new Error('BaseURL must start with http(s)://');
|
|
49
|
+
return baseUrl;
|
|
50
|
+
},
|
|
51
|
+
toBaseWmts() {
|
|
52
|
+
const api = Config.ApiKey == null || Config.ApiKey === '' ? '' : `?api=${Config.ApiKey}`;
|
|
53
|
+
return `${this.baseUrl()}/v1/tiles/WMTSCapabilities.xml${api}`;
|
|
54
|
+
},
|
|
55
|
+
toImageryUrl(layerId, imageryType) {
|
|
56
|
+
return `${this.baseUrl()}/v1/imagery/${layerId}/${imageryType}`;
|
|
57
|
+
},
|
|
58
|
+
toTileUrl(urlType, tileMatrix, layerId, style) {
|
|
59
|
+
const api = Config.ApiKey == null || Config.ApiKey === '' ? '' : `?api=${Config.ApiKey}`;
|
|
60
|
+
const isDefaultTileMatrix = TileMatrixSets.get(tileMatrix.projection).identifier === tileMatrix.identifier;
|
|
61
|
+
const projectionPath = isDefaultTileMatrix ? tileMatrix.projection.toEpsgString() : tileMatrix.identifier;
|
|
62
|
+
const baseTileUrl = `${this.baseUrl()}/v1/tiles/${layerId}/${projectionPath}`;
|
|
63
|
+
if (urlType === "raster" /* TileRaster */)
|
|
64
|
+
return `${baseTileUrl}/{z}/{x}/{y}.${WindowUrl.ImageFormat}${api}`;
|
|
65
|
+
if (urlType === "vector-xyz" /* TileVectorXyz */)
|
|
66
|
+
return `${baseTileUrl}/{z}/{x}/{y}.pbf${api}`;
|
|
67
|
+
if (urlType === "style" /* TileVectorStyle */)
|
|
68
|
+
return `${baseTileUrl}/style/${style}.json${api}`;
|
|
69
|
+
if (urlType === "wmts" /* Wmts */)
|
|
70
|
+
return `${baseTileUrl}/WMTSCapabilities.xml${api}`;
|
|
71
|
+
if (urlType === "attribution" /* Attribution */)
|
|
72
|
+
return `${baseTileUrl}/attribution.json${api}`;
|
|
73
|
+
if (urlType === "tile-wmts" /* TileWmts */) {
|
|
74
|
+
return `${baseTileUrl}/{TileMatrix}/{TileCol}/{TileRow}.${WindowUrl.ImageFormat}${api}`;
|
|
75
|
+
}
|
|
76
|
+
throw new Error('Unknown url type: ' + urlType);
|
|
77
|
+
},
|
|
78
|
+
};
|
package/build/webp.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webp.d.ts","sourceRoot":"","sources":["../src/webp.ts"],"names":[],"mappings":"AA6BA,sDAAsD;AACtD,wBAAgB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAKlD"}
|
package/build/webp.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const WebpImage = `data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAwA0JaQAA3AA/vuUAAA=`;
|
|
2
|
+
// Source https://stackoverflow.com/questions/5573096/detecting-webp-support
|
|
3
|
+
function isCanvasWebpSupported() {
|
|
4
|
+
const elem = document.createElement('canvas');
|
|
5
|
+
if (!!(elem.getContext && elem.getContext('2d'))) {
|
|
6
|
+
// was able or not to get WebP representation
|
|
7
|
+
return elem.toDataURL('image/webp').indexOf('data:image/webp') === 0;
|
|
8
|
+
}
|
|
9
|
+
// very old browser like IE 8, canvas not supported
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Is this runtime able to support webp
|
|
14
|
+
*/
|
|
15
|
+
function isWebpImageSupported() {
|
|
16
|
+
// Some browsers (firefox) support rendering webp but not creating with canvas
|
|
17
|
+
const img = new Image();
|
|
18
|
+
const promise = new Promise((resolve) => {
|
|
19
|
+
img.onload = () => resolve(true);
|
|
20
|
+
img.onerror = () => resolve(false);
|
|
21
|
+
});
|
|
22
|
+
img.src = WebpImage;
|
|
23
|
+
return promise;
|
|
24
|
+
}
|
|
25
|
+
/** Is WebP able to be rendered in this environment */
|
|
26
|
+
export function isWebpSupported() {
|
|
27
|
+
return new Promise((resolve) => {
|
|
28
|
+
if (isCanvasWebpSupported())
|
|
29
|
+
return resolve(true);
|
|
30
|
+
isWebpImageSupported().then(resolve);
|
|
31
|
+
});
|
|
32
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@basemaps/landing",
|
|
3
|
+
"version": "6.27.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/linz/basemaps.git",
|
|
7
|
+
"directory": "packages/landing"
|
|
8
|
+
},
|
|
9
|
+
"author": {
|
|
10
|
+
"name": "Land Information New Zealand",
|
|
11
|
+
"url": "https://linz.govt.nz",
|
|
12
|
+
"organization": true
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"main": "./build/index.js",
|
|
20
|
+
"types": "./build/index.d.ts",
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "ospec --globs 'build/**/*.test.js'",
|
|
23
|
+
"start": "TILE_HOST=${TILE_HOST:-https://dev.basemaps.linz.govt.nz} nodemon ../../scripts/bundle.js -e 'ts html css' -i 'dist/*' -- package.json",
|
|
24
|
+
"bundle": "../../scripts/bundle.js package.json",
|
|
25
|
+
"deploy:deploy": "node scripts/deploy.js"
|
|
26
|
+
},
|
|
27
|
+
"browserslist": [
|
|
28
|
+
"last 2 Chrome versions"
|
|
29
|
+
],
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@basemaps/attribution": "^6.26.0",
|
|
32
|
+
"@basemaps/geo": "^6.26.0",
|
|
33
|
+
"@basemaps/infra": "^6.27.0",
|
|
34
|
+
"@basemaps/shared": "^6.27.0",
|
|
35
|
+
"@linzjs/lui": "^10.11.3",
|
|
36
|
+
"@servie/events": "^3.0.0",
|
|
37
|
+
"@splitsoftware/splitio": "^10.16.1",
|
|
38
|
+
"@types/geojson": "^7946.0.7",
|
|
39
|
+
"@types/proj4": "^2.5.0",
|
|
40
|
+
"maplibre-gl": "^1.14.1-rc.2",
|
|
41
|
+
"preact": "^10.5.15",
|
|
42
|
+
"proj4": "^2.6.2",
|
|
43
|
+
"ulid": "^2.3.0"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"dist",
|
|
50
|
+
"build"
|
|
51
|
+
],
|
|
52
|
+
"bundle": [
|
|
53
|
+
{
|
|
54
|
+
"entry": "../../node_modules/@linzjs/lui/dist/assets/images/nz-govt-logo-rev.svg",
|
|
55
|
+
"outfile": "dist/assets/logo-nz-govt.svg"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"entry": "../../node_modules/@linzjs/lui/dist/assets/images/linz-logo-col-n-white-txt.svg",
|
|
59
|
+
"outfile": "dist/assets/logo-linz.svg"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"entry": "../../node_modules/@linzjs/lui/dist/assets/fonts",
|
|
63
|
+
"outfile": "dist/assets/fonts"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"entry": "static",
|
|
67
|
+
"outfile": "dist"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"entry": "../attribution/src/attribution.index.ts",
|
|
71
|
+
"outfile": "dist/lib/attribution.js",
|
|
72
|
+
"platform": "browser"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"entry": "static/examples/index.openlayers.attribution.wmts.3857.html",
|
|
76
|
+
"outdir": "dist/examples",
|
|
77
|
+
"subresourceHash": {
|
|
78
|
+
"$ATTR_FILE": "../lib/attribution.js"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"entry": "src/index.tsx",
|
|
83
|
+
"env": {
|
|
84
|
+
"API_KEY": null,
|
|
85
|
+
"GOOGLE_ANALYTICS": null,
|
|
86
|
+
"TILE_HOST": null,
|
|
87
|
+
"SPLIT_IO_KEY": null
|
|
88
|
+
},
|
|
89
|
+
"platform": "browser"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"entry": "static/index.css",
|
|
93
|
+
"external": [
|
|
94
|
+
"@linzjs/lui/dist/lui.css",
|
|
95
|
+
"maplibre-gl/dist/maplibre-gl.css"
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"entry": "static/index.html",
|
|
100
|
+
"subresourceHash": {
|
|
101
|
+
"$JS_FILE": "index.js",
|
|
102
|
+
"$CSS_FILE": "index.css"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"gitHead": "c6aa61c20503cbc7f04cf31927f4e2b95aed34cb"
|
|
107
|
+
}
|