ol-wfst 3.0.2 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +71 -64
- package/README.md +530 -478
- package/dist/assets/i18n/en.d.ts.map +1 -1
- package/dist/assets/i18n/es.d.ts.map +1 -1
- package/dist/assets/i18n/zh.d.ts.map +1 -1
- package/dist/css/ol-wfst.bootstrap5.css +364 -481
- package/dist/css/ol-wfst.bootstrap5.min.css +1 -1
- package/dist/css/ol-wfst.css +3 -0
- package/dist/ol-wfst.d.ts +38 -11
- package/dist/ol-wfst.d.ts.map +1 -1
- package/dist/ol-wfst.js +3673 -3617
- package/dist/ol-wfst.js.map +1 -1
- package/dist/ol-wfst.min.js +16 -16
- package/dist/ol-wfst.min.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/assets/i18n/en.d.ts.map +1 -1
- package/lib/assets/i18n/es.d.ts.map +1 -1
- package/lib/assets/i18n/zh.d.ts.map +1 -1
- package/lib/ol-wfst.d.ts +38 -11
- package/lib/ol-wfst.d.ts.map +1 -1
- package/lib/ol-wfst.js +245 -197
- package/lib/ol-wfst.js.map +1 -1
- package/lib/style/css/ol-gisify.css +3 -0
- package/lib/style/css/ol-wfst.bootstrap5.css +364 -481
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +70 -70
package/README.md
CHANGED
|
@@ -1,478 +1,530 @@
|
|
|
1
|
-
# OpenLayers WFST
|
|
2
|
-
|
|
3
|
-
Tiny WFST-T client to insert (drawing/uploading), modify and delete features on GeoServers using OpenLayers. Layers with these types of geometries are supported: _GeometryCollection_ (in this case, you can choose the geometry type of each element to draw), _Point_, _MultiPoint_, _LineString_, _MultiLineString_, _Polygon_ and _MultiPolygon_.
|
|
4
|
-
|
|
5
|
-
Tested with OpenLayers version 5 and 6.
|
|
6
|
-
|
|
7
|
-
<img src="screenshots/example-1.jpg" alt="Drawing" style="width:50%; float:left;">
|
|
8
|
-
<img src="screenshots/example-2.jpg" alt="Editing fields" style="width:50%; float:left;">
|
|
9
|
-
|
|
10
|
-
## Usage
|
|
11
|
-
|
|
12
|
-
See [Wfst Options](#options) for more details.
|
|
13
|
-
|
|
14
|
-
```javascript
|
|
15
|
-
import Wfst from 'ol-wfst';
|
|
16
|
-
import { Fill, Stroke, Circle, Style } from 'ol/style';
|
|
17
|
-
|
|
18
|
-
// Style
|
|
19
|
-
import 'ol-wfst/lib/scss/ol-wfst.css';
|
|
20
|
-
import 'ol-wfst/lib/scss/ol-wfst.bootstrap5.css'; // Do not import if you already have boostrap css
|
|
21
|
-
|
|
22
|
-
// Optional credentials
|
|
23
|
-
const password = 123456;
|
|
24
|
-
const username = 'username';
|
|
25
|
-
|
|
26
|
-
const wfst = new Wfst({
|
|
27
|
-
geoServerUrl: 'https://mysite.com/geoserver/myworkspace/ows',
|
|
28
|
-
geoServerAdvanced: {
|
|
29
|
-
getCapabilitiesVersion: '1.3.0',
|
|
30
|
-
getFeatureVersion: '1.0.0',
|
|
31
|
-
describeFeatureTypeVersion: '1.1.0',
|
|
32
|
-
lockFeatureVersion: '1.1.0',
|
|
33
|
-
projection: 'EPSG:3857'
|
|
34
|
-
},
|
|
35
|
-
// Maybe you wanna add this on a proxy, at the backend
|
|
36
|
-
headers: { Authorization: 'Basic ' + btoa(username + ':' + password) },
|
|
37
|
-
layers: [
|
|
38
|
-
{
|
|
39
|
-
name: 'myPointsLayer', // Name of the layer on the GeoServer
|
|
40
|
-
label: 'Photos', // Optional Label to be displayed in the controller
|
|
41
|
-
mode: 'wfs',
|
|
42
|
-
zIndex: 99,
|
|
43
|
-
style: new Style({
|
|
44
|
-
image: new Circle({
|
|
45
|
-
radius: 7,
|
|
46
|
-
fill: new Fill({
|
|
47
|
-
color: '#000000'
|
|
48
|
-
}),
|
|
49
|
-
stroke: new Stroke({
|
|
50
|
-
color: [255, 0, 0],
|
|
51
|
-
width: 2
|
|
52
|
-
})
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: 'myMultiGeometryLayer',
|
|
58
|
-
label: 'Other elements'
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
name: 'myLineStringLayer',
|
|
62
|
-
label: 'Routes',
|
|
63
|
-
visible: false
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
wfst.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
- `
|
|
239
|
-
|
|
240
|
-
Returns **
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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
|
-
|
|
402
|
-
|
|
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
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
1
|
+
# OpenLayers WFST
|
|
2
|
+
|
|
3
|
+
Tiny WFST-T client to insert (drawing/uploading), modify and delete features on GeoServers using OpenLayers. Layers with these types of geometries are supported: _GeometryCollection_ (in this case, you can choose the geometry type of each element to draw), _Point_, _MultiPoint_, _LineString_, _MultiLineString_, _Polygon_ and _MultiPolygon_.
|
|
4
|
+
|
|
5
|
+
Tested with OpenLayers version 5 and 6.
|
|
6
|
+
|
|
7
|
+
<img src="screenshots/example-1.jpg" alt="Drawing" style="width:50%; float:left;">
|
|
8
|
+
<img src="screenshots/example-2.jpg" alt="Editing fields" style="width:50%; float:left;">
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
See [Wfst Options](#options) for more details.
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
import Wfst from 'ol-wfst';
|
|
16
|
+
import { Fill, Stroke, Circle, Style } from 'ol/style';
|
|
17
|
+
|
|
18
|
+
// Style
|
|
19
|
+
import 'ol-wfst/lib/scss/ol-wfst.css';
|
|
20
|
+
import 'ol-wfst/lib/scss/ol-wfst.bootstrap5.css'; // Do not import if you already have boostrap css
|
|
21
|
+
|
|
22
|
+
// Optional credentials
|
|
23
|
+
const password = 123456;
|
|
24
|
+
const username = 'username';
|
|
25
|
+
|
|
26
|
+
const wfst = new Wfst({
|
|
27
|
+
geoServerUrl: 'https://mysite.com/geoserver/myworkspace/ows',
|
|
28
|
+
geoServerAdvanced: {
|
|
29
|
+
getCapabilitiesVersion: '1.3.0',
|
|
30
|
+
getFeatureVersion: '1.0.0',
|
|
31
|
+
describeFeatureTypeVersion: '1.1.0',
|
|
32
|
+
lockFeatureVersion: '1.1.0',
|
|
33
|
+
projection: 'EPSG:3857'
|
|
34
|
+
},
|
|
35
|
+
// Maybe you wanna add this on a proxy, at the backend
|
|
36
|
+
headers: { Authorization: 'Basic ' + btoa(username + ':' + password) },
|
|
37
|
+
layers: [
|
|
38
|
+
{
|
|
39
|
+
name: 'myPointsLayer', // Name of the layer on the GeoServer
|
|
40
|
+
label: 'Photos', // Optional Label to be displayed in the controller
|
|
41
|
+
mode: 'wfs',
|
|
42
|
+
zIndex: 99,
|
|
43
|
+
style: new Style({
|
|
44
|
+
image: new Circle({
|
|
45
|
+
radius: 7,
|
|
46
|
+
fill: new Fill({
|
|
47
|
+
color: '#000000'
|
|
48
|
+
}),
|
|
49
|
+
stroke: new Stroke({
|
|
50
|
+
color: [255, 0, 0],
|
|
51
|
+
width: 2
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'myMultiGeometryLayer',
|
|
58
|
+
label: 'Other elements'
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'myLineStringLayer',
|
|
62
|
+
label: 'Routes',
|
|
63
|
+
visible: false
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'myMultiPointLayer',
|
|
67
|
+
label: 'Markers',
|
|
68
|
+
visible: false
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
language: 'en',
|
|
72
|
+
minZoom: 12,
|
|
73
|
+
showUpload: true,
|
|
74
|
+
beforeInsertFeature: function (feature) {
|
|
75
|
+
// Add a custom value o perform an action before insert features
|
|
76
|
+
feature.set('customProperty', 'customValue', true);
|
|
77
|
+
return feature;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Adding custom feature without drawing
|
|
82
|
+
const feature = new ol.Feature({
|
|
83
|
+
geometry: new ol.geom.MultiPoint([[`-57.1145}`, `-36.2855`]])
|
|
84
|
+
});
|
|
85
|
+
const inserted = await wfst.insertFeaturesTo('myMultiPointLayer', [feature]);
|
|
86
|
+
|
|
87
|
+
if (inserted) {
|
|
88
|
+
alert('Feature inserted');
|
|
89
|
+
} else {
|
|
90
|
+
alert('Feature not inserted');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Events
|
|
94
|
+
wfst.on(['getCapabilities', 'getFeaturesLoaded'], function (evt) {
|
|
95
|
+
console.log(evt.type, evt.data);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
wfst.on(['describeFeatureType', 'getFeature'], function (evt) {
|
|
99
|
+
console.log(evt.type, evt.layer, evt.data);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
wfst.on(['modifystart', 'modifyend', 'drawstart', 'drawend'], function (evt) {
|
|
103
|
+
console.log(evt.type, evt);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
map.addControl(wfst);
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Some considerations
|
|
110
|
+
|
|
111
|
+
- If the features/vertex appear to be slightly offset after adding them, check the _Number of Decimals_ in your Workplace, you may have to increment that to have a more accurete preview.
|
|
112
|
+
- You can configure a _Basic Authentication_ or an _HTTP Header Proxy Authentication_ with this client, but in some cases is recommended setting that on an reverse proxy on the backend.
|
|
113
|
+
- If you don't use a reverse proxy, remeber configure [cors](https://docs.geoserver.org/latest/en/user/production/container.html#enable-cors)
|
|
114
|
+
|
|
115
|
+
## Changelog
|
|
116
|
+
|
|
117
|
+
See [CHANGELOG](./CHANGELOG.md) for details of changes in each release.
|
|
118
|
+
|
|
119
|
+
## Install
|
|
120
|
+
|
|
121
|
+
### Browser
|
|
122
|
+
|
|
123
|
+
#### JS
|
|
124
|
+
|
|
125
|
+
Load `ol-wfst.js` after OpenLayers. Wfst is available as `Wfst`.
|
|
126
|
+
|
|
127
|
+
```HTML
|
|
128
|
+
<script src="https://unpkg.com/ol-wfst@3.0.3"></script>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
#### CSS
|
|
132
|
+
|
|
133
|
+
```HTML
|
|
134
|
+
<link rel="stylesheet" href="https://unpkg.com/ol-wfst@3.0.3/dist/css/ol-wfst.min.css" />
|
|
135
|
+
<link rel="stylesheet" href="https://unpkg.com/ol-wfst@3.0.3/dist/css/ol-wfst.bootstrap5.min.css" />
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Parcel, Webpack, etc.
|
|
139
|
+
|
|
140
|
+
NPM package: [ol-wfst](https://www.npmjs.com/package/ol-wfst).
|
|
141
|
+
|
|
142
|
+
Install the package via `npm`
|
|
143
|
+
|
|
144
|
+
npm install ol-wfst
|
|
145
|
+
|
|
146
|
+
#### JS
|
|
147
|
+
|
|
148
|
+
```js
|
|
149
|
+
import Wfst from 'ol-wfst';
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
#### CSS
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
// scss
|
|
156
|
+
import 'ol-wfst/dist/scss/ol-wfst.scss';
|
|
157
|
+
import 'ol-wfst/dist/scss/-ol-wfst.bootstrap5.scss';
|
|
158
|
+
|
|
159
|
+
// or css
|
|
160
|
+
import 'ol-wfst/dist/css/ol-wfst.css';
|
|
161
|
+
import 'ol-wfst/dist/css/ol-wfst.bootstrap5.css';
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
##### TypeScript type definition
|
|
165
|
+
|
|
166
|
+
TypeScript types are shipped with the project in the dist directory and should be automatically used in a TypeScript project. Interfaces are provided for Wfst Options.
|
|
167
|
+
|
|
168
|
+
## API
|
|
169
|
+
|
|
170
|
+
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
171
|
+
|
|
172
|
+
#### Table of Contents
|
|
173
|
+
|
|
174
|
+
- [Wfst](#wfst)
|
|
175
|
+
- [Parameters](#parameters)
|
|
176
|
+
- [getLayers](#getlayers)
|
|
177
|
+
- [Parameters](#parameters-1)
|
|
178
|
+
- [activateDrawMode](#activatedrawmode)
|
|
179
|
+
- [Parameters](#parameters-2)
|
|
180
|
+
- [activateEditMode](#activateeditmode)
|
|
181
|
+
- [Parameters](#parameters-3)
|
|
182
|
+
- [insertFeaturesTo](#insertfeaturesto)
|
|
183
|
+
- [Parameters](#parameters-4)
|
|
184
|
+
- [Options](#options)
|
|
185
|
+
- [geoServerUrl](#geoserverurl)
|
|
186
|
+
- [geoServerAdvanced](#geoserveradvanced)
|
|
187
|
+
- [headers](#headers)
|
|
188
|
+
- [credentials](#credentials)
|
|
189
|
+
- [layers](#layers)
|
|
190
|
+
- [active](#active)
|
|
191
|
+
- [evtType](#evttype)
|
|
192
|
+
- [useLockFeature](#uselockfeature)
|
|
193
|
+
- [showControl](#showcontrol)
|
|
194
|
+
- [minZoom](#minzoom)
|
|
195
|
+
- [modal](#modal)
|
|
196
|
+
- [language](#language)
|
|
197
|
+
- [i18n](#i18n)
|
|
198
|
+
- [showUpload](#showupload)
|
|
199
|
+
- [uploadFormats](#uploadformats)
|
|
200
|
+
- [processUpload](#processupload)
|
|
201
|
+
- [Parameters](#parameters-5)
|
|
202
|
+
- [beforeInsertFeature](#beforeinsertfeature)
|
|
203
|
+
- [Parameters](#parameters-6)
|
|
204
|
+
- [LayerParams](#layerparams)
|
|
205
|
+
- [name](#name)
|
|
206
|
+
- [label](#label)
|
|
207
|
+
- [mode](#mode)
|
|
208
|
+
- [wfsStrategy](#wfsstrategy)
|
|
209
|
+
- [cqlFilter](#cqlfilter)
|
|
210
|
+
- [tilesBuffer](#tilesbuffer)
|
|
211
|
+
- [WfstLayer](#wfstlayer)
|
|
212
|
+
- [IWfstLayersList](#iwfstlayerslist)
|
|
213
|
+
- [I18n](#i18n-1)
|
|
214
|
+
- [labels](#labels)
|
|
215
|
+
- [errors](#errors)
|
|
216
|
+
|
|
217
|
+
### Wfst
|
|
218
|
+
|
|
219
|
+
**Extends ol/control/Control~Control**
|
|
220
|
+
|
|
221
|
+
Tiny WFST-T client to insert (drawing/uploading), modify and delete
|
|
222
|
+
features on GeoServers using OpenLayers. Layers with these types
|
|
223
|
+
of geometries are supported: "GeometryCollection" (in this case, you can
|
|
224
|
+
choose the geometry type of each element to draw), "Point", "MultiPoint",
|
|
225
|
+
"LineString", "MultiLineString", "Polygon" and "MultiPolygon".
|
|
226
|
+
|
|
227
|
+
#### Parameters
|
|
228
|
+
|
|
229
|
+
- `opt_options` **[Options](#options)?** Wfst options, see [Wfst Options](#options) for more details.
|
|
230
|
+
|
|
231
|
+
#### getLayers
|
|
232
|
+
|
|
233
|
+
Gat all the layers in the ol-wfst instance
|
|
234
|
+
If a name is provided, only returns that layer
|
|
235
|
+
|
|
236
|
+
##### Parameters
|
|
237
|
+
|
|
238
|
+
- `layerName` (optional, default `''`)
|
|
239
|
+
|
|
240
|
+
Returns **([Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[WfstLayer](#wfstlayer)> | [WfstLayer](#wfstlayer))**
|
|
241
|
+
|
|
242
|
+
#### activateDrawMode
|
|
243
|
+
|
|
244
|
+
Activate/deactivate the draw mode
|
|
245
|
+
|
|
246
|
+
##### Parameters
|
|
247
|
+
|
|
248
|
+
- `layerName` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean))**
|
|
249
|
+
|
|
250
|
+
Returns **void**
|
|
251
|
+
|
|
252
|
+
#### activateEditMode
|
|
253
|
+
|
|
254
|
+
Activate/desactivate the edit mode
|
|
255
|
+
|
|
256
|
+
##### Parameters
|
|
257
|
+
|
|
258
|
+
- `bool` (optional, default `true`)
|
|
259
|
+
|
|
260
|
+
Returns **void**
|
|
261
|
+
|
|
262
|
+
#### insertFeaturesTo
|
|
263
|
+
|
|
264
|
+
Add features directly to the geoserver, in a custom layer
|
|
265
|
+
without checking geometry or showing modal to confirm.
|
|
266
|
+
Returns `true` if features are inserted correctly
|
|
267
|
+
|
|
268
|
+
##### Parameters
|
|
269
|
+
|
|
270
|
+
- `layerName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
|
|
271
|
+
- `features` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<Feature\<Geometry>>**
|
|
272
|
+
|
|
273
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)>**
|
|
274
|
+
|
|
275
|
+
### Options
|
|
276
|
+
|
|
277
|
+
**_\[interface]_** - Wfst Options specified when creating a Wfst instance
|
|
278
|
+
|
|
279
|
+
Default values:
|
|
280
|
+
|
|
281
|
+
```javascript
|
|
282
|
+
{
|
|
283
|
+
geoServerUrl: null,
|
|
284
|
+
geoServerAdvanced: {
|
|
285
|
+
getCapabilitiesVersion: '1.3.0',
|
|
286
|
+
getFeatureVersion: '1.0.0',
|
|
287
|
+
describeFeatureTypeVersion: '1.1.0',
|
|
288
|
+
lockFeatureVersion: '1.1.0',
|
|
289
|
+
wfsTransactionVersion: '1.1.0',
|
|
290
|
+
projection: 'EPSG:3857'
|
|
291
|
+
},
|
|
292
|
+
headers: {},
|
|
293
|
+
credentials: 'same-origin',
|
|
294
|
+
layers: null,
|
|
295
|
+
evtType: 'singleclick',
|
|
296
|
+
active: true,
|
|
297
|
+
showControl: true,
|
|
298
|
+
useLockFeature: true,
|
|
299
|
+
minZoom: 9,
|
|
300
|
+
language: 'en',
|
|
301
|
+
i18n: {...}, // according to language selection
|
|
302
|
+
uploadFormats: '.geojson,.json,.kml',
|
|
303
|
+
processUpload: null,
|
|
304
|
+
beforeInsertFeature: null,
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
#### geoServerUrl
|
|
309
|
+
|
|
310
|
+
Url for OWS services. This endpoint will recive the WFS, WFST and WMS requests
|
|
311
|
+
|
|
312
|
+
Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
|
|
313
|
+
|
|
314
|
+
#### geoServerAdvanced
|
|
315
|
+
|
|
316
|
+
Advanced options for geoserver requests
|
|
317
|
+
|
|
318
|
+
Type: {getCapabilitiesVersion: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, getFeatureVersion: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, lockFeatureVersion: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, describeFeatureTypeVersion: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, wfsTransactionVersion: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, projection: ProjectionLike?}
|
|
319
|
+
|
|
320
|
+
#### headers
|
|
321
|
+
|
|
322
|
+
Url headers for GeoServer requests. You can use it to add Authorization credentials
|
|
323
|
+
<https://developer.mozilla.org/en-US/docs/Web/API/Request/headers>
|
|
324
|
+
|
|
325
|
+
Type: HeadersInit
|
|
326
|
+
|
|
327
|
+
#### credentials
|
|
328
|
+
|
|
329
|
+
Credentials for fetch requests
|
|
330
|
+
<https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials>
|
|
331
|
+
|
|
332
|
+
Type: RequestCredentials
|
|
333
|
+
|
|
334
|
+
#### layers
|
|
335
|
+
|
|
336
|
+
Layers to be loaded from the geoserver
|
|
337
|
+
|
|
338
|
+
Type: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[LayerParams](#layerparams)>
|
|
339
|
+
|
|
340
|
+
#### active
|
|
341
|
+
|
|
342
|
+
Init active
|
|
343
|
+
|
|
344
|
+
Type: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
|
|
345
|
+
|
|
346
|
+
#### evtType
|
|
347
|
+
|
|
348
|
+
The click event to allow selection of Features to be edited
|
|
349
|
+
|
|
350
|
+
Type: (`"singleclick"` | `"dblclick"`)
|
|
351
|
+
|
|
352
|
+
#### useLockFeature
|
|
353
|
+
|
|
354
|
+
Use LockFeatue request on GeoServer when selecting features.
|
|
355
|
+
This is not always supportedd by the GeoServer.
|
|
356
|
+
See <https://docs.geoserver.org/stable/en/user/services/wfs/reference.html>
|
|
357
|
+
|
|
358
|
+
Type: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
|
|
359
|
+
|
|
360
|
+
#### showControl
|
|
361
|
+
|
|
362
|
+
Show/hide the control map
|
|
363
|
+
|
|
364
|
+
Type: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
|
|
365
|
+
|
|
366
|
+
#### minZoom
|
|
367
|
+
|
|
368
|
+
Zoom level to hide features to prevent too much features being loaded
|
|
369
|
+
|
|
370
|
+
Type: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
|
|
371
|
+
|
|
372
|
+
#### modal
|
|
373
|
+
|
|
374
|
+
Modal configuration
|
|
375
|
+
|
|
376
|
+
Type: {animateClass: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, animateInClass: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, transition: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?, backdropTransition: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?, templates: {dialog: ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element))?, headerClose: ([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element))?}?}
|
|
377
|
+
|
|
378
|
+
#### language
|
|
379
|
+
|
|
380
|
+
Language to be used
|
|
381
|
+
|
|
382
|
+
Type: (`"es"` | `"en"` | `"zh"`)
|
|
383
|
+
|
|
384
|
+
#### i18n
|
|
385
|
+
|
|
386
|
+
Custom translations
|
|
387
|
+
|
|
388
|
+
Type: [I18n](#i18n)
|
|
389
|
+
|
|
390
|
+
#### showUpload
|
|
391
|
+
|
|
392
|
+
Show/hide the upload button
|
|
393
|
+
|
|
394
|
+
Type: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
|
|
395
|
+
|
|
396
|
+
#### uploadFormats
|
|
397
|
+
|
|
398
|
+
Accepted extension formats on upload
|
|
399
|
+
Example: ".json,.geojson"
|
|
400
|
+
|
|
401
|
+
Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
|
|
402
|
+
|
|
403
|
+
#### processUpload
|
|
404
|
+
|
|
405
|
+
Triggered to allow implement custom functions or to parse other formats than default
|
|
406
|
+
by filtering the extension. If this doesn't return features, the default function
|
|
407
|
+
will be used to extract them.
|
|
408
|
+
|
|
409
|
+
##### Parameters
|
|
410
|
+
|
|
411
|
+
- `file` **File**
|
|
412
|
+
|
|
413
|
+
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<Feature\<Geometry>>**
|
|
414
|
+
|
|
415
|
+
#### beforeInsertFeature
|
|
416
|
+
|
|
417
|
+
Triggered before inserting new features to the Geoserver.
|
|
418
|
+
Use this to insert custom properties, modify the feature, etc.
|
|
419
|
+
|
|
420
|
+
##### Parameters
|
|
421
|
+
|
|
422
|
+
- `feature` **Feature\<Geometry>**
|
|
423
|
+
|
|
424
|
+
Returns **Feature\<Geometry>**
|
|
425
|
+
|
|
426
|
+
### LayerParams
|
|
427
|
+
|
|
428
|
+
**Extends Omit\<[VectorLayerOptions](https://openlayers.org/en/latest/apidoc/module-ol_layer_Vector-VectorLayer.html)\<any>, 'source'>**
|
|
429
|
+
|
|
430
|
+
**_\[interface]_** - Parameters to create the layers and connect to the GeoServer
|
|
431
|
+
|
|
432
|
+
You can use all the parameters supported by OpenLayers
|
|
433
|
+
|
|
434
|
+
Default values:
|
|
435
|
+
|
|
436
|
+
```javascript
|
|
437
|
+
{
|
|
438
|
+
name: null,
|
|
439
|
+
label: null, // `name` if not provided
|
|
440
|
+
mode: 'wfs',
|
|
441
|
+
wfsStrategy: 'bbox',
|
|
442
|
+
cqlFilter: null,
|
|
443
|
+
tilesBuffer: 0,
|
|
444
|
+
}
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
#### name
|
|
448
|
+
|
|
449
|
+
Layer name in the GeoServer
|
|
450
|
+
|
|
451
|
+
Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
|
|
452
|
+
|
|
453
|
+
#### label
|
|
454
|
+
|
|
455
|
+
Label to be displayed in the widget control
|
|
456
|
+
|
|
457
|
+
Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
|
|
458
|
+
|
|
459
|
+
#### mode
|
|
460
|
+
|
|
461
|
+
Mode to use in the layer
|
|
462
|
+
|
|
463
|
+
Type: (`"wfs"` | `"wms"`)
|
|
464
|
+
|
|
465
|
+
#### wfsStrategy
|
|
466
|
+
|
|
467
|
+
Strategy function for loading features. Only works if mode is "wfs"
|
|
468
|
+
|
|
469
|
+
Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
|
|
470
|
+
|
|
471
|
+
#### cqlFilter
|
|
472
|
+
|
|
473
|
+
The cql_filter GeoServer parameter is similar to the standard filter parameter,
|
|
474
|
+
but the filter is expressed using ECQL (Extended Common Query Language).
|
|
475
|
+
ECQL provides a more compact and readable syntax compared to OGC XML filters.
|
|
476
|
+
For full details see the [ECQL Reference](https://docs.geoserver.org/stable/en/user/filter/ecql_reference.html#filter-ecql-reference) and CQL and ECQL tutorial.
|
|
477
|
+
|
|
478
|
+
Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
|
|
479
|
+
|
|
480
|
+
#### tilesBuffer
|
|
481
|
+
|
|
482
|
+
The buffer parameter specifies the number of additional
|
|
483
|
+
border pixels that are used on requesting rasted tiles
|
|
484
|
+
Only works if mode is 'wms'
|
|
485
|
+
|
|
486
|
+
Type: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
|
|
487
|
+
|
|
488
|
+
### WfstLayer
|
|
489
|
+
|
|
490
|
+
**_\[type]_** - Supported layers
|
|
491
|
+
|
|
492
|
+
Type: (VectorLayer\<any> | TileLayer\<any>)
|
|
493
|
+
|
|
494
|
+
### IWfstLayersList
|
|
495
|
+
|
|
496
|
+
**_\[interface]_** - Custom Language specified when creating a WFST instance
|
|
497
|
+
|
|
498
|
+
### I18n
|
|
499
|
+
|
|
500
|
+
**_\[interface]_** - Custom Language specified when creating a WFST instance
|
|
501
|
+
|
|
502
|
+
#### labels
|
|
503
|
+
|
|
504
|
+
Labels section
|
|
505
|
+
|
|
506
|
+
Type: {select: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, addElement: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, editElement: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, save: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, delete: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, cancel: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, apply: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, upload: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, editMode: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, confirmDelete: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, geomTypeNotSupported: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, editFields: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, editGeom: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, selectDrawType: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, uploadToLayer: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, uploadFeatures: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, validFeatures: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, invalidFeatures: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, loading: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, toggleVisibility: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, close: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?}
|
|
507
|
+
|
|
508
|
+
#### errors
|
|
509
|
+
|
|
510
|
+
Errors section
|
|
511
|
+
|
|
512
|
+
Type: {capabilities: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, wfst: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, layer: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, layerNotFound: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, noValidGeometry: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, geoserver: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, badFormat: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, badFile: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, lockFeature: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, transaction: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?, getFeatures: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?}
|
|
513
|
+
|
|
514
|
+
## TODO
|
|
515
|
+
|
|
516
|
+
- \~~Add support to diferent layer styles~~
|
|
517
|
+
- \~~Improve widget controller: visibility toggle~~
|
|
518
|
+
- \~~Add events~~
|
|
519
|
+
- Add customizables styles
|
|
520
|
+
- Improve scss (add variables)
|
|
521
|
+
- Add cookies to persist widget controller state
|
|
522
|
+
- Geometry type _LinearRing_ support
|
|
523
|
+
- Tests!
|
|
524
|
+
- Improve comments and documentation
|
|
525
|
+
- Improve interface
|
|
526
|
+
- Change svg imports to preserve svg structure
|
|
527
|
+
|
|
528
|
+
## License
|
|
529
|
+
|
|
530
|
+
MIT (c) Gastón Zalba.
|