ol-wfst 4.0.5 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +367 -359
  2. package/dist/@types.d.ts +6 -0
  3. package/dist/@types.d.ts.map +1 -1
  4. package/dist/Geoserver.d.ts +20 -12
  5. package/dist/Geoserver.d.ts.map +1 -1
  6. package/dist/WfsLayer.d.ts +13 -13
  7. package/dist/WfsLayer.d.ts.map +1 -1
  8. package/dist/WmsLayer.d.ts +14 -13
  9. package/dist/WmsLayer.d.ts.map +1 -1
  10. package/dist/css/ol-wfst.bootstrap5.css +40 -11
  11. package/dist/css/ol-wfst.bootstrap5.min.css +1 -1
  12. package/dist/modules/EditControlChanges.d.ts +10 -10
  13. package/dist/modules/EditControlChanges.d.ts.map +1 -1
  14. package/dist/modules/EditFieldsModal.d.ts +3 -2
  15. package/dist/modules/EditFieldsModal.d.ts.map +1 -1
  16. package/dist/modules/EditOverlay.d.ts +4 -3
  17. package/dist/modules/EditOverlay.d.ts.map +1 -1
  18. package/dist/modules/LayersControl.d.ts +2 -3
  19. package/dist/modules/LayersControl.d.ts.map +1 -1
  20. package/dist/modules/Uploads.d.ts +6 -3
  21. package/dist/modules/Uploads.d.ts.map +1 -1
  22. package/dist/modules/base/BaseLayer.d.ts +5 -5
  23. package/dist/modules/base/BaseLayer.d.ts.map +1 -1
  24. package/dist/modules/base/WfsSource.d.ts +1 -1
  25. package/dist/modules/base/WfsSource.d.ts.map +1 -1
  26. package/dist/modules/base/WmsSource.d.ts +1 -1
  27. package/dist/modules/base/WmsSource.d.ts.map +1 -1
  28. package/dist/modules/editLayer.d.ts +2 -2
  29. package/dist/modules/editLayer.d.ts.map +1 -1
  30. package/dist/modules/errors.d.ts +2 -1
  31. package/dist/modules/errors.d.ts.map +1 -1
  32. package/dist/modules/state.d.ts +2 -2
  33. package/dist/modules/state.d.ts.map +1 -1
  34. package/dist/modules/styleFunction.d.ts +3 -3
  35. package/dist/modules/styleFunction.d.ts.map +1 -1
  36. package/dist/ol-wfst.d.ts +21 -15
  37. package/dist/ol-wfst.d.ts.map +1 -1
  38. package/dist/ol-wfst.js +219 -2785
  39. package/dist/ol-wfst.js.map +1 -1
  40. package/dist/ol-wfst.min.js +1 -1
  41. package/dist/ol-wfst.min.js.map +1 -1
  42. package/lib/@types.d.ts +6 -0
  43. package/lib/@types.d.ts.map +1 -1
  44. package/lib/Geoserver.d.ts +20 -12
  45. package/lib/Geoserver.d.ts.map +1 -1
  46. package/lib/WfsLayer.d.ts +13 -13
  47. package/lib/WfsLayer.d.ts.map +1 -1
  48. package/lib/WmsLayer.d.ts +14 -13
  49. package/lib/WmsLayer.d.ts.map +1 -1
  50. package/lib/modules/EditControlChanges.d.ts +10 -10
  51. package/lib/modules/EditControlChanges.d.ts.map +1 -1
  52. package/lib/modules/EditFieldsModal.d.ts +3 -2
  53. package/lib/modules/EditFieldsModal.d.ts.map +1 -1
  54. package/lib/modules/EditOverlay.d.ts +4 -3
  55. package/lib/modules/EditOverlay.d.ts.map +1 -1
  56. package/lib/modules/LayersControl.d.ts +2 -3
  57. package/lib/modules/LayersControl.d.ts.map +1 -1
  58. package/lib/modules/Uploads.d.ts +6 -3
  59. package/lib/modules/Uploads.d.ts.map +1 -1
  60. package/lib/modules/base/BaseLayer.d.ts +5 -5
  61. package/lib/modules/base/BaseLayer.d.ts.map +1 -1
  62. package/lib/modules/base/WfsSource.d.ts +1 -1
  63. package/lib/modules/base/WfsSource.d.ts.map +1 -1
  64. package/lib/modules/base/WmsSource.d.ts +1 -1
  65. package/lib/modules/base/WmsSource.d.ts.map +1 -1
  66. package/lib/modules/editLayer.d.ts +2 -2
  67. package/lib/modules/editLayer.d.ts.map +1 -1
  68. package/lib/modules/errors.d.ts +2 -1
  69. package/lib/modules/errors.d.ts.map +1 -1
  70. package/lib/modules/state.d.ts +2 -2
  71. package/lib/modules/state.d.ts.map +1 -1
  72. package/lib/modules/styleFunction.d.ts +3 -3
  73. package/lib/modules/styleFunction.d.ts.map +1 -1
  74. package/lib/ol-wfst.d.ts +21 -15
  75. package/lib/ol-wfst.d.ts.map +1 -1
  76. package/lib/ol-wfst.js +151 -236
  77. package/lib/ol-wfst.js.map +1 -1
  78. package/lib/style/css/ol-wfst.bootstrap5.css +40 -11
  79. package/lib/style/scss/-ol-wfst.bootstrap5.scss +10 -10
  80. package/lib/style/scss/_variables.scss +17 -17
  81. package/lib/style/scss/ol-wfst.scss +230 -230
  82. package/package.json +71 -72
  83. package/CHANGELOG.md +0 -103
