@maptrip/map-tiles 1.2.0 → 1.3.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/README.md +5 -0
- package/dist/api-extensions/google/MapTripGoogleMapType.d.ts +1 -1
- package/dist/api-extensions/leaflet/MapTripLeafletGridLayer.d.ts +33 -1
- package/dist/api-extensions/openlayers/MapTripOpenLayersSource.d.ts +7 -0
- package/dist/core/VectorTileFactory.d.ts +1 -1
- package/dist/core/VectorTileRenderer.d.ts +1 -1
- package/dist/core/rendering_config_grayscale.d.ts +34 -0
- package/dist/map-tiles.d.ts +3 -2
- package/dist/map-tiles.js +1065 -865
- package/dist/map-tiles.js.map +1 -1
- package/dist/types/interfaces.d.ts +9 -9
- package/dist/util/MapReleaseFetcher.d.ts +12 -0
- package/lib/api-extensions/google/MapTripGoogleMapType.ts +4 -1
- package/lib/api-extensions/leaflet/MapTripLeafletGridLayer.ts +119 -23
- package/lib/api-extensions/openlayers/MapTripOpenLayersSource.ts +37 -0
- package/lib/core/VectorTileFactory.ts +17 -13
- package/lib/core/VectorTileRenderer.ts +13 -5
- package/lib/core/rendering_config_grayscale.ts +1126 -1104
- package/lib/main.ts +3 -2
- package/lib/types/interfaces.ts +11 -10
- package/lib/util/MapReleaseFetcher.ts +82 -0
- package/package.json +7 -6
package/lib/main.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type * as types from "./types/interfaces.js";
|
|
2
1
|
import { VectorTileFactory } from "./core/VectorTileFactory.js";
|
|
3
2
|
import { RENDERING_CONFIG_DEFAULT } from "./core/rendering_config_default.js";
|
|
4
3
|
import { RENDERING_CONFIG_GRAYSCALE } from "./core/rendering_config_grayscale.js";
|
|
5
4
|
import { RENDERING_CONFIG_TRAFFIC } from "./core/rendering_config_traffic.js";
|
|
6
5
|
|
|
6
|
+
import { MapReleaseFetcher } from "./util/MapReleaseFetcher.js";
|
|
7
|
+
|
|
7
8
|
import { MapTripGoogleMapType } from "./api-extensions/google/MapTripGoogleMapType.js";
|
|
8
9
|
import { MapTripLeafletGridLayer } from "./api-extensions/leaflet/MapTripLeafletGridLayer.js";
|
|
9
10
|
import { MapTripOpenLayersSource } from "./api-extensions/openlayers/MapTripOpenLayersSource.js";
|
|
@@ -13,8 +14,8 @@ export {
|
|
|
13
14
|
RENDERING_CONFIG_DEFAULT,
|
|
14
15
|
RENDERING_CONFIG_GRAYSCALE,
|
|
15
16
|
RENDERING_CONFIG_TRAFFIC,
|
|
17
|
+
MapReleaseFetcher,
|
|
16
18
|
MapTripLeafletGridLayer,
|
|
17
19
|
MapTripGoogleMapType,
|
|
18
20
|
MapTripOpenLayersSource,
|
|
19
|
-
types,
|
|
20
21
|
};
|
package/lib/types/interfaces.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface MapTilesProperties {
|
|
|
12
12
|
maxZoom?: number;
|
|
13
13
|
name?: string;
|
|
14
14
|
NAME?: string;
|
|
15
|
+
releaseDate?: boolean | false;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export interface Renderer {
|
|
@@ -36,14 +37,7 @@ export interface Renderer {
|
|
|
36
37
|
dy: number;
|
|
37
38
|
};
|
|
38
39
|
filters?: Filter[];
|
|
39
|
-
[key: string]: any;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface Filter {
|
|
43
|
-
interface: string;
|
|
44
|
-
key: string;
|
|
45
|
-
value?: any;
|
|
46
|
-
type: string;
|
|
40
|
+
// [key: string]: any;
|
|
47
41
|
}
|
|
48
42
|
|
|
49
43
|
export interface RENDERING_CONFIG {
|
|
@@ -56,6 +50,13 @@ export interface RENDERING_CONFIG {
|
|
|
56
50
|
renderers: { [key: string]: Renderer[] };
|
|
57
51
|
}
|
|
58
52
|
|
|
53
|
+
export interface Filter {
|
|
54
|
+
interface: string;
|
|
55
|
+
key: string;
|
|
56
|
+
value?: any;
|
|
57
|
+
type: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
59
60
|
export interface PolylineTextStyle {
|
|
60
61
|
size: number;
|
|
61
62
|
color: string;
|
|
@@ -81,8 +82,8 @@ export interface PolygonStyle {
|
|
|
81
82
|
opacity?: number | undefined;
|
|
82
83
|
outlineColor?: string | undefined;
|
|
83
84
|
outlineWidth?: number | undefined;
|
|
84
|
-
url
|
|
85
|
-
font
|
|
85
|
+
url?: string | undefined;
|
|
86
|
+
font?: string | undefined;
|
|
86
87
|
fontStyle?: string | undefined;
|
|
87
88
|
fontWeight?: string | undefined;
|
|
88
89
|
size?: number | undefined;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export class MapReleaseFetcher {
|
|
2
|
+
private _baseUrl: string;
|
|
3
|
+
private _token: string;
|
|
4
|
+
|
|
5
|
+
private _tomtom: Promise<string | null> | null = null;
|
|
6
|
+
private _osm: Promise<string | null> | null = null;
|
|
7
|
+
private _here: Promise<string | null> | null = null;
|
|
8
|
+
|
|
9
|
+
constructor(token: string) {
|
|
10
|
+
this._baseUrl =
|
|
11
|
+
"https://v1.maptrip.de/?CMD=GETFILE&PROJECT=${project}&RELATIVEPATH=/data/mapset/data/routing_geocoder/admin.bin&acao=true";
|
|
12
|
+
this._token = token;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
updateUrl(provider: string) {
|
|
16
|
+
if (provider === "tomtom") {
|
|
17
|
+
this._baseUrl = this._baseUrl.replace("${project}", "TomTom_latest");
|
|
18
|
+
} else if (provider === "openstreetmap") {
|
|
19
|
+
this._baseUrl = this._baseUrl.replace("${project}", "OSM_latest");
|
|
20
|
+
} else {
|
|
21
|
+
this._baseUrl = this._baseUrl.replace("${project}", "HERE_latest");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async getRelease(provider: string) {
|
|
26
|
+
const providerLowercase = provider.toLowerCase();
|
|
27
|
+
if (providerLowercase === "tomtom") {
|
|
28
|
+
if (!this._tomtom) {
|
|
29
|
+
this._tomtom = this.fetchAndExtractRelease(providerLowercase);
|
|
30
|
+
}
|
|
31
|
+
return this._tomtom;
|
|
32
|
+
} else if (providerLowercase === "here") {
|
|
33
|
+
if (!this._here) {
|
|
34
|
+
this._here = this.fetchAndExtractRelease(providerLowercase);
|
|
35
|
+
}
|
|
36
|
+
return this._here;
|
|
37
|
+
} else {
|
|
38
|
+
if (!this._osm) {
|
|
39
|
+
this._osm = this.fetchAndExtractRelease(providerLowercase);
|
|
40
|
+
}
|
|
41
|
+
return this._osm;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async fetchAndExtractRelease(provider: string): Promise<string | null> {
|
|
46
|
+
const providerVar = this.updateUrl(provider);
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
var xhr = new XMLHttpRequest();
|
|
49
|
+
xhr.onreadystatechange = () => {
|
|
50
|
+
if (xhr.readyState !== XMLHttpRequest.DONE) return;
|
|
51
|
+
|
|
52
|
+
if (xhr.status === 200) {
|
|
53
|
+
const text = new TextDecoder("latin1").decode(xhr.response);
|
|
54
|
+
const textString = this.extractTargetString(text);
|
|
55
|
+
const release = ` ${textString}`;
|
|
56
|
+
|
|
57
|
+
if (provider === "tomtom") {
|
|
58
|
+
this._tomtom = Promise.resolve(release);
|
|
59
|
+
} else if (provider === "here") {
|
|
60
|
+
this._here = Promise.resolve(release);
|
|
61
|
+
} else if (provider === "openstreetmap") {
|
|
62
|
+
this._osm = Promise.resolve(release);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
resolve(release);
|
|
66
|
+
} else {
|
|
67
|
+
reject(`Error fetching: ${xhr.status}`);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
xhr.open("GET", this._baseUrl, true);
|
|
71
|
+
xhr.setRequestHeader("Authorization", `Bearer ${this._token}`);
|
|
72
|
+
xhr.setRequestHeader("Accept", "*/*");
|
|
73
|
+
xhr.setRequestHeader("Content-Type", "application/octet-stream");
|
|
74
|
+
xhr.responseType = "arraybuffer";
|
|
75
|
+
xhr.send(null);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
private extractTargetString(text: string): string | null {
|
|
79
|
+
const match = text.match(/2\d{3}Q[1-4]/);
|
|
80
|
+
return match ? match[0] : null;
|
|
81
|
+
}
|
|
82
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maptrip/map-tiles",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "API to use MapTrip map tiles in other map APIs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"map",
|
|
@@ -18,32 +18,33 @@
|
|
|
18
18
|
"main": "dist/map-tiles.js",
|
|
19
19
|
"types": "dist/map-tiles.d.ts",
|
|
20
20
|
"scripts": {
|
|
21
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
22
21
|
"dev": "vite src",
|
|
23
22
|
"prepublish": "tsc",
|
|
24
|
-
"build": "tsc && vite build"
|
|
23
|
+
"build": "tsc && vite build",
|
|
24
|
+
"publish": "tsc && vite build && npm login --scope=@maptrip && npm publish"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@googlemaps/js-api-loader": "^1.16.2",
|
|
28
28
|
"@types/google.maps": "^3.55.4",
|
|
29
|
-
"@types/leaflet": "^1.9.8",
|
|
30
29
|
"@types/rtree": "^1.4.30",
|
|
31
30
|
"eslint": "^8.52.0",
|
|
32
|
-
"leaflet": "~1.9.x",
|
|
33
31
|
"ol": "~8.2.x",
|
|
34
32
|
"typescript": "^5.4.5",
|
|
35
33
|
"vite": "^4.5.0"
|
|
36
34
|
},
|
|
37
35
|
"dependencies": {
|
|
38
36
|
"@types/geojson": "^7946.0.14",
|
|
37
|
+
|
|
39
38
|
"@types/webfontloader": "^1.6.38",
|
|
39
|
+
|
|
40
40
|
"rtree": "^1.4.2",
|
|
41
41
|
"vite-plugin-dts": "^3.9.0",
|
|
42
42
|
"webfontloader": "^1.6.28"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
+
"leaflet": "^1.9.x",
|
|
46
|
+
"@types/leaflet": "^1.9.12",
|
|
45
47
|
"@googlemaps/js-api-loader": "^1.16.2",
|
|
46
|
-
"leaflet": "~1.9.x",
|
|
47
48
|
"ol": "~8.2.x"
|
|
48
49
|
},
|
|
49
50
|
"directories": {
|