geoserver-node-client 1.6.1 → 1.6.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/dist/geoserver-rest-client.js +38 -39
- package/dist/package.json +7 -7
- package/dist/src/about.js +35 -86
- package/dist/src/datastore.js +524 -950
- package/dist/src/imagemosaic.js +103 -211
- package/dist/src/layer.js +718 -1287
- package/dist/src/layergroup.js +128 -226
- package/dist/src/namespace.js +110 -222
- package/dist/src/reset-reload.js +41 -96
- package/dist/src/security.js +279 -567
- package/dist/src/settings.js +127 -255
- package/dist/src/style.js +228 -448
- package/dist/src/util/geoserver.js +17 -44
- package/dist/src/workspace.js +116 -229
- package/package.json +7 -7
package/dist/src/layer.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
7
|
+
exports.default = void 0;
|
|
12
8
|
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
13
9
|
var _geoserver = require("./util/geoserver.js");
|
|
14
10
|
var _about = _interopRequireDefault(require("./about.js"));
|
|
@@ -17,15 +13,14 @@ var _about = _interopRequireDefault(require("./about.js"));
|
|
|
17
13
|
*
|
|
18
14
|
* @module LayerClient
|
|
19
15
|
*/
|
|
20
|
-
|
|
16
|
+
class LayerClient {
|
|
21
17
|
/**
|
|
22
18
|
* Creates a GeoServer REST LayerClient instance.
|
|
23
19
|
*
|
|
24
20
|
* @param {String} url The URL of the GeoServer REST API endpoint
|
|
25
21
|
* @param {String} auth The Basic Authentication string
|
|
26
22
|
*/
|
|
27
|
-
|
|
28
|
-
(0, _classCallCheck2["default"])(this, LayerClient);
|
|
23
|
+
constructor(url, auth) {
|
|
29
24
|
this.url = url;
|
|
30
25
|
this.auth = auth;
|
|
31
26
|
}
|
|
@@ -41,1301 +36,737 @@ var LayerClient = exports["default"] = /*#__PURE__*/function () {
|
|
|
41
36
|
*
|
|
42
37
|
* @returns {Object} An object with layer information or undefined if it cannot be found
|
|
43
38
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
_context.next = 1;
|
|
58
|
-
return (0, _nodeFetch["default"])(this.url + 'layers/' + qualifiedName + '.json', {
|
|
59
|
-
credentials: 'include',
|
|
60
|
-
method: 'GET',
|
|
61
|
-
headers: {
|
|
62
|
-
Authorization: this.auth
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
case 1:
|
|
66
|
-
response = _context.sent;
|
|
67
|
-
if (response.ok) {
|
|
68
|
-
_context.next = 5;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
grc = new _about["default"](this.url, this.auth);
|
|
72
|
-
_context.next = 2;
|
|
73
|
-
return grc.exists();
|
|
74
|
-
case 2:
|
|
75
|
-
if (!_context.sent) {
|
|
76
|
-
_context.next = 3;
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
return _context.abrupt("return");
|
|
80
|
-
case 3:
|
|
81
|
-
_context.next = 4;
|
|
82
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
83
|
-
case 4:
|
|
84
|
-
geoServerResponse = _context.sent;
|
|
85
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
86
|
-
case 5:
|
|
87
|
-
return _context.abrupt("return", response.json());
|
|
88
|
-
case 6:
|
|
89
|
-
case "end":
|
|
90
|
-
return _context.stop();
|
|
91
|
-
}
|
|
92
|
-
}, _callee, this);
|
|
93
|
-
}));
|
|
94
|
-
function get(_x, _x2) {
|
|
95
|
-
return _get.apply(this, arguments);
|
|
39
|
+
async get(workspace, layerName) {
|
|
40
|
+
let qualifiedName;
|
|
41
|
+
if (workspace) {
|
|
42
|
+
qualifiedName = `${workspace}:${layerName}`;
|
|
43
|
+
} else {
|
|
44
|
+
qualifiedName = layerName;
|
|
45
|
+
}
|
|
46
|
+
const response = await (0, _nodeFetch.default)(this.url + 'layers/' + qualifiedName + '.json', {
|
|
47
|
+
credentials: 'include',
|
|
48
|
+
method: 'GET',
|
|
49
|
+
headers: {
|
|
50
|
+
Authorization: this.auth
|
|
96
51
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
* @throws Error if request fails
|
|
108
|
-
*/
|
|
109
|
-
)
|
|
110
|
-
}, {
|
|
111
|
-
key: "modifyAttribution",
|
|
112
|
-
value: (function () {
|
|
113
|
-
var _modifyAttribution = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(workspace, layerName, attributionText, attributionLink) {
|
|
114
|
-
var qualifiedName, jsonBody, url, response, geoServerResponse;
|
|
115
|
-
return _regenerator["default"].wrap(function (_context2) {
|
|
116
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
117
|
-
case 0:
|
|
118
|
-
if (workspace) {
|
|
119
|
-
qualifiedName = "".concat(workspace, ":").concat(layerName);
|
|
120
|
-
} else {
|
|
121
|
-
qualifiedName = layerName;
|
|
122
|
-
}
|
|
123
|
-
// take existing layer properties as template
|
|
124
|
-
_context2.next = 1;
|
|
125
|
-
return this.get(workspace, layerName);
|
|
126
|
-
case 1:
|
|
127
|
-
jsonBody = _context2.sent;
|
|
128
|
-
if (!(!jsonBody || !jsonBody.layer || !jsonBody.layer.attribution)) {
|
|
129
|
-
_context2.next = 2;
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
throw new _geoserver.GeoServerResponseError("layer '".concat(workspace, ":").concat(layerName, "' misses the property 'attribution'"));
|
|
133
|
-
case 2:
|
|
134
|
-
// set attribution text and link
|
|
135
|
-
if (attributionText) {
|
|
136
|
-
jsonBody.layer.attribution.title = attributionText;
|
|
137
|
-
}
|
|
138
|
-
if (attributionLink) {
|
|
139
|
-
jsonBody.layer.attribution.href = attributionLink;
|
|
140
|
-
}
|
|
141
|
-
url = this.url + 'layers/' + qualifiedName + '.json';
|
|
142
|
-
_context2.next = 3;
|
|
143
|
-
return (0, _nodeFetch["default"])(url, {
|
|
144
|
-
credentials: 'include',
|
|
145
|
-
method: 'PUT',
|
|
146
|
-
headers: {
|
|
147
|
-
Authorization: this.auth,
|
|
148
|
-
'Content-Type': 'application/json'
|
|
149
|
-
},
|
|
150
|
-
body: JSON.stringify(jsonBody)
|
|
151
|
-
});
|
|
152
|
-
case 3:
|
|
153
|
-
response = _context2.sent;
|
|
154
|
-
if (response.ok) {
|
|
155
|
-
_context2.next = 5;
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
_context2.next = 4;
|
|
159
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
160
|
-
case 4:
|
|
161
|
-
geoServerResponse = _context2.sent;
|
|
162
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
163
|
-
case 5:
|
|
164
|
-
case "end":
|
|
165
|
-
return _context2.stop();
|
|
166
|
-
}
|
|
167
|
-
}, _callee2, this);
|
|
168
|
-
}));
|
|
169
|
-
function modifyAttribution(_x3, _x4, _x5, _x6) {
|
|
170
|
-
return _modifyAttribution.apply(this, arguments);
|
|
52
|
+
});
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
const grc = new _about.default(this.url, this.auth);
|
|
55
|
+
if (await grc.exists()) {
|
|
56
|
+
// GeoServer exists, but requested item does not exist, we return empty
|
|
57
|
+
return;
|
|
58
|
+
} else {
|
|
59
|
+
// There was a general problem with GeoServer
|
|
60
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
61
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
171
62
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
63
|
+
}
|
|
64
|
+
return response.json();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Sets the attribution text and link of a layer.
|
|
69
|
+
*
|
|
70
|
+
* @param {String} workspace The name of the workspace, can be undefined
|
|
71
|
+
* @param {String} layerName The name of the layer to query
|
|
72
|
+
* @param {String} [attributionText] The attribution text
|
|
73
|
+
* @param {String} [attributionLink] The attribution link
|
|
74
|
+
*
|
|
75
|
+
* @throws Error if request fails
|
|
76
|
+
*/
|
|
77
|
+
async modifyAttribution(workspace, layerName, attributionText, attributionLink) {
|
|
78
|
+
let qualifiedName;
|
|
79
|
+
if (workspace) {
|
|
80
|
+
qualifiedName = `${workspace}:${layerName}`;
|
|
81
|
+
} else {
|
|
82
|
+
qualifiedName = layerName;
|
|
83
|
+
}
|
|
84
|
+
// take existing layer properties as template
|
|
85
|
+
const jsonBody = await this.get(workspace, layerName);
|
|
86
|
+
if (!jsonBody || !jsonBody.layer || !jsonBody.layer.attribution) {
|
|
87
|
+
throw new _geoserver.GeoServerResponseError(`layer '${workspace}:${layerName}' misses the property 'attribution'`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// set attribution text and link
|
|
91
|
+
if (attributionText) {
|
|
92
|
+
jsonBody.layer.attribution.title = attributionText;
|
|
93
|
+
}
|
|
94
|
+
if (attributionLink) {
|
|
95
|
+
jsonBody.layer.attribution.href = attributionLink;
|
|
96
|
+
}
|
|
97
|
+
const url = this.url + 'layers/' + qualifiedName + '.json';
|
|
98
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
99
|
+
credentials: 'include',
|
|
100
|
+
method: 'PUT',
|
|
101
|
+
headers: {
|
|
102
|
+
Authorization: this.auth,
|
|
103
|
+
'Content-Type': 'application/json'
|
|
104
|
+
},
|
|
105
|
+
body: JSON.stringify(jsonBody)
|
|
106
|
+
});
|
|
107
|
+
if (!response.ok) {
|
|
108
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
109
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Returns all layers in the GeoServer.
|
|
115
|
+
*
|
|
116
|
+
* @throws Error if request fails
|
|
117
|
+
*
|
|
118
|
+
* @returns {Object} An object with all layer information
|
|
119
|
+
*/
|
|
120
|
+
async getAll() {
|
|
121
|
+
const response = await (0, _nodeFetch.default)(this.url + 'layers.json', {
|
|
122
|
+
credentials: 'include',
|
|
123
|
+
method: 'GET',
|
|
124
|
+
headers: {
|
|
125
|
+
Authorization: this.auth
|
|
219
126
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
method: 'GET',
|
|
244
|
-
headers: {
|
|
245
|
-
Authorization: this.auth
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
case 1:
|
|
249
|
-
response = _context4.sent;
|
|
250
|
-
if (response.ok) {
|
|
251
|
-
_context4.next = 3;
|
|
252
|
-
break;
|
|
253
|
-
}
|
|
254
|
-
_context4.next = 2;
|
|
255
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
256
|
-
case 2:
|
|
257
|
-
geoServerResponse = _context4.sent;
|
|
258
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
259
|
-
case 3:
|
|
260
|
-
_context4.next = 4;
|
|
261
|
-
return response.json();
|
|
262
|
-
case 4:
|
|
263
|
-
return _context4.abrupt("return", _context4.sent);
|
|
264
|
-
case 5:
|
|
265
|
-
case "end":
|
|
266
|
-
return _context4.stop();
|
|
267
|
-
}
|
|
268
|
-
}, _callee4, this);
|
|
269
|
-
}));
|
|
270
|
-
function getLayers(_x7) {
|
|
271
|
-
return _getLayers.apply(this, arguments);
|
|
127
|
+
});
|
|
128
|
+
if (!response.ok) {
|
|
129
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
130
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
131
|
+
}
|
|
132
|
+
return response.json();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Get all layers of a workspace.
|
|
137
|
+
*
|
|
138
|
+
* @param {String} workspace The workspace
|
|
139
|
+
*
|
|
140
|
+
* @throws Error if request fails
|
|
141
|
+
*
|
|
142
|
+
* @return {Object} An object with the information about the layers
|
|
143
|
+
*/
|
|
144
|
+
async getLayers(workspace) {
|
|
145
|
+
const response = await (0, _nodeFetch.default)(this.url + 'workspaces/' + workspace + '/layers.json', {
|
|
146
|
+
credentials: 'include',
|
|
147
|
+
method: 'GET',
|
|
148
|
+
headers: {
|
|
149
|
+
Authorization: this.auth
|
|
272
150
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
grc = new _about["default"](this.url, this.auth);
|
|
310
|
-
_context5.next = 2;
|
|
311
|
-
return grc.exists();
|
|
312
|
-
case 2:
|
|
313
|
-
if (!_context5.sent) {
|
|
314
|
-
_context5.next = 3;
|
|
315
|
-
break;
|
|
316
|
-
}
|
|
317
|
-
return _context5.abrupt("return");
|
|
318
|
-
case 3:
|
|
319
|
-
_context5.next = 4;
|
|
320
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
321
|
-
case 4:
|
|
322
|
-
geoServerResponse = _context5.sent;
|
|
323
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
324
|
-
case 5:
|
|
325
|
-
_context5.next = 6;
|
|
326
|
-
return response.json();
|
|
327
|
-
case 6:
|
|
328
|
-
return _context5.abrupt("return", _context5.sent);
|
|
329
|
-
case 7:
|
|
330
|
-
case "end":
|
|
331
|
-
return _context5.stop();
|
|
332
|
-
}
|
|
333
|
-
}, _callee5, this);
|
|
334
|
-
}));
|
|
335
|
-
function getWmsLayer(_x8, _x9, _x0) {
|
|
336
|
-
return _getWmsLayer.apply(this, arguments);
|
|
151
|
+
});
|
|
152
|
+
if (!response.ok) {
|
|
153
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
154
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
155
|
+
}
|
|
156
|
+
return await response.json();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Returns information about a cascaded WMS layer.
|
|
161
|
+
*
|
|
162
|
+
* @param {String} workspace The workspace
|
|
163
|
+
* @param {String} datastore The datastore
|
|
164
|
+
* @param {String} layerName The WMS layer name
|
|
165
|
+
*
|
|
166
|
+
* @throws Error if request fails
|
|
167
|
+
*
|
|
168
|
+
* @returns {Object} An object with layer information or undefined if it cannot be found
|
|
169
|
+
*/
|
|
170
|
+
async getWmsLayer(workspace, datastore, layerName) {
|
|
171
|
+
const response = await (0, _nodeFetch.default)(this.url + 'workspaces/' + workspace + '/wmsstores/' + datastore + '/wmslayers/' + layerName + '.json', {
|
|
172
|
+
credentials: 'include',
|
|
173
|
+
method: 'GET',
|
|
174
|
+
headers: {
|
|
175
|
+
Authorization: this.auth
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
if (!response.ok) {
|
|
179
|
+
const grc = new _about.default(this.url, this.auth);
|
|
180
|
+
if (await grc.exists()) {
|
|
181
|
+
// GeoServer exists, but requested item does not exist, we return empty
|
|
182
|
+
return;
|
|
183
|
+
} else {
|
|
184
|
+
// There was a general problem with GeoServer
|
|
185
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
186
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
337
187
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
188
|
+
}
|
|
189
|
+
return await response.json();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// TODO: automated test needed
|
|
193
|
+
/**
|
|
194
|
+
* Returns information about a cascaded WMTS layer.
|
|
195
|
+
*
|
|
196
|
+
* @param {String} workspace The workspace
|
|
197
|
+
* @param {String} datastore The datastore
|
|
198
|
+
* @param {String} layerName The WMTS layer name
|
|
199
|
+
*
|
|
200
|
+
* @throws Error if request fails
|
|
201
|
+
*
|
|
202
|
+
* @returns {Object} An object with layer information or undefined if it cannot be found
|
|
203
|
+
*/
|
|
204
|
+
async getWmtsLayer(workspace, datastore, layerName) {
|
|
205
|
+
const response = await (0, _nodeFetch.default)(this.url + 'workspaces/' + workspace + '/wmtsstores/' + datastore + '/layers/' + layerName + '.json', {
|
|
206
|
+
credentials: 'include',
|
|
207
|
+
method: 'GET',
|
|
208
|
+
headers: {
|
|
209
|
+
Authorization: this.auth
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
if (!response.ok) {
|
|
213
|
+
const grc = new _about.default(this.url, this.auth);
|
|
214
|
+
if (await grc.exists()) {
|
|
215
|
+
// GeoServer exists, but requested item does not exist, we return empty
|
|
216
|
+
return;
|
|
217
|
+
} else {
|
|
218
|
+
// There was a general problem with GeoServer
|
|
219
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
220
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return await response.json();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Publishes a FeatureType in the default data store of the workspace.
|
|
228
|
+
*
|
|
229
|
+
* @param {String} workspace Workspace to publish FeatureType in
|
|
230
|
+
* @param {String} [nativeName] Native name of FeatureType
|
|
231
|
+
* @param {String} name Published name of FeatureType
|
|
232
|
+
* @param {String} [title] Published title of FeatureType
|
|
233
|
+
* @param {String} [srs="EPSG:4326"] The SRS of the FeatureType
|
|
234
|
+
* @param {String} enabled Flag to enable FeatureType by default
|
|
235
|
+
* @param {String} [abstract] The abstract of the layer
|
|
236
|
+
*
|
|
237
|
+
* @throws Error if request fails
|
|
238
|
+
*/
|
|
239
|
+
async publishFeatureTypeDefaultDataStore(workspace, nativeName, name, title, srs, enabled, abstract) {
|
|
240
|
+
const body = {
|
|
241
|
+
featureType: {
|
|
242
|
+
name: name,
|
|
243
|
+
nativeName: nativeName || name,
|
|
244
|
+
title: title || name,
|
|
245
|
+
srs: srs || 'EPSG:4326',
|
|
246
|
+
enabled: enabled,
|
|
247
|
+
abstract: abstract || ''
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
const response = await (0, _nodeFetch.default)(this.url + 'workspaces/' + workspace + '/featuretypes', {
|
|
251
|
+
credentials: 'include',
|
|
252
|
+
method: 'POST',
|
|
253
|
+
headers: {
|
|
254
|
+
Authorization: this.auth,
|
|
255
|
+
'Content-Type': 'application/json'
|
|
256
|
+
},
|
|
257
|
+
body: JSON.stringify(body)
|
|
258
|
+
});
|
|
259
|
+
if (!response.ok) {
|
|
260
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
261
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Publishes a FeatureType in the given data store of the workspace.
|
|
267
|
+
*
|
|
268
|
+
* @param {String} workspace Workspace to publish FeatureType in
|
|
269
|
+
* @param {String} dataStore The datastore where the FeatureType's data is in
|
|
270
|
+
* @param {String} [nativeName] Native name of FeatureType
|
|
271
|
+
* @param {String} name Published name of FeatureType
|
|
272
|
+
* @param {String} [title] Published title of FeatureType
|
|
273
|
+
* @param {String} [srs="EPSG:4326"] The SRS of the FeatureType
|
|
274
|
+
* @param {String} enabled Flag to enable FeatureType by default
|
|
275
|
+
* @param {String} [abstract] The abstract of the layer
|
|
276
|
+
* @param {String} [nativeBoundingBox] The native BoundingBox of the FeatureType (has to be set if no data is in store at creation time)
|
|
277
|
+
*
|
|
278
|
+
* @throws Error if request fails
|
|
279
|
+
*/
|
|
280
|
+
async publishFeatureType(workspace, dataStore, nativeName, name, title, srs, enabled, abstract, nativeBoundingBox) {
|
|
281
|
+
// apply CRS info for native BBOX if not provided
|
|
282
|
+
if (nativeBoundingBox && !nativeBoundingBox.crs) {
|
|
283
|
+
nativeBoundingBox.crs = {
|
|
284
|
+
'@class': 'projected',
|
|
285
|
+
$: srs
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
const body = {
|
|
289
|
+
featureType: {
|
|
290
|
+
name: name || nativeName,
|
|
291
|
+
nativeName: nativeName,
|
|
292
|
+
title: title || name,
|
|
293
|
+
srs: srs || 'EPSG:4326',
|
|
294
|
+
enabled: enabled,
|
|
295
|
+
abstract: abstract || '',
|
|
296
|
+
nativeBoundingBox: nativeBoundingBox
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
const response = await (0, _nodeFetch.default)(this.url + 'workspaces/' + workspace + '/datastores/' + dataStore + '/featuretypes', {
|
|
300
|
+
credentials: 'include',
|
|
301
|
+
method: 'POST',
|
|
302
|
+
headers: {
|
|
303
|
+
Authorization: this.auth,
|
|
304
|
+
'Content-Type': 'application/json'
|
|
305
|
+
},
|
|
306
|
+
body: JSON.stringify(body)
|
|
307
|
+
});
|
|
308
|
+
if (!response.ok) {
|
|
309
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
310
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Get detailed information about a FeatureType.
|
|
316
|
+
*
|
|
317
|
+
* @param {String} workspace The workspace of the FeatureType
|
|
318
|
+
* @param {String} datastore The datastore of the FeatureType
|
|
319
|
+
* @param {String} name The name of the FeatureType
|
|
320
|
+
*
|
|
321
|
+
* @throws Error if request fails
|
|
322
|
+
*
|
|
323
|
+
* @returns {Object} The object of the FeatureType
|
|
324
|
+
*/
|
|
325
|
+
async getFeatureType(workspace, datastore, name) {
|
|
326
|
+
const url = this.url + 'workspaces/' + workspace + '/datastores/' + datastore + '/featuretypes/' + name + '.json';
|
|
327
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
328
|
+
credentials: 'include',
|
|
329
|
+
method: 'GET',
|
|
330
|
+
headers: {
|
|
331
|
+
Authorization: this.auth
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
if (!response.ok) {
|
|
335
|
+
const grc = new _about.default(this.url, this.auth);
|
|
336
|
+
if (await grc.exists()) {
|
|
337
|
+
// GeoServer exists, but requested item does not exist, we return empty
|
|
338
|
+
return;
|
|
339
|
+
} else {
|
|
340
|
+
// There was a general problem with GeoServer
|
|
341
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
342
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return response.json();
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Get detailed information about a FeatureType.
|
|
350
|
+
*
|
|
351
|
+
* @param {String} workspace The workspace of the FeatureType
|
|
352
|
+
* @param {String} name The name of the FeatureType
|
|
353
|
+
*
|
|
354
|
+
* @throws GeoServerResponseError if request fails or layer does not exist or lacks the right properties.
|
|
355
|
+
*
|
|
356
|
+
* @returns {Object} The object of the FeatureType
|
|
357
|
+
*/
|
|
358
|
+
async getFeatureTypeFromLayer(workspace, layer) {
|
|
359
|
+
const layerObj = await this.get(workspace, layer);
|
|
360
|
+
if (!layerObj || !layerObj.layer || !layerObj.layer.resource || !layerObj.layer.resource.href) {
|
|
361
|
+
throw new _geoserver.GeoServerResponseError(`Layer '${workspace}:${layer}' does not exist or lacks the layer.resource.href property.`);
|
|
362
|
+
}
|
|
363
|
+
const url = layerObj?.layer?.resource?.href;
|
|
364
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
365
|
+
credentials: 'include',
|
|
366
|
+
method: 'GET',
|
|
367
|
+
headers: {
|
|
368
|
+
Authorization: this.auth
|
|
402
369
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
_context7.next = 1;
|
|
437
|
-
return (0, _nodeFetch["default"])(this.url + 'workspaces/' + workspace + '/featuretypes', {
|
|
438
|
-
credentials: 'include',
|
|
439
|
-
method: 'POST',
|
|
440
|
-
headers: {
|
|
441
|
-
Authorization: this.auth,
|
|
442
|
-
'Content-Type': 'application/json'
|
|
443
|
-
},
|
|
444
|
-
body: JSON.stringify(body)
|
|
445
|
-
});
|
|
446
|
-
case 1:
|
|
447
|
-
response = _context7.sent;
|
|
448
|
-
if (response.ok) {
|
|
449
|
-
_context7.next = 3;
|
|
450
|
-
break;
|
|
451
|
-
}
|
|
452
|
-
_context7.next = 2;
|
|
453
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
454
|
-
case 2:
|
|
455
|
-
geoServerResponse = _context7.sent;
|
|
456
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
457
|
-
case 3:
|
|
458
|
-
case "end":
|
|
459
|
-
return _context7.stop();
|
|
460
|
-
}
|
|
461
|
-
}, _callee7, this);
|
|
462
|
-
}));
|
|
463
|
-
function publishFeatureTypeDefaultDataStore(_x12, _x13, _x14, _x15, _x16, _x17, _x18) {
|
|
464
|
-
return _publishFeatureTypeDefaultDataStore.apply(this, arguments);
|
|
370
|
+
});
|
|
371
|
+
if (!response.ok) {
|
|
372
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
373
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
374
|
+
}
|
|
375
|
+
return response.json();
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Publishes a WMS layer.
|
|
380
|
+
*
|
|
381
|
+
* @param {String} workspace Workspace to publish WMS layer in
|
|
382
|
+
* @param {String} dataStore The datastore where the WMS is connected
|
|
383
|
+
* @param {String} nativeName Native name of WMS layer
|
|
384
|
+
* @param {String} [name] Published name of WMS layer
|
|
385
|
+
* @param {String} [title] Published title of WMS layer
|
|
386
|
+
* @param {String} [srs="EPSG:4326"] The SRS of the WMS layer
|
|
387
|
+
* @param {String} enabled Flag to enable WMS layer by default
|
|
388
|
+
* @param {String} [abstract] The abstract of the layer
|
|
389
|
+
*
|
|
390
|
+
* @throws Error if request fails
|
|
391
|
+
*/
|
|
392
|
+
async publishWmsLayer(workspace, dataStore, nativeName, name, title, srs, enabled, abstract) {
|
|
393
|
+
const body = {
|
|
394
|
+
wmsLayer: {
|
|
395
|
+
name: name || nativeName,
|
|
396
|
+
nativeName: nativeName,
|
|
397
|
+
title: title || name || nativeName,
|
|
398
|
+
srs: srs || 'EPSG:4326',
|
|
399
|
+
enabled: enabled,
|
|
400
|
+
abstract: abstract || ''
|
|
465
401
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
enabled: enabled,
|
|
506
|
-
"abstract": _abstract2 || '',
|
|
507
|
-
nativeBoundingBox: nativeBoundingBox
|
|
508
|
-
}
|
|
509
|
-
};
|
|
510
|
-
_context8.next = 1;
|
|
511
|
-
return (0, _nodeFetch["default"])(this.url + 'workspaces/' + workspace + '/datastores/' + dataStore + '/featuretypes', {
|
|
512
|
-
credentials: 'include',
|
|
513
|
-
method: 'POST',
|
|
514
|
-
headers: {
|
|
515
|
-
Authorization: this.auth,
|
|
516
|
-
'Content-Type': 'application/json'
|
|
517
|
-
},
|
|
518
|
-
body: JSON.stringify(body)
|
|
519
|
-
});
|
|
520
|
-
case 1:
|
|
521
|
-
response = _context8.sent;
|
|
522
|
-
if (response.ok) {
|
|
523
|
-
_context8.next = 3;
|
|
524
|
-
break;
|
|
525
|
-
}
|
|
526
|
-
_context8.next = 2;
|
|
527
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
528
|
-
case 2:
|
|
529
|
-
geoServerResponse = _context8.sent;
|
|
530
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
531
|
-
case 3:
|
|
532
|
-
case "end":
|
|
533
|
-
return _context8.stop();
|
|
534
|
-
}
|
|
535
|
-
}, _callee8, this);
|
|
536
|
-
}));
|
|
537
|
-
function publishFeatureType(_x19, _x20, _x21, _x22, _x23, _x24, _x25, _x26, _x27) {
|
|
538
|
-
return _publishFeatureType.apply(this, arguments);
|
|
402
|
+
};
|
|
403
|
+
const response = await (0, _nodeFetch.default)(this.url + 'workspaces/' + workspace + '/wmsstores/' + dataStore + '/wmslayers', {
|
|
404
|
+
credentials: 'include',
|
|
405
|
+
method: 'POST',
|
|
406
|
+
headers: {
|
|
407
|
+
Authorization: this.auth,
|
|
408
|
+
'Content-Type': 'application/json'
|
|
409
|
+
},
|
|
410
|
+
body: JSON.stringify(body)
|
|
411
|
+
});
|
|
412
|
+
if (!response.ok) {
|
|
413
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
414
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Publishes a raster stored in a database.
|
|
420
|
+
*
|
|
421
|
+
* @param {String} workspace Workspace to publish layer in
|
|
422
|
+
* @param {String} coverageStore The coveragestore where the layer's data is in
|
|
423
|
+
* @param {String} nativeName Native name of raster
|
|
424
|
+
* @param {String} name Published name of layer
|
|
425
|
+
* @param {String} [title] Published title of layer
|
|
426
|
+
* @param {String} [srs="EPSG:4326"] The SRS of the layer
|
|
427
|
+
* @param {String} enabled Flag to enable layer by default
|
|
428
|
+
* @param {String} [abstract] The abstract of the layer
|
|
429
|
+
*
|
|
430
|
+
* @throws Error if request fails
|
|
431
|
+
*/
|
|
432
|
+
async publishDbRaster(workspace, coverageStore, nativeName, name, title, srs, enabled, abstract) {
|
|
433
|
+
const body = {
|
|
434
|
+
coverage: {
|
|
435
|
+
name: name || nativeName,
|
|
436
|
+
nativeName: nativeName,
|
|
437
|
+
title: title || name,
|
|
438
|
+
srs: srs,
|
|
439
|
+
enabled: enabled,
|
|
440
|
+
abstract: abstract || ''
|
|
539
441
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
response = _context9.sent;
|
|
573
|
-
if (response.ok) {
|
|
574
|
-
_context9.next = 5;
|
|
575
|
-
break;
|
|
576
|
-
}
|
|
577
|
-
grc = new _about["default"](this.url, this.auth);
|
|
578
|
-
_context9.next = 2;
|
|
579
|
-
return grc.exists();
|
|
580
|
-
case 2:
|
|
581
|
-
if (!_context9.sent) {
|
|
582
|
-
_context9.next = 3;
|
|
583
|
-
break;
|
|
584
|
-
}
|
|
585
|
-
return _context9.abrupt("return");
|
|
586
|
-
case 3:
|
|
587
|
-
_context9.next = 4;
|
|
588
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
589
|
-
case 4:
|
|
590
|
-
geoServerResponse = _context9.sent;
|
|
591
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
592
|
-
case 5:
|
|
593
|
-
return _context9.abrupt("return", response.json());
|
|
594
|
-
case 6:
|
|
595
|
-
case "end":
|
|
596
|
-
return _context9.stop();
|
|
597
|
-
}
|
|
598
|
-
}, _callee9, this);
|
|
599
|
-
}));
|
|
600
|
-
function getFeatureType(_x28, _x29, _x30) {
|
|
601
|
-
return _getFeatureType.apply(this, arguments);
|
|
442
|
+
};
|
|
443
|
+
const response = await (0, _nodeFetch.default)(this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/coverages', {
|
|
444
|
+
credentials: 'include',
|
|
445
|
+
method: 'POST',
|
|
446
|
+
headers: {
|
|
447
|
+
Authorization: this.auth,
|
|
448
|
+
'Content-Type': 'application/json'
|
|
449
|
+
},
|
|
450
|
+
body: JSON.stringify(body)
|
|
451
|
+
});
|
|
452
|
+
if (!response.ok) {
|
|
453
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
454
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Deletes a FeatureType.
|
|
460
|
+
*
|
|
461
|
+
* @param {String} workspace Workspace where layer to delete is in
|
|
462
|
+
* @param {String} datastore The datastore where the layer to delete is in
|
|
463
|
+
* @param {String} name Layer to delete
|
|
464
|
+
* @param {Boolean} recurse Flag to enable recursive deletion
|
|
465
|
+
*
|
|
466
|
+
* @throws Error if request fails
|
|
467
|
+
*/
|
|
468
|
+
async deleteFeatureType(workspace, datastore, name, recurse) {
|
|
469
|
+
const response = await (0, _nodeFetch.default)(this.url + 'workspaces/' + workspace + '/datastores/' + datastore + '/featuretypes/' + name + '?recurse=' + recurse, {
|
|
470
|
+
credentials: 'include',
|
|
471
|
+
method: 'DELETE',
|
|
472
|
+
headers: {
|
|
473
|
+
Authorization: this.auth
|
|
602
474
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
response = _context0.sent;
|
|
646
|
-
if (response.ok) {
|
|
647
|
-
_context0.next = 5;
|
|
648
|
-
break;
|
|
649
|
-
}
|
|
650
|
-
_context0.next = 4;
|
|
651
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
652
|
-
case 4:
|
|
653
|
-
geoServerResponse = _context0.sent;
|
|
654
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
655
|
-
case 5:
|
|
656
|
-
return _context0.abrupt("return", response.json());
|
|
657
|
-
case 6:
|
|
658
|
-
case "end":
|
|
659
|
-
return _context0.stop();
|
|
660
|
-
}
|
|
661
|
-
}, _callee0, this);
|
|
662
|
-
}));
|
|
663
|
-
function getFeatureTypeFromLayer(_x31, _x32) {
|
|
664
|
-
return _getFeatureTypeFromLayer.apply(this, arguments);
|
|
475
|
+
});
|
|
476
|
+
if (!response.ok) {
|
|
477
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
478
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Enables TIME dimension for the given coverage layer.
|
|
484
|
+
*
|
|
485
|
+
* @param {String} workspace Workspace where layer to enable time dimension for is in
|
|
486
|
+
* @param {String} datastore The datastore where the layer to enable time dimension for is in
|
|
487
|
+
* @param {String} name Layer to enable time dimension for
|
|
488
|
+
* @param {String} presentation Presentation type: 'LIST' or 'DISCRETE_INTERVAL' or 'CONTINUOUS_INTERVAL'
|
|
489
|
+
* @param {Number} resolution Resolution in milliseconds, e.g. 3600000 for 1 hour
|
|
490
|
+
* @param {String} defaultValue The default time value, e.g. 'MINIMUM' or 'MAXIMUM' or 'NEAREST' or 'FIXED'
|
|
491
|
+
* @param {Boolean} [nearestMatchEnabled] Enable nearest match
|
|
492
|
+
* @param {Boolean} [rawNearestMatchEnabled] Enable raw nearest match
|
|
493
|
+
* @param {String} [acceptableInterval] Acceptable interval for nearest match, e.g.'PT30M'
|
|
494
|
+
*
|
|
495
|
+
* @throws Error if request fails
|
|
496
|
+
*/
|
|
497
|
+
async enableTimeCoverage(workspace, dataStore, name, presentation, resolution, defaultValue, nearestMatchEnabled, rawNearestMatchEnabled, acceptableInterval) {
|
|
498
|
+
const body = {
|
|
499
|
+
coverage: {
|
|
500
|
+
metadata: {
|
|
501
|
+
entry: [{
|
|
502
|
+
'@key': 'time',
|
|
503
|
+
dimensionInfo: {
|
|
504
|
+
enabled: true,
|
|
505
|
+
presentation: presentation || 'DISCRETE_INTERVAL',
|
|
506
|
+
resolution: resolution,
|
|
507
|
+
units: 'ISO8601',
|
|
508
|
+
defaultValue: {
|
|
509
|
+
strategy: defaultValue
|
|
510
|
+
},
|
|
511
|
+
nearestMatchEnabled: nearestMatchEnabled,
|
|
512
|
+
rawNearestMatchEnabled: rawNearestMatchEnabled,
|
|
513
|
+
acceptableInterval: acceptableInterval
|
|
514
|
+
}
|
|
515
|
+
}]
|
|
516
|
+
}
|
|
665
517
|
}
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
719
|
-
case 2:
|
|
720
|
-
geoServerResponse = _context1.sent;
|
|
721
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
722
|
-
case 3:
|
|
723
|
-
case "end":
|
|
724
|
-
return _context1.stop();
|
|
725
|
-
}
|
|
726
|
-
}, _callee1, this);
|
|
727
|
-
}));
|
|
728
|
-
function publishWmsLayer(_x33, _x34, _x35, _x36, _x37, _x38, _x39, _x40) {
|
|
729
|
-
return _publishWmsLayer.apply(this, arguments);
|
|
518
|
+
};
|
|
519
|
+
const url = this.url + 'workspaces/' + workspace + '/coveragestores/' + dataStore + '/coverages/' + name + '.json';
|
|
520
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
521
|
+
credentials: 'include',
|
|
522
|
+
method: 'PUT',
|
|
523
|
+
headers: {
|
|
524
|
+
Authorization: this.auth,
|
|
525
|
+
'Content-Type': 'application/json'
|
|
526
|
+
},
|
|
527
|
+
body: JSON.stringify(body)
|
|
528
|
+
});
|
|
529
|
+
if (!response.ok) {
|
|
530
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
531
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Enables TIME dimension for the given FeatureType layer.
|
|
537
|
+
*
|
|
538
|
+
* @param {String} workspace Workspace containing layer to enable time dimension for
|
|
539
|
+
* @param {String} datastore The datastore containing the FeatureType to enable time dimension for
|
|
540
|
+
* @param {String} name FeatureType to enable time dimension for
|
|
541
|
+
* @param {String} attribute Data column / attribute holding the time values
|
|
542
|
+
* @param {String} presentation Presentation type: 'LIST' or 'DISCRETE_INTERVAL' or 'CONTINUOUS_INTERVAL'
|
|
543
|
+
* @param {Number} resolution Resolution in milliseconds, e.g. 3600000 for 1 hour
|
|
544
|
+
* @param {String} defaultValue The default time value, e.g. 'MINIMUM' or 'MAXIMUM' or 'NEAREST' or 'FIXED'
|
|
545
|
+
* @param {Boolean} [nearestMatchEnabled] Enable nearest match
|
|
546
|
+
* @param {Boolean} [rawNearestMatchEnabled] Enable raw nearest match
|
|
547
|
+
*
|
|
548
|
+
* @throws Error if request fails
|
|
549
|
+
*/
|
|
550
|
+
async enableTimeFeatureType(workspace, dataStore, name, attribute, presentation, resolution, defaultValue, nearestMatchEnabled, rawNearestMatchEnabled, acceptableInterval) {
|
|
551
|
+
const body = {
|
|
552
|
+
featureType: {
|
|
553
|
+
metadata: {
|
|
554
|
+
entry: [{
|
|
555
|
+
'@key': 'time',
|
|
556
|
+
dimensionInfo: {
|
|
557
|
+
attribute: attribute,
|
|
558
|
+
presentation: presentation,
|
|
559
|
+
resolution: resolution,
|
|
560
|
+
units: 'ISO8601',
|
|
561
|
+
defaultValue: {
|
|
562
|
+
strategy: defaultValue
|
|
563
|
+
},
|
|
564
|
+
nearestMatchEnabled: nearestMatchEnabled,
|
|
565
|
+
rawNearestMatchEnabled: rawNearestMatchEnabled,
|
|
566
|
+
acceptableInterval: acceptableInterval
|
|
567
|
+
}
|
|
568
|
+
}]
|
|
569
|
+
}
|
|
730
570
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
_context10.next = 1;
|
|
767
|
-
return (0, _nodeFetch["default"])(this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/coverages', {
|
|
768
|
-
credentials: 'include',
|
|
769
|
-
method: 'POST',
|
|
770
|
-
headers: {
|
|
771
|
-
Authorization: this.auth,
|
|
772
|
-
'Content-Type': 'application/json'
|
|
773
|
-
},
|
|
774
|
-
body: JSON.stringify(body)
|
|
775
|
-
});
|
|
776
|
-
case 1:
|
|
777
|
-
response = _context10.sent;
|
|
778
|
-
if (response.ok) {
|
|
779
|
-
_context10.next = 3;
|
|
780
|
-
break;
|
|
781
|
-
}
|
|
782
|
-
_context10.next = 2;
|
|
783
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
784
|
-
case 2:
|
|
785
|
-
geoServerResponse = _context10.sent;
|
|
786
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
787
|
-
case 3:
|
|
788
|
-
case "end":
|
|
789
|
-
return _context10.stop();
|
|
790
|
-
}
|
|
791
|
-
}, _callee10, this);
|
|
792
|
-
}));
|
|
793
|
-
function publishDbRaster(_x41, _x42, _x43, _x44, _x45, _x46, _x47, _x48) {
|
|
794
|
-
return _publishDbRaster.apply(this, arguments);
|
|
571
|
+
};
|
|
572
|
+
const url = this.url + 'workspaces/' + workspace + '/datastores/' + dataStore + '/featuretypes/' + name + '.json';
|
|
573
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
574
|
+
credentials: 'include',
|
|
575
|
+
method: 'PUT',
|
|
576
|
+
headers: {
|
|
577
|
+
Authorization: this.auth,
|
|
578
|
+
'Content-Type': 'application/json'
|
|
579
|
+
},
|
|
580
|
+
body: JSON.stringify(body)
|
|
581
|
+
});
|
|
582
|
+
if (!response.ok) {
|
|
583
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
584
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Returns a dedicated coverage object.
|
|
590
|
+
*
|
|
591
|
+
* @param {String} workspace Workspace containing the coverage
|
|
592
|
+
* @param {String} coverageStore The coveragestore containing the coverage
|
|
593
|
+
* @param {String} name Coverage to query
|
|
594
|
+
*
|
|
595
|
+
* @throws Error if request fails
|
|
596
|
+
*
|
|
597
|
+
* @returns {Object} An object with coverage information or undefined if it cannot be found
|
|
598
|
+
*/
|
|
599
|
+
async getCoverage(workspace, coverageStore, name) {
|
|
600
|
+
const url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/coverages/' + name + '.json';
|
|
601
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
602
|
+
credentials: 'include',
|
|
603
|
+
method: 'GET',
|
|
604
|
+
headers: {
|
|
605
|
+
Authorization: this.auth
|
|
795
606
|
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
* @throws Error if request fails
|
|
807
|
-
*/
|
|
808
|
-
)
|
|
809
|
-
}, {
|
|
810
|
-
key: "deleteFeatureType",
|
|
811
|
-
value: (function () {
|
|
812
|
-
var _deleteFeatureType = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee11(workspace, datastore, name, recurse) {
|
|
813
|
-
var response, geoServerResponse;
|
|
814
|
-
return _regenerator["default"].wrap(function (_context11) {
|
|
815
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
816
|
-
case 0:
|
|
817
|
-
_context11.next = 1;
|
|
818
|
-
return (0, _nodeFetch["default"])(this.url + 'workspaces/' + workspace + '/datastores/' + datastore + '/featuretypes/' + name + '?recurse=' + recurse, {
|
|
819
|
-
credentials: 'include',
|
|
820
|
-
method: 'DELETE',
|
|
821
|
-
headers: {
|
|
822
|
-
Authorization: this.auth
|
|
823
|
-
}
|
|
824
|
-
});
|
|
825
|
-
case 1:
|
|
826
|
-
response = _context11.sent;
|
|
827
|
-
if (response.ok) {
|
|
828
|
-
_context11.next = 3;
|
|
829
|
-
break;
|
|
830
|
-
}
|
|
831
|
-
_context11.next = 2;
|
|
832
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
833
|
-
case 2:
|
|
834
|
-
geoServerResponse = _context11.sent;
|
|
835
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
836
|
-
case 3:
|
|
837
|
-
case "end":
|
|
838
|
-
return _context11.stop();
|
|
839
|
-
}
|
|
840
|
-
}, _callee11, this);
|
|
841
|
-
}));
|
|
842
|
-
function deleteFeatureType(_x49, _x50, _x51, _x52) {
|
|
843
|
-
return _deleteFeatureType.apply(this, arguments);
|
|
607
|
+
});
|
|
608
|
+
if (!response.ok) {
|
|
609
|
+
const grc = new _about.default(this.url, this.auth);
|
|
610
|
+
if (await grc.exists()) {
|
|
611
|
+
// GeoServer exists, but requested item does not exist, we return empty
|
|
612
|
+
return;
|
|
613
|
+
} else {
|
|
614
|
+
// There was a general problem with GeoServer
|
|
615
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
616
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
844
617
|
}
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
var _enableTimeCoverage = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee12(workspace, dataStore, name, presentation, resolution, defaultValue, nearestMatchEnabled, rawNearestMatchEnabled, acceptableInterval) {
|
|
867
|
-
var body, url, response, geoServerResponse;
|
|
868
|
-
return _regenerator["default"].wrap(function (_context12) {
|
|
869
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
870
|
-
case 0:
|
|
871
|
-
body = {
|
|
872
|
-
coverage: {
|
|
873
|
-
metadata: {
|
|
874
|
-
entry: [{
|
|
875
|
-
'@key': 'time',
|
|
876
|
-
dimensionInfo: {
|
|
877
|
-
enabled: true,
|
|
878
|
-
presentation: presentation || 'DISCRETE_INTERVAL',
|
|
879
|
-
resolution: resolution,
|
|
880
|
-
units: 'ISO8601',
|
|
881
|
-
defaultValue: {
|
|
882
|
-
strategy: defaultValue
|
|
883
|
-
},
|
|
884
|
-
nearestMatchEnabled: nearestMatchEnabled,
|
|
885
|
-
rawNearestMatchEnabled: rawNearestMatchEnabled,
|
|
886
|
-
acceptableInterval: acceptableInterval
|
|
887
|
-
}
|
|
888
|
-
}]
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
};
|
|
892
|
-
url = this.url + 'workspaces/' + workspace + '/coveragestores/' + dataStore + '/coverages/' + name + '.json';
|
|
893
|
-
_context12.next = 1;
|
|
894
|
-
return (0, _nodeFetch["default"])(url, {
|
|
895
|
-
credentials: 'include',
|
|
896
|
-
method: 'PUT',
|
|
897
|
-
headers: {
|
|
898
|
-
Authorization: this.auth,
|
|
899
|
-
'Content-Type': 'application/json'
|
|
900
|
-
},
|
|
901
|
-
body: JSON.stringify(body)
|
|
902
|
-
});
|
|
903
|
-
case 1:
|
|
904
|
-
response = _context12.sent;
|
|
905
|
-
if (response.ok) {
|
|
906
|
-
_context12.next = 3;
|
|
907
|
-
break;
|
|
908
|
-
}
|
|
909
|
-
_context12.next = 2;
|
|
910
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
911
|
-
case 2:
|
|
912
|
-
geoServerResponse = _context12.sent;
|
|
913
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
914
|
-
case 3:
|
|
915
|
-
case "end":
|
|
916
|
-
return _context12.stop();
|
|
917
|
-
}
|
|
918
|
-
}, _callee12, this);
|
|
919
|
-
}));
|
|
920
|
-
function enableTimeCoverage(_x53, _x54, _x55, _x56, _x57, _x58, _x59, _x60, _x61) {
|
|
921
|
-
return _enableTimeCoverage.apply(this, arguments);
|
|
618
|
+
}
|
|
619
|
+
return response.json();
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Returns a dedicated coverage object.
|
|
624
|
+
*
|
|
625
|
+
* @param {String} workspace Workspace containing the coverage
|
|
626
|
+
* @param {String} name Coverage to query
|
|
627
|
+
*
|
|
628
|
+
* @throws Error if request fails
|
|
629
|
+
*
|
|
630
|
+
* @returns {Object} An object with coverage information or undefined if it cannot be found
|
|
631
|
+
*/
|
|
632
|
+
async getCoverageFromLayer(workspace, name) {
|
|
633
|
+
const url = this.url + '/workspaces/' + workspace + '/coverages/' + name + '.json';
|
|
634
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
635
|
+
credentials: 'include',
|
|
636
|
+
method: 'GET',
|
|
637
|
+
headers: {
|
|
638
|
+
Authorization: this.auth
|
|
922
639
|
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
* @param {Number} resolution Resolution in milliseconds, e.g. 3600000 for 1 hour
|
|
934
|
-
* @param {String} defaultValue The default time value, e.g. 'MINIMUM' or 'MAXIMUM' or 'NEAREST' or 'FIXED'
|
|
935
|
-
* @param {Boolean} [nearestMatchEnabled] Enable nearest match
|
|
936
|
-
* @param {Boolean} [rawNearestMatchEnabled] Enable raw nearest match
|
|
937
|
-
*
|
|
938
|
-
* @throws Error if request fails
|
|
939
|
-
*/
|
|
940
|
-
)
|
|
941
|
-
}, {
|
|
942
|
-
key: "enableTimeFeatureType",
|
|
943
|
-
value: (function () {
|
|
944
|
-
var _enableTimeFeatureType = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee13(workspace, dataStore, name, attribute, presentation, resolution, defaultValue, nearestMatchEnabled, rawNearestMatchEnabled, acceptableInterval) {
|
|
945
|
-
var body, url, response, geoServerResponse;
|
|
946
|
-
return _regenerator["default"].wrap(function (_context13) {
|
|
947
|
-
while (1) switch (_context13.prev = _context13.next) {
|
|
948
|
-
case 0:
|
|
949
|
-
body = {
|
|
950
|
-
featureType: {
|
|
951
|
-
metadata: {
|
|
952
|
-
entry: [{
|
|
953
|
-
'@key': 'time',
|
|
954
|
-
dimensionInfo: {
|
|
955
|
-
attribute: attribute,
|
|
956
|
-
presentation: presentation,
|
|
957
|
-
resolution: resolution,
|
|
958
|
-
units: 'ISO8601',
|
|
959
|
-
defaultValue: {
|
|
960
|
-
strategy: defaultValue
|
|
961
|
-
},
|
|
962
|
-
nearestMatchEnabled: nearestMatchEnabled,
|
|
963
|
-
rawNearestMatchEnabled: rawNearestMatchEnabled,
|
|
964
|
-
acceptableInterval: acceptableInterval
|
|
965
|
-
}
|
|
966
|
-
}]
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
};
|
|
970
|
-
url = this.url + 'workspaces/' + workspace + '/datastores/' + dataStore + '/featuretypes/' + name + '.json';
|
|
971
|
-
_context13.next = 1;
|
|
972
|
-
return (0, _nodeFetch["default"])(url, {
|
|
973
|
-
credentials: 'include',
|
|
974
|
-
method: 'PUT',
|
|
975
|
-
headers: {
|
|
976
|
-
Authorization: this.auth,
|
|
977
|
-
'Content-Type': 'application/json'
|
|
978
|
-
},
|
|
979
|
-
body: JSON.stringify(body)
|
|
980
|
-
});
|
|
981
|
-
case 1:
|
|
982
|
-
response = _context13.sent;
|
|
983
|
-
if (response.ok) {
|
|
984
|
-
_context13.next = 3;
|
|
985
|
-
break;
|
|
986
|
-
}
|
|
987
|
-
_context13.next = 2;
|
|
988
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
989
|
-
case 2:
|
|
990
|
-
geoServerResponse = _context13.sent;
|
|
991
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
992
|
-
case 3:
|
|
993
|
-
case "end":
|
|
994
|
-
return _context13.stop();
|
|
995
|
-
}
|
|
996
|
-
}, _callee13, this);
|
|
997
|
-
}));
|
|
998
|
-
function enableTimeFeatureType(_x62, _x63, _x64, _x65, _x66, _x67, _x68, _x69, _x70, _x71) {
|
|
999
|
-
return _enableTimeFeatureType.apply(this, arguments);
|
|
640
|
+
});
|
|
641
|
+
if (!response.ok) {
|
|
642
|
+
const grc = new _about.default(this.url, this.auth);
|
|
643
|
+
if (await grc.exists()) {
|
|
644
|
+
// GeoServer exists, but requested item does not exist, we return empty
|
|
645
|
+
return;
|
|
646
|
+
} else {
|
|
647
|
+
// There was a general problem with GeoServer
|
|
648
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
649
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
1000
650
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/coverages/' + name + '.json';
|
|
1024
|
-
_context14.next = 1;
|
|
1025
|
-
return (0, _nodeFetch["default"])(url, {
|
|
1026
|
-
credentials: 'include',
|
|
1027
|
-
method: 'GET',
|
|
1028
|
-
headers: {
|
|
1029
|
-
Authorization: this.auth
|
|
1030
|
-
}
|
|
1031
|
-
});
|
|
1032
|
-
case 1:
|
|
1033
|
-
response = _context14.sent;
|
|
1034
|
-
if (response.ok) {
|
|
1035
|
-
_context14.next = 5;
|
|
1036
|
-
break;
|
|
1037
|
-
}
|
|
1038
|
-
grc = new _about["default"](this.url, this.auth);
|
|
1039
|
-
_context14.next = 2;
|
|
1040
|
-
return grc.exists();
|
|
1041
|
-
case 2:
|
|
1042
|
-
if (!_context14.sent) {
|
|
1043
|
-
_context14.next = 3;
|
|
1044
|
-
break;
|
|
1045
|
-
}
|
|
1046
|
-
return _context14.abrupt("return");
|
|
1047
|
-
case 3:
|
|
1048
|
-
_context14.next = 4;
|
|
1049
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
1050
|
-
case 4:
|
|
1051
|
-
geoServerResponse = _context14.sent;
|
|
1052
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
1053
|
-
case 5:
|
|
1054
|
-
return _context14.abrupt("return", response.json());
|
|
1055
|
-
case 6:
|
|
1056
|
-
case "end":
|
|
1057
|
-
return _context14.stop();
|
|
1058
|
-
}
|
|
1059
|
-
}, _callee14, this);
|
|
1060
|
-
}));
|
|
1061
|
-
function getCoverage(_x72, _x73, _x74) {
|
|
1062
|
-
return _getCoverage.apply(this, arguments);
|
|
651
|
+
}
|
|
652
|
+
return response.json();
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Renames the existing bands of a coverage layer.
|
|
657
|
+
*
|
|
658
|
+
* Make sure to provide the same number of bands as existing in the layer.
|
|
659
|
+
*
|
|
660
|
+
* @param {String} workspace Workspace of layer
|
|
661
|
+
* @param {String} datastore The datastore of the layer
|
|
662
|
+
* @param {String} layername The layer name
|
|
663
|
+
* @param {String[]} bandNames An array of the new band names in correct order
|
|
664
|
+
*
|
|
665
|
+
* @throws Error if request fails
|
|
666
|
+
*/
|
|
667
|
+
async renameCoverageBands(workspace, dataStore, layername, bandNames) {
|
|
668
|
+
const body = {
|
|
669
|
+
coverage: {
|
|
670
|
+
dimensions: {
|
|
671
|
+
coverageDimension: []
|
|
672
|
+
}
|
|
1063
673
|
}
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
case 3:
|
|
1110
|
-
_context15.next = 4;
|
|
1111
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
1112
|
-
case 4:
|
|
1113
|
-
geoServerResponse = _context15.sent;
|
|
1114
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
1115
|
-
case 5:
|
|
1116
|
-
return _context15.abrupt("return", response.json());
|
|
1117
|
-
case 6:
|
|
1118
|
-
case "end":
|
|
1119
|
-
return _context15.stop();
|
|
1120
|
-
}
|
|
1121
|
-
}, _callee15, this);
|
|
1122
|
-
}));
|
|
1123
|
-
function getCoverageFromLayer(_x75, _x76) {
|
|
1124
|
-
return _getCoverageFromLayer.apply(this, arguments);
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
// dynamically create the body
|
|
677
|
+
bandNames.forEach(bandName => {
|
|
678
|
+
body.coverage.dimensions.coverageDimension.push({
|
|
679
|
+
name: bandName
|
|
680
|
+
});
|
|
681
|
+
});
|
|
682
|
+
const url = this.url + 'workspaces/' + workspace + '/coveragestores/' + dataStore + '/coverages/' + layername + '.json';
|
|
683
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
684
|
+
credentials: 'include',
|
|
685
|
+
method: 'PUT',
|
|
686
|
+
headers: {
|
|
687
|
+
Authorization: this.auth,
|
|
688
|
+
'Content-Type': 'application/json'
|
|
689
|
+
},
|
|
690
|
+
body: JSON.stringify(body)
|
|
691
|
+
});
|
|
692
|
+
if (!response.ok) {
|
|
693
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
694
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Returns the data store of a layer.
|
|
700
|
+
*
|
|
701
|
+
* @param {String} workspace The workspace of the layer
|
|
702
|
+
* @param {String} layer The name of the layer
|
|
703
|
+
*
|
|
704
|
+
* @throws GeoServerResponseError if request fails or layer does not exist or lacks a data store.
|
|
705
|
+
*
|
|
706
|
+
* @returns {Object} The data store object
|
|
707
|
+
*/
|
|
708
|
+
async getDataStore(workspace, layer) {
|
|
709
|
+
const featureTypeObj = await this.getFeatureTypeFromLayer(workspace, layer);
|
|
710
|
+
if (!featureTypeObj || !featureTypeObj.featureType || !featureTypeObj.featureType.store || !featureTypeObj.featureType.store.name) {
|
|
711
|
+
throw new _geoserver.GeoServerResponseError(`Layer '${workspace}:${layer}' lacks a feature type or the feature type lacks a data store.`);
|
|
712
|
+
}
|
|
713
|
+
const url = featureTypeObj?.featureType?.store?.href;
|
|
714
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
715
|
+
credentials: 'include',
|
|
716
|
+
method: 'GET',
|
|
717
|
+
headers: {
|
|
718
|
+
Authorization: this.auth
|
|
1125
719
|
}
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
* @param {String[]} bandNames An array of the new band names in correct order
|
|
1137
|
-
*
|
|
1138
|
-
* @throws Error if request fails
|
|
1139
|
-
*/
|
|
1140
|
-
)
|
|
1141
|
-
}, {
|
|
1142
|
-
key: "renameCoverageBands",
|
|
1143
|
-
value: (function () {
|
|
1144
|
-
var _renameCoverageBands = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee16(workspace, dataStore, layername, bandNames) {
|
|
1145
|
-
var body, url, response, geoServerResponse;
|
|
1146
|
-
return _regenerator["default"].wrap(function (_context16) {
|
|
1147
|
-
while (1) switch (_context16.prev = _context16.next) {
|
|
1148
|
-
case 0:
|
|
1149
|
-
body = {
|
|
1150
|
-
coverage: {
|
|
1151
|
-
dimensions: {
|
|
1152
|
-
coverageDimension: []
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
}; // dynamically create the body
|
|
1156
|
-
bandNames.forEach(function (bandName) {
|
|
1157
|
-
body.coverage.dimensions.coverageDimension.push({
|
|
1158
|
-
name: bandName
|
|
1159
|
-
});
|
|
1160
|
-
});
|
|
1161
|
-
url = this.url + 'workspaces/' + workspace + '/coveragestores/' + dataStore + '/coverages/' + layername + '.json';
|
|
1162
|
-
_context16.next = 1;
|
|
1163
|
-
return (0, _nodeFetch["default"])(url, {
|
|
1164
|
-
credentials: 'include',
|
|
1165
|
-
method: 'PUT',
|
|
1166
|
-
headers: {
|
|
1167
|
-
Authorization: this.auth,
|
|
1168
|
-
'Content-Type': 'application/json'
|
|
1169
|
-
},
|
|
1170
|
-
body: JSON.stringify(body)
|
|
1171
|
-
});
|
|
1172
|
-
case 1:
|
|
1173
|
-
response = _context16.sent;
|
|
1174
|
-
if (response.ok) {
|
|
1175
|
-
_context16.next = 3;
|
|
1176
|
-
break;
|
|
1177
|
-
}
|
|
1178
|
-
_context16.next = 2;
|
|
1179
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
1180
|
-
case 2:
|
|
1181
|
-
geoServerResponse = _context16.sent;
|
|
1182
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
1183
|
-
case 3:
|
|
1184
|
-
case "end":
|
|
1185
|
-
return _context16.stop();
|
|
1186
|
-
}
|
|
1187
|
-
}, _callee16, this);
|
|
1188
|
-
}));
|
|
1189
|
-
function renameCoverageBands(_x77, _x78, _x79, _x80) {
|
|
1190
|
-
return _renameCoverageBands.apply(this, arguments);
|
|
720
|
+
});
|
|
721
|
+
if (!response.ok) {
|
|
722
|
+
const grc = new _about.default(this.url, this.auth);
|
|
723
|
+
if (await grc.exists()) {
|
|
724
|
+
// GeoServer exists, but requested item does not exist, we return empty
|
|
725
|
+
return;
|
|
726
|
+
} else {
|
|
727
|
+
// There was a general problem with GeoServer
|
|
728
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
729
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
1191
730
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
featureTypeObj = _context17.sent;
|
|
1218
|
-
if (!(!featureTypeObj || !featureTypeObj.featureType || !featureTypeObj.featureType.store || !featureTypeObj.featureType.store.name)) {
|
|
1219
|
-
_context17.next = 2;
|
|
1220
|
-
break;
|
|
1221
|
-
}
|
|
1222
|
-
throw new _geoserver.GeoServerResponseError("Layer '".concat(workspace, ":").concat(layer, "' lacks a feature type or the feature type lacks a data store."));
|
|
1223
|
-
case 2:
|
|
1224
|
-
url = featureTypeObj === null || featureTypeObj === void 0 || (_featureTypeObj$featu = featureTypeObj.featureType) === null || _featureTypeObj$featu === void 0 || (_featureTypeObj$featu = _featureTypeObj$featu.store) === null || _featureTypeObj$featu === void 0 ? void 0 : _featureTypeObj$featu.href;
|
|
1225
|
-
_context17.next = 3;
|
|
1226
|
-
return (0, _nodeFetch["default"])(url, {
|
|
1227
|
-
credentials: 'include',
|
|
1228
|
-
method: 'GET',
|
|
1229
|
-
headers: {
|
|
1230
|
-
Authorization: this.auth
|
|
1231
|
-
}
|
|
1232
|
-
});
|
|
1233
|
-
case 3:
|
|
1234
|
-
response = _context17.sent;
|
|
1235
|
-
if (response.ok) {
|
|
1236
|
-
_context17.next = 7;
|
|
1237
|
-
break;
|
|
1238
|
-
}
|
|
1239
|
-
grc = new _about["default"](this.url, this.auth);
|
|
1240
|
-
_context17.next = 4;
|
|
1241
|
-
return grc.exists();
|
|
1242
|
-
case 4:
|
|
1243
|
-
if (!_context17.sent) {
|
|
1244
|
-
_context17.next = 5;
|
|
1245
|
-
break;
|
|
1246
|
-
}
|
|
1247
|
-
return _context17.abrupt("return");
|
|
1248
|
-
case 5:
|
|
1249
|
-
_context17.next = 6;
|
|
1250
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
1251
|
-
case 6:
|
|
1252
|
-
geoServerResponse = _context17.sent;
|
|
1253
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
1254
|
-
case 7:
|
|
1255
|
-
return _context17.abrupt("return", response.json());
|
|
1256
|
-
case 8:
|
|
1257
|
-
case "end":
|
|
1258
|
-
return _context17.stop();
|
|
1259
|
-
}
|
|
1260
|
-
}, _callee17, this);
|
|
1261
|
-
}));
|
|
1262
|
-
function getDataStore(_x81, _x82) {
|
|
1263
|
-
return _getDataStore.apply(this, arguments);
|
|
731
|
+
}
|
|
732
|
+
return response.json();
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Returns the coverage store of a layer.
|
|
737
|
+
*
|
|
738
|
+
* @param {String} workspace The workspace of the layer
|
|
739
|
+
* @param {String} layer The name of the layer
|
|
740
|
+
*
|
|
741
|
+
* @throws GeoServerResponseError if request fails or layer does not exist or lacks a coverage store.
|
|
742
|
+
*
|
|
743
|
+
* @returns {Object} The coverage store object
|
|
744
|
+
*/
|
|
745
|
+
async getCoverageStore(workspace, layer) {
|
|
746
|
+
const coverageObj = await this.getCoverageFromLayer(workspace, layer);
|
|
747
|
+
if (!coverageObj || !coverageObj.coverage || !coverageObj.coverage.store || !coverageObj.coverage.store.name) {
|
|
748
|
+
throw new _geoserver.GeoServerResponseError(`Layer '${workspace}:${layer}' lacks a coverage or the coverage lacks a coverage store.`);
|
|
749
|
+
}
|
|
750
|
+
const url = coverageObj?.coverage?.store?.href;
|
|
751
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
752
|
+
credentials: 'include',
|
|
753
|
+
method: 'GET',
|
|
754
|
+
headers: {
|
|
755
|
+
Authorization: this.auth
|
|
1264
756
|
}
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
* @returns {Object} The coverage store object
|
|
1276
|
-
*/
|
|
1277
|
-
)
|
|
1278
|
-
}, {
|
|
1279
|
-
key: "getCoverageStore",
|
|
1280
|
-
value: (function () {
|
|
1281
|
-
var _getCoverageStore = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee18(workspace, layer) {
|
|
1282
|
-
var _coverageObj$coverage;
|
|
1283
|
-
var coverageObj, url, response, grc, geoServerResponse;
|
|
1284
|
-
return _regenerator["default"].wrap(function (_context18) {
|
|
1285
|
-
while (1) switch (_context18.prev = _context18.next) {
|
|
1286
|
-
case 0:
|
|
1287
|
-
_context18.next = 1;
|
|
1288
|
-
return this.getCoverageFromLayer(workspace, layer);
|
|
1289
|
-
case 1:
|
|
1290
|
-
coverageObj = _context18.sent;
|
|
1291
|
-
if (!(!coverageObj || !coverageObj.coverage || !coverageObj.coverage.store || !coverageObj.coverage.store.name)) {
|
|
1292
|
-
_context18.next = 2;
|
|
1293
|
-
break;
|
|
1294
|
-
}
|
|
1295
|
-
throw new _geoserver.GeoServerResponseError("Layer '".concat(workspace, ":").concat(layer, "' lacks a coverage or the coverage lacks a coverage store."));
|
|
1296
|
-
case 2:
|
|
1297
|
-
url = coverageObj === null || coverageObj === void 0 || (_coverageObj$coverage = coverageObj.coverage) === null || _coverageObj$coverage === void 0 || (_coverageObj$coverage = _coverageObj$coverage.store) === null || _coverageObj$coverage === void 0 ? void 0 : _coverageObj$coverage.href;
|
|
1298
|
-
_context18.next = 3;
|
|
1299
|
-
return (0, _nodeFetch["default"])(url, {
|
|
1300
|
-
credentials: 'include',
|
|
1301
|
-
method: 'GET',
|
|
1302
|
-
headers: {
|
|
1303
|
-
Authorization: this.auth
|
|
1304
|
-
}
|
|
1305
|
-
});
|
|
1306
|
-
case 3:
|
|
1307
|
-
response = _context18.sent;
|
|
1308
|
-
if (response.ok) {
|
|
1309
|
-
_context18.next = 7;
|
|
1310
|
-
break;
|
|
1311
|
-
}
|
|
1312
|
-
grc = new _about["default"](this.url, this.auth);
|
|
1313
|
-
_context18.next = 4;
|
|
1314
|
-
return grc.exists();
|
|
1315
|
-
case 4:
|
|
1316
|
-
if (!_context18.sent) {
|
|
1317
|
-
_context18.next = 5;
|
|
1318
|
-
break;
|
|
1319
|
-
}
|
|
1320
|
-
return _context18.abrupt("return");
|
|
1321
|
-
case 5:
|
|
1322
|
-
_context18.next = 6;
|
|
1323
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
1324
|
-
case 6:
|
|
1325
|
-
geoServerResponse = _context18.sent;
|
|
1326
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
1327
|
-
case 7:
|
|
1328
|
-
return _context18.abrupt("return", response.json());
|
|
1329
|
-
case 8:
|
|
1330
|
-
case "end":
|
|
1331
|
-
return _context18.stop();
|
|
1332
|
-
}
|
|
1333
|
-
}, _callee18, this);
|
|
1334
|
-
}));
|
|
1335
|
-
function getCoverageStore(_x83, _x84) {
|
|
1336
|
-
return _getCoverageStore.apply(this, arguments);
|
|
757
|
+
});
|
|
758
|
+
if (!response.ok) {
|
|
759
|
+
const grc = new _about.default(this.url, this.auth);
|
|
760
|
+
if (await grc.exists()) {
|
|
761
|
+
// GeoServer exists, but requested item does not exist, we return empty
|
|
762
|
+
return;
|
|
763
|
+
} else {
|
|
764
|
+
// There was a general problem with GeoServer
|
|
765
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
766
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
1337
767
|
}
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
768
|
+
}
|
|
769
|
+
return response.json();
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
exports.default = LayerClient;
|