package/lib/ol-wfst.js CHANGED
@@ -1,26 +1,38 @@
1
- import { Style, Stroke, Fill, Circle } from 'ol/style';
2
- import { Control } from 'ol/control';
3
- import { Modify, Snap, Select, Draw } from 'ol/interaction';
4
- import { Observable, Feature, Overlay, Collection } from 'ol';
5
- import BaseEvent from 'ol/events/Event';
6
- import { primaryAction, never } from 'ol/events/condition';
7
- import { unByKey } from 'ol/Observable';
1
+ import CircleStyle from 'ol/style/Circle.js';
2
+ import Fill$1 from 'ol/style/Fill.js';
3
+ import Stroke$1 from 'ol/style/Stroke.js';
4
+ import Style$1 from 'ol/style/Style.js';
5
+ import Control from 'ol/control/Control.js';
6
+ import Draw from 'ol/interaction/Draw.js';
7
+ import Modify from 'ol/interaction/Modify.js';
8
+ import Select from 'ol/interaction/Select.js';
9
+ import Snap from 'ol/interaction/Snap.js';
10
+ import Collection from 'ol/Collection.js';
11
+ import BaseEvent from 'ol/events/Event.js';
12
+ import { primaryAction, never } from 'ol/events/condition.js';
13
+ import Observable, { unByKey } from 'ol/Observable.js';
8
14
  import Modal from 'modal-vanilla';
9
- import VectorLayer from 'ol/layer/Vector';
15
+ import VectorLayer from 'ol/layer/Vector.js';
10
16
  import { Mixin } from 'ts-mixer';
11
- import Layer from 'ol/layer/Base';
12
- import GeoJSON from 'ol/format/GeoJSON';
13
- import VectorSource, { VectorSourceEvent } from 'ol/source/Vector';
14
- import { transformExtent } from 'ol/proj';
15
- import { bbox } from 'ol/loadingstrategy';
16
- import TileLayer from 'ol/layer/Tile';
17
- import { GeoJSON as GeoJSON$1, WFS, KML } from 'ol/format';
18
- import TileWMS from 'ol/source/TileWMS';
19
- import TileState from 'ol/TileState';
20
- import { MultiPolygon, MultiLineString, MultiPoint, GeometryCollection, Polygon, Circle as Circle$1 } from 'ol/geom';
21
- import BaseObject from 'ol/Object';
22
- import { fromCircle } from 'ol/geom/Polygon';
23
- import { getCenter } from 'ol/extent';
17
+ import Layer from 'ol/layer/Base.js';
18
+ import GeoJSON from 'ol/format/GeoJSON.js';
19
+ import VectorSource, { VectorSourceEvent } from 'ol/source/Vector.js';
20
+ import { transformExtent } from 'ol/proj.js';
21
+ import { bbox } from 'ol/loadingstrategy.js';
22
+ import TileLayer from 'ol/layer/Tile.js';
23
+ import TileWMS from 'ol/source/TileWMS.js';
24
+ import TileState from 'ol/TileState.js';
25
+ import { MultiPolygon, MultiLineString, MultiPoint, GeometryCollection, Polygon } from 'ol/geom.js';
26
+ import KML from 'ol/format/KML.js';
27
+ import WFS from 'ol/format/WFS.js';
28
+ import { Style, Stroke, Fill, Circle } from 'ol/style.js';
29
+ import BaseObject from 'ol/Object.js';
30
+ import Circle$1 from 'ol/geom/Circle.js';
31
+ import GeometryCollection$1 from 'ol/geom/GeometryCollection.js';
32
+ import Feature from 'ol/Feature.js';
33
+ import { fromCircle } from 'ol/geom/Polygon.js';
34
+ import { getCenter } from 'ol/extent.js';
35
+ import Overlay from 'ol/Overlay.js';
24
36
 
25
37
  // External
26
38
  let options = {};
@@ -29,9 +41,11 @@ const isError = new Set();
29
41
  const initModal = (opts) => {
30
42
  options = opts;
31
43
  };
