@elastic/ems-client 8.0.0 → 8.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/CHANGELOG.md +7 -0
- package/package.json +2 -1
- package/src/ems_client.ts +1 -1
- package/src/index.ts +1 -1
- package/src/tms_service.ts +31 -53
- package/target/index.d.ts +1 -1
- package/target/node/ems_client.js +1 -1
- package/target/node/index.js +12 -0
- package/target/node/tms_service.js +22 -19
- package/target/tms_service.d.ts +10 -30
- package/target/web/ems_client.js +1 -1
- package/target/web/index.js +1 -1
- package/target/web/tms_service.js +42 -41
- package/test/ems_client.test.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file.
|
|
|
3
3
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
5
5
|
|
|
6
|
+
## [8.1.0] - 2021-11-09
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
- Default EMS version is 8.1
|
|
10
|
+
- Export EmsSprite and EmsSpritesheet types
|
|
11
|
+
- Inherit types from maplibre-gl
|
|
12
|
+
|
|
6
13
|
## [8.0.0] - 2021-10-20
|
|
7
14
|
|
|
8
15
|
### Changed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elastic/ems-client",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "JavaScript client library for the Elastic Maps Service",
|
|
5
5
|
"main": "target/node/index.js",
|
|
6
6
|
"browser": "target/web/index.js",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"eslint-plugin-prettier": "^3.1.3",
|
|
64
64
|
"husky": "^4.2.5",
|
|
65
65
|
"jest": "^26.4.0",
|
|
66
|
+
"maplibre-gl": "^1.15.2",
|
|
66
67
|
"node-fetch": "^2.6.1",
|
|
67
68
|
"prettier": "^2.0.5",
|
|
68
69
|
"ts-jest": "^26.2.0",
|
package/src/ems_client.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { toAbsoluteUrl } from './utils';
|
|
|
16
16
|
import { ParsedUrlQueryInput } from 'querystring';
|
|
17
17
|
import LRUCache from 'lru-cache';
|
|
18
18
|
|
|
19
|
-
const DEFAULT_EMS_VERSION = '8.
|
|
19
|
+
const DEFAULT_EMS_VERSION = '8.1';
|
|
20
20
|
|
|
21
21
|
type URLMeaningfulParts = {
|
|
22
22
|
auth?: string | null;
|
package/src/index.ts
CHANGED
package/src/tms_service.ts
CHANGED
|
@@ -6,52 +6,31 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import _ from 'lodash';
|
|
9
|
+
import { Style as MapLibreStyle, VectorSource as MapLibreVectorSource } from 'maplibre-gl';
|
|
9
10
|
import { EMSClient, EmsTmsFormat, TMSServiceConfig } from './ems_client';
|
|
10
11
|
import { AbstractEmsService } from './ems_service';
|
|
11
12
|
|
|
12
|
-
type
|
|
13
|
-
type: 'vector';
|
|
14
|
-
url: string;
|
|
15
|
-
tiles: string[];
|
|
16
|
-
bounds?: number[];
|
|
17
|
-
scheme?: 'xyz' | 'tms';
|
|
18
|
-
minzoom?: number;
|
|
19
|
-
maxzoom?: number;
|
|
20
|
-
attribution?: string;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type EmsVectorSources = {
|
|
24
|
-
[sourceName: string]: EmsVectorSource;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
type EmsVectorStyle = {
|
|
28
|
-
sources: EmsVectorSources;
|
|
29
|
-
sprite: string;
|
|
30
|
-
glyphs: string;
|
|
31
|
-
bearing?: number;
|
|
32
|
-
center?: number[];
|
|
33
|
-
layers?: unknown[];
|
|
34
|
-
metadata?: unknown;
|
|
35
|
-
name?: string;
|
|
36
|
-
pitch?: number;
|
|
37
|
-
light?: unknown;
|
|
38
|
-
transition?: unknown;
|
|
39
|
-
version: number;
|
|
40
|
-
zoom?: number;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
type EmsSprite = {
|
|
13
|
+
export type EmsSprite = {
|
|
44
14
|
height: number;
|
|
45
15
|
pixelRatio: number;
|
|
46
16
|
width: number;
|
|
47
17
|
x: number;
|
|
48
18
|
y: number;
|
|
19
|
+
sdf?: boolean;
|
|
49
20
|
};
|
|
50
21
|
|
|
51
|
-
type EmsSpriteSheet = {
|
|
22
|
+
export type EmsSpriteSheet = {
|
|
52
23
|
[spriteName: string]: EmsSprite;
|
|
53
24
|
};
|
|
54
25
|
|
|
26
|
+
type EmsVectorSources = {
|
|
27
|
+
[sourceName: string]: MapLibreVectorSource;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type EmsVectorStyle = MapLibreStyle & {
|
|
31
|
+
sources: EmsVectorSources;
|
|
32
|
+
};
|
|
33
|
+
|
|
55
34
|
type EmsRasterStyle = {
|
|
56
35
|
tilejson: string;
|
|
57
36
|
name: string;
|
|
@@ -98,19 +77,20 @@ export class TMSService extends AbstractEmsService {
|
|
|
98
77
|
const { sources } = vectorJson;
|
|
99
78
|
for (const sourceName of Object.getOwnPropertyNames(sources)) {
|
|
100
79
|
const { url } = sources[sourceName];
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
80
|
+
if (url) {
|
|
81
|
+
const sourceUrl = this._proxyPath + this._getAbsoluteUrl(url);
|
|
82
|
+
const extendedUrl = this._emsClient.extendUrlWithParams(sourceUrl);
|
|
83
|
+
const sourceJson = await this._emsClient.getManifest<MapLibreVectorSource>(extendedUrl);
|
|
84
|
+
const tiles = sourceJson?.tiles?.map((tileUrl) => {
|
|
85
|
+
const directUrl = this._proxyPath + this._getAbsoluteUrl(tileUrl);
|
|
86
|
+
return this._emsClient.extendUrlWithParams(directUrl);
|
|
87
|
+
});
|
|
88
|
+
inlinedSources[sourceName] = {
|
|
89
|
+
...sourceJson,
|
|
90
|
+
type: 'vector',
|
|
91
|
+
tiles,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
114
94
|
}
|
|
115
95
|
return {
|
|
116
96
|
...vectorJson,
|
|
@@ -155,11 +135,9 @@ export class TMSService extends AbstractEmsService {
|
|
|
155
135
|
|
|
156
136
|
async getUrlTemplateForVector(sourceId: string): Promise<string> {
|
|
157
137
|
const tileJson = await this._getVectorStyleJsonInlined();
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (tileJson.sources[sourceId] && tileJson.sources[sourceId].tiles) {
|
|
162
|
-
const directUrl = this._proxyPath + this._getAbsoluteUrl(tileJson.sources[sourceId].tiles[0]);
|
|
138
|
+
const url = tileJson?.sources[sourceId]?.tiles?.pop();
|
|
139
|
+
if (url) {
|
|
140
|
+
const directUrl = this._proxyPath + this._getAbsoluteUrl(url);
|
|
163
141
|
return this._emsClient.extendUrlWithParams(directUrl);
|
|
164
142
|
} else {
|
|
165
143
|
return '';
|
|
@@ -271,7 +249,7 @@ export class TMSService extends AbstractEmsService {
|
|
|
271
249
|
|
|
272
250
|
private async _getSpriteSheetRootPath(): Promise<string> {
|
|
273
251
|
const vectorStyleJson = await this._getVectorStyleJsonRaw();
|
|
274
|
-
if (vectorStyleJson) {
|
|
252
|
+
if (vectorStyleJson?.sprite) {
|
|
275
253
|
return this._proxyPath + this._getAbsoluteUrl(vectorStyleJson.sprite);
|
|
276
254
|
} else {
|
|
277
255
|
return '';
|
|
@@ -280,7 +258,7 @@ export class TMSService extends AbstractEmsService {
|
|
|
280
258
|
|
|
281
259
|
private async _getUrlTemplateForGlyphs(): Promise<string> {
|
|
282
260
|
const vectorStyleJson = await this._getVectorStyleJsonRaw();
|
|
283
|
-
if (vectorStyleJson) {
|
|
261
|
+
if (vectorStyleJson?.glyphs) {
|
|
284
262
|
return this._proxyPath + this._getAbsoluteUrl(vectorStyleJson.glyphs);
|
|
285
263
|
} else {
|
|
286
264
|
return '';
|
package/target/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
23
23
|
|
|
24
24
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
25
|
|
|
26
|
-
const DEFAULT_EMS_VERSION = '8.
|
|
26
|
+
const DEFAULT_EMS_VERSION = '8.1';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* plugins cannot have upstream dependencies on core/*-kibana.
|
package/target/node/index.js
CHANGED
|
@@ -9,6 +9,18 @@ Object.defineProperty(exports, "EMSClient", {
|
|
|
9
9
|
return _ems_client.EMSClient;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "EmsSprite", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _tms_service.EmsSprite;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "EmsSpriteSheet", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _tms_service.EmsSpriteSheet;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
12
24
|
Object.defineProperty(exports, "FileLayer", {
|
|
13
25
|
enumerable: true,
|
|
14
26
|
get: function () {
|
|
@@ -59,20 +59,24 @@ class TMSService extends _ems_service.AbstractEmsService {
|
|
|
59
59
|
url
|
|
60
60
|
} = sources[sourceName];
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
if (url) {
|
|
63
|
+
var _sourceJson$tiles;
|
|
63
64
|
|
|
64
|
-
|
|
65
|
+
const sourceUrl = this._proxyPath + this._getAbsoluteUrl(url);
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
const extendedTileUrls = sourceJson.tiles.map(tileUrl => {
|
|
68
|
-
const url = this._proxyPath + this._getAbsoluteUrl(tileUrl);
|
|
67
|
+
const extendedUrl = this._emsClient.extendUrlWithParams(sourceUrl);
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
const sourceJson = await this._emsClient.getManifest(extendedUrl);
|
|
70
|
+
const tiles = sourceJson === null || sourceJson === void 0 ? void 0 : (_sourceJson$tiles = sourceJson.tiles) === null || _sourceJson$tiles === void 0 ? void 0 : _sourceJson$tiles.map(tileUrl => {
|
|
71
|
+
const directUrl = this._proxyPath + this._getAbsoluteUrl(tileUrl);
|
|
72
|
+
|
|
73
|
+
return this._emsClient.extendUrlWithParams(directUrl);
|
|
74
|
+
});
|
|
75
|
+
inlinedSources[sourceName] = { ...sourceJson,
|
|
76
|
+
type: 'vector',
|
|
77
|
+
tiles
|
|
78
|
+
};
|
|
79
|
+
}
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
return { ...vectorJson,
|
|
@@ -116,14 +120,13 @@ class TMSService extends _ems_service.AbstractEmsService {
|
|
|
116
120
|
}
|
|
117
121
|
|
|
118
122
|
async getUrlTemplateForVector(sourceId) {
|
|
119
|
-
|
|
123
|
+
var _tileJson$sources$sou, _tileJson$sources$sou2;
|
|
120
124
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
125
|
+
const tileJson = await this._getVectorStyleJsonInlined();
|
|
126
|
+
const url = tileJson === null || tileJson === void 0 ? void 0 : (_tileJson$sources$sou = tileJson.sources[sourceId]) === null || _tileJson$sources$sou === void 0 ? void 0 : (_tileJson$sources$sou2 = _tileJson$sources$sou.tiles) === null || _tileJson$sources$sou2 === void 0 ? void 0 : _tileJson$sources$sou2.pop();
|
|
124
127
|
|
|
125
|
-
if (
|
|
126
|
-
const directUrl = this._proxyPath + this._getAbsoluteUrl(
|
|
128
|
+
if (url) {
|
|
129
|
+
const directUrl = this._proxyPath + this._getAbsoluteUrl(url);
|
|
127
130
|
|
|
128
131
|
return this._emsClient.extendUrlWithParams(directUrl);
|
|
129
132
|
} else {
|
|
@@ -241,7 +244,7 @@ class TMSService extends _ems_service.AbstractEmsService {
|
|
|
241
244
|
async _getSpriteSheetRootPath() {
|
|
242
245
|
const vectorStyleJson = await this._getVectorStyleJsonRaw();
|
|
243
246
|
|
|
244
|
-
if (vectorStyleJson) {
|
|
247
|
+
if (vectorStyleJson !== null && vectorStyleJson !== void 0 && vectorStyleJson.sprite) {
|
|
245
248
|
return this._proxyPath + this._getAbsoluteUrl(vectorStyleJson.sprite);
|
|
246
249
|
} else {
|
|
247
250
|
return '';
|
|
@@ -251,7 +254,7 @@ class TMSService extends _ems_service.AbstractEmsService {
|
|
|
251
254
|
async _getUrlTemplateForGlyphs() {
|
|
252
255
|
const vectorStyleJson = await this._getVectorStyleJsonRaw();
|
|
253
256
|
|
|
254
|
-
if (vectorStyleJson) {
|
|
257
|
+
if (vectorStyleJson !== null && vectorStyleJson !== void 0 && vectorStyleJson.glyphs) {
|
|
255
258
|
return this._proxyPath + this._getAbsoluteUrl(vectorStyleJson.glyphs);
|
|
256
259
|
} else {
|
|
257
260
|
return '';
|
package/target/tms_service.d.ts
CHANGED
|
@@ -1,43 +1,23 @@
|
|
|
1
|
+
import { Style as MapLibreStyle, VectorSource as MapLibreVectorSource } from 'maplibre-gl';
|
|
1
2
|
import { EMSClient, TMSServiceConfig } from './ems_client';
|
|
2
3
|
import { AbstractEmsService } from './ems_service';
|
|
3
|
-
declare type
|
|
4
|
-
type: 'vector';
|
|
5
|
-
url: string;
|
|
6
|
-
tiles: string[];
|
|
7
|
-
bounds?: number[];
|
|
8
|
-
scheme?: 'xyz' | 'tms';
|
|
9
|
-
minzoom?: number;
|
|
10
|
-
maxzoom?: number;
|
|
11
|
-
attribution?: string;
|
|
12
|
-
};
|
|
13
|
-
declare type EmsVectorSources = {
|
|
14
|
-
[sourceName: string]: EmsVectorSource;
|
|
15
|
-
};
|
|
16
|
-
declare type EmsVectorStyle = {
|
|
17
|
-
sources: EmsVectorSources;
|
|
18
|
-
sprite: string;
|
|
19
|
-
glyphs: string;
|
|
20
|
-
bearing?: number;
|
|
21
|
-
center?: number[];
|
|
22
|
-
layers?: unknown[];
|
|
23
|
-
metadata?: unknown;
|
|
24
|
-
name?: string;
|
|
25
|
-
pitch?: number;
|
|
26
|
-
light?: unknown;
|
|
27
|
-
transition?: unknown;
|
|
28
|
-
version: number;
|
|
29
|
-
zoom?: number;
|
|
30
|
-
};
|
|
31
|
-
declare type EmsSprite = {
|
|
4
|
+
export declare type EmsSprite = {
|
|
32
5
|
height: number;
|
|
33
6
|
pixelRatio: number;
|
|
34
7
|
width: number;
|
|
35
8
|
x: number;
|
|
36
9
|
y: number;
|
|
10
|
+
sdf?: boolean;
|
|
37
11
|
};
|
|
38
|
-
declare type EmsSpriteSheet = {
|
|
12
|
+
export declare type EmsSpriteSheet = {
|
|
39
13
|
[spriteName: string]: EmsSprite;
|
|
40
14
|
};
|
|
15
|
+
declare type EmsVectorSources = {
|
|
16
|
+
[sourceName: string]: MapLibreVectorSource;
|
|
17
|
+
};
|
|
18
|
+
declare type EmsVectorStyle = MapLibreStyle & {
|
|
19
|
+
sources: EmsVectorSources;
|
|
20
|
+
};
|
|
41
21
|
declare type EmsRasterStyle = {
|
|
42
22
|
tilejson: string;
|
|
43
23
|
name: string;
|
package/target/web/ems_client.js
CHANGED
|
@@ -23,7 +23,7 @@ import semver from 'semver';
|
|
|
23
23
|
import { format as formatUrl, parse as parseUrl } from 'url';
|
|
24
24
|
import { toAbsoluteUrl } from './utils';
|
|
25
25
|
import LRUCache from 'lru-cache';
|
|
26
|
-
var DEFAULT_EMS_VERSION = '8.
|
|
26
|
+
var DEFAULT_EMS_VERSION = '8.1';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* plugins cannot have upstream dependencies on core/*-kibana.
|
package/target/web/index.js
CHANGED
|
@@ -118,7 +118,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
|
|
|
118
118
|
}))));
|
|
119
119
|
|
|
120
120
|
_defineProperty(_assertThisInitialized(_this), "_getVectorStyleJsonInlined", _.once( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
121
|
-
var vectorJson, inlinedSources, sources, _iterator, _step, _sourceName, url, sourceUrl, extendedUrl, sourceJson,
|
|
121
|
+
var vectorJson, inlinedSources, sources, _iterator, _step, _sourceName, url, _sourceJson$tiles, sourceUrl, extendedUrl, sourceJson, tiles;
|
|
122
122
|
|
|
123
123
|
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
124
124
|
while (1) {
|
|
@@ -131,7 +131,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
|
|
|
131
131
|
vectorJson = _context3.sent;
|
|
132
132
|
|
|
133
133
|
if (!vectorJson) {
|
|
134
|
-
_context3.next =
|
|
134
|
+
_context3.next = 44;
|
|
135
135
|
break;
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -144,64 +144,70 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
|
|
|
144
144
|
|
|
145
145
|
case 9:
|
|
146
146
|
if ((_step = _iterator.n()).done) {
|
|
147
|
-
_context3.next =
|
|
147
|
+
_context3.next = 22;
|
|
148
148
|
break;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
_sourceName = _step.value;
|
|
152
152
|
url = sources[_sourceName].url;
|
|
153
|
+
|
|
154
|
+
if (!url) {
|
|
155
|
+
_context3.next = 20;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
|
|
153
159
|
sourceUrl = _this._proxyPath + _this._getAbsoluteUrl(url);
|
|
154
160
|
extendedUrl = _this._emsClient.extendUrlWithParams(sourceUrl);
|
|
155
|
-
_context3.next =
|
|
161
|
+
_context3.next = 17;
|
|
156
162
|
return _this._emsClient.getManifest(extendedUrl);
|
|
157
163
|
|
|
158
|
-
case
|
|
164
|
+
case 17:
|
|
159
165
|
sourceJson = _context3.sent;
|
|
160
|
-
|
|
161
|
-
var
|
|
166
|
+
tiles = sourceJson === null || sourceJson === void 0 ? void 0 : (_sourceJson$tiles = sourceJson.tiles) === null || _sourceJson$tiles === void 0 ? void 0 : _sourceJson$tiles.map(function (tileUrl) {
|
|
167
|
+
var directUrl = _this._proxyPath + _this._getAbsoluteUrl(tileUrl);
|
|
162
168
|
|
|
163
|
-
return _this._emsClient.extendUrlWithParams(
|
|
169
|
+
return _this._emsClient.extendUrlWithParams(directUrl);
|
|
164
170
|
});
|
|
165
171
|
inlinedSources[_sourceName] = _objectSpread(_objectSpread({}, sourceJson), {}, {
|
|
166
172
|
type: 'vector',
|
|
167
|
-
tiles:
|
|
173
|
+
tiles: tiles
|
|
168
174
|
});
|
|
169
175
|
|
|
170
|
-
case
|
|
176
|
+
case 20:
|
|
171
177
|
_context3.next = 9;
|
|
172
178
|
break;
|
|
173
179
|
|
|
174
|
-
case
|
|
175
|
-
_context3.next =
|
|
180
|
+
case 22:
|
|
181
|
+
_context3.next = 27;
|
|
176
182
|
break;
|
|
177
183
|
|
|
178
|
-
case
|
|
179
|
-
_context3.prev =
|
|
184
|
+
case 24:
|
|
185
|
+
_context3.prev = 24;
|
|
180
186
|
_context3.t0 = _context3["catch"](7);
|
|
181
187
|
|
|
182
188
|
_iterator.e(_context3.t0);
|
|
183
189
|
|
|
184
|
-
case
|
|
185
|
-
_context3.prev =
|
|
190
|
+
case 27:
|
|
191
|
+
_context3.prev = 27;
|
|
186
192
|
|
|
187
193
|
_iterator.f();
|
|
188
194
|
|
|
189
|
-
return _context3.finish(
|
|
195
|
+
return _context3.finish(27);
|
|
190
196
|
|
|
191
|
-
case
|
|
197
|
+
case 30:
|
|
192
198
|
_context3.t1 = _objectSpread;
|
|
193
199
|
_context3.t2 = _objectSpread({}, vectorJson);
|
|
194
200
|
_context3.t3 = {};
|
|
195
201
|
_context3.t4 = inlinedSources;
|
|
196
|
-
_context3.next =
|
|
202
|
+
_context3.next = 36;
|
|
197
203
|
return _this._getSpriteSheetRootPath();
|
|
198
204
|
|
|
199
|
-
case
|
|
205
|
+
case 36:
|
|
200
206
|
_context3.t5 = _context3.sent;
|
|
201
|
-
_context3.next =
|
|
207
|
+
_context3.next = 39;
|
|
202
208
|
return _this._getUrlTemplateForGlyphs();
|
|
203
209
|
|
|
204
|
-
case
|
|
210
|
+
case 39:
|
|
205
211
|
_context3.t6 = _context3.sent;
|
|
206
212
|
_context3.t7 = {
|
|
207
213
|
sources: _context3.t4,
|
|
@@ -210,15 +216,15 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
|
|
|
210
216
|
};
|
|
211
217
|
return _context3.abrupt("return", (0, _context3.t1)(_context3.t2, _context3.t3, _context3.t7));
|
|
212
218
|
|
|
213
|
-
case
|
|
219
|
+
case 44:
|
|
214
220
|
return _context3.abrupt("return");
|
|
215
221
|
|
|
216
|
-
case
|
|
222
|
+
case 45:
|
|
217
223
|
case "end":
|
|
218
224
|
return _context3.stop();
|
|
219
225
|
}
|
|
220
226
|
}
|
|
221
|
-
}, _callee3, null, [[7,
|
|
227
|
+
}, _callee3, null, [[7, 24, 27, 30]]);
|
|
222
228
|
}))));
|
|
223
229
|
|
|
224
230
|
_this._config = config;
|
|
@@ -315,7 +321,9 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
|
|
|
315
321
|
key: "getUrlTemplateForVector",
|
|
316
322
|
value: function () {
|
|
317
323
|
var _getUrlTemplateForVector = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(sourceId) {
|
|
318
|
-
var
|
|
324
|
+
var _tileJson$sources$sou, _tileJson$sources$sou2;
|
|
325
|
+
|
|
326
|
+
var tileJson, url, directUrl;
|
|
319
327
|
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
320
328
|
while (1) {
|
|
321
329
|
switch (_context6.prev = _context6.next) {
|
|
@@ -325,27 +333,20 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
|
|
|
325
333
|
|
|
326
334
|
case 2:
|
|
327
335
|
tileJson = _context6.sent;
|
|
336
|
+
url = tileJson === null || tileJson === void 0 ? void 0 : (_tileJson$sources$sou = tileJson.sources[sourceId]) === null || _tileJson$sources$sou === void 0 ? void 0 : (_tileJson$sources$sou2 = _tileJson$sources$sou.tiles) === null || _tileJson$sources$sou2 === void 0 ? void 0 : _tileJson$sources$sou2.pop();
|
|
328
337
|
|
|
329
|
-
if (
|
|
330
|
-
_context6.next =
|
|
338
|
+
if (!url) {
|
|
339
|
+
_context6.next = 9;
|
|
331
340
|
break;
|
|
332
341
|
}
|
|
333
342
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
case 5:
|
|
337
|
-
if (!(tileJson.sources[sourceId] && tileJson.sources[sourceId].tiles)) {
|
|
338
|
-
_context6.next = 10;
|
|
339
|
-
break;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
directUrl = this._proxyPath + this._getAbsoluteUrl(tileJson.sources[sourceId].tiles[0]);
|
|
343
|
+
directUrl = this._proxyPath + this._getAbsoluteUrl(url);
|
|
343
344
|
return _context6.abrupt("return", this._emsClient.extendUrlWithParams(directUrl));
|
|
344
345
|
|
|
345
|
-
case
|
|
346
|
+
case 9:
|
|
346
347
|
return _context6.abrupt("return", '');
|
|
347
348
|
|
|
348
|
-
case
|
|
349
|
+
case 10:
|
|
349
350
|
case "end":
|
|
350
351
|
return _context6.stop();
|
|
351
352
|
}
|
|
@@ -703,7 +704,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
|
|
|
703
704
|
case 2:
|
|
704
705
|
vectorStyleJson = _context14.sent;
|
|
705
706
|
|
|
706
|
-
if (!vectorStyleJson) {
|
|
707
|
+
if (!(vectorStyleJson !== null && vectorStyleJson !== void 0 && vectorStyleJson.sprite)) {
|
|
707
708
|
_context14.next = 7;
|
|
708
709
|
break;
|
|
709
710
|
}
|
|
@@ -742,7 +743,7 @@ export var TMSService = /*#__PURE__*/function (_AbstractEmsService) {
|
|
|
742
743
|
case 2:
|
|
743
744
|
vectorStyleJson = _context15.sent;
|
|
744
745
|
|
|
745
|
-
if (!vectorStyleJson) {
|
|
746
|
+
if (!(vectorStyleJson !== null && vectorStyleJson !== void 0 && vectorStyleJson.glyphs)) {
|
|
746
747
|
_context15.next = 7;
|
|
747
748
|
break;
|
|
748
749
|
}
|
package/test/ems_client.test.ts
CHANGED
|
@@ -431,8 +431,8 @@ it('should retrieve vectorstylesheet with all sources inlined)', async () => {
|
|
|
431
431
|
|
|
432
432
|
expect(styleSheet!.layers!.length).toBe(111);
|
|
433
433
|
expect(styleSheet!.sprite).toBe('https://tiles.foobar/styles/osm-bright/sprite');
|
|
434
|
-
expect(styleSheet!.sources!.openmaptiles!.tiles
|
|
435
|
-
expect(styleSheet!.sources!.openmaptiles!.tiles[0]).toBe(
|
|
434
|
+
expect(styleSheet!.sources!.openmaptiles!.tiles!.length).toBe(1);
|
|
435
|
+
expect(styleSheet!.sources!.openmaptiles!.tiles![0]).toBe(
|
|
436
436
|
'https://tiles.foobar/data/v3/{z}/{x}/{y}.pbf?elastic_tile_service_tos=agree&my_app_name=tester&my_app_version=7.x.x'
|
|
437
437
|
);
|
|
438
438
|
expect(styleSheet!.sources!.openmaptiles!.type).toBe('vector');
|