@elastic/ems-client 7.16.0 → 7.17.2
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/.backportrc.json +13 -2
- package/.buildkite/build.sh +16 -0
- package/.buildkite/pipeline.yml +8 -0
- package/.buildkite/pull-requests.json +30 -0
- package/.nvmrc +1 -0
- package/CHANGELOG.md +15 -0
- package/catalog-info.yaml +68 -0
- package/package.json +10 -7
- package/src/ems_client.ts +1 -1
- package/target/ems_client.d.ts +16 -16
- package/target/ems_client.js +318 -0
- package/target/ems_service.js +47 -0
- package/target/file_layer.d.ts +1 -1
- package/target/file_layer.js +176 -0
- package/target/index.js +16 -0
- package/target/node/ems_client.js +25 -93
- package/target/node/ems_service.js +11 -23
- package/target/node/file_layer.js +18 -63
- package/target/node/index.js +0 -4
- package/target/node/origin.js +3 -4
- package/target/node/tms_service.js +17 -65
- package/target/node/utils.js +0 -3
- package/target/tms_service.d.ts +6 -6
- package/target/tms_service.js +409 -0
- package/target/utils.js +86 -0
- package/target/web/ems_client.js +304 -444
- package/target/web/ems_service.js +12 -29
- package/target/web/file_layer.js +73 -130
- package/target/web/index.js +1 -0
- package/target/web/origin.js +1 -0
- package/target/web/tms_service.js +380 -555
- package/target/web/utils.js +0 -2
- package/.ci/jobs/defaults.yml +0 -67
- package/.ci/jobs/elastic+ems-client+master.yml +0 -18
- package/.ci/jobs/elastic+ems-client+pull-request.yml +0 -18
|
@@ -4,74 +4,59 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.FileLayer = exports.EMSFormatType = void 0;
|
|
7
|
-
|
|
8
7
|
var _url = _interopRequireDefault(require("url"));
|
|
9
|
-
|
|
10
8
|
var _ems_service = require("./ems_service");
|
|
11
|
-
|
|
12
9
|
var topojson = _interopRequireWildcard(require("topojson-client"));
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
(function (EMSFormatType) {
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
15
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
|
16
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
17
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
18
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
19
|
+
* 2.0.
|
|
20
|
+
*/
|
|
21
|
+
let EMSFormatType = exports.EMSFormatType = /*#__PURE__*/function (EMSFormatType) {
|
|
26
22
|
EMSFormatType["geojson"] = "geojson";
|
|
27
23
|
EMSFormatType["topojson"] = "topojson";
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
return EMSFormatType;
|
|
25
|
+
}({});
|
|
30
26
|
class FileLayer extends _ems_service.AbstractEmsService {
|
|
31
27
|
constructor(config, emsClient, proxyPath) {
|
|
32
28
|
super(config, emsClient, proxyPath);
|
|
33
|
-
|
|
34
29
|
_defineProperty(this, "_config", void 0);
|
|
35
|
-
|
|
36
30
|
this._config = config;
|
|
37
31
|
}
|
|
38
|
-
|
|
39
32
|
async getGeoJson() {
|
|
40
33
|
const cachedGeoJson = this._emsClient.getCachedGeoJson(this.getId());
|
|
41
|
-
|
|
42
34
|
if (cachedGeoJson) {
|
|
43
35
|
return cachedGeoJson;
|
|
44
36
|
}
|
|
45
|
-
|
|
46
37
|
const format = this.getDefaultFormatType();
|
|
47
38
|
const fetchUrl = this.getDefaultFormatUrl();
|
|
48
39
|
let geojson;
|
|
49
40
|
const fetchedJson = await this._emsClient.getManifest(fetchUrl);
|
|
50
|
-
|
|
51
41
|
if (fetchedJson) {
|
|
52
42
|
if (format === 'geojson') {
|
|
53
43
|
geojson = fetchedJson;
|
|
54
44
|
} else if (format === 'topojson') {
|
|
55
45
|
const meta = this.getDefaultFormatMeta();
|
|
56
|
-
const featureCollectionPath =
|
|
57
|
-
|
|
46
|
+
const featureCollectionPath = meta?.feature_collection_path ?? 'data';
|
|
47
|
+
// @ts-expect-error see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52156
|
|
58
48
|
geojson = topojson.feature(fetchedJson, featureCollectionPath);
|
|
59
49
|
} else {
|
|
60
50
|
return;
|
|
61
51
|
}
|
|
62
|
-
|
|
63
52
|
this._emsClient.cacheGeoJson(this.getId(), geojson);
|
|
64
|
-
|
|
65
53
|
return geojson;
|
|
66
54
|
}
|
|
67
|
-
|
|
68
55
|
return;
|
|
69
56
|
}
|
|
70
|
-
|
|
71
57
|
getFields() {
|
|
72
58
|
return this._config.fields;
|
|
73
59
|
}
|
|
74
|
-
|
|
75
60
|
getFieldsInLanguage() {
|
|
76
61
|
return this.getFields().map(field => {
|
|
77
62
|
return {
|
|
@@ -81,84 +66,61 @@ class FileLayer extends _ems_service.AbstractEmsService {
|
|
|
81
66
|
};
|
|
82
67
|
});
|
|
83
68
|
}
|
|
84
|
-
|
|
85
69
|
getDisplayName() {
|
|
86
70
|
const layerName = this._emsClient.getValueInLanguage(this._config.layer_name);
|
|
87
|
-
|
|
88
71
|
return layerName ? layerName : '';
|
|
89
72
|
}
|
|
90
|
-
|
|
91
73
|
getId() {
|
|
92
74
|
return this._config.layer_id;
|
|
93
75
|
}
|
|
94
|
-
|
|
95
76
|
hasId(id) {
|
|
96
77
|
const matchesLegacyId = this._config.legacy_ids.indexOf(id) >= 0;
|
|
97
78
|
return this._config.layer_id === id || matchesLegacyId;
|
|
98
79
|
}
|
|
99
|
-
|
|
100
80
|
getEMSHotLink() {
|
|
101
81
|
const landingPageString = this._emsClient.getLandingPageUrl();
|
|
102
|
-
|
|
103
82
|
const urlObject = _url.default.parse(landingPageString, true);
|
|
104
|
-
|
|
105
83
|
urlObject.hash = `file/${this.getId()}`;
|
|
106
|
-
urlObject.query = {
|
|
84
|
+
urlObject.query = {
|
|
85
|
+
...urlObject.query,
|
|
107
86
|
locale: this._emsClient.getLocale()
|
|
108
87
|
};
|
|
109
88
|
return _url.default.format(urlObject);
|
|
110
89
|
}
|
|
111
|
-
|
|
112
90
|
getDefaultFormatType() {
|
|
113
91
|
const format = this._getDefaultFormat();
|
|
114
|
-
|
|
115
92
|
return format.type;
|
|
116
93
|
}
|
|
117
|
-
|
|
118
94
|
getFormatOfType(type) {
|
|
119
95
|
const format = this._getFormatOfType(type);
|
|
120
|
-
|
|
121
96
|
return format.type;
|
|
122
97
|
}
|
|
123
|
-
|
|
124
98
|
getDefaultFormatMeta() {
|
|
125
99
|
const format = this._getDefaultFormat();
|
|
126
|
-
|
|
127
100
|
return this._getFormatMeta(format);
|
|
128
101
|
}
|
|
129
|
-
|
|
130
102
|
getFormatOfTypeMeta(type) {
|
|
131
103
|
const format = this._getFormatOfType(type);
|
|
132
|
-
|
|
133
104
|
return this._getFormatMeta(format);
|
|
134
105
|
}
|
|
135
|
-
|
|
136
106
|
getDefaultFormatUrl() {
|
|
137
107
|
const format = this._getDefaultFormat();
|
|
138
|
-
|
|
139
108
|
return this._getFormatUrl(format);
|
|
140
109
|
}
|
|
141
|
-
|
|
142
110
|
getFormatOfTypeUrl(type) {
|
|
143
111
|
const format = this._getFormatOfType(type);
|
|
144
|
-
|
|
145
112
|
return this._getFormatUrl(format);
|
|
146
113
|
}
|
|
147
|
-
|
|
148
114
|
getCreatedAt() {
|
|
149
115
|
return this._config.created_at;
|
|
150
116
|
}
|
|
151
|
-
|
|
152
117
|
getApiUrl() {
|
|
153
118
|
return this._emsClient.getFileApiUrl();
|
|
154
119
|
}
|
|
155
|
-
|
|
156
120
|
_getFormatUrl(format) {
|
|
157
121
|
const url = this._proxyPath + this._getAbsoluteUrl(format.url);
|
|
158
|
-
|
|
159
122
|
return this._emsClient.extendUrlWithParams(url);
|
|
160
123
|
}
|
|
161
|
-
|
|
162
124
|
_getFormatMeta(format) {
|
|
163
125
|
if ('meta' in format) {
|
|
164
126
|
return format.meta;
|
|
@@ -166,27 +128,20 @@ class FileLayer extends _ems_service.AbstractEmsService {
|
|
|
166
128
|
return;
|
|
167
129
|
}
|
|
168
130
|
}
|
|
169
|
-
|
|
170
131
|
_getDefaultFormat() {
|
|
171
132
|
const defaultFormat = this._config.formats.find(format => {
|
|
172
133
|
return format.legacy_default;
|
|
173
134
|
});
|
|
174
|
-
|
|
175
135
|
if (defaultFormat) {
|
|
176
136
|
return defaultFormat;
|
|
177
137
|
}
|
|
178
|
-
|
|
179
138
|
return this._config.formats[0];
|
|
180
139
|
}
|
|
181
|
-
|
|
182
140
|
_getFormatOfType(type) {
|
|
183
141
|
const requestedFormat = this._config.formats.find(format => {
|
|
184
142
|
return format.type === type;
|
|
185
143
|
});
|
|
186
|
-
|
|
187
144
|
return requestedFormat || this._getDefaultFormat();
|
|
188
145
|
}
|
|
189
|
-
|
|
190
146
|
}
|
|
191
|
-
|
|
192
147
|
exports.FileLayer = FileLayer;
|
package/target/node/index.js
CHANGED
|
@@ -33,11 +33,7 @@ Object.defineProperty(exports, "TMSService", {
|
|
|
33
33
|
return _tms_service.TMSService;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
|
|
37
36
|
var _ems_client = require("./ems_client");
|
|
38
|
-
|
|
39
37
|
var _origin = require("./origin");
|
|
40
|
-
|
|
41
38
|
var _file_layer = require("./file_layer");
|
|
42
|
-
|
|
43
39
|
var _tms_service = require("./tms_service");
|
package/target/node/origin.js
CHANGED
|
@@ -4,15 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ORIGIN = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
10
9
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
11
10
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
12
11
|
* 2.0.
|
|
13
12
|
*/
|
|
14
|
-
|
|
13
|
+
|
|
14
|
+
const ORIGIN = exports.ORIGIN = {
|
|
15
15
|
EMS: 'elastic_maps_service',
|
|
16
16
|
KIBANA_YML: 'self_hosted'
|
|
17
|
-
};
|
|
18
|
-
exports.ORIGIN = ORIGIN;
|
|
17
|
+
};
|
|
@@ -4,78 +4,68 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TMSService = void 0;
|
|
7
|
-
|
|
8
7
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
-
|
|
10
8
|
var _ems_service = require("./ems_service");
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
|
13
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
14
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
15
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
16
|
+
* 2.0.
|
|
17
|
+
*/
|
|
16
18
|
class TMSService extends _ems_service.AbstractEmsService {
|
|
17
19
|
constructor(config, emsClient, proxyPath) {
|
|
18
20
|
super(config, emsClient, proxyPath);
|
|
19
|
-
|
|
20
21
|
_defineProperty(this, "_config", void 0);
|
|
21
|
-
|
|
22
22
|
_defineProperty(this, "_getRasterStyleJson", _lodash.default.once(async () => {
|
|
23
23
|
const rasterUrl = this._getStyleUrlForLocale('raster');
|
|
24
|
-
|
|
25
24
|
if (rasterUrl) {
|
|
26
25
|
const url = this._proxyPath + this._getAbsoluteUrl(rasterUrl);
|
|
27
|
-
|
|
28
26
|
return this._emsClient.getManifest(this._emsClient.extendUrlWithParams(url));
|
|
29
27
|
} else {
|
|
30
28
|
return;
|
|
31
29
|
}
|
|
32
30
|
}));
|
|
33
|
-
|
|
34
31
|
_defineProperty(this, "_getVectorStyleJsonRaw", _lodash.default.once(async () => {
|
|
35
32
|
const vectorUrl = this._getStyleUrlForLocale('vector');
|
|
36
|
-
|
|
37
33
|
if (vectorUrl) {
|
|
38
34
|
const url = this._proxyPath + this._getAbsoluteUrl(vectorUrl);
|
|
39
|
-
|
|
40
35
|
const vectorJson = await this._emsClient.getManifest(this._emsClient.extendUrlWithParams(url));
|
|
41
|
-
return {
|
|
36
|
+
return {
|
|
37
|
+
...vectorJson
|
|
42
38
|
};
|
|
43
39
|
} else {
|
|
44
40
|
return;
|
|
45
41
|
}
|
|
46
42
|
}));
|
|
47
|
-
|
|
48
43
|
_defineProperty(this, "_getVectorStyleJsonInlined", _lodash.default.once(async () => {
|
|
49
44
|
const vectorJson = await this._getVectorStyleJsonRaw();
|
|
50
|
-
|
|
51
45
|
if (vectorJson) {
|
|
52
46
|
const inlinedSources = {};
|
|
53
47
|
const {
|
|
54
48
|
sources
|
|
55
49
|
} = vectorJson;
|
|
56
|
-
|
|
57
50
|
for (const sourceName of Object.getOwnPropertyNames(sources)) {
|
|
58
51
|
const {
|
|
59
52
|
url
|
|
60
53
|
} = sources[sourceName];
|
|
61
|
-
|
|
62
54
|
const sourceUrl = this._proxyPath + this._getAbsoluteUrl(url);
|
|
63
|
-
|
|
64
55
|
const extendedUrl = this._emsClient.extendUrlWithParams(sourceUrl);
|
|
65
|
-
|
|
66
56
|
const sourceJson = await this._emsClient.getManifest(extendedUrl);
|
|
67
57
|
const extendedTileUrls = sourceJson.tiles.map(tileUrl => {
|
|
68
58
|
const url = this._proxyPath + this._getAbsoluteUrl(tileUrl);
|
|
69
|
-
|
|
70
59
|
return this._emsClient.extendUrlWithParams(url);
|
|
71
60
|
});
|
|
72
|
-
inlinedSources[sourceName] = {
|
|
61
|
+
inlinedSources[sourceName] = {
|
|
62
|
+
...sourceJson,
|
|
73
63
|
type: 'vector',
|
|
74
64
|
tiles: extendedTileUrls
|
|
75
65
|
};
|
|
76
66
|
}
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
return {
|
|
68
|
+
...vectorJson,
|
|
79
69
|
sources: inlinedSources,
|
|
80
70
|
sprite: await this._getSpriteSheetRootPath(),
|
|
81
71
|
glyphs: await this._getUrlTemplateForGlyphs()
|
|
@@ -84,16 +74,14 @@ class TMSService extends _ems_service.AbstractEmsService {
|
|
|
84
74
|
return;
|
|
85
75
|
}
|
|
86
76
|
}));
|
|
87
|
-
|
|
88
77
|
this._config = config;
|
|
89
78
|
}
|
|
90
|
-
|
|
91
79
|
async getDefaultRasterStyle() {
|
|
92
80
|
const tileJson = await this._getRasterStyleJson();
|
|
93
|
-
|
|
94
81
|
if (tileJson) {
|
|
95
82
|
const tiles = tileJson.tiles.map(tile => this._proxyPath + this._getAbsoluteUrl(tile));
|
|
96
|
-
return {
|
|
83
|
+
return {
|
|
84
|
+
...tileJson,
|
|
97
85
|
...{
|
|
98
86
|
tiles
|
|
99
87
|
}
|
|
@@ -102,50 +90,38 @@ class TMSService extends _ems_service.AbstractEmsService {
|
|
|
102
90
|
return;
|
|
103
91
|
}
|
|
104
92
|
}
|
|
105
|
-
|
|
106
93
|
async getUrlTemplate() {
|
|
107
94
|
const tileJson = await this._getRasterStyleJson();
|
|
108
|
-
|
|
109
95
|
if (tileJson) {
|
|
110
96
|
const directUrl = this._proxyPath + this._getAbsoluteUrl(tileJson.tiles[0]);
|
|
111
|
-
|
|
112
97
|
return this._emsClient.extendUrlWithParams(directUrl);
|
|
113
98
|
} else {
|
|
114
99
|
return '';
|
|
115
100
|
}
|
|
116
101
|
}
|
|
117
|
-
|
|
118
102
|
async getUrlTemplateForVector(sourceId) {
|
|
119
103
|
const tileJson = await this._getVectorStyleJsonInlined();
|
|
120
|
-
|
|
121
104
|
if (!tileJson) {
|
|
122
105
|
return '';
|
|
123
106
|
}
|
|
124
|
-
|
|
125
107
|
if (tileJson.sources[sourceId] && tileJson.sources[sourceId].tiles) {
|
|
126
108
|
const directUrl = this._proxyPath + this._getAbsoluteUrl(tileJson.sources[sourceId].tiles[0]);
|
|
127
|
-
|
|
128
109
|
return this._emsClient.extendUrlWithParams(directUrl);
|
|
129
110
|
} else {
|
|
130
111
|
return '';
|
|
131
112
|
}
|
|
132
113
|
}
|
|
133
|
-
|
|
134
114
|
async getVectorStyleSheet() {
|
|
135
115
|
return await this._getVectorStyleJsonInlined();
|
|
136
116
|
}
|
|
137
|
-
|
|
138
117
|
async getVectorStyleSheetRaw() {
|
|
139
118
|
return await this._getVectorStyleJsonRaw();
|
|
140
119
|
}
|
|
141
|
-
|
|
142
120
|
async getSpriteSheetMeta(isRetina = false) {
|
|
143
121
|
const metaUrl = await this.getSpriteSheetJsonPath(isRetina);
|
|
144
122
|
const spritePngs = await this.getSpriteSheetPngPath(isRetina);
|
|
145
|
-
|
|
146
123
|
if (metaUrl && spritePngs) {
|
|
147
124
|
const metaUrlExtended = this._emsClient.extendUrlWithParams(metaUrl);
|
|
148
|
-
|
|
149
125
|
const jsonMeta = await this._emsClient.getManifest(metaUrlExtended);
|
|
150
126
|
return {
|
|
151
127
|
png: spritePngs,
|
|
@@ -155,10 +131,8 @@ class TMSService extends _ems_service.AbstractEmsService {
|
|
|
155
131
|
return;
|
|
156
132
|
}
|
|
157
133
|
}
|
|
158
|
-
|
|
159
134
|
async getSpriteSheetJsonPath(isRetina = false) {
|
|
160
135
|
const spriteSheetRootPath = await this._getSpriteSheetRootPath();
|
|
161
|
-
|
|
162
136
|
if (spriteSheetRootPath) {
|
|
163
137
|
const suffix = isRetina ? '@2x' : '';
|
|
164
138
|
return spriteSheetRootPath + suffix + '.json';
|
|
@@ -166,10 +140,8 @@ class TMSService extends _ems_service.AbstractEmsService {
|
|
|
166
140
|
return '';
|
|
167
141
|
}
|
|
168
142
|
}
|
|
169
|
-
|
|
170
143
|
async getSpriteSheetPngPath(isRetina = false) {
|
|
171
144
|
const spriteSheetRootPath = await this._getSpriteSheetRootPath();
|
|
172
|
-
|
|
173
145
|
if (spriteSheetRootPath) {
|
|
174
146
|
const suffix = isRetina ? '@2x' : '';
|
|
175
147
|
return spriteSheetRootPath + suffix + '.png';
|
|
@@ -177,87 +149,67 @@ class TMSService extends _ems_service.AbstractEmsService {
|
|
|
177
149
|
return '';
|
|
178
150
|
}
|
|
179
151
|
}
|
|
180
|
-
|
|
181
152
|
getDisplayName() {
|
|
182
153
|
return this._emsClient.getValueInLanguage(this._config.name);
|
|
183
154
|
}
|
|
184
|
-
|
|
185
155
|
async getMinZoom() {
|
|
186
156
|
const tileJson = await this._getRasterStyleJson();
|
|
187
|
-
|
|
188
157
|
if (tileJson) {
|
|
189
158
|
return tileJson.minzoom;
|
|
190
159
|
} else {
|
|
191
160
|
return;
|
|
192
161
|
}
|
|
193
162
|
}
|
|
194
|
-
|
|
195
163
|
async getMaxZoom() {
|
|
196
164
|
const tileJson = await this._getRasterStyleJson();
|
|
197
|
-
|
|
198
165
|
if (tileJson) {
|
|
199
166
|
return tileJson.maxzoom;
|
|
200
167
|
} else {
|
|
201
168
|
return;
|
|
202
169
|
}
|
|
203
170
|
}
|
|
204
|
-
|
|
205
171
|
getId() {
|
|
206
172
|
return this._config.id;
|
|
207
173
|
}
|
|
208
|
-
|
|
209
174
|
hasId(id) {
|
|
210
175
|
return this._config.id === id;
|
|
211
176
|
}
|
|
212
|
-
|
|
213
177
|
getApiUrl() {
|
|
214
178
|
return this._emsClient.getTileApiUrl();
|
|
215
179
|
}
|
|
216
|
-
|
|
217
180
|
_getStyleUrlForLocale(formatType) {
|
|
218
181
|
let vectorFormats = this._getFormats(formatType, this._emsClient.getLocale());
|
|
219
|
-
|
|
220
182
|
if (!vectorFormats.length) {
|
|
221
183
|
//fallback to default locale
|
|
222
184
|
vectorFormats = this._getFormats(formatType, this._emsClient.getDefaultLocale());
|
|
223
185
|
}
|
|
224
|
-
|
|
225
186
|
if (!vectorFormats.length) {
|
|
226
187
|
// eslint-disable-next-line max-len
|
|
227
188
|
throw new Error(`Cannot find ${formatType} tile layer for locale ${this._emsClient.getLocale()} or ${this._emsClient.getDefaultLocale()}`);
|
|
228
189
|
}
|
|
229
|
-
|
|
230
190
|
const defaultStyle = vectorFormats[0];
|
|
231
|
-
|
|
232
191
|
if (defaultStyle && defaultStyle.hasOwnProperty('url')) {
|
|
233
192
|
return defaultStyle.url;
|
|
234
193
|
}
|
|
235
194
|
}
|
|
236
|
-
|
|
237
195
|
_getFormats(formatType, locale) {
|
|
238
196
|
return this._config.formats.filter(format => format.locale === locale && format.format === formatType);
|
|
239
197
|
}
|
|
240
|
-
|
|
241
198
|
async _getSpriteSheetRootPath() {
|
|
242
199
|
const vectorStyleJson = await this._getVectorStyleJsonRaw();
|
|
243
|
-
|
|
244
200
|
if (vectorStyleJson) {
|
|
245
201
|
return this._proxyPath + this._getAbsoluteUrl(vectorStyleJson.sprite);
|
|
246
202
|
} else {
|
|
247
203
|
return '';
|
|
248
204
|
}
|
|
249
205
|
}
|
|
250
|
-
|
|
251
206
|
async _getUrlTemplateForGlyphs() {
|
|
252
207
|
const vectorStyleJson = await this._getVectorStyleJsonRaw();
|
|
253
|
-
|
|
254
208
|
if (vectorStyleJson) {
|
|
255
209
|
return this._proxyPath + this._getAbsoluteUrl(vectorStyleJson.glyphs);
|
|
256
210
|
} else {
|
|
257
211
|
return '';
|
|
258
212
|
}
|
|
259
213
|
}
|
|
260
|
-
|
|
261
214
|
}
|
|
262
|
-
|
|
263
215
|
exports.TMSService = TMSService;
|
package/target/node/utils.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.toAbsoluteUrl = toAbsoluteUrl;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
10
9
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -21,10 +20,8 @@ function toAbsoluteUrl(host, path) {
|
|
|
21
20
|
if (!host) {
|
|
22
21
|
return path;
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
const hostEndWithSlash = host[host.length - 1] === '/';
|
|
26
24
|
const pathStartsWithSlash = path[0] === '/';
|
|
27
|
-
|
|
28
25
|
if (hostEndWithSlash === true && pathStartsWithSlash === true) {
|
|
29
26
|
return host + path.slice(1);
|
|
30
27
|
} else if (hostEndWithSlash !== pathStartsWithSlash) {
|
package/target/tms_service.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EMSClient, TMSServiceConfig } from './ems_client';
|
|
2
2
|
import { AbstractEmsService } from './ems_service';
|
|
3
|
-
|
|
3
|
+
type EmsVectorSource = {
|
|
4
4
|
type: 'vector';
|
|
5
5
|
url: string;
|
|
6
6
|
tiles: string[];
|
|
@@ -10,10 +10,10 @@ declare type EmsVectorSource = {
|
|
|
10
10
|
maxzoom?: number;
|
|
11
11
|
attribution?: string;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
type EmsVectorSources = {
|
|
14
14
|
[sourceName: string]: EmsVectorSource;
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
type EmsVectorStyle = {
|
|
17
17
|
sources: EmsVectorSources;
|
|
18
18
|
sprite: string;
|
|
19
19
|
glyphs: string;
|
|
@@ -28,17 +28,17 @@ declare type EmsVectorStyle = {
|
|
|
28
28
|
version: number;
|
|
29
29
|
zoom?: number;
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
type EmsSprite = {
|
|
32
32
|
height: number;
|
|
33
33
|
pixelRatio: number;
|
|
34
34
|
width: number;
|
|
35
35
|
x: number;
|
|
36
36
|
y: number;
|
|
37
37
|
};
|
|
38
|
-
|
|
38
|
+
type EmsSpriteSheet = {
|
|
39
39
|
[spriteName: string]: EmsSprite;
|
|
40
40
|
};
|
|
41
|
-
|
|
41
|
+
type EmsRasterStyle = {
|
|
42
42
|
tilejson: string;
|
|
43
43
|
name: string;
|
|
44
44
|
attribution: string;
|