32
- const parseError = (geoserverError) => {
33
- if ('exceptions' in geoserverError) {
34
- return geoserverError.exceptions.map((e) => e.text).join(',');
44
+ const parseError = (geoserverResponse) => {
45
+ if ('exceptions' in geoserverResponse) {
46
+ return geoserverResponse.exceptions
47
+ .map((e) => e.text)
48
+ .join(',');
35
49
  }
36
50
  else {
37
51
  return '';
@@ -50,7 +64,7 @@ const showError = (msg, originalError = null, layerName = '') => {
50
64
  }
51
65
  isError.add(layerName);
52
66
  let err_msg = `<b>Error: ${msg}</b>`;
53
- if (originalError) {
67
+ if (originalError && originalError.message !== msg) {
54
68
  err_msg += `. ${originalError.message}`;
55
69
  }
56
70
  const al = Modal.alert(err_msg, options);
@@ -94,9 +108,9 @@ const es = {
94
108
  geoserver: 'No se pudieron obtener datos desde el GeoServer',
95
109
  badFormat: 'Formato no soportado',
96
110
  badFile: 'Error al leer elementos del archivo',
97
- lockFeature: 'No se pudieron bloquear elementos en el GeoServer.',
98
- transaction: 'Error al hacer transacción con el GeoServer.',
99
- getFeatures: 'Error al obtener elemento desde el GeoServer.'
111
+ lockFeature: 'No se pudieron bloquear elementos en el GeoServer',
112
+ transaction: 'Error al hacer transacción con el GeoServer',
113
+ getFeatures: 'Error al obtener elemento desde el GeoServer'
100
114
  }
101
115
  };
102
116
 
@@ -134,9 +148,9 @@ const en = {
134
148
  geoserver: 'Failed to get data from GeoServer',
135
149
  badFormat: 'Unsupported format',
136
150
  badFile: 'Error reading items from file',
137
- lockFeature: 'Could not lock items on the GeoServer.',
138
- transaction: 'Error when doing Transaction with GeoServer.',
139
- getFeatures: 'Error getting elements from GeoServer.'
151
+ lockFeature: 'Could not lock items on the GeoServer',
152
+ transaction: 'Error when doing Transaction with GeoServer',
153
+ getFeatures: 'Error getting elements from GeoServer'
140
154
  }
141
155
  };
142
156
 
@@ -194,7 +208,7 @@ const setLang = (lang = 'en', customI18n = null) => {
194
208
  }
195
209
  // Check if customs translations are provided
196
210
  if (customI18n) {
197
- I18N = { ...I18N, ...customI18n };
211
+ I18N = Object.assign(Object.assign({}, I18N), customI18n);
198
212
  }
199
213
  };
200
214
 
@@ -293,7 +307,7 @@ class BaseLayer extends Layer {
293
307
  this.getAndUpdateDescribeFeatureType();
294
308
  }
295
309
  else {
296
- geoserver.on('change:capabilities', () => {
310
+ geoserver.on('change:capabilities', async () => {
297
311
  this.getAndUpdateDescribeFeatureType();
298
312
  });
299
313
  }
@@ -328,6 +342,9 @@ class BaseLayer extends Layer {
328
342
  if (!data) {
329
343
  throw new Error('');
330
344
  }
345
+ if (data.exceptions) {
346
+ throw new Error(parseError(data));
347
+ }
331
348
  const targetNamespace = data.targetNamespace;
332
349
  const properties = data.featureTypes[0].properties;
333
350
  // Find the geometry field
@@ -342,7 +359,7 @@ class BaseLayer extends Layer {
342
359
  }
343
360
  catch (err) {
344
361
  console.error(err);
345
- throw new Error(`${I18N.errors.layer} "${layerLabel}"`);
362
+ showError(`${I18N.errors.layer} "${layerLabel}"`, err, layerName);
346
363
  }
347
364
  }
348
365
  /**
@@ -411,17 +428,8 @@ var BaseLayerProperty;
411
428
  * @param options
412
429
  */
413
430
  class WfsSource extends VectorSource {
414
- urlParams = new URLSearchParams({
415
- SERVICE: 'wfs',
416
- REQUEST: 'GetFeature',
417
- OUTPUTFORMAT: 'application/json',
418
- EXCEPTIONS: 'application/json'
419
- });
420
431
  constructor(options) {
421
- super({
422
- ...options,
423
- format: new GeoJSON(),
424
- loader: async (extent, resolution, projection, success, failure) => {
432
+ super(Object.assign(Object.assign({}, options), { format: new GeoJSON(), loader: async (extent, resolution, projection, success, failure) => {
425
433
  try {
426
434
  // If bbox, add extent to the request
427
435
  if (options.strategy == bbox) {
@@ -459,7 +467,12 @@ class WfsSource extends VectorSource {
459
467
  showError(I18N.errors.geoserver, err, options.name);
460
468
  failure();
461
469
  }
462
- }
470
+ } }));
471
+ this.urlParams = new URLSearchParams({
472
+ SERVICE: 'wfs',
473
+ REQUEST: 'GetFeature',
474
+ OUTPUTFORMAT: 'application/json',
475
+ EXCEPTIONS: 'application/json'
463
476
  });
464
477
  this.urlParams.set('version', options.geoServerAdvanced.getFeatureVersion);
465
478
  this.urlParams.set('typename', options.name);
@@ -476,27 +489,15 @@ class WfsSource extends VectorSource {
476
489
  * @param options
477
490
  */
478
491
  class WfsLayer extends Mixin(BaseLayer, (VectorLayer)) {
479
- _loadingCount = 0;
480
- _loadedCount = 0;
481
- beforeTransactFeature;
482
492
  constructor(options) {
483
- super({
484
- name: options.name,
485
- label: options.label || options.name,
486
- minZoom: options.minZoom,
487
- ...options
488
- });
493
+ super(Object.assign({ name: options.name, label: options.label || options.name, minZoom: options.minZoom }, options));
494
+ this._loadingCount = 0;
495
+ this._loadedCount = 0;
489
496
  if (options.beforeTransactFeature) {
490
497
  this.beforeTransactFeature = options.beforeTransactFeature;
491
498
  }
492
499
  const geoserver = options.geoserver;
493
- const source = new WfsSource({
494
- name: options.name,
495
- geoserverUrl: geoserver.getUrl(),
496
- geoServerAdvanced: geoserver.getAdvanced(),
497
- ...(options.strategy && { strategy: options.strategy }),
498
- geoserverVendor: options.geoserverVendor
499
- });
500
+ const source = new WfsSource(Object.assign(Object.assign({ name: options.name, geoserverUrl: geoserver.getUrl(), geoServerAdvanced: geoserver.getAdvanced() }, (options.strategy && { strategy: options.strategy })), { geoserverVendor: options.geoserverVendor }));
500
501
  this._loadingCount = 0;
501
502
  this._loadedCount = 0;
502
503
  source.on('featuresloadstart', () => {
@@ -565,17 +566,7 @@ class WfsLayer extends Mixin(BaseLayer, (VectorLayer)) {
565
566
  */
566
567
  class WmsSource extends TileWMS {
567
568
  constructor(options) {
568
- super({
569
- url: options.geoserverUrl,
570
- serverType: 'geoserver',
571
- params: {
572
- SERVICE: 'wms',
573
- TILED: true,
574
- LAYERS: options.name,
575
- EXCEPTIONS: 'application/json',
576
- ...(options.geoserverVendor && options.geoserverVendor)
577
- },
578
- tileLoadFunction: async (tile, src) => {
569
+ super(Object.assign({ url: options.geoserverUrl, serverType: 'geoserver', params: Object.assign({ SERVICE: 'wms', TILED: true, LAYERS: options.name, EXCEPTIONS: 'application/json' }, (options.geoserverVendor && options.geoserverVendor)), tileLoadFunction: async (tile, src) => {
579
570
  const blobToJson = (blob) => {
580
571
  return new Promise((resolve) => {
581
572
  const reader = new FileReader();
@@ -605,9 +596,7 @@ class WmsSource extends TileWMS {
605
596
  showError(I18N.errors.geoserver, err, options.name);
606
597
  tile.setState(TileState.ERROR);
607
598
  }
608
- },
609
- ...options
610
- });
599
+ } }, options));
611
600
  }
612
601
  }
613
602
 
@@ -620,22 +609,14 @@ class WmsSource extends TileWMS {
620
609
  * @param options
621
610
  */
622
611
  class WmsLayer extends Mixin(BaseLayer, (TileLayer)) {
623
- _loadingCount = 0;
624
- _loadedCount = 0;
625
- beforeTransactFeature;
626
- // Formats
627
- _formatGeoJSON;
628
612
  constructor(options) {
629
- super({
630
- name: options.name,
631
- label: options.label || options.name,
632
- minZoom: options.minZoom,
633
- ...options
634
- });
613
+ super(Object.assign({ name: options.name, label: options.label || options.name, minZoom: options.minZoom }, options));
614
+ this._loadingCount = 0;
615
+ this._loadedCount = 0;
635
616
  if (options.beforeTransactFeature) {
636
617
  this.beforeTransactFeature = options.beforeTransactFeature;
637
618
  }
638
- this._formatGeoJSON = new GeoJSON$1();
619
+ this._formatGeoJSON = new GeoJSON();
639
620
  const geoserver = options.geoserver;
640
621
  const source = new WmsSource({
641
622
  name: options.name,
@@ -741,6 +722,14 @@ class WmsLayer extends Mixin(BaseLayer, (TileLayer)) {
741
722
  }
742
723
  }
743
724
 
725
+ var img$5 = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'%3e%3cpath d='M240 352h-240v128h480v-128h-240zM448 416h-64v-32h64v32zM112 160l128-128 128 128h-80v160h-96v-160z'%3e%3c/path%3e%3c/svg%3e";
726
+
727
+ var img$4 = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e %3cpath d='M663 225l-58.5 58.5-120-120 58.5-58.5q9-9 22.5-9t22.5 9l75 75q9 9 9 22.5t-9 22.5zM96 552l354-354 120 120-354 354h-120v-120z'%3e%3c/path%3e%3c/svg%3e";
728
+
729
+ var img$3 = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e%3cpath d='M384 288q39 0 67.5 28.5t28.5 67.5-28.5 67.5-67.5 28.5-67.5-28.5-28.5-67.5 28.5-67.5 67.5-28.5zM384 544.5q66 0 113.25-47.25t47.25-113.25-47.25-113.25-113.25-47.25-113.25 47.25-47.25 113.25 47.25 113.25 113.25 47.25zM384 144q118.5 0 214.5 66t138 174q-42 108-138 174t-214.5 66-214.5-66-138-174q42-108 138-174t214.5-66z'%3e%3c/path%3e%3c/svg%3e";
730
+
731
+ var img$2 = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e%3cpath d='M379.5 288h4.5q39 0 67.5 28.5t28.5 67.5v6zM241.5 313.5q-18 36-18 70.5 0 66 47.25 113.25t113.25 47.25q34.5 0 70.5-18l-49.5-49.5q-12 3-21 3-39 0-67.5-28.5t-28.5-67.5q0-9 3-21zM64.5 136.5l40.5-40.5 567 567-40.5 40.5q-7.5-7.5-47.25-46.5t-60.75-60q-64.5 27-139.5 27-118.5 0-214.5-66t-138-174q16.5-39 51.75-86.25t68.25-72.75q-18-18-50.25-51t-36.75-37.5zM384 223.5q-30 0-58.5 12l-69-69q58.5-22.5 127.5-22.5 118.5 0 213.75 66t137.25 174q-36 88.5-109.5 151.5l-93-93q12-28.5 12-58.5 0-66-47.25-113.25t-113.25-47.25z'%3e%3c/path%3e%3c/svg%3e";
732
+
744
733
  function createElement(tagName, attrs = {}, ...children) {
745
734
  if (typeof tagName === 'function')
746
735
  return tagName(attrs, children);
@@ -778,14 +767,6 @@ function createElement(tagName, attrs = {}, ...children) {
778
767
  return elem;
779
768
  }
780
769
 
781
- var img$5 = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'%3e%3cpath d='M240 352h-240v128h480v-128h-240zM448 416h-64v-32h64v32zM112 160l128-128 128 128h-80v160h-96v-160z'%3e%3c/path%3e%3c/svg%3e";
782
-
783
- var img$4 = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e %3cpath d='M663 225l-58.5 58.5-120-120 58.5-58.5q9-9 22.5-9t22.5 9l75 75q9 9 9 22.5t-9 22.5zM96 552l354-354 120 120-354 354h-120v-120z'%3e%3c/path%3e%3c/svg%3e";
784
-
785
- var img$3 = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e%3cpath d='M384 288q39 0 67.5 28.5t28.5 67.5-28.5 67.5-67.5 28.5-67.5-28.5-28.5-67.5 28.5-67.5 67.5-28.5zM384 544.5q66 0 113.25-47.25t47.25-113.25-47.25-113.25-113.25-47.25-113.25 47.25-47.25 113.25 47.25 113.25 113.25 47.25zM384 144q118.5 0 214.5 66t138 174q-42 108-138 174t-214.5 66-214.5-66-138-174q42-108 138-174t214.5-66z'%3e%3c/path%3e%3c/svg%3e";
786
-
787
- var img$2 = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='768' height='768' viewBox='0 0 768 768'%3e%3cpath d='M379.5 288h4.5q39 0 67.5 28.5t28.5 67.5v6zM241.5 313.5q-18 36-18 70.5 0 66 47.25 113.25t113.25 47.25q34.5 0 70.5-18l-49.5-49.5q-12 3-21 3-39 0-67.5-28.5t-28.5-67.5q0-9 3-21zM64.5 136.5l40.5-40.5 567 567-40.5 40.5q-7.5-7.5-47.25-46.5t-60.75-60q-64.5 27-139.5 27-118.5 0-214.5-66t-138-174q16.5-39 51.75-86.25t68.25-72.75q-18-18-50.25-51t-36.75-37.5zM384 223.5q-30 0-58.5 12l-69-69q58.5-22.5 127.5-22.5 118.5 0 213.75 66t137.25 174q-36 88.5-109.5 151.5l-93-93q12-28.5 12-58.5 0-66-47.25-113.25t-113.25-47.25z'%3e%3c/path%3e%3c/svg%3e";
788
-
789
770
  /**
790
771
  * Removes in the DOM the class of the tools
791
772
  * @private
@@ -809,8 +790,6 @@ const activateDrawButton = () => {
809
790
  }
810
791
  };
811
792
  class LayersControl extends Observable {
812
- _uploads;
813
- _uploadFormats;
814
793
  constructor(uploads, uploadFormats) {
815
794
  super();
816
795
  this._uploads = uploads;
@@ -824,17 +803,17 @@ class LayersControl extends Observable {
824
803
  addLayerEl(layer) {
825
804
  const container = document.querySelector('.wfst--tools-control--select-layers');
826
805
  const layerName = layer.get(BaseLayerProperty.NAME);
827
- const checked = layer === getActiveLayerToInsertEls() ? { checked: 'checked' } : {};
828
- const input = (createElement("input", { value: layerName, id: `wfst--${layerName}`, type: "radio", className: "ol-wfst--tools-control-input", name: "wfst--select-layer", ...checked, onchange: (evt) => this._layerChangeHandler(evt, layer) }));
829
- const layerDom = (createElement("div", { className: `wfst--layer-control
830
- ${layer.getVisible() ? 'ol-wfst--visible-on' : ''}
806
+ const checked = layer === getActiveLayerToInsertEls() ? { checked: true } : {};
807
+ const input = (createElement("input", Object.assign({ value: layerName, id: `wfst--${layerName}`, type: "radio", className: "ol-wfst--tools-control-input", name: "wfst--select-layer" }, checked, { onChange: (evt) => this._layerChangeHandler(evt, layer) })));
808
+ const layerDom = (createElement("div", { className: `wfst--layer-control
809
+ ${layer.getVisible() ? 'ol-wfst--visible-on' : ''}
831
810
  ${layer === getActiveLayerToInsertEls()
832
811
  ? 'ol-wfst--selected-on'
833
812
  : ''}`, "data-layer": layerName },
834
813
  createElement("div", { className: "ol-wfst--tools-control-visible" },
835
- createElement("span", { className: "ol-wfst--tools-control-visible-btn ol-wfst--visible-btn-on", title: I18N.labels.toggleVisibility, onclick: (evt) => this._visibilityClickHandler(evt) },
814
+ createElement("span", { className: "ol-wfst--tools-control-visible-btn ol-wfst--visible-btn-on", title: I18N.labels.toggleVisibility, onClick: (evt) => this._visibilityClickHandler(evt) },
836
815
  createElement("img", { src: img$3 })),
837
- createElement("span", { className: "ol-wfst--tools-control-visible-btn ol-wfst--visible-btn-off", title: I18N.labels.toggleVisibility, onclick: (evt) => this._visibilityClickHandler(evt) },
816
+ createElement("span", { className: "ol-wfst--tools-control-visible-btn ol-wfst--visible-btn-off", title: I18N.labels.toggleVisibility, onClick: (evt) => this._visibilityClickHandler(evt) },
838
817
  createElement("img", { src: img$2 }))),
839
818
  createElement("label", { htmlFor: `wfst--${layerName}` },
840
819
  input,
@@ -933,17 +912,16 @@ class LayersControl extends Observable {
933
912
  return (createElement(null, null,
934
913
  createElement("div", { className: "wfst--tools-control--head" },
935
914
  this._uploads && (createElement("div", null,
936
- createElement("input", { id: "ol-wfst--upload", type: "file", accept: this._uploadFormats, onchange: (evt) => this._uploads.process(evt) }),
915
+ createElement("input", { id: "ol-wfst--upload", type: "file", accept: this._uploadFormats, onChange: (evt) => this._uploads.process(evt) }),
937
916
  createElement("label", { className: "ol-wfst--tools-control-btn ol-wfst--tools-control-btn-upload", htmlFor: "ol-wfst--upload", title: I18N.labels.uploadToLayer },
938
917
  createElement("img", { src: img$5 })))),
939
918
  createElement("div", { className: "ol-wfst--tools-control-draw-cnt" },
940
- createElement("button", { className: "ol-wfst--tools-control-btn ol-wfst--tools-control-btn-draw", type: "button", title: I18N.labels.addElement, onclick: () => {
919
+ createElement("button", { className: "ol-wfst--tools-control-btn ol-wfst--tools-control-btn-draw", type: "button", title: I18N.labels.addElement, onClick: () => {
941
920
  this.dispatchEvent('drawMode');
942
921
  } },
943
922
  createElement("img", { src: img$4 })),
944
- createElement("select", { title: I18N.labels.selectDrawType, className: "wfst--tools-control--select-draw", onchange: (evt) => {
945
- const selectedValue = evt.target
946
- .value;
923
+ createElement("select", { title: I18N.labels.selectDrawType, className: "wfst--tools-control--select-draw", onChange: (evt) => {
924
+ const selectedValue = evt.target.value;
947
925
  this._changeStateSelect(getActiveLayerToInsertEls(), selectedValue);
948
926
  this.dispatchEvent('changeGeom');
949
927
  } }, [
@@ -972,20 +950,13 @@ const getEditLayer = () => {
972
950
 
973
951
  // Ol
974
952
  class Uploads extends Observable {
975
- _options;
976
- // Formats
977
- _formatWFS;
978
- _formatGeoJSON;
979
- _formatKml;
980
- _xs;
981
- _processUpload;
982
953
  constructor(options) {
983
954
  super();
984
955
  this._options = options;
985
956
  this._processUpload = options.processUpload;
986
957
  // Formats
987
958
  this._formatWFS = new WFS();
988
- this._formatGeoJSON = new GeoJSON$1();
959
+ this._formatGeoJSON = new GeoJSON();
989
960
  this._formatKml = new KML({
990
961
  extractStyles: false,
991
962
  showPointNames: false
@@ -1053,8 +1024,8 @@ class Uploads extends Observable {
1053
1024
  else {
1054
1025
  resetStateButtons();
1055
1026
  this.dispatchEvent(new VectorSourceEvent('loadedFeatures', null, featuresToInsert));
1056
- const content = `
1057
- ${I18N.labels.validFeatures}: ${validFeaturesCount}<br>
1027
+ const content = `
1028
+ ${I18N.labels.validFeatures}: ${validFeaturesCount}<br>
1058
1029
  ${invalidFeaturesCount
1059
1030
  ? `${I18N.labels.invalidFeatures}: ${invalidFeaturesCount}`
1060
1031
  : ''}`;
@@ -1150,25 +1121,17 @@ class Uploads extends Observable {
1150
1121
  * @private
1151
1122
  */
1152
1123
  _initModal(content, featuresToInsert) {
1153
- const footer = `
1154
- <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">
1155
- ${I18N.labels.cancel}
1156
- </button>
1157
- <button type="button" class="btn btn-sm btn-primary" data-action="save" data-dismiss="modal">
1158
- ${I18N.labels.upload}
1159
- </button>
1124
+ const footer = `
1125
+ <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">
1126
+ ${I18N.labels.cancel}
1127
+ </button>
1128
+ <button type="button" class="btn btn-sm btn-primary" data-action="save" data-dismiss="modal">
1129
+ ${I18N.labels.upload}
1130
+ </button>
1160
1131
  `;
1161
- const modal = new Modal({
1162
- ...this._options.modal,
1163
- header: true,
1164
- headerClose: false,
1165
- title: I18N.labels.uploadFeatures +
1132
+ const modal = new Modal(Object.assign(Object.assign({}, this._options.modal), { header: true, headerClose: false, title: I18N.labels.uploadFeatures +
1166
1133
  ' ' +
1167
- getActiveLayerToInsertEls().get(BaseLayerProperty.NAME),
1168
- content: content,
1169
- backdrop: 'static',
1170
- footer: footer
1171
- }).show();
1134
+ getActiveLayerToInsertEls().get(BaseLayerProperty.NAME), content: content, backdrop: 'static', footer: footer })).show();
1172
1135
  modal.on('dismiss', (modal, event) => {
1173
1136
  // On saving changes
1174
1137
  if (event.target.dataset.action === 'save') {
@@ -1238,13 +1201,13 @@ class EditControlChangesEl extends Control {
1238
1201
  " -",
1239
1202
  ' ',
1240
1203
  createElement("i", null, String(feature.getId()))),
1241
- createElement("button", { type: "button", className: "btn btn-sm btn-secondary", onclick: () => {
1204
+ createElement("button", { type: "button", className: "btn btn-sm btn-secondary", onClick: () => {
1242
1205
  this.dispatchEvent(new VectorSourceEvent('cancel', feature));
1243
1206
  } }, I18N.labels.cancel),
1244
- createElement("button", { type: "button", className: "btn btn-sm btn-primary", onclick: () => {
1207
+ createElement("button", { type: "button", className: "btn btn-sm btn-primary", onClick: () => {
1245
1208
  this.dispatchEvent(new VectorSourceEvent('apply', feature));
1246
1209
  } }, I18N.labels.apply),
1247
- createElement("button", { type: "button", className: "btn btn-sm btn-danger-outline", onclick: () => {
1210
+ createElement("button", { type: "button", className: "btn btn-sm btn-danger-outline", onClick: () => {
1248
1211
  this.dispatchEvent(new VectorSourceEvent('delete', feature));
1249
1212
  } }, I18N.labels.delete))))
1250
1213
  });
@@ -1399,31 +1362,21 @@ function styleFunction(feature) {
1399
1362
  * @private
1400
1363
  */
1401
1364
  class EditFieldsModal extends Observable {
1402
- _options;
1403
- _modal;
1404
- _feature;
1405
1365
  constructor(options) {
1406
1366
  super();
1407
1367
  this._options = options;
1408
- const footer = `
1409
- <button type="button" class="btn btn-sm btn-link btn-third" data-action="delete" data-dismiss="modal">
1410
- ${I18N.labels.delete}
1411
- </button>
1412
- <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">
1413
- ${I18N.labels.cancel}
1414
- </button>
1415
- <button type="button" class="btn btn-sm btn-primary" data-action="save" data-dismiss="modal">
1416
- ${I18N.labels.save}
1417
- </button>
1368
+ const footer = `
1369
+ <button type="button" class="btn btn-sm btn-link btn-third" data-action="delete" data-dismiss="modal">
1370
+ ${I18N.labels.delete}
1371
+ </button>
1372
+ <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">
1373
+ ${I18N.labels.cancel}
1374
+ </button>
1375
+ <button type="button" class="btn btn-sm btn-primary" data-action="save" data-dismiss="modal">
1376
+ ${I18N.labels.save}
1377
+ </button>
1418
1378
  `;
1419
- this._modal = new Modal({
1420
- ...this._options,
1421
- header: true,
1422
- headerClose: true,
1423
- title: '',
1424
- content: '<div></div>',
1425
- footer: footer
1426
- });
1379
+ this._modal = new Modal(Object.assign(Object.assign({}, this._options), { header: true, headerClose: true, title: '', content: '<div></div>', footer: footer }));
1427
1380
  this._modal.on('dismiss', (modal, event) => {
1428
1381
  // On saving changes
1429
1382
  if (event.target.dataset.action === 'save') {
@@ -1472,10 +1425,10 @@ class EditFieldsModal extends Observable {
1472
1425
  type = 'text';
1473
1426
  }
1474
1427
  if (type) {
1475
- content += `
1476
- <div class="ol-wfst--input-field-container">
1477
- <label class="ol-wfst--input-field-label" for="${key}">${key}</label>
1478
- <input placeholder="NULL" class="ol-wfst--input-field-input" type="${type}" name="${key}" value="${properties[key] || ''}">
1428
+ content += `
1429
+ <div class="ol-wfst--input-field-container">
1430
+ <label class="ol-wfst--input-field-label" for="${key}">${key}</label>
1431
+ <input placeholder="NULL" class="ol-wfst--input-field-input" type="${type}" name="${key}" value="${properties[key] || ''}">
1479
1432
  </div>`;
1480
1433
  }
1481
1434
  }
@@ -1497,17 +1450,6 @@ const DEFAULT_GEOSERVER_SRS = 'EPSG:3857';
1497
1450
  * @param options
1498
1451
  */
1499
1452
  class Geoserver extends BaseObject {
1500
- _options;
1501
- _countRequests;
1502
- _insertFeatures;
1503
- _updateFeatures;
1504
- _deleteFeatures;
1505
- // Formats
1506
- _formatWFS;
1507
- _formatGeoJSON;
1508
- _formatKml;
1509
- _xs;
1510
- state_;
1511
1453
  constructor(options) {
1512
1454
  super();
1513
1455
  const defaults = {
@@ -1541,7 +1483,7 @@ class Geoserver extends BaseObject {
1541
1483
  this._deleteFeatures = [];
1542
1484
  // Formats
1543
1485
  this._formatWFS = new WFS();
1544
- this._formatGeoJSON = new GeoJSON$1();
1486
+ this._formatGeoJSON = new GeoJSON();
1545
1487
  this._formatKml = new KML({
1546
1488
  extractStyles: false,
1547
1489
  showPointNames: false
@@ -1740,7 +1682,7 @@ class Geoserver extends BaseObject {
1740
1682
  * @private
1741
1683
  */
1742
1684
  async transact(transactionType, features, layerName) {
1743
- features = Array.isArray(features) ? features : [features];
1685
+ features = (Array.isArray(features) ? features : [features]);
1744
1686
  const clonedFeatures = [];
1745
1687
  const geoLayer = getStoredLayer(layerName);
1746
1688
  for (const feature of features) {
@@ -1748,7 +1690,7 @@ class Geoserver extends BaseObject {
1748
1690
  const cloneGeom = clone.getGeometry();
1749
1691
  // Ugly fix to support GeometryCollection on GML
1750
1692
  // See https://github.com/openlayers/openlayers/issues/4220
1751
- if (cloneGeom instanceof GeometryCollection) {
1693
+ if (cloneGeom instanceof GeometryCollection$1) {
1752
1694
  this._transformGeoemtryCollectionToGeometries(clone, cloneGeom);
1753
1695
  }
1754
1696
  else if (cloneGeom instanceof Circle$1) {
@@ -1804,10 +1746,10 @@ class Geoserver extends BaseObject {
1804
1746
  srs === 'EPSG:4326'
1805
1747
  ? 'urn:x-ogc:def:crs:EPSG:4326'
1806
1748
  : srs;
1807
- const describeFeatureType = geoLayer.getDescribeFeatureType()._parsed;
1808
- if (!geoLayer) {
1809
- throw new Error(I18N.errors.layerNotFound);
1749
+ if (!geoLayer || !geoLayer.getDescribeFeatureType()) {
1750
+ throw new Error(`${I18N.errors.layerNotFound}: "${layerName}"`);
1810
1751
  }
1752
+ const describeFeatureType = geoLayer.getDescribeFeatureType()._parsed;
1811
1753
  const options = {
1812
1754
  featureNS: describeFeatureType.namespace,
1813
1755
  featureType: layerName,
@@ -1847,10 +1789,7 @@ class Geoserver extends BaseObject {
1847
1789
  transactionType !== TransactionType.Insert) {
1848
1790
  payload = payload.replace(`</Transaction>`, `<LockId>${this._options.advanced.lockFeatureParams.lockId}</LockId></Transaction>`);
1849
1791
  }
1850
- const headers = {
1851
- 'Content-Type': 'text/xml',
1852
- ...this.getHeaders()
1853
- };
1792
+ const headers = Object.assign({ 'Content-Type': 'text/xml' }, this.getHeaders());
1854
1793
  const response = await fetch(this.getUrl(), {
1855
1794
  method: 'POST',
1856
1795
  body: payload,
@@ -1860,20 +1799,22 @@ class Geoserver extends BaseObject {
1860
1799
  if (!response.ok) {
1861
1800
  throw new Error(I18N.errors.transaction + ' ' + response.status);
1862
1801
  }
1863
- const parseResponse = this._formatWFS.readTransactionResponse(await response.text());
1802
+ const responseStr = await response.text();
1803
+ const parseResponse = this._formatWFS.readTransactionResponse(responseStr);
1804
+ const wlayer = getStoredLayer(layerName);
1864
1805
  if (!Object.keys(parseResponse).length) {
1865
- const responseStr = await response.text();
1866
1806
  const findError = String(responseStr).match(/<ows:ExceptionText>([\s\S]*?)<\/ows:ExceptionText>/);
1867
1807
  if (findError) {
1808
+ if (wlayer instanceof WmsLayer) {
1809
+ this._removeFeatures(features);
1810
+ }
1811
+ // maybe remove tmp wms features here
1868
1812
  throw new Error(findError[1]);
1869
1813
  }
1870
1814
  }
1871
1815
  if (transactionType !== TransactionType.Delete) {
1872
- for (const feature of features) {
1873
- getEditLayer().getSource().removeFeature(feature);
1874
- }
1816
+ this._removeFeatures(features);
1875
1817
  }
1876
- const wlayer = getStoredLayer(layerName);
1877
1818
  wlayer.refresh();
1878
1819
  showLoading(false);
1879
1820
  this._insertFeatures = [];
@@ -1891,6 +1832,14 @@ class Geoserver extends BaseObject {
1891
1832
  }, 0);
1892
1833
  });
1893
1834
  }
1835
+ /**
1836
+ * @privatwe
1837
+ */
1838
+ _removeFeatures(features) {
1839
+ for (const feature of features) {
1840
+ getEditLayer().getSource().removeFeature(feature);
1841
+ }
1842
+ }
1894
1843
  /**
1895
1844
  *
1896
1845
  * @param feature
@@ -1964,6 +1913,7 @@ class Geoserver extends BaseObject {
1964
1913
  // First, check if is a JSON (with errors)
1965
1914
  const dataParsed = JSON.parse(data);
1966
1915
  if ('exceptions' in dataParsed) {
1916
+ const error = new Error(parseError(dataParsed));
1967
1917
  const exceptions = dataParsed.exceptions;
1968
1918
  if (exceptions[0].code === 'CannotLockAllFeatures') {
1969
1919
  // Maybe the Feature is already blocked, ant thats trigger error, so, we try one locking more time again
@@ -1971,11 +1921,11 @@ class Geoserver extends BaseObject {
1971
1921
  this.lockFeature(featureId, layerName, 1);
1972
1922
  }
1973
1923
  else {
1974
- showError(I18N.errors.lockFeature, exceptions);
1924
+ throw error;
1975
1925
  }
1976
1926
  }
1977
1927
  else {
1978
- showError(exceptions[0].text, exceptions);
1928
+ throw error;
1979
1929
  }
1980
1930
  }
1981
1931
  }
@@ -2030,12 +1980,12 @@ class EditOverlay extends Overlay {
2030
1980
  offset: [0, -40],
2031
1981
  stopEvent: true,
2032
1982
  element: (createElement("div", null,
2033
- createElement("div", { className: "ol-wfst--edit-button-cnt", onclick: () => {
1983
+ createElement("div", { className: "ol-wfst--edit-button-cnt", onClick: () => {
2034
1984
  this.dispatchEvent('editFields');
2035
1985
  } },
2036
1986
  createElement("button", { className: "ol-wfst--edit-button", type: "button", title: I18N.labels.editFields },
2037
1987
  createElement("img", { src: img$1, alt: I18N.labels.editFields }))),
2038
- createElement("div", { className: "ol-wfst--edit-button-cnt", onclick: () => {
1988
+ createElement("div", { className: "ol-wfst--edit-button-cnt", onClick: () => {
2039
1989
  this.dispatchEvent('editGeom');
2040
1990
  } },
2041
1991
  createElement("button", { class: "ol-wfst--edit-button", type: "button", title: I18N.labels.editGeom },
@@ -2063,38 +2013,6 @@ const controlElement = document.createElement('div');
2063
2013
  * @param options Wfst options, see [Wfst Options](#options) for more details.
2064
2014
  */
2065
2015
  class Wfst extends Control {
2066
- _options;
2067
- _i18n;
2068
- // Ol
2069
- _map;
2070
- _view;
2071
- _viewport;
2072
- _initialized = false;
2073
- _layersControl;
2074
- _overlay;
2075
- // Interactions
2076
- _interactionWfsSelect;
2077
- _interactionSelectModify;
2078
- _collectionModify;
2079
- _interactionModify;
2080
- _interactionSnap;
2081
- _interactionDraw;
2082
- // Obserbable keys
2083
- _keyClickWms;
2084
- _keyRemove;
2085
- _keySelect;
2086
- // Controls
2087
- _controlApplyDiscardChanges;
2088
- _controlWidgetToolsDiv;
2089
- _selectDraw;
2090
- // State
2091
- _currentZoom;
2092
- _lastZoom;
2093
- // Editing
2094
- _editFeature;
2095
- _editFeatureOriginal;
2096
- _uploads;
2097
- _editFields;
2098
2016
  constructor(options) {
2099
2017
  super({
2100
2018
  target: null,
@@ -2104,6 +2022,7 @@ class Wfst extends Control {
2104
2022
  this._init();
2105
2023
  }
2106
2024
  });
2025
+ this._initialized = false;
2107
2026
  setLang(options.language, options.i18n);
2108
2027
  const defaultOptions = getDefaultOptions();
2109
2028
  this._options = deepObjectAssign(defaultOptions, options);
@@ -2338,13 +2257,13 @@ class Wfst extends Control {
2338
2257
  this._interactionModify = new Modify({
2339
2258
  style: () => {
2340
2259
  if (getMode() === Modes.Edit) {
2341
- return new Style({
2342
- image: new Circle({
2260
+ return new Style$1({
2261
+ image: new CircleStyle({
2343
2262
  radius: 6,
2344
- fill: new Fill({
2263
+ fill: new Fill$1({
2345
2264
  color: '#ff0000'
2346
2265
  }),
2347
- stroke: new Stroke({
2266
+ stroke: new Stroke$1({
2348
2267
  width: 2,
2349
2268
  color: 'rgba(5, 5, 5, 0.9)'
2350
2269
  })
@@ -2612,9 +2531,7 @@ class Wfst extends Control {
2612
2531
  }
2613
2532
  };
2614
2533
  if (confirm) {
2615
- const confirmModal = Modal.confirm(I18N.labels.confirmDelete, {
2616
- ...this._options.modal
2617
- });
2534
+ const confirmModal = Modal.confirm(I18N.labels.confirmDelete, Object.assign({}, this._options.modal));
2618
2535
  confirmModal.show().once('dismiss', function (modal, ev, button) {
2619
2536
  if (button && button.value) {
2620
2537
  deleteEl();
@@ -2757,8 +2674,6 @@ class Wfst extends Control {
2757
2674
  }
2758
2675
  }
2759
2676
  class WfstEvent extends BaseEvent {
2760
- data;
2761
- layer;
2762
2677
  constructor(options) {
2763
2678
  super(options.type);
2764
2679
  this.layer = options.layer;
@@ -2766,5 +2681,5 @@ class WfstEvent extends BaseEvent {
2766
2681
  }
2767
2682
  }
2768
2683
 
2769
- export { Geoserver, WfsLayer, WmsLayer, Wfst as default };
2684
+ export { Geoserver, WfsLayer, WfstEvent, WmsLayer, Wfst as default };
2770
2685
  //# sourceMappingURL=ol-wfst.js.map