@elastic/ems-client 7.15.1 → 7.17.1
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 +16 -0
- package/catalog-info.yaml +68 -0
- package/package.json +8 -5
- package/src/ems_client.ts +14 -12
- package/src/file_layer.ts +0 -1
- package/target/node/ems_client.js +33 -100
- package/target/node/ems_service.js +11 -23
- package/target/node/file_layer.js +18 -64
- package/target/node/index.js +6 -10
- package/target/node/origin.js +3 -4
- package/target/node/tms_service.js +16 -64
- package/target/node/utils.js +0 -3
- package/target/web/ems_client.js +300 -432
- package/target/web/ems_service.js +10 -26
- package/target/web/file_layer.js +62 -118
- package/target/web/index.js +1 -0
- package/target/web/origin.js +1 -0
- package/target/web/tms_service.js +367 -540
- 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
- package/target/ems_client.js +0 -443
- package/target/ems_service.js +0 -76
- package/target/file_layer.js +0 -123
- package/target/index.js +0 -28
- package/target/origin.js +0 -24
- package/target/tms_service.js +0 -429
- package/target/tsdoc-metadata.json +0 -11
- package/target/utils.js +0 -42
|
@@ -4,21 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.AbstractEmsService = void 0;
|
|
7
|
-
|
|
8
7
|
var _origin = require("./origin");
|
|
9
|
-
|
|
10
8
|
var _utils = require("./utils");
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
9
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
11
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /*
|
|
12
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
13
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
14
|
+
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
15
|
+
* 2.0.
|
|
16
|
+
*/
|
|
14
17
|
class AbstractEmsService {
|
|
15
18
|
constructor(config, emsClient, proxyPath) {
|
|
16
19
|
_defineProperty(this, "_emsClient", void 0);
|
|
17
|
-
|
|
18
20
|
_defineProperty(this, "_config", void 0);
|
|
19
|
-
|
|
20
21
|
_defineProperty(this, "_proxyPath", void 0);
|
|
21
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Checks if url is absolute. If not, prepend the basePath.
|
|
24
|
+
*/
|
|
22
25
|
_defineProperty(this, "_getAbsoluteUrl", url => {
|
|
23
26
|
if (/^https?:\/\//.test(url)) {
|
|
24
27
|
return url;
|
|
@@ -26,45 +29,30 @@ class AbstractEmsService {
|
|
|
26
29
|
return (0, _utils.toAbsoluteUrl)(this.getApiUrl(), url);
|
|
27
30
|
}
|
|
28
31
|
});
|
|
29
|
-
|
|
30
32
|
this._config = config;
|
|
31
33
|
this._emsClient = emsClient;
|
|
32
34
|
this._proxyPath = proxyPath;
|
|
33
35
|
}
|
|
34
|
-
|
|
35
36
|
getAttributions() {
|
|
36
37
|
return this._config.attribution.map(attribution => {
|
|
37
38
|
const url = this._emsClient.getValueInLanguage(attribution.url);
|
|
38
|
-
|
|
39
39
|
const label = this._emsClient.getValueInLanguage(attribution.label);
|
|
40
|
-
|
|
41
40
|
return {
|
|
42
41
|
url: url,
|
|
43
42
|
label: label
|
|
44
43
|
};
|
|
45
44
|
});
|
|
46
45
|
}
|
|
47
|
-
|
|
48
46
|
getMarkdownAttribution() {
|
|
49
47
|
const attributions = this._config.attribution.map(attribution => {
|
|
50
48
|
const url = this._emsClient.getValueInLanguage(attribution.url);
|
|
51
|
-
|
|
52
49
|
const label = this._emsClient.getValueInLanguage(attribution.label);
|
|
53
|
-
|
|
54
50
|
return `[${label}](${url})`;
|
|
55
51
|
});
|
|
56
|
-
|
|
57
52
|
return attributions.join('|');
|
|
58
53
|
}
|
|
59
|
-
|
|
60
54
|
getOrigin() {
|
|
61
55
|
return _origin.ORIGIN.EMS;
|
|
62
56
|
}
|
|
63
|
-
/**
|
|
64
|
-
* Checks if url is absolute. If not, prepend the basePath.
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
57
|
}
|
|
69
|
-
|
|
70
58
|
exports.AbstractEmsService = AbstractEmsService;
|
|
@@ -4,75 +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 _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
-
|
|
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 && Object.prototype.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; }
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
15
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /*
|
|
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
|
-
const fetchUrl = this.getDefaultFormatUrl();
|
|
48
|
-
|
|
38
|
+
const fetchUrl = this.getDefaultFormatUrl();
|
|
49
39
|
let geojson;
|
|
50
40
|
const fetchedJson = await this._emsClient.getManifest(fetchUrl);
|
|
51
|
-
|
|
52
41
|
if (fetchedJson) {
|
|
53
42
|
if (format === 'geojson') {
|
|
54
43
|
geojson = fetchedJson;
|
|
55
44
|
} else if (format === 'topojson') {
|
|
56
45
|
const meta = this.getDefaultFormatMeta();
|
|
57
|
-
const featureCollectionPath =
|
|
58
|
-
|
|
46
|
+
const featureCollectionPath = meta?.feature_collection_path ?? 'data';
|
|
47
|
+
// @ts-expect-error see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52156
|
|
59
48
|
geojson = topojson.feature(fetchedJson, featureCollectionPath);
|
|
60
49
|
} else {
|
|
61
50
|
return;
|
|
62
51
|
}
|
|
63
|
-
|
|
64
52
|
this._emsClient.cacheGeoJson(this.getId(), geojson);
|
|
65
|
-
|
|
66
53
|
return geojson;
|
|
67
54
|
}
|
|
68
|
-
|
|
69
55
|
return;
|
|
70
56
|
}
|
|
71
|
-
|
|
72
57
|
getFields() {
|
|
73
58
|
return this._config.fields;
|
|
74
59
|
}
|
|
75
|
-
|
|
76
60
|
getFieldsInLanguage() {
|
|
77
61
|
return this.getFields().map(field => {
|
|
78
62
|
return {
|
|
@@ -82,84 +66,61 @@ class FileLayer extends _ems_service.AbstractEmsService {
|
|
|
82
66
|
};
|
|
83
67
|
});
|
|
84
68
|
}
|
|
85
|
-
|
|
86
69
|
getDisplayName() {
|
|
87
70
|
const layerName = this._emsClient.getValueInLanguage(this._config.layer_name);
|
|
88
|
-
|
|
89
71
|
return layerName ? layerName : '';
|
|
90
72
|
}
|
|
91
|
-
|
|
92
73
|
getId() {
|
|
93
74
|
return this._config.layer_id;
|
|
94
75
|
}
|
|
95
|
-
|
|
96
76
|
hasId(id) {
|
|
97
77
|
const matchesLegacyId = this._config.legacy_ids.indexOf(id) >= 0;
|
|
98
78
|
return this._config.layer_id === id || matchesLegacyId;
|
|
99
79
|
}
|
|
100
|
-
|
|
101
80
|
getEMSHotLink() {
|
|
102
81
|
const landingPageString = this._emsClient.getLandingPageUrl();
|
|
103
|
-
|
|
104
82
|
const urlObject = _url.default.parse(landingPageString, true);
|
|
105
|
-
|
|
106
83
|
urlObject.hash = `file/${this.getId()}`;
|
|
107
|
-
urlObject.query = {
|
|
84
|
+
urlObject.query = {
|
|
85
|
+
...urlObject.query,
|
|
108
86
|
locale: this._emsClient.getLocale()
|
|
109
87
|
};
|
|
110
88
|
return _url.default.format(urlObject);
|
|
111
89
|
}
|
|
112
|
-
|
|
113
90
|
getDefaultFormatType() {
|
|
114
91
|
const format = this._getDefaultFormat();
|
|
115
|
-
|
|
116
92
|
return format.type;
|
|
117
93
|
}
|
|
118
|
-
|
|
119
94
|
getFormatOfType(type) {
|
|
120
95
|
const format = this._getFormatOfType(type);
|
|
121
|
-
|
|
122
96
|
return format.type;
|
|
123
97
|
}
|
|
124
|
-
|
|
125
98
|
getDefaultFormatMeta() {
|
|
126
99
|
const format = this._getDefaultFormat();
|
|
127
|
-
|
|
128
100
|
return this._getFormatMeta(format);
|
|
129
101
|
}
|
|
130
|
-
|
|
131
102
|
getFormatOfTypeMeta(type) {
|
|
132
103
|
const format = this._getFormatOfType(type);
|
|
133
|
-
|
|
134
104
|
return this._getFormatMeta(format);
|
|
135
105
|
}
|
|
136
|
-
|
|
137
106
|
getDefaultFormatUrl() {
|
|
138
107
|
const format = this._getDefaultFormat();
|
|
139
|
-
|
|
140
108
|
return this._getFormatUrl(format);
|
|
141
109
|
}
|
|
142
|
-
|
|
143
110
|
getFormatOfTypeUrl(type) {
|
|
144
111
|
const format = this._getFormatOfType(type);
|
|
145
|
-
|
|
146
112
|
return this._getFormatUrl(format);
|
|
147
113
|
}
|
|
148
|
-
|
|
149
114
|
getCreatedAt() {
|
|
150
115
|
return this._config.created_at;
|
|
151
116
|
}
|
|
152
|
-
|
|
153
117
|
getApiUrl() {
|
|
154
118
|
return this._emsClient.getFileApiUrl();
|
|
155
119
|
}
|
|
156
|
-
|
|
157
120
|
_getFormatUrl(format) {
|
|
158
121
|
const url = this._proxyPath + this._getAbsoluteUrl(format.url);
|
|
159
|
-
|
|
160
122
|
return this._emsClient.extendUrlWithParams(url);
|
|
161
123
|
}
|
|
162
|
-
|
|
163
124
|
_getFormatMeta(format) {
|
|
164
125
|
if ('meta' in format) {
|
|
165
126
|
return format.meta;
|
|
@@ -167,27 +128,20 @@ class FileLayer extends _ems_service.AbstractEmsService {
|
|
|
167
128
|
return;
|
|
168
129
|
}
|
|
169
130
|
}
|
|
170
|
-
|
|
171
131
|
_getDefaultFormat() {
|
|
172
132
|
const defaultFormat = this._config.formats.find(format => {
|
|
173
133
|
return format.legacy_default;
|
|
174
134
|
});
|
|
175
|
-
|
|
176
135
|
if (defaultFormat) {
|
|
177
136
|
return defaultFormat;
|
|
178
137
|
}
|
|
179
|
-
|
|
180
138
|
return this._config.formats[0];
|
|
181
139
|
}
|
|
182
|
-
|
|
183
140
|
_getFormatOfType(type) {
|
|
184
141
|
const requestedFormat = this._config.formats.find(format => {
|
|
185
142
|
return format.type === type;
|
|
186
143
|
});
|
|
187
|
-
|
|
188
144
|
return requestedFormat || this._getDefaultFormat();
|
|
189
145
|
}
|
|
190
|
-
|
|
191
146
|
}
|
|
192
|
-
|
|
193
147
|
exports.FileLayer = FileLayer;
|
package/target/node/index.js
CHANGED
|
@@ -9,22 +9,22 @@ Object.defineProperty(exports, "EMSClient", {
|
|
|
9
9
|
return _ems_client.EMSClient;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "FileLayer", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return
|
|
15
|
+
return _file_layer.FileLayer;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
Object.defineProperty(exports, "
|
|
18
|
+
Object.defineProperty(exports, "FileLayerField", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function () {
|
|
21
|
-
return
|
|
21
|
+
return _ems_client.FileLayerField;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(exports, "
|
|
24
|
+
Object.defineProperty(exports, "ORIGIN", {
|
|
25
25
|
enumerable: true,
|
|
26
26
|
get: function () {
|
|
27
|
-
return
|
|
27
|
+
return _origin.ORIGIN;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "TMSService", {
|
|
@@ -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
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /*
|
|
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) {
|