geoserver-node-client 0.0.5 → 1.0.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/LICENSE +25 -0
- package/README.md +81 -9
- package/dist/geoserver-rest-client.js +87 -0
- package/dist/package.json +55 -0
- package/dist/src/about.js +145 -0
- package/dist/src/datastore.js +1050 -0
- package/dist/src/imagemosaic.js +297 -0
- package/dist/src/layer.js +1040 -0
- package/dist/src/namespace.js +315 -0
- package/dist/src/security.js +297 -0
- package/dist/src/settings.js +345 -0
- package/dist/src/style.js +597 -0
- package/dist/src/util/geoserver.js +97 -0
- package/dist/src/workspace.js +321 -0
- package/geoserver-rest-client.js +15 -52
- package/package.json +28 -10
- package/src/about.js +59 -0
- package/src/datastore.js +161 -200
- package/src/imagemosaic.js +74 -97
- package/src/layer.js +376 -332
- package/src/namespace.js +84 -83
- package/src/security.js +61 -84
- package/src/settings.js +76 -91
- package/src/style.js +200 -147
- package/src/util/geoserver.js +41 -0
- package/src/workspace.js +89 -81
- package/.eslintrc.json +0 -20
- package/.github/workflows/ci-geoserver-node-client.yml +0 -54
- package/.github/workflows/ci-publish-docs.yml +0 -24
- package/.github/workflows/wait-for.sh +0 -145
- package/DOCS_HOME.md +0 -24
- package/demo/index.js +0 -188
- package/release-it.json +0 -8
- package/test/sample_data/iceland.gpkg +0 -0
- package/test/sample_data/world.geotiff +0 -0
- package/test/test.js +0 -491
|
@@ -0,0 +1,1040 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
|
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
18
|
+
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
19
|
+
|
|
20
|
+
var _geoserver = require("./util/geoserver.js");
|
|
21
|
+
|
|
22
|
+
var _about = _interopRequireDefault(require("./about.js"));
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Client for GeoServer layers
|
|
26
|
+
*
|
|
27
|
+
* @module LayerClient
|
|
28
|
+
*/
|
|
29
|
+
var LayerClient = /*#__PURE__*/function () {
|
|
30
|
+
/**
|
|
31
|
+
* Creates a GeoServer REST LayerClient instance.
|
|
32
|
+
*
|
|
33
|
+
* @param {String} url The URL of the GeoServer REST API endpoint
|
|
34
|
+
* @param {String} auth The Basic Authentication string
|
|
35
|
+
*/
|
|
36
|
+
function LayerClient(url, auth) {
|
|
37
|
+
(0, _classCallCheck2["default"])(this, LayerClient);
|
|
38
|
+
this.url = url;
|
|
39
|
+
this.auth = auth;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns a GeoServer layer by the given workspace and layer name,
|
|
43
|
+
* e.g. "myWs:myLayer".
|
|
44
|
+
*
|
|
45
|
+
* @param {String} workspace The name of the workspace, can be undefined
|
|
46
|
+
* @param {String} layerName The name of the layer to query
|
|
47
|
+
*
|
|
48
|
+
* @throws Error if request fails
|
|
49
|
+
*
|
|
50
|
+
* @returns {Object} An object with layer information or undefined if it cannot be found
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
(0, _createClass2["default"])(LayerClient, [{
|
|
55
|
+
key: "get",
|
|
56
|
+
value: function () {
|
|
57
|
+
var _get = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(workspace, layerName) {
|
|
58
|
+
var qualifiedName, response, grc, geoServerResponse;
|
|
59
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
60
|
+
while (1) {
|
|
61
|
+
switch (_context.prev = _context.next) {
|
|
62
|
+
case 0:
|
|
63
|
+
if (workspace) {
|
|
64
|
+
qualifiedName = "".concat(workspace, ":").concat(layerName);
|
|
65
|
+
} else {
|
|
66
|
+
qualifiedName = layerName;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_context.next = 3;
|
|
70
|
+
return (0, _nodeFetch["default"])(this.url + 'layers/' + qualifiedName + '.json', {
|
|
71
|
+
credentials: 'include',
|
|
72
|
+
method: 'GET',
|
|
73
|
+
headers: {
|
|
74
|
+
Authorization: this.auth
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
case 3:
|
|
79
|
+
response = _context.sent;
|
|
80
|
+
|
|
81
|
+
if (response.ok) {
|
|
82
|
+
_context.next = 16;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
grc = new _about["default"](this.url, this.auth);
|
|
87
|
+
_context.next = 8;
|
|
88
|
+
return grc.exists();
|
|
89
|
+
|
|
90
|
+
case 8:
|
|
91
|
+
if (!_context.sent) {
|
|
92
|
+
_context.next = 12;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return _context.abrupt("return");
|
|
97
|
+
|
|
98
|
+
case 12:
|
|
99
|
+
_context.next = 14;
|
|
100
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
101
|
+
|
|
102
|
+
case 14:
|
|
103
|
+
geoServerResponse = _context.sent;
|
|
104
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
105
|
+
|
|
106
|
+
case 16:
|
|
107
|
+
return _context.abrupt("return", response.json());
|
|
108
|
+
|
|
109
|
+
case 17:
|
|
110
|
+
case "end":
|
|
111
|
+
return _context.stop();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}, _callee, this);
|
|
115
|
+
}));
|
|
116
|
+
|
|
117
|
+
function get(_x, _x2) {
|
|
118
|
+
return _get.apply(this, arguments);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return get;
|
|
122
|
+
}()
|
|
123
|
+
/**
|
|
124
|
+
* Sets the attribution text and link of a layer.
|
|
125
|
+
*
|
|
126
|
+
* @param {String} workspace The name of the workspace, can be undefined
|
|
127
|
+
* @param {String} layerName The name of the layer to query
|
|
128
|
+
* @param {String} [attributionText] The attribution text
|
|
129
|
+
* @param {String} [attributionLink] The attribution link
|
|
130
|
+
*
|
|
131
|
+
* @throws Error if request fails
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
}, {
|
|
135
|
+
key: "modifyAttribution",
|
|
136
|
+
value: function () {
|
|
137
|
+
var _modifyAttribution = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(workspace, layerName, attributionText, attributionLink) {
|
|
138
|
+
var qualifiedName, jsonBody, url, response, geoServerResponse;
|
|
139
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
140
|
+
while (1) {
|
|
141
|
+
switch (_context2.prev = _context2.next) {
|
|
142
|
+
case 0:
|
|
143
|
+
if (workspace) {
|
|
144
|
+
qualifiedName = "".concat(workspace, ":").concat(layerName);
|
|
145
|
+
} else {
|
|
146
|
+
qualifiedName = layerName;
|
|
147
|
+
} // take existing layer properties as template
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
_context2.next = 3;
|
|
151
|
+
return this.get(workspace, layerName);
|
|
152
|
+
|
|
153
|
+
case 3:
|
|
154
|
+
jsonBody = _context2.sent;
|
|
155
|
+
|
|
156
|
+
if (!(!jsonBody || !jsonBody.layer || !jsonBody.layer.attribution)) {
|
|
157
|
+
_context2.next = 6;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
throw new _geoserver.GeoServerResponseError("layer '".concat(workspace, ":").concat(layerName, "' misses the property 'attribution'"));
|
|
162
|
+
|
|
163
|
+
case 6:
|
|
164
|
+
// set attribution text and link
|
|
165
|
+
if (attributionText) {
|
|
166
|
+
jsonBody.layer.attribution.title = attributionText;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (attributionLink) {
|
|
170
|
+
jsonBody.layer.attribution.href = attributionLink;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
url = this.url + 'layers/' + qualifiedName + '.json';
|
|
174
|
+
_context2.next = 11;
|
|
175
|
+
return (0, _nodeFetch["default"])(url, {
|
|
176
|
+
credentials: 'include',
|
|
177
|
+
method: 'PUT',
|
|
178
|
+
headers: {
|
|
179
|
+
Authorization: this.auth,
|
|
180
|
+
'Content-Type': 'application/json'
|
|
181
|
+
},
|
|
182
|
+
body: JSON.stringify(jsonBody)
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
case 11:
|
|
186
|
+
response = _context2.sent;
|
|
187
|
+
|
|
188
|
+
if (response.ok) {
|
|
189
|
+
_context2.next = 17;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
_context2.next = 15;
|
|
194
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
195
|
+
|
|
196
|
+
case 15:
|
|
197
|
+
geoServerResponse = _context2.sent;
|
|
198
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
199
|
+
|
|
200
|
+
case 17:
|
|
201
|
+
case "end":
|
|
202
|
+
return _context2.stop();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}, _callee2, this);
|
|
206
|
+
}));
|
|
207
|
+
|
|
208
|
+
function modifyAttribution(_x3, _x4, _x5, _x6) {
|
|
209
|
+
return _modifyAttribution.apply(this, arguments);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return modifyAttribution;
|
|
213
|
+
}()
|
|
214
|
+
/**
|
|
215
|
+
* Returns all layers in the GeoServer.
|
|
216
|
+
*
|
|
217
|
+
* @throws Error if request fails
|
|
218
|
+
*
|
|
219
|
+
* @returns {Object} An object with all layer information
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
}, {
|
|
223
|
+
key: "getAll",
|
|
224
|
+
value: function () {
|
|
225
|
+
var _getAll = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
226
|
+
var response, geoServerResponse;
|
|
227
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
228
|
+
while (1) {
|
|
229
|
+
switch (_context3.prev = _context3.next) {
|
|
230
|
+
case 0:
|
|
231
|
+
_context3.next = 2;
|
|
232
|
+
return (0, _nodeFetch["default"])(this.url + 'layers.json', {
|
|
233
|
+
credentials: 'include',
|
|
234
|
+
method: 'GET',
|
|
235
|
+
headers: {
|
|
236
|
+
Authorization: this.auth
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
case 2:
|
|
241
|
+
response = _context3.sent;
|
|
242
|
+
|
|
243
|
+
if (response.ok) {
|
|
244
|
+
_context3.next = 8;
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
_context3.next = 6;
|
|
249
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
250
|
+
|
|
251
|
+
case 6:
|
|
252
|
+
geoServerResponse = _context3.sent;
|
|
253
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
254
|
+
|
|
255
|
+
case 8:
|
|
256
|
+
return _context3.abrupt("return", response.json());
|
|
257
|
+
|
|
258
|
+
case 9:
|
|
259
|
+
case "end":
|
|
260
|
+
return _context3.stop();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}, _callee3, this);
|
|
264
|
+
}));
|
|
265
|
+
|
|
266
|
+
function getAll() {
|
|
267
|
+
return _getAll.apply(this, arguments);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return getAll;
|
|
271
|
+
}()
|
|
272
|
+
/**
|
|
273
|
+
* Publishes a FeatureType in the default data store of the workspace.
|
|
274
|
+
*
|
|
275
|
+
* @param {String} workspace Workspace to publish FeatureType in
|
|
276
|
+
* @param {String} [nativeName] Native name of FeatureType
|
|
277
|
+
* @param {String} name Published name of FeatureType
|
|
278
|
+
* @param {String} [title] Published title of FeatureType
|
|
279
|
+
* @param {String} [srs="EPSG:4326"] The SRS of the FeatureType
|
|
280
|
+
* @param {String} enabled Flag to enable FeatureType by default
|
|
281
|
+
* @param {String} [abstract] The abstract of the layer
|
|
282
|
+
*
|
|
283
|
+
* @throws Error if request fails
|
|
284
|
+
*/
|
|
285
|
+
|
|
286
|
+
}, {
|
|
287
|
+
key: "publishFeatureTypeDefaultDataStore",
|
|
288
|
+
value: function () {
|
|
289
|
+
var _publishFeatureTypeDefaultDataStore = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(workspace, nativeName, name, title, srs, enabled, _abstract) {
|
|
290
|
+
var body, response, geoServerResponse;
|
|
291
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
292
|
+
while (1) {
|
|
293
|
+
switch (_context4.prev = _context4.next) {
|
|
294
|
+
case 0:
|
|
295
|
+
body = {
|
|
296
|
+
featureType: {
|
|
297
|
+
name: name,
|
|
298
|
+
nativeName: nativeName || name,
|
|
299
|
+
title: title || name,
|
|
300
|
+
srs: srs || 'EPSG:4326',
|
|
301
|
+
enabled: enabled,
|
|
302
|
+
"abstract": _abstract || ''
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
_context4.next = 3;
|
|
306
|
+
return (0, _nodeFetch["default"])(this.url + 'workspaces/' + workspace + '/featuretypes', {
|
|
307
|
+
credentials: 'include',
|
|
308
|
+
method: 'POST',
|
|
309
|
+
headers: {
|
|
310
|
+
Authorization: this.auth,
|
|
311
|
+
'Content-Type': 'application/json'
|
|
312
|
+
},
|
|
313
|
+
body: JSON.stringify(body)
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
case 3:
|
|
317
|
+
response = _context4.sent;
|
|
318
|
+
|
|
319
|
+
if (response.ok) {
|
|
320
|
+
_context4.next = 9;
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
_context4.next = 7;
|
|
325
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
326
|
+
|
|
327
|
+
case 7:
|
|
328
|
+
geoServerResponse = _context4.sent;
|
|
329
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
330
|
+
|
|
331
|
+
case 9:
|
|
332
|
+
case "end":
|
|
333
|
+
return _context4.stop();
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}, _callee4, this);
|
|
337
|
+
}));
|
|
338
|
+
|
|
339
|
+
function publishFeatureTypeDefaultDataStore(_x7, _x8, _x9, _x10, _x11, _x12, _x13) {
|
|
340
|
+
return _publishFeatureTypeDefaultDataStore.apply(this, arguments);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return publishFeatureTypeDefaultDataStore;
|
|
344
|
+
}()
|
|
345
|
+
/**
|
|
346
|
+
* Publishes a FeatureType in the given data store of the workspace.
|
|
347
|
+
*
|
|
348
|
+
* @param {String} workspace Workspace to publish FeatureType in
|
|
349
|
+
* @param {String} dataStore The datastore where the FeatureType's data is in
|
|
350
|
+
* @param {String} [nativeName] Native name of FeatureType
|
|
351
|
+
* @param {String} name Published name of FeatureType
|
|
352
|
+
* @param {String} [title] Published title of FeatureType
|
|
353
|
+
* @param {String} [srs="EPSG:4326"] The SRS of the FeatureType
|
|
354
|
+
* @param {String} enabled Flag to enable FeatureType by default
|
|
355
|
+
* @param {String} [abstract] The abstract of the layer
|
|
356
|
+
* @param {String} [nativeBoundingBox] The native BoundingBox of the FeatureType (has to be set if no data is in store at creation time)
|
|
357
|
+
*
|
|
358
|
+
* @throws Error if request fails
|
|
359
|
+
*/
|
|
360
|
+
|
|
361
|
+
}, {
|
|
362
|
+
key: "publishFeatureType",
|
|
363
|
+
value: function () {
|
|
364
|
+
var _publishFeatureType = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(workspace, dataStore, nativeName, name, title, srs, enabled, _abstract2, nativeBoundingBox) {
|
|
365
|
+
var body, response, geoServerResponse;
|
|
366
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
367
|
+
while (1) {
|
|
368
|
+
switch (_context5.prev = _context5.next) {
|
|
369
|
+
case 0:
|
|
370
|
+
// apply CRS info for native BBOX if not provided
|
|
371
|
+
if (nativeBoundingBox && !nativeBoundingBox.crs) {
|
|
372
|
+
nativeBoundingBox.crs = {
|
|
373
|
+
'@class': 'projected',
|
|
374
|
+
$: srs
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
body = {
|
|
379
|
+
featureType: {
|
|
380
|
+
name: name || nativeName,
|
|
381
|
+
nativeName: nativeName,
|
|
382
|
+
title: title || name,
|
|
383
|
+
srs: srs || 'EPSG:4326',
|
|
384
|
+
enabled: enabled,
|
|
385
|
+
"abstract": _abstract2 || '',
|
|
386
|
+
nativeBoundingBox: nativeBoundingBox
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
_context5.next = 4;
|
|
390
|
+
return (0, _nodeFetch["default"])(this.url + 'workspaces/' + workspace + '/datastores/' + dataStore + '/featuretypes', {
|
|
391
|
+
credentials: 'include',
|
|
392
|
+
method: 'POST',
|
|
393
|
+
headers: {
|
|
394
|
+
Authorization: this.auth,
|
|
395
|
+
'Content-Type': 'application/json'
|
|
396
|
+
},
|
|
397
|
+
body: JSON.stringify(body)
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
case 4:
|
|
401
|
+
response = _context5.sent;
|
|
402
|
+
|
|
403
|
+
if (response.ok) {
|
|
404
|
+
_context5.next = 10;
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
_context5.next = 8;
|
|
409
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
410
|
+
|
|
411
|
+
case 8:
|
|
412
|
+
geoServerResponse = _context5.sent;
|
|
413
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
414
|
+
|
|
415
|
+
case 10:
|
|
416
|
+
case "end":
|
|
417
|
+
return _context5.stop();
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}, _callee5, this);
|
|
421
|
+
}));
|
|
422
|
+
|
|
423
|
+
function publishFeatureType(_x14, _x15, _x16, _x17, _x18, _x19, _x20, _x21, _x22) {
|
|
424
|
+
return _publishFeatureType.apply(this, arguments);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return publishFeatureType;
|
|
428
|
+
}()
|
|
429
|
+
/**
|
|
430
|
+
* Get detailed information about a FeatureType.
|
|
431
|
+
*
|
|
432
|
+
* @param {String} workspace The workspace of the FeatureType
|
|
433
|
+
* @param {String} datastore The datastore of the FeatureType
|
|
434
|
+
* @param {String} name The name of the FeatureType
|
|
435
|
+
*
|
|
436
|
+
* @throws Error if request fails
|
|
437
|
+
*
|
|
438
|
+
* @returns {Object} The object of the FeatureType
|
|
439
|
+
*/
|
|
440
|
+
|
|
441
|
+
}, {
|
|
442
|
+
key: "getFeatureType",
|
|
443
|
+
value: function () {
|
|
444
|
+
var _getFeatureType = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(workspace, datastore, name) {
|
|
445
|
+
var url, response, grc, geoServerResponse;
|
|
446
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
447
|
+
while (1) {
|
|
448
|
+
switch (_context6.prev = _context6.next) {
|
|
449
|
+
case 0:
|
|
450
|
+
url = this.url + 'workspaces/' + workspace + '/datastores/' + datastore + '/featuretypes/' + name + '.json';
|
|
451
|
+
_context6.next = 3;
|
|
452
|
+
return (0, _nodeFetch["default"])(url, {
|
|
453
|
+
credentials: 'include',
|
|
454
|
+
method: 'GET',
|
|
455
|
+
headers: {
|
|
456
|
+
Authorization: this.auth
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
case 3:
|
|
461
|
+
response = _context6.sent;
|
|
462
|
+
|
|
463
|
+
if (response.ok) {
|
|
464
|
+
_context6.next = 16;
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
grc = new _about["default"](this.url, this.auth);
|
|
469
|
+
_context6.next = 8;
|
|
470
|
+
return grc.exists();
|
|
471
|
+
|
|
472
|
+
case 8:
|
|
473
|
+
if (!_context6.sent) {
|
|
474
|
+
_context6.next = 12;
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
return _context6.abrupt("return");
|
|
479
|
+
|
|
480
|
+
case 12:
|
|
481
|
+
_context6.next = 14;
|
|
482
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
483
|
+
|
|
484
|
+
case 14:
|
|
485
|
+
geoServerResponse = _context6.sent;
|
|
486
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
487
|
+
|
|
488
|
+
case 16:
|
|
489
|
+
return _context6.abrupt("return", response.json());
|
|
490
|
+
|
|
491
|
+
case 17:
|
|
492
|
+
case "end":
|
|
493
|
+
return _context6.stop();
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}, _callee6, this);
|
|
497
|
+
}));
|
|
498
|
+
|
|
499
|
+
function getFeatureType(_x23, _x24, _x25) {
|
|
500
|
+
return _getFeatureType.apply(this, arguments);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
return getFeatureType;
|
|
504
|
+
}()
|
|
505
|
+
/**
|
|
506
|
+
* Publishes a WMS layer.
|
|
507
|
+
*
|
|
508
|
+
* @param {String} workspace Workspace to publish WMS layer in
|
|
509
|
+
* @param {String} dataStore The datastore where the WMS is connected
|
|
510
|
+
* @param {String} nativeName Native name of WMS layer
|
|
511
|
+
* @param {String} [name] Published name of WMS layer
|
|
512
|
+
* @param {String} [title] Published title of WMS layer
|
|
513
|
+
* @param {String} [srs="EPSG:4326"] The SRS of the WMS layer
|
|
514
|
+
* @param {String} enabled Flag to enable WMS layer by default
|
|
515
|
+
* @param {String} [abstract] The abstract of the layer
|
|
516
|
+
*
|
|
517
|
+
* @throws Error if request fails
|
|
518
|
+
*/
|
|
519
|
+
|
|
520
|
+
}, {
|
|
521
|
+
key: "publishWmsLayer",
|
|
522
|
+
value: function () {
|
|
523
|
+
var _publishWmsLayer = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(workspace, dataStore, nativeName, name, title, srs, enabled, _abstract3) {
|
|
524
|
+
var body, response, geoServerResponse;
|
|
525
|
+
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
526
|
+
while (1) {
|
|
527
|
+
switch (_context7.prev = _context7.next) {
|
|
528
|
+
case 0:
|
|
529
|
+
body = {
|
|
530
|
+
wmsLayer: {
|
|
531
|
+
name: name || nativeName,
|
|
532
|
+
nativeName: nativeName,
|
|
533
|
+
title: title || name || nativeName,
|
|
534
|
+
srs: srs || 'EPSG:4326',
|
|
535
|
+
enabled: enabled,
|
|
536
|
+
"abstract": _abstract3 || ''
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
_context7.next = 3;
|
|
540
|
+
return (0, _nodeFetch["default"])(this.url + 'workspaces/' + workspace + '/wmsstores/' + dataStore + '/wmslayers', {
|
|
541
|
+
credentials: 'include',
|
|
542
|
+
method: 'POST',
|
|
543
|
+
headers: {
|
|
544
|
+
Authorization: this.auth,
|
|
545
|
+
'Content-Type': 'application/json'
|
|
546
|
+
},
|
|
547
|
+
body: JSON.stringify(body)
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
case 3:
|
|
551
|
+
response = _context7.sent;
|
|
552
|
+
|
|
553
|
+
if (response.ok) {
|
|
554
|
+
_context7.next = 9;
|
|
555
|
+
break;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
_context7.next = 7;
|
|
559
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
560
|
+
|
|
561
|
+
case 7:
|
|
562
|
+
geoServerResponse = _context7.sent;
|
|
563
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
564
|
+
|
|
565
|
+
case 9:
|
|
566
|
+
case "end":
|
|
567
|
+
return _context7.stop();
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}, _callee7, this);
|
|
571
|
+
}));
|
|
572
|
+
|
|
573
|
+
function publishWmsLayer(_x26, _x27, _x28, _x29, _x30, _x31, _x32, _x33) {
|
|
574
|
+
return _publishWmsLayer.apply(this, arguments);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
return publishWmsLayer;
|
|
578
|
+
}()
|
|
579
|
+
/**
|
|
580
|
+
* Publishes a raster stored in a database.
|
|
581
|
+
*
|
|
582
|
+
* @param {String} workspace Workspace to publish layer in
|
|
583
|
+
* @param {String} coverageStore The coveragestore where the layer's data is in
|
|
584
|
+
* @param {String} nativeName Native name of raster
|
|
585
|
+
* @param {String} name Published name of layer
|
|
586
|
+
* @param {String} [title] Published title of layer
|
|
587
|
+
* @param {String} [srs="EPSG:4326"] The SRS of the layer
|
|
588
|
+
* @param {String} enabled Flag to enable layer by default
|
|
589
|
+
* @param {String} [abstract] The abstract of the layer
|
|
590
|
+
*
|
|
591
|
+
* @throws Error if request fails
|
|
592
|
+
*/
|
|
593
|
+
|
|
594
|
+
}, {
|
|
595
|
+
key: "publishDbRaster",
|
|
596
|
+
value: function () {
|
|
597
|
+
var _publishDbRaster = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(workspace, coverageStore, nativeName, name, title, srs, enabled, _abstract4) {
|
|
598
|
+
var body, response, geoServerResponse;
|
|
599
|
+
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
|
600
|
+
while (1) {
|
|
601
|
+
switch (_context8.prev = _context8.next) {
|
|
602
|
+
case 0:
|
|
603
|
+
body = {
|
|
604
|
+
coverage: {
|
|
605
|
+
name: name || nativeName,
|
|
606
|
+
nativeName: nativeName,
|
|
607
|
+
title: title || name,
|
|
608
|
+
srs: srs,
|
|
609
|
+
enabled: enabled,
|
|
610
|
+
"abstract": _abstract4 || ''
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
_context8.next = 3;
|
|
614
|
+
return (0, _nodeFetch["default"])(this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/coverages', {
|
|
615
|
+
credentials: 'include',
|
|
616
|
+
method: 'POST',
|
|
617
|
+
headers: {
|
|
618
|
+
Authorization: this.auth,
|
|
619
|
+
'Content-Type': 'application/json'
|
|
620
|
+
},
|
|
621
|
+
body: JSON.stringify(body)
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
case 3:
|
|
625
|
+
response = _context8.sent;
|
|
626
|
+
|
|
627
|
+
if (response.ok) {
|
|
628
|
+
_context8.next = 9;
|
|
629
|
+
break;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
_context8.next = 7;
|
|
633
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
634
|
+
|
|
635
|
+
case 7:
|
|
636
|
+
geoServerResponse = _context8.sent;
|
|
637
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
638
|
+
|
|
639
|
+
case 9:
|
|
640
|
+
case "end":
|
|
641
|
+
return _context8.stop();
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}, _callee8, this);
|
|
645
|
+
}));
|
|
646
|
+
|
|
647
|
+
function publishDbRaster(_x34, _x35, _x36, _x37, _x38, _x39, _x40, _x41) {
|
|
648
|
+
return _publishDbRaster.apply(this, arguments);
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
return publishDbRaster;
|
|
652
|
+
}()
|
|
653
|
+
/**
|
|
654
|
+
* Deletes a FeatureType.
|
|
655
|
+
*
|
|
656
|
+
* @param {String} workspace Workspace where layer to delete is in
|
|
657
|
+
* @param {String} datastore The datastore where the layer to delete is in
|
|
658
|
+
* @param {String} name Layer to delete
|
|
659
|
+
* @param {Boolean} recurse Flag to enable recursive deletion
|
|
660
|
+
*
|
|
661
|
+
* @throws Error if request fails
|
|
662
|
+
*/
|
|
663
|
+
|
|
664
|
+
}, {
|
|
665
|
+
key: "deleteFeatureType",
|
|
666
|
+
value: function () {
|
|
667
|
+
var _deleteFeatureType = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(workspace, datastore, name, recurse) {
|
|
668
|
+
var response, geoServerResponse;
|
|
669
|
+
return _regenerator["default"].wrap(function _callee9$(_context9) {
|
|
670
|
+
while (1) {
|
|
671
|
+
switch (_context9.prev = _context9.next) {
|
|
672
|
+
case 0:
|
|
673
|
+
_context9.next = 2;
|
|
674
|
+
return (0, _nodeFetch["default"])(this.url + 'workspaces/' + workspace + '/datastores/' + datastore + '/featuretypes/' + name + '?recurse=' + recurse, {
|
|
675
|
+
credentials: 'include',
|
|
676
|
+
method: 'DELETE',
|
|
677
|
+
headers: {
|
|
678
|
+
Authorization: this.auth
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
|
|
682
|
+
case 2:
|
|
683
|
+
response = _context9.sent;
|
|
684
|
+
|
|
685
|
+
if (response.ok) {
|
|
686
|
+
_context9.next = 8;
|
|
687
|
+
break;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
_context9.next = 6;
|
|
691
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
692
|
+
|
|
693
|
+
case 6:
|
|
694
|
+
geoServerResponse = _context9.sent;
|
|
695
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
696
|
+
|
|
697
|
+
case 8:
|
|
698
|
+
case "end":
|
|
699
|
+
return _context9.stop();
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}, _callee9, this);
|
|
703
|
+
}));
|
|
704
|
+
|
|
705
|
+
function deleteFeatureType(_x42, _x43, _x44, _x45) {
|
|
706
|
+
return _deleteFeatureType.apply(this, arguments);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
return deleteFeatureType;
|
|
710
|
+
}()
|
|
711
|
+
/**
|
|
712
|
+
* Enables TIME dimension for the given coverage layer.
|
|
713
|
+
*
|
|
714
|
+
* @param {String} workspace Workspace where layer to enable time dimension for is in
|
|
715
|
+
* @param {String} datastore The datastore where the layer to enable time dimension for is in
|
|
716
|
+
* @param {String} name Layer to enable time dimension for
|
|
717
|
+
* @param {String} presentation Presentation type: 'LIST' or 'DISCRETE_INTERVAL' or 'CONTINUOUS_INTERVAL'
|
|
718
|
+
* @param {Number} resolution Resolution in milliseconds, e.g. 3600000 for 1 hour
|
|
719
|
+
* @param {String} defaultValue The default time value, e.g. 'MINIMUM' or 'MAXIMUM' or 'NEAREST' or 'FIXED'
|
|
720
|
+
* @param {Boolean} [nearestMatchEnabled] Enable nearest match
|
|
721
|
+
* @param {Boolean} [rawNearestMatchEnabled] Enable raw nearest match
|
|
722
|
+
* @param {String} [acceptableInterval] Acceptable interval for nearest match, e.g.'PT30M'
|
|
723
|
+
*
|
|
724
|
+
* @throws Error if request fails
|
|
725
|
+
*/
|
|
726
|
+
|
|
727
|
+
}, {
|
|
728
|
+
key: "enableTimeCoverage",
|
|
729
|
+
value: function () {
|
|
730
|
+
var _enableTimeCoverage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(workspace, dataStore, name, presentation, resolution, defaultValue, nearestMatchEnabled, rawNearestMatchEnabled, acceptableInterval) {
|
|
731
|
+
var body, url, response, geoServerResponse;
|
|
732
|
+
return _regenerator["default"].wrap(function _callee10$(_context10) {
|
|
733
|
+
while (1) {
|
|
734
|
+
switch (_context10.prev = _context10.next) {
|
|
735
|
+
case 0:
|
|
736
|
+
body = {
|
|
737
|
+
coverage: {
|
|
738
|
+
metadata: {
|
|
739
|
+
entry: [{
|
|
740
|
+
'@key': 'time',
|
|
741
|
+
dimensionInfo: {
|
|
742
|
+
presentation: presentation || 'DISCRETE_INTERVAL',
|
|
743
|
+
resolution: resolution,
|
|
744
|
+
units: 'ISO8601',
|
|
745
|
+
defaultValue: {
|
|
746
|
+
strategy: defaultValue
|
|
747
|
+
},
|
|
748
|
+
nearestMatchEnabled: nearestMatchEnabled,
|
|
749
|
+
rawNearestMatchEnabled: rawNearestMatchEnabled,
|
|
750
|
+
acceptableInterval: acceptableInterval
|
|
751
|
+
}
|
|
752
|
+
}]
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
};
|
|
756
|
+
url = this.url + 'workspaces/' + workspace + '/coveragestores/' + dataStore + '/coverages/' + name + '.json';
|
|
757
|
+
_context10.next = 4;
|
|
758
|
+
return (0, _nodeFetch["default"])(url, {
|
|
759
|
+
credentials: 'include',
|
|
760
|
+
method: 'PUT',
|
|
761
|
+
headers: {
|
|
762
|
+
Authorization: this.auth,
|
|
763
|
+
'Content-Type': 'application/json'
|
|
764
|
+
},
|
|
765
|
+
body: JSON.stringify(body)
|
|
766
|
+
});
|
|
767
|
+
|
|
768
|
+
case 4:
|
|
769
|
+
response = _context10.sent;
|
|
770
|
+
|
|
771
|
+
if (response.ok) {
|
|
772
|
+
_context10.next = 10;
|
|
773
|
+
break;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
_context10.next = 8;
|
|
777
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
778
|
+
|
|
779
|
+
case 8:
|
|
780
|
+
geoServerResponse = _context10.sent;
|
|
781
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
782
|
+
|
|
783
|
+
case 10:
|
|
784
|
+
case "end":
|
|
785
|
+
return _context10.stop();
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}, _callee10, this);
|
|
789
|
+
}));
|
|
790
|
+
|
|
791
|
+
function enableTimeCoverage(_x46, _x47, _x48, _x49, _x50, _x51, _x52, _x53, _x54) {
|
|
792
|
+
return _enableTimeCoverage.apply(this, arguments);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
return enableTimeCoverage;
|
|
796
|
+
}()
|
|
797
|
+
/**
|
|
798
|
+
* Enables TIME dimension for the given FeatureType layer.
|
|
799
|
+
*
|
|
800
|
+
* @param {String} workspace Workspace containing layer to enable time dimension for
|
|
801
|
+
* @param {String} datastore The datastore containing the FeatureType to enable time dimension for
|
|
802
|
+
* @param {String} name FeatureType to enable time dimension for
|
|
803
|
+
* @param {String} attribute Data column / attribute holding the time values
|
|
804
|
+
* @param {String} presentation Presentation type: 'LIST' or 'DISCRETE_INTERVAL' or 'CONTINUOUS_INTERVAL'
|
|
805
|
+
* @param {Number} resolution Resolution in milliseconds, e.g. 3600000 for 1 hour
|
|
806
|
+
* @param {String} defaultValue The default time value, e.g. 'MINIMUM' or 'MAXIMUM' or 'NEAREST' or 'FIXED'
|
|
807
|
+
* @param {Boolean} [nearestMatchEnabled] Enable nearest match
|
|
808
|
+
* @param {Boolean} [rawNearestMatchEnabled] Enable raw nearest match
|
|
809
|
+
*
|
|
810
|
+
* @throws Error if request fails
|
|
811
|
+
*/
|
|
812
|
+
|
|
813
|
+
}, {
|
|
814
|
+
key: "enableTimeFeatureType",
|
|
815
|
+
value: function () {
|
|
816
|
+
var _enableTimeFeatureType = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee11(workspace, dataStore, name, attribute, presentation, resolution, defaultValue, nearestMatchEnabled, rawNearestMatchEnabled, acceptableInterval) {
|
|
817
|
+
var body, url, response, geoServerResponse;
|
|
818
|
+
return _regenerator["default"].wrap(function _callee11$(_context11) {
|
|
819
|
+
while (1) {
|
|
820
|
+
switch (_context11.prev = _context11.next) {
|
|
821
|
+
case 0:
|
|
822
|
+
body = {
|
|
823
|
+
featureType: {
|
|
824
|
+
metadata: {
|
|
825
|
+
entry: [{
|
|
826
|
+
'@key': 'time',
|
|
827
|
+
dimensionInfo: {
|
|
828
|
+
attribute: attribute,
|
|
829
|
+
presentation: presentation,
|
|
830
|
+
resolution: resolution,
|
|
831
|
+
units: 'ISO8601',
|
|
832
|
+
defaultValue: {
|
|
833
|
+
strategy: defaultValue
|
|
834
|
+
},
|
|
835
|
+
nearestMatchEnabled: nearestMatchEnabled,
|
|
836
|
+
rawNearestMatchEnabled: rawNearestMatchEnabled,
|
|
837
|
+
acceptableInterval: acceptableInterval
|
|
838
|
+
}
|
|
839
|
+
}]
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
url = this.url + 'workspaces/' + workspace + '/datastores/' + dataStore + '/featuretypes/' + name + '.json';
|
|
844
|
+
_context11.next = 4;
|
|
845
|
+
return (0, _nodeFetch["default"])(url, {
|
|
846
|
+
credentials: 'include',
|
|
847
|
+
method: 'PUT',
|
|
848
|
+
headers: {
|
|
849
|
+
Authorization: this.auth,
|
|
850
|
+
'Content-Type': 'application/json'
|
|
851
|
+
},
|
|
852
|
+
body: JSON.stringify(body)
|
|
853
|
+
});
|
|
854
|
+
|
|
855
|
+
case 4:
|
|
856
|
+
response = _context11.sent;
|
|
857
|
+
|
|
858
|
+
if (response.ok) {
|
|
859
|
+
_context11.next = 10;
|
|
860
|
+
break;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
_context11.next = 8;
|
|
864
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
865
|
+
|
|
866
|
+
case 8:
|
|
867
|
+
geoServerResponse = _context11.sent;
|
|
868
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
869
|
+
|
|
870
|
+
case 10:
|
|
871
|
+
case "end":
|
|
872
|
+
return _context11.stop();
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
}, _callee11, this);
|
|
876
|
+
}));
|
|
877
|
+
|
|
878
|
+
function enableTimeFeatureType(_x55, _x56, _x57, _x58, _x59, _x60, _x61, _x62, _x63, _x64) {
|
|
879
|
+
return _enableTimeFeatureType.apply(this, arguments);
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
return enableTimeFeatureType;
|
|
883
|
+
}()
|
|
884
|
+
/**
|
|
885
|
+
* Returns a dedicated coverage object.
|
|
886
|
+
*
|
|
887
|
+
* @param {String} workspace Workspace containing the coverage
|
|
888
|
+
* @param {String} coverageStore The coveragestore containing the coverage
|
|
889
|
+
* @param {String} name Coverage to query
|
|
890
|
+
*
|
|
891
|
+
* @throws Error if request fails
|
|
892
|
+
*
|
|
893
|
+
* @returns {Object} An object with coverage information or undefined if it cannot be found
|
|
894
|
+
*/
|
|
895
|
+
|
|
896
|
+
}, {
|
|
897
|
+
key: "getCoverage",
|
|
898
|
+
value: function () {
|
|
899
|
+
var _getCoverage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12(workspace, coverageStore, name) {
|
|
900
|
+
var url, response, grc, geoServerResponse;
|
|
901
|
+
return _regenerator["default"].wrap(function _callee12$(_context12) {
|
|
902
|
+
while (1) {
|
|
903
|
+
switch (_context12.prev = _context12.next) {
|
|
904
|
+
case 0:
|
|
905
|
+
url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/coverages/' + name + '.json';
|
|
906
|
+
_context12.next = 3;
|
|
907
|
+
return (0, _nodeFetch["default"])(url, {
|
|
908
|
+
credentials: 'include',
|
|
909
|
+
method: 'GET',
|
|
910
|
+
headers: {
|
|
911
|
+
Authorization: this.auth
|
|
912
|
+
}
|
|
913
|
+
});
|
|
914
|
+
|
|
915
|
+
case 3:
|
|
916
|
+
response = _context12.sent;
|
|
917
|
+
|
|
918
|
+
if (response.ok) {
|
|
919
|
+
_context12.next = 16;
|
|
920
|
+
break;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
grc = new _about["default"](this.url, this.auth);
|
|
924
|
+
_context12.next = 8;
|
|
925
|
+
return grc.exists();
|
|
926
|
+
|
|
927
|
+
case 8:
|
|
928
|
+
if (!_context12.sent) {
|
|
929
|
+
_context12.next = 12;
|
|
930
|
+
break;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
return _context12.abrupt("return");
|
|
934
|
+
|
|
935
|
+
case 12:
|
|
936
|
+
_context12.next = 14;
|
|
937
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
938
|
+
|
|
939
|
+
case 14:
|
|
940
|
+
geoServerResponse = _context12.sent;
|
|
941
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
942
|
+
|
|
943
|
+
case 16:
|
|
944
|
+
return _context12.abrupt("return", response.json());
|
|
945
|
+
|
|
946
|
+
case 17:
|
|
947
|
+
case "end":
|
|
948
|
+
return _context12.stop();
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}, _callee12, this);
|
|
952
|
+
}));
|
|
953
|
+
|
|
954
|
+
function getCoverage(_x65, _x66, _x67) {
|
|
955
|
+
return _getCoverage.apply(this, arguments);
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
return getCoverage;
|
|
959
|
+
}()
|
|
960
|
+
/**
|
|
961
|
+
* Renames the existing bands of a coverage layer.
|
|
962
|
+
*
|
|
963
|
+
* Make sure to provide the same number of bands as existing in the layer.
|
|
964
|
+
*
|
|
965
|
+
* @param {String} workspace Workspace of layer
|
|
966
|
+
* @param {String} datastore The datastore of the layer
|
|
967
|
+
* @param {String} layername The layer name
|
|
968
|
+
* @param {String[]} bandNames An array of the new band names in correct order
|
|
969
|
+
*
|
|
970
|
+
* @throws Error if request fails
|
|
971
|
+
*/
|
|
972
|
+
|
|
973
|
+
}, {
|
|
974
|
+
key: "renameCoverageBands",
|
|
975
|
+
value: function () {
|
|
976
|
+
var _renameCoverageBands = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13(workspace, dataStore, layername, bandNames) {
|
|
977
|
+
var body, url, response, geoServerResponse;
|
|
978
|
+
return _regenerator["default"].wrap(function _callee13$(_context13) {
|
|
979
|
+
while (1) {
|
|
980
|
+
switch (_context13.prev = _context13.next) {
|
|
981
|
+
case 0:
|
|
982
|
+
body = {
|
|
983
|
+
coverage: {
|
|
984
|
+
dimensions: {
|
|
985
|
+
coverageDimension: []
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
}; // dynamically create the body
|
|
989
|
+
|
|
990
|
+
bandNames.forEach(function (bandName) {
|
|
991
|
+
body.coverage.dimensions.coverageDimension.push({
|
|
992
|
+
name: bandName
|
|
993
|
+
});
|
|
994
|
+
});
|
|
995
|
+
url = this.url + 'workspaces/' + workspace + '/coveragestores/' + dataStore + '/coverages/' + layername + '.json';
|
|
996
|
+
_context13.next = 5;
|
|
997
|
+
return (0, _nodeFetch["default"])(url, {
|
|
998
|
+
credentials: 'include',
|
|
999
|
+
method: 'PUT',
|
|
1000
|
+
headers: {
|
|
1001
|
+
Authorization: this.auth,
|
|
1002
|
+
'Content-Type': 'application/json'
|
|
1003
|
+
},
|
|
1004
|
+
body: JSON.stringify(body)
|
|
1005
|
+
});
|
|
1006
|
+
|
|
1007
|
+
case 5:
|
|
1008
|
+
response = _context13.sent;
|
|
1009
|
+
|
|
1010
|
+
if (response.ok) {
|
|
1011
|
+
_context13.next = 11;
|
|
1012
|
+
break;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
_context13.next = 9;
|
|
1016
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
1017
|
+
|
|
1018
|
+
case 9:
|
|
1019
|
+
geoServerResponse = _context13.sent;
|
|
1020
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
1021
|
+
|
|
1022
|
+
case 11:
|
|
1023
|
+
case "end":
|
|
1024
|
+
return _context13.stop();
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
}, _callee13, this);
|
|
1028
|
+
}));
|
|
1029
|
+
|
|
1030
|
+
function renameCoverageBands(_x68, _x69, _x70, _x71) {
|
|
1031
|
+
return _renameCoverageBands.apply(this, arguments);
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
return renameCoverageBands;
|
|
1035
|
+
}()
|
|
1036
|
+
}]);
|
|
1037
|
+
return LayerClient;
|
|
1038
|
+
}();
|
|
1039
|
+
|
|
1040
|
+
exports["default"] = LayerClient;
|