ol-wfst 4.0.6 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +123 -0
  2. package/README.md +27 -12
  3. package/dist/Geoserver.d.ts +24 -17
  4. package/dist/Geoserver.d.ts.map +1 -1
  5. package/dist/WfsLayer.d.ts +10 -10
  6. package/dist/WfsLayer.d.ts.map +1 -1
  7. package/dist/WmsLayer.d.ts +11 -11
  8. package/dist/WmsLayer.d.ts.map +1 -1
  9. package/dist/modules/EditControlChanges.d.ts +9 -9
  10. package/dist/modules/EditControlChanges.d.ts.map +1 -1
  11. package/dist/modules/EditFieldsModal.d.ts +3 -2
  12. package/dist/modules/EditFieldsModal.d.ts.map +1 -1
  13. package/dist/modules/EditOverlay.d.ts +4 -3
  14. package/dist/modules/EditOverlay.d.ts.map +1 -1
  15. package/dist/modules/LayersControl.d.ts +2 -3
  16. package/dist/modules/LayersControl.d.ts.map +1 -1
  17. package/dist/modules/Uploads.d.ts +6 -3
  18. package/dist/modules/Uploads.d.ts.map +1 -1
  19. package/dist/modules/base/BaseLayer.d.ts +4 -4
  20. package/dist/modules/base/BaseLayer.d.ts.map +1 -1
  21. package/dist/modules/base/WfsSource.d.ts +1 -1
  22. package/dist/modules/base/WfsSource.d.ts.map +1 -1
  23. package/dist/modules/base/WmsSource.d.ts +1 -1
  24. package/dist/modules/base/WmsSource.d.ts.map +1 -1
  25. package/dist/modules/editLayer.d.ts +2 -2
  26. package/dist/modules/editLayer.d.ts.map +1 -1
  27. package/dist/modules/state.d.ts +2 -2
  28. package/dist/modules/state.d.ts.map +1 -1
  29. package/dist/modules/styleFunction.d.ts +3 -3
  30. package/dist/modules/styleFunction.d.ts.map +1 -1
  31. package/dist/ol-wfst.d.ts +20 -20
  32. package/dist/ol-wfst.d.ts.map +1 -1
  33. package/dist/ol-wfst.js +1431 -2386
  34. package/dist/ol-wfst.js.map +1 -1
  35. package/dist/ol-wfst.min.js +6 -1
  36. package/dist/ol-wfst.min.js.map +1 -1
  37. package/dist/tsconfig.tsbuildinfo +1 -1
  38. package/lib/Geoserver.d.ts +24 -17
  39. package/lib/Geoserver.d.ts.map +1 -1
  40. package/lib/WfsLayer.d.ts +10 -10
  41. package/lib/WfsLayer.d.ts.map +1 -1
  42. package/lib/WmsLayer.d.ts +11 -11
  43. package/lib/WmsLayer.d.ts.map +1 -1
  44. package/lib/modules/EditControlChanges.d.ts +9 -9
  45. package/lib/modules/EditControlChanges.d.ts.map +1 -1
  46. package/lib/modules/EditFieldsModal.d.ts +3 -2
  47. package/lib/modules/EditFieldsModal.d.ts.map +1 -1
  48. package/lib/modules/EditOverlay.d.ts +4 -3
  49. package/lib/modules/EditOverlay.d.ts.map +1 -1
  50. package/lib/modules/LayersControl.d.ts +2 -3
  51. package/lib/modules/LayersControl.d.ts.map +1 -1
  52. package/lib/modules/Uploads.d.ts +6 -3
  53. package/lib/modules/Uploads.d.ts.map +1 -1
  54. package/lib/modules/base/BaseLayer.d.ts +4 -4
  55. package/lib/modules/base/BaseLayer.d.ts.map +1 -1
  56. package/lib/modules/base/WfsSource.d.ts +1 -1
  57. package/lib/modules/base/WfsSource.d.ts.map +1 -1
  58. package/lib/modules/base/WmsSource.d.ts +1 -1
  59. package/lib/modules/base/WmsSource.d.ts.map +1 -1
  60. package/lib/modules/editLayer.d.ts +2 -2
  61. package/lib/modules/editLayer.d.ts.map +1 -1
  62. package/lib/modules/state.d.ts +2 -2
  63. package/lib/modules/state.d.ts.map +1 -1
  64. package/lib/modules/styleFunction.d.ts +3 -3
  65. package/lib/modules/styleFunction.d.ts.map +1 -1
  66. package/lib/ol-wfst.d.ts +20 -20
  67. package/lib/ol-wfst.d.ts.map +1 -1
  68. package/lib/ol-wfst.js +133 -211
  69. package/lib/ol-wfst.js.map +1 -1
  70. package/lib/tsconfig.tsbuildinfo +1 -1
  71. package/package.json +8 -6
package/dist/ol-wfst.js CHANGED
@@ -1,8 +1,13 @@
1
+ /*!
2
+ * ol-wfst - v4.1.1
3
+ * https://github.com/GastonZalba/ol-wfst#readme
4
+ * Built: Tue Aug 29 2023 11:10:04 GMT-0300 (hora estándar de Argentina)
5
+ */
1
6
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('ol/style/Circle'), require('ol/style/Fill'), require('ol/style/Stroke'), require('ol/style/Style'), require('ol/control/Control'), require('ol/interaction/Draw'), require('ol/interaction/Modify'), require('ol/interaction/Select'), require('ol/interaction/Snap'), require('ol/Collection'), require('ol/events/Event'), require('ol/events/condition'), require('ol/Observable'), require('ol/layer/Vector'), require('ol/layer/Base'), require('ol/format/GeoJSON'), require('ol/source/Vector'), require('ol/proj'), require('ol/loadingstrategy'), require('ol/layer/Tile'), require('ol/source/TileWMS'), require('ol/geom'), require('ol/format'), require('ol/control'), require('ol/style'), require('ol/Object'), require('ol/geom/Circle'), require('ol/geom/GeometryCollection'), require('ol/Feature'), require('ol/format/KML'), require('ol/format/WFS'), require('ol/geom/Polygon'), require('ol/extent')) :
3
- typeof define === 'function' && define.amd ? define(['ol/style/Circle', 'ol/style/Fill', 'ol/style/Stroke', 'ol/style/Style', 'ol/control/Control', 'ol/interaction/Draw', 'ol/interaction/Modify', 'ol/interaction/Select', 'ol/interaction/Snap', 'ol/Collection', 'ol/events/Event', 'ol/events/condition', 'ol/Observable', 'ol/layer/Vector', 'ol/layer/Base', 'ol/format/GeoJSON', 'ol/source/Vector', 'ol/proj', 'ol/loadingstrategy', 'ol/layer/Tile', 'ol/source/TileWMS', 'ol/geom', 'ol/format', 'ol/control', 'ol/style', 'ol/Object', 'ol/geom/Circle', 'ol/geom/GeometryCollection', 'ol/Feature', 'ol/format/KML', 'ol/format/WFS', 'ol/geom/Polygon', 'ol/extent'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Wfst = factory(global.ol.style.Circle, global.ol.style.Fill, global.ol.style.Stroke, global.ol.style.Style, global.ol.control.Control, global.ol.interaction.Draw, global.ol.interaction.Modify, global.ol.interaction.Select, global.ol.interaction.Snap, global.ol.Collection, global.ol.events.Event, global.ol.events.condition, global.ol.Observable, global.ol.layer.Vector, global.ol.layer.Base, global.ol.format.GeoJSON, global.ol.source.Vector, global.ol.proj, global.ol.loadingstrategy, global.ol.layer.Tile, global.ol.source.TileWMS, global.ol.geom, global.ol.format, global.ol.control, global.ol.style, global.ol.Object, global.ol.geom.Circle, global.ol.geom.GeometryCollection, global.ol.Feature, global.ol.format.KML, global.ol.format.WFS, global.ol.geom.Polygon, global.ol.extent));
5
- })(this, (function (CircleStyle, Fill, Stroke, Style, Control, Draw, Modify, Select, Snap, Collection, BaseEvent$1, condition, Observable$2, VectorLayer, Layer, GeoJSON, VectorSource, proj, loadingstrategy, TileLayer, TileWMS, geom, format, control, style, BaseObject$2, Circle, GeometryCollection, Feature, KML, WFS, Polygon, extent) { 'use strict';
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('ol/style/Circle.js'), require('ol/style/Fill.js'), require('ol/style/Stroke.js'), require('ol/style/Style.js'), require('ol/control/Control.js'), require('ol/interaction/Draw.js'), require('ol/interaction/Modify.js'), require('ol/interaction/Select.js'), require('ol/interaction/Snap.js'), require('ol/Collection.js'), require('ol/events/Event.js'), require('ol/events/condition.js'), require('ol/Observable.js'), require('ol/layer/Vector.js'), require('ol/layer/Base.js'), require('ol/format/GeoJSON.js'), require('ol/source/Vector.js'), require('ol/proj.js'), require('ol/loadingstrategy.js'), require('ol/layer/Tile.js'), require('ol/source/TileWMS.js'), require('ol/geom.js'), require('ol/format/KML.js'), require('ol/format/WFS.js'), require('ol/style.js'), require('ol/Object.js'), require('ol/geom/Circle.js'), require('ol/geom/GeometryCollection.js'), require('ol/Feature.js'), require('ol/geom/Polygon.js'), require('ol/format/XML.js'), require('ol/xml.js'), require('ol/format/xlink.js'), require('ol/format/xsd.js'), require('ol/extent.js'), require('ol/Overlay.js')) :
8
+ typeof define === 'function' && define.amd ? define(['ol/style/Circle.js', 'ol/style/Fill.js', 'ol/style/Stroke.js', 'ol/style/Style.js', 'ol/control/Control.js', 'ol/interaction/Draw.js', 'ol/interaction/Modify.js', 'ol/interaction/Select.js', 'ol/interaction/Snap.js', 'ol/Collection.js', 'ol/events/Event.js', 'ol/events/condition.js', 'ol/Observable.js', 'ol/layer/Vector.js', 'ol/layer/Base.js', 'ol/format/GeoJSON.js', 'ol/source/Vector.js', 'ol/proj.js', 'ol/loadingstrategy.js', 'ol/layer/Tile.js', 'ol/source/TileWMS.js', 'ol/geom.js', 'ol/format/KML.js', 'ol/format/WFS.js', 'ol/style.js', 'ol/Object.js', 'ol/geom/Circle.js', 'ol/geom/GeometryCollection.js', 'ol/Feature.js', 'ol/geom/Polygon.js', 'ol/format/XML.js', 'ol/xml.js', 'ol/format/xlink.js', 'ol/format/xsd.js', 'ol/extent.js', 'ol/Overlay.js'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Wfst = factory(global.ol.style.Circle, global.ol.style.Fill, global.ol.style.Stroke, global.ol.style.Style, global.ol.control.Control, global.ol.interaction.Draw, global.ol.interaction.Modify, global.ol.interaction.Select, global.ol.interaction.Snap, global.ol.Collection, global.ol.events.Event, global.ol.events.condition, global.ol.Observable, global.ol.layer.Vector, global.ol.layer.Base, global.ol.format.GeoJSON, global.ol.source.Vector, global.ol.proj, global.ol.loadingstrategy, global.ol.layer.Tile, global.ol.source.TileWMS, global.ol.geom, global.ol.format.KML, global.ol.format.WFS, global.ol.style, global.ol.Object, global.ol.geom.Circle, global.ol.geom.GeometryCollection, global.ol.Feature, global.ol.geom.Polygon, global.ol.format.XML, global.ol.xml, global.ol.format.xlink, global.ol.format.xsd, global.ol.extent, global.ol.Overlay));
10
+ })(this, (function (CircleStyle, Fill, Stroke, Style, Control, Draw, Modify, Select, Snap, Collection, BaseEvent, condition_js, Observable, VectorLayer, Layer, GeoJSON, VectorSource, proj_js, loadingstrategy_js, TileLayer, TileWMS, geom_js, KML, WFS, style_js, BaseObject, Circle, GeometryCollection, Feature, Polygon_js, XML, xml_js, xlink_js, xsd_js, extent_js, Overlay) { 'use strict';
6
11
 
7
12
  var domain;
8
13
 
@@ -1266,7 +1271,7 @@
1266
1271
  }
1267
1272
  // Check if customs translations are provided
1268
1273
  if (customI18n) {
1269
- I18N = { ...I18N, ...customI18n };
1274
+ I18N = Object.assign(Object.assign({}, I18N), customI18n);
1270
1275
  }
1271
1276
  };
1272
1277
 
@@ -1657,21 +1662,12 @@
1657
1662
  * @param options
1658
1663
  */
1659
1664
  class WfsSource extends VectorSource {
1660
- urlParams = new URLSearchParams({
1661
- SERVICE: 'wfs',
1662
- REQUEST: 'GetFeature',
1663
- OUTPUTFORMAT: 'application/json',
1664
- EXCEPTIONS: 'application/json'
1665
- });
1666
1665
  constructor(options) {
1667
- super({
1668
- ...options,
1669
- format: new GeoJSON(),
1670
- loader: async (extent, resolution, projection, success, failure) => {
1666
+ super(Object.assign(Object.assign({}, options), { format: new GeoJSON(), loader: async (extent, resolution, projection, success, failure) => {
1671
1667
  try {
1672
1668
  // If bbox, add extent to the request
1673
- if (options.strategy == loadingstrategy.bbox) {
1674
- const extentGeoServer = proj.transformExtent(extent, projection.getCode(), options.geoServerAdvanced.projection);
1669
+ if (options.strategy == loadingstrategy_js.bbox) {
1670
+ const extentGeoServer = proj_js.transformExtent(extent, projection.getCode(), options.geoServerAdvanced.projection);
1675
1671
  // https://docs.geoserver.org/stable/en/user/services/wfs/reference.html
1676
1672
  // request features using a bounding box with CRS maybe different from featureTypes native CRS
1677
1673
  this.urlParams.set('bbox', extentGeoServer.toString() +
@@ -1705,7 +1701,12 @@
1705
1701
  showError(I18N.errors.geoserver, err, options.name);
1706
1702
  failure();
1707
1703
  }
1708
- }
1704
+ } }));
1705
+ this.urlParams = new URLSearchParams({
1706
+ SERVICE: 'wfs',
1707
+ REQUEST: 'GetFeature',
1708
+ OUTPUTFORMAT: 'application/json',
1709
+ EXCEPTIONS: 'application/json'
1709
1710
  });
1710
1711
  this.urlParams.set('version', options.geoServerAdvanced.getFeatureVersion);
1711
1712
  this.urlParams.set('typename', options.name);
@@ -1722,27 +1723,15 @@
1722
1723
  * @param options
1723
1724
  */
1724
1725
  class WfsLayer extends Mixin(BaseLayer, (VectorLayer)) {
1725
- _loadingCount = 0;
1726
- _loadedCount = 0;
1727
- beforeTransactFeature;
1728
1726
  constructor(options) {
1729
- super({
1730
- name: options.name,
1731
- label: options.label || options.name,
1732
- minZoom: options.minZoom,
1733
- ...options
1734
- });
1727
+ super(Object.assign({ name: options.name, label: options.label || options.name, minZoom: options.minZoom }, options));
1728
+ this._loadingCount = 0;
1729
+ this._loadedCount = 0;
1735
1730
  if (options.beforeTransactFeature) {
1736
1731
  this.beforeTransactFeature = options.beforeTransactFeature;
1737
1732
  }
1738
1733
  const geoserver = options.geoserver;
1739
- const source = new WfsSource({
1740
- name: options.name,
1741
- geoserverUrl: geoserver.getUrl(),
1742
- geoServerAdvanced: geoserver.getAdvanced(),
1743
- ...(options.strategy && { strategy: options.strategy }),
1744
- geoserverVendor: options.geoserverVendor
1745
- });
1734
+ 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 }));
1746
1735
  this._loadingCount = 0;
1747
1736
  this._loadedCount = 0;
1748
1737
  source.on('featuresloadstart', () => {
@@ -1830,17 +1819,7 @@
1830
1819
  */
1831
1820
  class WmsSource extends TileWMS {
1832
1821
  constructor(options) {
1833
- super({
1834
- url: options.geoserverUrl,
1835
- serverType: 'geoserver',
1836
- params: {
1837
- SERVICE: 'wms',
1838
- TILED: true,
1839
- LAYERS: options.name,
1840
- EXCEPTIONS: 'application/json',
1841
- ...(options.geoserverVendor && options.geoserverVendor)
1842
- },
1843
- tileLoadFunction: async (tile, src) => {
1822
+ 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) => {
1844
1823
  const blobToJson = (blob) => {
1845
1824
  return new Promise((resolve) => {
1846
1825
  const reader = new FileReader();
@@ -1870,9 +1849,7 @@
1870
1849
  showError(I18N.errors.geoserver, err, options.name);
1871
1850
  tile.setState(TileState.ERROR);
1872
1851
  }
1873
- },
1874
- ...options
1875
- });
1852
+ } }, options));
1876
1853
  }
1877
1854
  }
1878
1855
 
@@ -1885,18 +1862,10 @@
1885
1862
  * @param options
1886
1863
  */
1887
1864
  class WmsLayer extends Mixin(BaseLayer, (TileLayer)) {
1888
- _loadingCount = 0;
1889
- _loadedCount = 0;
1890
- beforeTransactFeature;
1891
- // Formats
1892
- _formatGeoJSON;
1893
1865
  constructor(options) {
1894
- super({
1895
- name: options.name,
1896
- label: options.label || options.name,
1897
- minZoom: options.minZoom,
1898
- ...options
1899
- });
1866
+ super(Object.assign({ name: options.name, label: options.label || options.name, minZoom: options.minZoom }, options));
1867
+ this._loadingCount = 0;
1868
+ this._loadedCount = 0;
1900
1869
  if (options.beforeTransactFeature) {
1901
1870
  this.beforeTransactFeature = options.beforeTransactFeature;
1902
1871
  }
@@ -2006,2451 +1975,1534 @@
2006
1975
  }
2007
1976
  }
2008
1977
 
2009
- /**
2010
- * @module ol/events/Event
2011
- */
2012
-
2013
- /**
2014
- * @classdesc
2015
- * Stripped down implementation of the W3C DOM Level 2 Event interface.
2016
- * See https://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-interface.
2017
- *
2018
- * This implementation only provides `type` and `target` properties, and
2019
- * `stopPropagation` and `preventDefault` methods. It is meant as base class
2020
- * for higher level events defined in the library, and works with
2021
- * {@link module:ol/events/Target~Target}.
2022
- */
2023
- class BaseEvent {
2024
- /**
2025
- * @param {string} type Type.
2026
- */
2027
- constructor(type) {
2028
- /**
2029
- * @type {boolean}
2030
- */
2031
- this.propagationStopped;
1978
+ 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";
2032
1979
 
2033
- /**
2034
- * @type {boolean}
2035
- */
2036
- this.defaultPrevented;
1980
+ 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";
2037
1981
 
2038
- /**
2039
- * The event type.
2040
- * @type {string}
2041
- * @api
2042
- */
2043
- this.type = type;
1982
+ 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";
2044
1983
 
2045
- /**
2046
- * The event target.
2047
- * @type {Object}
2048
- * @api
2049
- */
2050
- this.target = null;
2051
- }
1984
+ 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";
2052
1985
 
2053
- /**
2054
- * Prevent default. This means that no emulated `click`, `singleclick` or `doubleclick` events
2055
- * will be fired.
2056
- * @api
2057
- */
2058
- preventDefault() {
2059
- this.defaultPrevented = true;
2060
- }
1986
+ function createElement(tagName, attrs = {}, ...children) {
1987
+ if (typeof tagName === 'function')
1988
+ return tagName(attrs, children);
1989
+ const elem = tagName === null
1990
+ ? new DocumentFragment()
1991
+ : document.createElement(tagName);
1992
+ Object.entries(attrs || {}).forEach(([name, value]) => {
1993
+ if (typeof value !== undefined &&
1994
+ value !== null &&
1995
+ value !== undefined) {
1996
+ if (name.startsWith('on') && name.toLowerCase() in window)
1997
+ elem.addEventListener(name.toLowerCase().substr(2), value);
1998
+ else {
1999
+ if (name === 'className')
2000
+ elem.setAttribute('class', value.toString());
2001
+ else if (name === 'htmlFor')
2002
+ elem.setAttribute('for', value.toString());
2003
+ else
2004
+ elem.setAttribute(name, value.toString());
2005
+ }
2006
+ }
2007
+ });
2008
+ for (const child of children) {
2009
+ if (!child)
2010
+ continue;
2011
+ if (Array.isArray(child))
2012
+ elem.append(...child);
2013
+ else {
2014
+ if (child.nodeType === undefined)
2015
+ elem.innerHTML += child;
2016
+ else
2017
+ elem.appendChild(child);
2018
+ }
2019
+ }
2020
+ return elem;
2021
+ }
2061
2022
 
2062
- /**
2063
- * Stop event propagation.
2064
- * @api
2065
- */
2066
- stopPropagation() {
2067
- this.propagationStopped = true;
2068
- }
2023
+ /**
2024
+ * Removes in the DOM the class of the tools
2025
+ * @private
2026
+ */
2027
+ const resetStateButtons = () => {
2028
+ const activeBtn = document.querySelector('.ol-wfst--tools-control-btn.wfst--active');
2029
+ if (activeBtn) {
2030
+ activeBtn.classList.remove('wfst--active');
2031
+ }
2032
+ };
2033
+ const activateModeButtons = () => {
2034
+ const btn = document.querySelector('.ol-wfst--tools-control-btn-edit');
2035
+ if (btn) {
2036
+ btn.classList.add('wfst--active');
2037
+ }
2038
+ };
2039
+ const activateDrawButton = () => {
2040
+ const btn = document.querySelector('.ol-wfst--tools-control-btn-draw');
2041
+ if (btn) {
2042
+ btn.classList.add('wfst--active');
2043
+ }
2044
+ };
2045
+ class LayersControl extends Observable {
2046
+ constructor(uploads, uploadFormats) {
2047
+ super();
2048
+ this._uploads = uploads;
2049
+ this._uploadFormats = uploadFormats;
2050
+ }
2051
+ /**
2052
+ *
2053
+ * @param layer
2054
+ * @public
2055
+ */
2056
+ addLayerEl(layer) {
2057
+ const container = document.querySelector('.wfst--tools-control--select-layers');
2058
+ const layerName = layer.get(BaseLayerProperty.NAME);
2059
+ const checked = layer === getActiveLayerToInsertEls() ? { checked: true } : {};
2060
+ 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) })));
2061
+ const layerDom = (createElement("div", { className: `wfst--layer-control
2062
+ ${layer.getVisible() ? 'ol-wfst--visible-on' : ''}
2063
+ ${layer === getActiveLayerToInsertEls()
2064
+ ? 'ol-wfst--selected-on'
2065
+ : ''}`, "data-layer": layerName },
2066
+ createElement("div", { className: "ol-wfst--tools-control-visible" },
2067
+ createElement("span", { className: "ol-wfst--tools-control-visible-btn ol-wfst--visible-btn-on", title: I18N.labels.toggleVisibility, onClick: (evt) => this._visibilityClickHandler(evt) },
2068
+ createElement("img", { src: img$3 })),
2069
+ createElement("span", { className: "ol-wfst--tools-control-visible-btn ol-wfst--visible-btn-off", title: I18N.labels.toggleVisibility, onClick: (evt) => this._visibilityClickHandler(evt) },
2070
+ createElement("img", { src: img$2 }))),
2071
+ createElement("label", { htmlFor: `wfst--${layerName}` },
2072
+ input,
2073
+ createElement("span", { title: layer.getDescribeFeatureType()._parsed.geomType }, layer.get(BaseLayerProperty.LABEL)))));
2074
+ container.appendChild(layerDom);
2075
+ if (layer === getActiveLayerToInsertEls()) {
2076
+ input.dispatchEvent(new Event('change'));
2077
+ }
2078
+ return layerDom;
2079
+ }
2080
+ /**
2081
+ * Update geom Types availibles to select for this layer
2082
+ *
2083
+ * @param layerName
2084
+ * @param geomDrawTypeSelected
2085
+ * @private
2086
+ */
2087
+ _changeStateSelect(layer, geomDrawTypeSelected = null) {
2088
+ /**
2089
+ * Set the geometry type in the select according to the geometry of
2090
+ * the layer in the geoserver and disable what does not correspond.
2091
+ *
2092
+ * @param value
2093
+ * @param options
2094
+ * @private
2095
+ */
2096
+ const setSelectState = (value, options) => {
2097
+ Array.from(selectDraw.options).forEach((option) => {
2098
+ option.selected = option.value === value ? true : false;
2099
+ option.disabled =
2100
+ options === 'all'
2101
+ ? false
2102
+ : options.includes(option.value)
2103
+ ? false
2104
+ : true;
2105
+ option.title = option.disabled
2106
+ ? I18N.labels.geomTypeNotSupported
2107
+ : '';
2108
+ });
2109
+ };
2110
+ const selectDraw = document.querySelector('.wfst--tools-control--select-draw');
2111
+ let drawType;
2112
+ if (selectDraw) {
2113
+ const geomLayer = layer.getDescribeFeatureType()._parsed.geomType;
2114
+ if (geomDrawTypeSelected) {
2115
+ drawType = selectDraw.value;
2116
+ }
2117
+ else {
2118
+ if (geomLayer === GeometryType.GeometryCollection) {
2119
+ drawType = GeometryType.LineString; // Default drawing type for GeometryCollection
2120
+ setSelectState(drawType, 'all');
2121
+ }
2122
+ else if (geomLayer === GeometryType.LinearRing) {
2123
+ drawType = GeometryType.LineString; // Default drawing type for GeometryCollection
2124
+ setSelectState(drawType, [
2125
+ GeometryType.Circle,
2126
+ GeometryType.LinearRing,
2127
+ GeometryType.Polygon
2128
+ ]);
2129
+ selectDraw.value = drawType;
2130
+ }
2131
+ else {
2132
+ drawType = geomLayer;
2133
+ setSelectState(drawType, [geomLayer]);
2134
+ }
2135
+ }
2136
+ }
2137
+ return drawType;
2138
+ }
2139
+ _visibilityClickHandler(evt) {
2140
+ const btn = evt.currentTarget;
2141
+ const parentDiv = btn.closest('.wfst--layer-control');
2142
+ const layerName = parentDiv.dataset['layer'];
2143
+ parentDiv.classList.toggle('ol-wfst--visible-on');
2144
+ const layer = getStoredMapLayers()[layerName];
2145
+ if (parentDiv.classList.contains('ol-wfst--visible-on')) {
2146
+ layer.setVisible(true);
2147
+ }
2148
+ else {
2149
+ layer.setVisible(false);
2150
+ }
2151
+ }
2152
+ _layerChangeHandler(evt, layer) {
2153
+ const radioInput = evt.currentTarget;
2154
+ const parentDiv = radioInput.closest('.wfst--layer-control');
2155
+ // Deselect DOM previous layer
2156
+ const selected = document.querySelector('.ol-wfst--selected-on');
2157
+ if (selected)
2158
+ selected.classList.remove('ol-wfst--selected-on');
2159
+ // Select this layer
2160
+ parentDiv.classList.add('ol-wfst--selected-on');
2161
+ setActiveLayerToInsertEls(layer);
2162
+ this._changeStateSelect(layer);
2163
+ }
2164
+ render() {
2165
+ return (createElement(null, null,
2166
+ createElement("div", { className: "wfst--tools-control--head" },
2167
+ this._uploads && (createElement("div", null,
2168
+ createElement("input", { id: "ol-wfst--upload", type: "file", accept: this._uploadFormats, onChange: (evt) => this._uploads.process(evt) }),
2169
+ createElement("label", { className: "ol-wfst--tools-control-btn ol-wfst--tools-control-btn-upload", htmlFor: "ol-wfst--upload", title: I18N.labels.uploadToLayer },
2170
+ createElement("img", { src: img$5 })))),
2171
+ createElement("div", { className: "ol-wfst--tools-control-draw-cnt" },
2172
+ createElement("button", { className: "ol-wfst--tools-control-btn ol-wfst--tools-control-btn-draw", type: "button", title: I18N.labels.addElement, onClick: () => {
2173
+ this.dispatchEvent('drawMode');
2174
+ } },
2175
+ createElement("img", { src: img$4 })),
2176
+ createElement("select", { title: I18N.labels.selectDrawType, className: "wfst--tools-control--select-draw", onChange: (evt) => {
2177
+ const selectedValue = evt.target.value;
2178
+ this._changeStateSelect(getActiveLayerToInsertEls(), selectedValue);
2179
+ this.dispatchEvent('changeGeom');
2180
+ } }, [
2181
+ GeometryType.Point,
2182
+ GeometryType.MultiPoint,
2183
+ GeometryType.LineString,
2184
+ GeometryType.MultiLineString,
2185
+ GeometryType.Polygon,
2186
+ GeometryType.MultiPolygon,
2187
+ GeometryType.Circle
2188
+ ].map((type) => {
2189
+ // Show all options, but enable only the accepted ones
2190
+ return createElement("option", { value: type }, type);
2191
+ })))),
2192
+ createElement("div", { className: "wfst--tools-control--select-layers" })));
2193
+ }
2069
2194
  }
2070
2195
 
2071
- var Event$1 = BaseEvent;
2196
+ let editLayer = new VectorLayer({
2197
+ source: new VectorSource(),
2198
+ zIndex: 100
2199
+ });
2200
+ const getEditLayer = () => {
2201
+ return editLayer;
2202
+ };
2072
2203
 
2073
- /**
2074
- * @module ol/ObjectEventType
2075
- */
2076
-
2077
- /**
2078
- * @enum {string}
2079
- */
2080
- var ObjectEventType = {
2081
- /**
2082
- * Triggered when a property is changed.
2083
- * @event module:ol/Object.ObjectEvent#propertychange
2084
- * @api
2085
- */
2086
- PROPERTYCHANGE: 'propertychange',
2087
- };
2088
-
2089
- /**
2090
- * @typedef {'propertychange'} Types
2091
- */
2092
-
2093
- /**
2094
- * @module ol/Disposable
2095
- */
2096
-
2097
- /**
2098
- * @classdesc
2099
- * Objects that need to clean up after themselves.
2100
- */
2101
- class Disposable {
2102
- constructor() {
2103
- /**
2104
- * The object has already been disposed.
2105
- * @type {boolean}
2106
- * @protected
2107
- */
2108
- this.disposed = false;
2109
- }
2110
-
2111
- /**
2112
- * Clean up.
2113
- */
2114
- dispose() {
2115
- if (!this.disposed) {
2116
- this.disposed = true;
2117
- this.disposeInternal();
2118
- }
2119
- }
2120
-
2121
- /**
2122
- * Extension point for disposable objects.
2123
- * @protected
2124
- */
2125
- disposeInternal() {}
2126
- }
2127
-
2128
- var Disposable$1 = Disposable;
2129
-
2130
- /**
2131
- * @module ol/functions
2132
- */
2133
-
2134
- /**
2135
- * A reusable function, used e.g. as a default for callbacks.
2136
- *
2137
- * @return {void} Nothing.
2138
- */
2139
- function VOID() {}
2140
-
2141
- /**
2142
- * @module ol/obj
2143
- */
2144
-
2145
- /**
2146
- * Removes all properties from an object.
2147
- * @param {Object} object The object to clear.
2148
- */
2149
- function clear(object) {
2150
- for (const property in object) {
2151
- delete object[property];
2152
- }
2153
- }
2154
-
2155
- /**
2156
- * Determine if an object has any properties.
2157
- * @param {Object} object The object to check.
2158
- * @return {boolean} The object is empty.
2159
- */
2160
- function isEmpty(object) {
2161
- let property;
2162
- for (property in object) {
2163
- return false;
2164
- }
2165
- return !property;
2166
- }
2167
-
2168
- /**
2169
- * @module ol/events/Target
2170
- */
2171
-
2172
- /**
2173
- * @typedef {EventTarget|Target} EventTargetLike
2174
- */
2175
-
2176
- /**
2177
- * @classdesc
2178
- * A simplified implementation of the W3C DOM Level 2 EventTarget interface.
2179
- * See https://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-EventTarget.
2180
- *
2181
- * There are two important simplifications compared to the specification:
2182
- *
2183
- * 1. The handling of `useCapture` in `addEventListener` and
2184
- * `removeEventListener`. There is no real capture model.
2185
- * 2. The handling of `stopPropagation` and `preventDefault` on `dispatchEvent`.
2186
- * There is no event target hierarchy. When a listener calls
2187
- * `stopPropagation` or `preventDefault` on an event object, it means that no
2188
- * more listeners after this one will be called. Same as when the listener
2189
- * returns false.
2190
- */
2191
- class Target extends Disposable$1 {
2192
- /**
2193
- * @param {*} [target] Default event target for dispatched events.
2194
- */
2195
- constructor(target) {
2196
- super();
2197
-
2198
- /**
2199
- * @private
2200
- * @type {*}
2201
- */
2202
- this.eventTarget_ = target;
2203
-
2204
- /**
2205
- * @private
2206
- * @type {Object<string, number>}
2207
- */
2208
- this.pendingRemovals_ = null;
2209
-
2210
- /**
2211
- * @private
2212
- * @type {Object<string, number>}
2213
- */
2214
- this.dispatching_ = null;
2215
-
2216
- /**
2217
- * @private
2218
- * @type {Object<string, Array<import("../events.js").Listener>>}
2219
- */
2220
- this.listeners_ = null;
2221
- }
2222
-
2223
- /**
2224
- * @param {string} type Type.
2225
- * @param {import("../events.js").Listener} listener Listener.
2226
- */
2227
- addEventListener(type, listener) {
2228
- if (!type || !listener) {
2229
- return;
2230
- }
2231
- const listeners = this.listeners_ || (this.listeners_ = {});
2232
- const listenersForType = listeners[type] || (listeners[type] = []);
2233
- if (!listenersForType.includes(listener)) {
2234
- listenersForType.push(listener);
2235
- }
2236
- }
2237
-
2238
- /**
2239
- * Dispatches an event and calls all listeners listening for events
2240
- * of this type. The event parameter can either be a string or an
2241
- * Object with a `type` property.
2242
- *
2243
- * @param {import("./Event.js").default|string} event Event object.
2244
- * @return {boolean|undefined} `false` if anyone called preventDefault on the
2245
- * event object or if any of the listeners returned false.
2246
- * @api
2247
- */
2248
- dispatchEvent(event) {
2249
- const isString = typeof event === 'string';
2250
- const type = isString ? event : event.type;
2251
- const listeners = this.listeners_ && this.listeners_[type];
2252
- if (!listeners) {
2253
- return;
2254
- }
2255
-
2256
- const evt = isString ? new Event$1(event) : /** @type {Event} */ (event);
2257
- if (!evt.target) {
2258
- evt.target = this.eventTarget_ || this;
2259
- }
2260
- const dispatching = this.dispatching_ || (this.dispatching_ = {});
2261
- const pendingRemovals =
2262
- this.pendingRemovals_ || (this.pendingRemovals_ = {});
2263
- if (!(type in dispatching)) {
2264
- dispatching[type] = 0;
2265
- pendingRemovals[type] = 0;
2266
- }
2267
- ++dispatching[type];
2268
- let propagate;
2269
- for (let i = 0, ii = listeners.length; i < ii; ++i) {
2270
- if ('handleEvent' in listeners[i]) {
2271
- propagate = /** @type {import("../events.js").ListenerObject} */ (
2272
- listeners[i]
2273
- ).handleEvent(evt);
2274
- } else {
2275
- propagate = /** @type {import("../events.js").ListenerFunction} */ (
2276
- listeners[i]
2277
- ).call(this, evt);
2278
- }
2279
- if (propagate === false || evt.propagationStopped) {
2280
- propagate = false;
2281
- break;
2282
- }
2283
- }
2284
- if (--dispatching[type] === 0) {
2285
- let pr = pendingRemovals[type];
2286
- delete pendingRemovals[type];
2287
- while (pr--) {
2288
- this.removeEventListener(type, VOID);
2289
- }
2290
- delete dispatching[type];
2291
- }
2292
- return propagate;
2293
- }
2294
-
2295
- /**
2296
- * Clean up.
2297
- */
2298
- disposeInternal() {
2299
- this.listeners_ && clear(this.listeners_);
2300
- }
2301
-
2302
- /**
2303
- * Get the listeners for a specified event type. Listeners are returned in the
2304
- * order that they will be called in.
2305
- *
2306
- * @param {string} type Type.
2307
- * @return {Array<import("../events.js").Listener>|undefined} Listeners.
2308
- */
2309
- getListeners(type) {
2310
- return (this.listeners_ && this.listeners_[type]) || undefined;
2311
- }
2312
-
2313
- /**
2314
- * @param {string} [type] Type. If not provided,
2315
- * `true` will be returned if this event target has any listeners.
2316
- * @return {boolean} Has listeners.
2317
- */
2318
- hasListener(type) {
2319
- if (!this.listeners_) {
2320
- return false;
2321
- }
2322
- return type
2323
- ? type in this.listeners_
2324
- : Object.keys(this.listeners_).length > 0;
2325
- }
2326
-
2327
- /**
2328
- * @param {string} type Type.
2329
- * @param {import("../events.js").Listener} listener Listener.
2330
- */
2331
- removeEventListener(type, listener) {
2332
- const listeners = this.listeners_ && this.listeners_[type];
2333
- if (listeners) {
2334
- const index = listeners.indexOf(listener);
2335
- if (index !== -1) {
2336
- if (this.pendingRemovals_ && type in this.pendingRemovals_) {
2337
- // make listener a no-op, and remove later in #dispatchEvent()
2338
- listeners[index] = VOID;
2339
- ++this.pendingRemovals_[type];
2340
- } else {
2341
- listeners.splice(index, 1);
2342
- if (listeners.length === 0) {
2343
- delete this.listeners_[type];
2344
- }
2345
- }
2346
- }
2347
- }
2348
- }
2204
+ // Ol
2205
+ class Uploads extends Observable {
2206
+ constructor(options) {
2207
+ super();
2208
+ this._options = options;
2209
+ this._processUpload = options.processUpload;
2210
+ // Formats
2211
+ this._formatWFS = new WFS();
2212
+ this._formatGeoJSON = new GeoJSON();
2213
+ this._formatKml = new KML({
2214
+ extractStyles: false,
2215
+ showPointNames: false
2216
+ });
2217
+ this._xs = new XMLSerializer();
2218
+ }
2219
+ /**
2220
+ * Parse and check geometry of uploaded files
2221
+ *
2222
+ * @param evt
2223
+ * @public
2224
+ */
2225
+ async process(evt) {
2226
+ const map = getMap();
2227
+ const view = map.getView();
2228
+ const file = evt.target.files[0];
2229
+ let features;
2230
+ if (!file) {
2231
+ return;
2232
+ }
2233
+ const extension = file.name.split('.').pop().toLowerCase();
2234
+ try {
2235
+ // If the user uses a custom fucntion...
2236
+ if (this._processUpload) {
2237
+ features = this._processUpload(file);
2238
+ }
2239
+ // If the user functions return features, we dont process anything more
2240
+ if (!features) {
2241
+ const string = await this._fileReader(file);
2242
+ if (extension === 'geojson' || extension === 'json') {
2243
+ features = this._formatGeoJSON.readFeatures(string, {
2244
+ featureProjection: view.getProjection().getCode()
2245
+ });
2246
+ }
2247
+ else if (extension === 'kml') {
2248
+ features = this._formatKml.readFeatures(string, {
2249
+ featureProjection: view.getProjection().getCode()
2250
+ });
2251
+ }
2252
+ else {
2253
+ showError(I18N.errors.badFormat);
2254
+ }
2255
+ }
2256
+ let invalidFeaturesCount = 0;
2257
+ let validFeaturesCount = 0;
2258
+ const featuresToInsert = [];
2259
+ for (let feature of features) {
2260
+ // If the geometry doesn't correspond to the layer, try to fixit.
2261
+ // If we can't, don't use it
2262
+ if (!this._checkGeometry(feature)) {
2263
+ feature = this._fixGeometry(feature);
2264
+ }
2265
+ if (feature) {
2266
+ featuresToInsert.push(feature);
2267
+ validFeaturesCount++;
2268
+ }
2269
+ else {
2270
+ invalidFeaturesCount++;
2271
+ continue;
2272
+ }
2273
+ }
2274
+ if (!validFeaturesCount) {
2275
+ showError(I18N.errors.noValidGeometry);
2276
+ }
2277
+ else {
2278
+ resetStateButtons();
2279
+ this.dispatchEvent(new VectorSource.VectorSourceEvent('loadedFeatures', null, featuresToInsert));
2280
+ const content = `
2281
+ ${I18N.labels.validFeatures}: ${validFeaturesCount}<br>
2282
+ ${invalidFeaturesCount
2283
+ ? `${I18N.labels.invalidFeatures}: ${invalidFeaturesCount}`
2284
+ : ''}`;
2285
+ this._initModal(content, featuresToInsert);
2286
+ }
2287
+ // Reset the input to allow another onChange trigger
2288
+ evt.target.value = null;
2289
+ }
2290
+ catch (err) {
2291
+ showError(I18N.errors.badFile, err);
2292
+ }
2293
+ }
2294
+ /**
2295
+ * Read data file
2296
+ * @param file
2297
+ * @public
2298
+ */
2299
+ async _fileReader(file) {
2300
+ return new Promise((resolve, reject) => {
2301
+ const reader = new FileReader();
2302
+ reader.addEventListener('load', async (e) => {
2303
+ const fileData = e.target.result;
2304
+ resolve(fileData);
2305
+ });
2306
+ reader.addEventListener('error', (err) => {
2307
+ console.error('Error' + err);
2308
+ reject();
2309
+ });
2310
+ reader.readAsText(file);
2311
+ });
2312
+ }
2313
+ /**
2314
+ * Attemp to change the geometry feature to the layer
2315
+ * @param feature
2316
+ * @private
2317
+ */
2318
+ _fixGeometry(feature) {
2319
+ // Geometry of the layer
2320
+ const geomTypeLayer = getActiveLayerToInsertEls().getDescribeFeatureType()._parsed
2321
+ .geomType;
2322
+ const geomTypeFeature = feature.getGeometry().getType();
2323
+ let geom;
2324
+ switch (geomTypeFeature) {
2325
+ case GeometryType.Point: {
2326
+ if (geomTypeLayer === GeometryType.MultiPoint) {
2327
+ const coords = feature.getGeometry().getCoordinates();
2328
+ geom = new geom_js.MultiPoint([coords]);
2329
+ }
2330
+ break;
2331
+ }
2332
+ case GeometryType.LineString:
2333
+ if (geomTypeLayer === GeometryType.MultiLineString) {
2334
+ const coords = feature.getGeometry().getCoordinates();
2335
+ geom = new geom_js.MultiLineString([coords]);
2336
+ }
2337
+ break;
2338
+ case GeometryType.Polygon:
2339
+ if (geomTypeLayer === GeometryType.MultiPolygon) {
2340
+ const coords = feature.getGeometry().getCoordinates();
2341
+ geom = new geom_js.MultiPolygon([coords]);
2342
+ }
2343
+ break;
2344
+ default:
2345
+ geom = null;
2346
+ }
2347
+ if (!geom) {
2348
+ return null;
2349
+ }
2350
+ feature.setGeometry(geom);
2351
+ return feature;
2352
+ }
2353
+ /**
2354
+ * Check if the feature has the same geometry as the target layer
2355
+ * @param feature
2356
+ * @private
2357
+ */
2358
+ _checkGeometry(feature) {
2359
+ // Geometry of the layer
2360
+ const geomTypeLayer = getActiveLayerToInsertEls().getDescribeFeatureType()._parsed
2361
+ .geomType;
2362
+ const geomTypeFeature = feature.getGeometry().getType();
2363
+ // This geom accepts every type of geometry
2364
+ if (geomTypeLayer === GeometryType.GeometryCollection) {
2365
+ return true;
2366
+ }
2367
+ return geomTypeFeature === geomTypeLayer;
2368
+ }
2369
+ /**
2370
+ * Confirm modal before transact to the GeoServer the features in the file
2371
+ *
2372
+ * @param content
2373
+ * @param featuresToInsert
2374
+ * @private
2375
+ */
2376
+ _initModal(content, featuresToInsert) {
2377
+ const footer = `
2378
+ <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">
2379
+ ${I18N.labels.cancel}
2380
+ </button>
2381
+ <button type="button" class="btn btn-sm btn-primary" data-action="save" data-dismiss="modal">
2382
+ ${I18N.labels.upload}
2383
+ </button>
2384
+ `;
2385
+ const modal = new Modal(Object.assign(Object.assign({}, this._options.modal), { header: true, headerClose: false, title: I18N.labels.uploadFeatures +
2386
+ ' ' +
2387
+ getActiveLayerToInsertEls().get(BaseLayerProperty.NAME), content: content, backdrop: 'static', footer: footer })).show();
2388
+ modal.on('dismiss', (modal, event) => {
2389
+ // On saving changes
2390
+ if (event.target.dataset.action === 'save') {
2391
+ this.dispatchEvent(new VectorSource.VectorSourceEvent('addedFeatures', null, featuresToInsert));
2392
+ }
2393
+ else {
2394
+ // On cancel button
2395
+ getEditLayer().getSource().clear();
2396
+ }
2397
+ });
2398
+ }
2349
2399
  }
2350
2400
 
2351
- var Target$1 = Target;
2352
-
2353
- /**
2354
- * @module ol/events/EventType
2355
- */
2356
-
2357
- /**
2358
- * @enum {string}
2359
- * @const
2360
- */
2361
- var EventType = {
2362
- /**
2363
- * Generic change event. Triggered when the revision counter is increased.
2364
- * @event module:ol/events/Event~BaseEvent#change
2365
- * @api
2366
- */
2367
- CHANGE: 'change',
2368
-
2369
- /**
2370
- * Generic error event. Triggered when an error occurs.
2371
- * @event module:ol/events/Event~BaseEvent#error
2372
- * @api
2373
- */
2374
- ERROR: 'error',
2375
-
2376
- BLUR: 'blur',
2377
- CLEAR: 'clear',
2378
- CONTEXTMENU: 'contextmenu',
2379
- CLICK: 'click',
2380
- DBLCLICK: 'dblclick',
2381
- DRAGENTER: 'dragenter',
2382
- DRAGOVER: 'dragover',
2383
- DROP: 'drop',
2384
- FOCUS: 'focus',
2385
- KEYDOWN: 'keydown',
2386
- KEYPRESS: 'keypress',
2387
- LOAD: 'load',
2388
- RESIZE: 'resize',
2389
- TOUCHMOVE: 'touchmove',
2390
- WHEEL: 'wheel',
2401
+ /**
2402
+ * @param target
2403
+ * @param sources
2404
+ * @returns
2405
+ */
2406
+ const deepObjectAssign = (target, ...sources) => {
2407
+ sources.forEach((source) => {
2408
+ Object.keys(source).forEach((key) => {
2409
+ const s_val = source[key];
2410
+ const t_val = target[key];
2411
+ target[key] =
2412
+ t_val &&
2413
+ s_val &&
2414
+ typeof t_val === 'object' &&
2415
+ typeof s_val === 'object' &&
2416
+ !Array.isArray(t_val) // Don't merge arrays
2417
+ ? deepObjectAssign(t_val, s_val)
2418
+ : s_val;
2419
+ });
2420
+ });
2421
+ return target;
2391
2422
  };
2392
2423
 
2393
- /**
2394
- * @module ol/events
2395
- */
2396
-
2397
- /**
2398
- * Key to use with {@link module:ol/Observable.unByKey}.
2399
- * @typedef {Object} EventsKey
2400
- * @property {ListenerFunction} listener Listener.
2401
- * @property {import("./events/Target.js").EventTargetLike} target Target.
2402
- * @property {string} type Type.
2403
- * @api
2404
- */
2405
-
2406
- /**
2407
- * Listener function. This function is called with an event object as argument.
2408
- * When the function returns `false`, event propagation will stop.
2409
- *
2410
- * @typedef {function((Event|import("./events/Event.js").default)): (void|boolean)} ListenerFunction
2411
- * @api
2412
- */
2413
-
2414
- /**
2415
- * @typedef {Object} ListenerObject
2416
- * @property {ListenerFunction} handleEvent HandleEvent listener function.
2417
- */
2418
-
2419
- /**
2420
- * @typedef {ListenerFunction|ListenerObject} Listener
2421
- */
2424
+ const DEFAULT_LANGUAGE = 'en';
2425
+ const getDefaultOptions = () => {
2426
+ return {
2427
+ layers: null,
2428
+ evtType: 'singleclick',
2429
+ active: true,
2430
+ showControl: true,
2431
+ language: DEFAULT_LANGUAGE,
2432
+ uploadFormats: '.geojson,.json,.kml',
2433
+ processUpload: null,
2434
+ modal: {
2435
+ animateClass: 'fade',
2436
+ animateInClass: 'show',
2437
+ transition: 300,
2438
+ backdropTransition: 150,
2439
+ templates: {
2440
+ dialog: '<div class="modal-dialog modal-dialog-centered"></div>',
2441
+ headerClose: `<button type="button" class="btn-close" data-dismiss="modal" aria-label="${I18N.labels.close}"><span aria-hidden="true">×</span></button>`
2442
+ }
2443
+ }
2444
+ };
2445
+ };
2422
2446
 
2423
- /**
2424
- * Registers an event listener on an event target. Inspired by
2425
- * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html
2426
- *
2427
- * This function efficiently binds a `listener` to a `this` object, and returns
2428
- * a key for use with {@link module:ol/events.unlistenByKey}.
2429
- *
2430
- * @param {import("./events/Target.js").EventTargetLike} target Event target.
2431
- * @param {string} type Event type.
2432
- * @param {ListenerFunction} listener Listener.
2433
- * @param {Object} [thisArg] Object referenced by the `this` keyword in the
2434
- * listener. Default is the `target`.
2435
- * @param {boolean} [once] If true, add the listener as one-off listener.
2436
- * @return {EventsKey} Unique key for the listener.
2437
- */
2438
- function listen(target, type, listener, thisArg, once) {
2439
- if (thisArg && thisArg !== target) {
2440
- listener = listener.bind(thisArg);
2441
- }
2442
- if (once) {
2443
- const originalListener = listener;
2444
- listener = function () {
2445
- target.removeEventListener(type, listener);
2446
- originalListener.apply(this, arguments);
2447
- };
2448
- }
2449
- const eventsKey = {
2450
- target: target,
2451
- type: type,
2452
- listener: listener,
2453
- };
2454
- target.addEventListener(type, listener);
2455
- return eventsKey;
2447
+ class EditControlChangesEl extends Control {
2448
+ constructor(feature) {
2449
+ super({
2450
+ element: (createElement("div", { className: "ol-wfst--changes-control" },
2451
+ createElement("div", { className: "ol-wfst--changes-control-el" },
2452
+ createElement("div", { className: "ol-wfst--changes-control-id" },
2453
+ createElement("b", null, I18N.labels.editMode),
2454
+ " -",
2455
+ ' ',
2456
+ createElement("i", null, String(feature.getId()))),
2457
+ createElement("button", { type: "button", className: "btn btn-sm btn-secondary", onClick: () => {
2458
+ this.dispatchEvent(new VectorSource.VectorSourceEvent('cancel', feature));
2459
+ } }, I18N.labels.cancel),
2460
+ createElement("button", { type: "button", className: "btn btn-sm btn-primary", onClick: () => {
2461
+ this.dispatchEvent(new VectorSource.VectorSourceEvent('apply', feature));
2462
+ } }, I18N.labels.apply),
2463
+ createElement("button", { type: "button", className: "btn btn-sm btn-danger-outline", onClick: () => {
2464
+ this.dispatchEvent(new VectorSource.VectorSourceEvent('delete', feature));
2465
+ } }, I18N.labels.delete))))
2466
+ });
2467
+ }
2456
2468
  }
2457
2469
 
2458
- /**
2459
- * Registers a one-off event listener on an event target. Inspired by
2460
- * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html
2461
- *
2462
- * This function efficiently binds a `listener` as self-unregistering listener
2463
- * to a `this` object, and returns a key for use with
2464
- * {@link module:ol/events.unlistenByKey} in case the listener needs to be
2465
- * unregistered before it is called.
2466
- *
2467
- * When {@link module:ol/events.listen} is called with the same arguments after this
2468
- * function, the self-unregistering listener will be turned into a permanent
2469
- * listener.
2470
- *
2471
- * @param {import("./events/Target.js").EventTargetLike} target Event target.
2472
- * @param {string} type Event type.
2473
- * @param {ListenerFunction} listener Listener.
2474
- * @param {Object} [thisArg] Object referenced by the `this` keyword in the
2475
- * listener. Default is the `target`.
2476
- * @return {EventsKey} Key for unlistenByKey.
2477
- */
2478
- function listenOnce(target, type, listener, thisArg) {
2479
- return listen(target, type, listener, thisArg, true);
2470
+ // Ol
2471
+ /**
2472
+ * Master style that handles two modes on the Edit Layer:
2473
+ * - one is the basic, showing only the vertices
2474
+ * - and the other when modify is active, showing bigger vertices
2475
+ *
2476
+ * @param feature
2477
+ * @private
2478
+ */
2479
+ function styleFunction(feature) {
2480
+ const getVertexs = (feature) => {
2481
+ let geometry = feature.getGeometry();
2482
+ if (geometry instanceof geom_js.GeometryCollection) {
2483
+ geometry = geometry.getGeometries()[0];
2484
+ }
2485
+ const coordinates = geometry.getCoordinates();
2486
+ let flatCoordinates = null;
2487
+ if (geometry instanceof geom_js.Polygon ||
2488
+ geometry instanceof geom_js.MultiLineString) {
2489
+ flatCoordinates = coordinates.flat(1);
2490
+ }
2491
+ else if (geometry instanceof geom_js.MultiPolygon) {
2492
+ flatCoordinates = coordinates.flat(2);
2493
+ }
2494
+ else {
2495
+ flatCoordinates = coordinates;
2496
+ }
2497
+ if (!flatCoordinates || !flatCoordinates.length) {
2498
+ return;
2499
+ }
2500
+ return new geom_js.MultiPoint(flatCoordinates);
2501
+ };
2502
+ let geometry = feature.getGeometry();
2503
+ let type = geometry.getType();
2504
+ if (geometry instanceof geom_js.GeometryCollection) {
2505
+ geometry = geometry.getGeometries()[0];
2506
+ type = geometry.getType();
2507
+ }
2508
+ switch (type) {
2509
+ case GeometryType.Point:
2510
+ case GeometryType.MultiPoint:
2511
+ if (getMode() === Modes.Edit) {
2512
+ return [
2513
+ new style_js.Style({
2514
+ image: new style_js.Circle({
2515
+ radius: 6,
2516
+ fill: new style_js.Fill({
2517
+ color: '#000000'
2518
+ })
2519
+ })
2520
+ }),
2521
+ new style_js.Style({
2522
+ image: new style_js.Circle({
2523
+ radius: 4,
2524
+ fill: new style_js.Fill({
2525
+ color: '#ff0000'
2526
+ })
2527
+ })
2528
+ })
2529
+ ];
2530
+ }
2531
+ else {
2532
+ return [
2533
+ new style_js.Style({
2534
+ image: new style_js.Circle({
2535
+ radius: 5,
2536
+ fill: new style_js.Fill({
2537
+ color: '#ff0000'
2538
+ })
2539
+ })
2540
+ }),
2541
+ new style_js.Style({
2542
+ image: new style_js.Circle({
2543
+ radius: 2,
2544
+ fill: new style_js.Fill({
2545
+ color: '#000000'
2546
+ })
2547
+ })
2548
+ })
2549
+ ];
2550
+ }
2551
+ default:
2552
+ // If editing mode is active, show bigger vertex
2553
+ if (getMode() == Modes.Draw || getMode() == Modes.Edit) {
2554
+ return [
2555
+ new style_js.Style({
2556
+ stroke: new style_js.Stroke({
2557
+ color: 'rgba( 255, 0, 0, 1)',
2558
+ width: 4
2559
+ }),
2560
+ fill: new style_js.Fill({
2561
+ color: 'rgba(255, 0, 0, 0.7)'
2562
+ })
2563
+ }),
2564
+ new style_js.Style({
2565
+ image: new style_js.Circle({
2566
+ radius: 4,
2567
+ fill: new style_js.Fill({
2568
+ color: '#ff0000'
2569
+ }),
2570
+ stroke: new style_js.Stroke({
2571
+ width: 2,
2572
+ color: 'rgba(5, 5, 5, 0.9)'
2573
+ })
2574
+ }),
2575
+ geometry: (feature) => getVertexs(feature)
2576
+ }),
2577
+ new style_js.Style({
2578
+ stroke: new style_js.Stroke({
2579
+ color: 'rgba(255, 255, 255, 0.7)',
2580
+ width: 2
2581
+ })
2582
+ })
2583
+ ];
2584
+ }
2585
+ else {
2586
+ return [
2587
+ new style_js.Style({
2588
+ image: new style_js.Circle({
2589
+ radius: 2,
2590
+ fill: new style_js.Fill({
2591
+ color: '#000000'
2592
+ })
2593
+ }),
2594
+ geometry: (feature) => getVertexs(feature)
2595
+ }),
2596
+ new style_js.Style({
2597
+ stroke: new style_js.Stroke({
2598
+ color: '#ff0000',
2599
+ width: 4
2600
+ }),
2601
+ fill: new style_js.Fill({
2602
+ color: 'rgba(255, 0, 0, 0.7)'
2603
+ })
2604
+ })
2605
+ ];
2606
+ }
2607
+ }
2480
2608
  }
2481
2609
 
2482
- /**
2483
- * Unregisters event listeners on an event target. Inspired by
2484
- * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html
2485
- *
2486
- * The argument passed to this function is the key returned from
2487
- * {@link module:ol/events.listen} or {@link module:ol/events.listenOnce}.
2488
- *
2489
- * @param {EventsKey} key The key.
2490
- */
2491
- function unlistenByKey(key) {
2492
- if (key && key.target) {
2493
- key.target.removeEventListener(key.type, key.listener);
2494
- clear(key);
2495
- }
2610
+ // Ol
2611
+ /**
2612
+ * Shows a fields form in a modal window to allow changes in the properties of the feature.
2613
+ *
2614
+ * @param feature
2615
+ * @private
2616
+ */
2617
+ class EditFieldsModal extends Observable {
2618
+ constructor(options) {
2619
+ super();
2620
+ this._options = options;
2621
+ const footer = `
2622
+ <button type="button" class="btn btn-sm btn-link btn-third" data-action="delete" data-dismiss="modal">
2623
+ ${I18N.labels.delete}
2624
+ </button>
2625
+ <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">
2626
+ ${I18N.labels.cancel}
2627
+ </button>
2628
+ <button type="button" class="btn btn-sm btn-primary" data-action="save" data-dismiss="modal">
2629
+ ${I18N.labels.save}
2630
+ </button>
2631
+ `;
2632
+ this._modal = new Modal(Object.assign(Object.assign({}, this._options), { header: true, headerClose: true, title: '', content: '<div></div>', footer: footer }));
2633
+ this._modal.on('dismiss', (modal, event) => {
2634
+ // On saving changes
2635
+ if (event.target.dataset.action === 'save') {
2636
+ const inputs = modal.el.querySelectorAll('input');
2637
+ inputs.forEach((el) => {
2638
+ const value = el.value;
2639
+ const field = el.name;
2640
+ this._feature.set(field, value, /*isSilent = */ true);
2641
+ });
2642
+ this._feature.changed();
2643
+ addFeatureToEditedList(this._feature);
2644
+ this.dispatchEvent(new VectorSource.VectorSourceEvent('save', this._feature));
2645
+ }
2646
+ else if (event.target.dataset.action === 'delete') {
2647
+ this.dispatchEvent(new VectorSource.VectorSourceEvent('delete', this._feature));
2648
+ }
2649
+ });
2650
+ }
2651
+ show(feature) {
2652
+ this._feature = feature;
2653
+ const title = `${I18N.labels.editElement} ${feature.getId()} `;
2654
+ const properties = feature.getProperties();
2655
+ const layerName = feature.get('_layerName_');
2656
+ // Data schema from the geoserver
2657
+ const layer = getStoredLayer(layerName);
2658
+ const dataSchema = layer.getDescribeFeatureType()._parsed.properties;
2659
+ let content = '<form autocomplete="false">';
2660
+ Object.keys(properties).forEach((key) => {
2661
+ // If the feature field exists in the geoserver and is not added by openlayers
2662
+ const field = dataSchema.find((data) => data.name === key);
2663
+ if (field) {
2664
+ const typeXsd = field.type;
2665
+ let type;
2666
+ switch (typeXsd) {
2667
+ case 'xsd:string':
2668
+ type = 'text';
2669
+ break;
2670
+ case 'xsd:number':
2671
+ case 'xsd:int':
2672
+ type = 'number';
2673
+ break;
2674
+ case 'xsd:date-time':
2675
+ type = 'datetime';
2676
+ break;
2677
+ default:
2678
+ type = 'text';
2679
+ }
2680
+ if (type) {
2681
+ content += `
2682
+ <div class="ol-wfst--input-field-container">
2683
+ <label class="ol-wfst--input-field-label" for="${key}">${key}</label>
2684
+ <input placeholder="NULL" class="ol-wfst--input-field-input" type="${type}" name="${key}" value="${properties[key] || ''}">
2685
+ </div>`;
2686
+ }
2687
+ }
2688
+ });
2689
+ content += '</form>';
2690
+ this._modal._html.body.innerHTML = content;
2691
+ this._modal._html.header.innerHTML = title;
2692
+ this._modal.show();
2693
+ }
2496
2694
  }
2497
2695
 
2498
2696
  /**
2499
- * @module ol/Observable
2500
- */
2501
-
2502
- /***
2503
- * @template {string} Type
2504
- * @template {Event|import("./events/Event.js").default} EventClass
2505
- * @template Return
2506
- * @typedef {(type: Type, listener: (event: EventClass) => ?) => Return} OnSignature
2507
- */
2508
-
2509
- /***
2510
- * @template {string} Type
2511
- * @template Return
2512
- * @typedef {(type: Type[], listener: (event: Event|import("./events/Event").default) => ?) => Return extends void ? void : Return[]} CombinedOnSignature
2697
+ * @module ol/format/WFSCapabilities
2513
2698
  */
2514
2699
 
2515
2700
  /**
2516
- * @typedef {'change'|'error'} EventTypes
2701
+ * @const
2702
+ * @type {Array<null|string>}
2517
2703
  */
2704
+ const NAMESPACE_URIS = [
2705
+ null,
2706
+ 'http://www.opengis.net/fes/2.0',
2707
+ 'http://www.opengis.net/ows/1.1',
2708
+ 'http://www.opengis.net/wfs/2.0',
2709
+ ];
2518
2710
 
2519
- /***
2520
- * @template Return
2521
- * @typedef {OnSignature<EventTypes, import("./events/Event.js").default, Return> & CombinedOnSignature<EventTypes, Return>} ObservableOnSignature
2711
+ /**
2712
+ * @const
2713
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
2522
2714
  */
2715
+ // @ts-ignore
2716
+ const PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2717
+ 'ServiceIdentification': xml_js.makeObjectPropertySetter(readServiceIdentification),
2718
+ 'ServiceProvider': xml_js.makeObjectPropertySetter(readServiceProvider),
2719
+ 'OperationsMetadata': xml_js.makeObjectPropertySetter(readOperationsMetadata),
2720
+ 'FeatureTypeList': xml_js.makeObjectPropertySetter(readFeatureTypeList),
2721
+ 'Filter_Capabilities': xml_js.makeObjectPropertySetter(readFilter_Capabilities),
2722
+ });
2523
2723
 
2524
2724
  /**
2525
2725
  * @classdesc
2526
- * Abstract base class; normally only used for creating subclasses and not
2527
- * instantiated in apps.
2528
- * An event target providing convenient methods for listener registration
2529
- * and unregistration. A generic `change` event is always available through
2530
- * {@link module:ol/Observable~Observable#changed}.
2726
+ * Format for reading WFS capabilities data
2531
2727
  *
2532
- * @fires import("./events/Event.js").default
2533
2728
  * @api
2534
2729
  */
2535
- class Observable extends Target$1 {
2730
+ class WFSCapabilities extends XML {
2536
2731
  constructor() {
2537
2732
  super();
2538
2733
 
2539
- this.on =
2540
- /** @type {ObservableOnSignature<import("./events").EventsKey>} */ (
2541
- this.onInternal
2542
- );
2543
-
2544
- this.once =
2545
- /** @type {ObservableOnSignature<import("./events").EventsKey>} */ (
2546
- this.onceInternal
2547
- );
2548
-
2549
- this.un = /** @type {ObservableOnSignature<void>} */ (this.unInternal);
2550
-
2551
2734
  /**
2552
- * @private
2553
- * @type {number}
2735
+ * @type {string|undefined}
2554
2736
  */
2555
- this.revision_ = 0;
2556
- }
2557
-
2558
- /**
2559
- * Increases the revision counter and dispatches a 'change' event.
2560
- * @api
2561
- */
2562
- changed() {
2563
- ++this.revision_;
2564
- this.dispatchEvent(EventType.CHANGE);
2565
- }
2566
-
2567
- /**
2568
- * Get the version number for this object. Each time the object is modified,
2569
- * its version number will be incremented.
2570
- * @return {number} Revision.
2571
- * @api
2572
- */
2573
- getRevision() {
2574
- return this.revision_;
2575
- }
2576
-
2577
- /**
2578
- * @param {string|Array<string>} type Type.
2579
- * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
2580
- * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
2581
- * @protected
2582
- */
2583
- onInternal(type, listener) {
2584
- if (Array.isArray(type)) {
2585
- const len = type.length;
2586
- const keys = new Array(len);
2587
- for (let i = 0; i < len; ++i) {
2588
- keys[i] = listen(this, type[i], listener);
2589
- }
2590
- return keys;
2591
- }
2592
- return listen(this, /** @type {string} */ (type), listener);
2593
- }
2594
-
2595
- /**
2596
- * @param {string|Array<string>} type Type.
2597
- * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
2598
- * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
2599
- * @protected
2600
- */
2601
- onceInternal(type, listener) {
2602
- let key;
2603
- if (Array.isArray(type)) {
2604
- const len = type.length;
2605
- key = new Array(len);
2606
- for (let i = 0; i < len; ++i) {
2607
- key[i] = listenOnce(this, type[i], listener);
2608
- }
2609
- } else {
2610
- key = listenOnce(this, /** @type {string} */ (type), listener);
2611
- }
2612
- /** @type {Object} */ (listener).ol_key = key;
2613
- return key;
2737
+ this.version = undefined;
2614
2738
  }
2615
2739
 
2616
2740
  /**
2617
- * Unlisten for a certain type of event.
2618
- * @param {string|Array<string>} type Type.
2619
- * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
2620
- * @protected
2741
+ * @param {Element} node Node.
2742
+ * @return {Object} Object
2621
2743
  */
2622
- unInternal(type, listener) {
2623
- const key = /** @type {Object} */ (listener).ol_key;
2624
- if (key) {
2625
- unByKey(key);
2626
- } else if (Array.isArray(type)) {
2627
- for (let i = 0, ii = type.length; i < ii; ++i) {
2628
- this.removeEventListener(type[i], listener);
2629
- }
2630
- } else {
2631
- this.removeEventListener(type, listener);
2632
- }
2744
+ readFromNode(node) {
2745
+ this.version = node.getAttribute('version').trim();
2746
+ const wfsCapabilityObject = xml_js.pushParseAndPop(
2747
+ {
2748
+ 'version': this.version,
2749
+ },
2750
+ PARSERS,
2751
+ node,
2752
+ []
2753
+ );
2754
+ return wfsCapabilityObject ? wfsCapabilityObject : null;
2633
2755
  }
2634
2756
  }
2635
2757
 
2636
2758
  /**
2637
- * Listen for a certain type of event.
2638
- * @function
2639
- * @param {string|Array<string>} type The event type or array of event types.
2640
- * @param {function((Event|import("./events/Event").default)): ?} listener The listener function.
2641
- * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Unique key for the listener. If
2642
- * called with an array of event types as the first argument, the return
2643
- * will be an array of keys.
2644
- * @api
2645
- */
2646
- Observable.prototype.on;
2647
-
2648
- /**
2649
- * Listen once for a certain type of event.
2650
- * @function
2651
- * @param {string|Array<string>} type The event type or array of event types.
2652
- * @param {function((Event|import("./events/Event").default)): ?} listener The listener function.
2653
- * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Unique key for the listener. If
2654
- * called with an array of event types as the first argument, the return
2655
- * will be an array of keys.
2656
- * @api
2657
- */
2658
- Observable.prototype.once;
2659
-
2660
- /**
2661
- * Unlisten for a certain type of event.
2662
- * @function
2663
- * @param {string|Array<string>} type The event type or array of event types.
2664
- * @param {function((Event|import("./events/Event").default)): ?} listener The listener function.
2665
- * @api
2666
- */
2667
- Observable.prototype.un;
2668
-
2669
- /**
2670
- * Removes an event listener using the key returned by `on()` or `once()`.
2671
- * @param {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} key The key returned by `on()`
2672
- * or `once()` (or an array of keys).
2673
- * @api
2759
+ * @const
2760
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
2674
2761
  */
2675
- function unByKey(key) {
2676
- if (Array.isArray(key)) {
2677
- for (let i = 0, ii = key.length; i < ii; ++i) {
2678
- unlistenByKey(key[i]);
2679
- }
2680
- } else {
2681
- unlistenByKey(/** @type {import("./events.js").EventsKey} */ (key));
2682
- }
2683
- }
2684
-
2685
- var Observable$1 = Observable;
2762
+ // @ts-ignore
2763
+ const SERVICE_IDENTIFICATION_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2764
+ 'Title': xml_js.makeObjectPropertySetter(xsd_js.readString),
2765
+ 'Abstract': xml_js.makeObjectPropertySetter(xsd_js.readString),
2766
+ 'Keywords': xml_js.makeObjectPropertySetter(readKeywordList),
2767
+ 'ServiceType': xml_js.makeObjectPropertySetter(xsd_js.readString),
2768
+ 'ServiceTypeVersion': xml_js.makeObjectPropertySetter(xsd_js.readString),
2769
+ 'Fees': xml_js.makeObjectPropertySetter(xsd_js.readString),
2770
+ 'AccessConstraints': xml_js.makeObjectPropertySetter(xsd_js.readString),
2771
+ });
2686
2772
 
2687
2773
  /**
2688
- * @module ol/util
2774
+ * @const
2775
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
2689
2776
  */
2777
+ // @ts-ignore
2778
+ const SERVICE_PROVIDER_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2779
+ 'ProviderName': xml_js.makeObjectPropertySetter(xsd_js.readString),
2780
+ 'ServiceContact': xml_js.makeObjectPropertySetter(readServiceContact),
2781
+ });
2690
2782
 
2691
2783
  /**
2692
- * Counter for getUid.
2693
- * @type {number}
2694
- * @private
2784
+ * @const
2785
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
2695
2786
  */
2696
- let uidCounter_ = 0;
2787
+ // @ts-ignore
2788
+ const OPERATIONS_METADATA_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2789
+ 'Operation': xml_js.makeObjectPropertyPusher(readNamedOperation),
2790
+ 'Constraint': xml_js.makeObjectPropertyPusher(readNamedConstraint),
2791
+ });
2697
2792
 
2698
2793
  /**
2699
- * Gets a unique ID for an object. This mutates the object so that further calls
2700
- * with the same object as a parameter returns the same value. Unique IDs are generated
2701
- * as a strictly increasing sequence. Adapted from goog.getUid.
2702
- *
2703
- * @param {Object} obj The object to get the unique ID for.
2704
- * @return {string} The unique ID for the object.
2705
- * @api
2794
+ * @const
2795
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
2706
2796
  */
2707
- function getUid(obj) {
2708
- return obj.ol_uid || (obj.ol_uid = String(++uidCounter_));
2709
- }
2797
+ // @ts-ignore
2798
+ const SERVICE_CONTACT_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2799
+ 'IndividualName': xml_js.makeObjectPropertySetter(xsd_js.readString),
2800
+ 'PositionName': xml_js.makeObjectPropertySetter(xsd_js.readString),
2801
+ 'ContactInfo': xml_js.makeObjectPropertySetter(readContactInfo),
2802
+ });
2710
2803
 
2711
2804
  /**
2712
- * @module ol/Object
2805
+ * @const
2806
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
2713
2807
  */
2808
+ // @ts-ignore
2809
+ const CONTACT_INFO_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2810
+ 'Phone': xml_js.makeObjectPropertySetter(readPhone),
2811
+ 'Address': xml_js.makeObjectPropertySetter(readAddress),
2812
+ });
2714
2813
 
2715
2814
  /**
2716
- * @classdesc
2717
- * Events emitted by {@link module:ol/Object~BaseObject} instances are instances of this type.
2718
- */
2719
- class ObjectEvent extends Event$1 {
2720
- /**
2721
- * @param {string} type The event type.
2722
- * @param {string} key The property name.
2723
- * @param {*} oldValue The old value for `key`.
2724
- */
2725
- constructor(type, key, oldValue) {
2726
- super(type);
2727
-
2728
- /**
2729
- * The name of the property whose value is changing.
2730
- * @type {string}
2731
- * @api
2732
- */
2733
- this.key = key;
2734
-
2735
- /**
2736
- * The old value. To get the new value use `e.target.get(e.key)` where
2737
- * `e` is the event object.
2738
- * @type {*}
2739
- * @api
2740
- */
2741
- this.oldValue = oldValue;
2742
- }
2743
- }
2744
-
2745
- /***
2746
- * @template Return
2747
- * @typedef {import("./Observable").OnSignature<import("./Observable").EventTypes, import("./events/Event.js").default, Return> &
2748
- * import("./Observable").OnSignature<import("./ObjectEventType").Types, ObjectEvent, Return> &
2749
- * import("./Observable").CombinedOnSignature<import("./Observable").EventTypes|import("./ObjectEventType").Types, Return>} ObjectOnSignature
2815
+ * @const
2816
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
2750
2817
  */
2818
+ // @ts-ignore
2819
+ const PHONE_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2820
+ 'Voice': xml_js.makeObjectPropertySetter(xsd_js.readString),
2821
+ 'Facsimile': xml_js.makeObjectPropertySetter(xsd_js.readString),
2822
+ });
2751
2823
 
2752
2824
  /**
2753
- * @classdesc
2754
- * Abstract base class; normally only used for creating subclasses and not
2755
- * instantiated in apps.
2756
- * Most non-trivial classes inherit from this.
2757
- *
2758
- * This extends {@link module:ol/Observable~Observable} with observable
2759
- * properties, where each property is observable as well as the object as a
2760
- * whole.
2761
- *
2762
- * Classes that inherit from this have pre-defined properties, to which you can
2763
- * add your owns. The pre-defined properties are listed in this documentation as
2764
- * 'Observable Properties', and have their own accessors; for example,
2765
- * {@link module:ol/Map~Map} has a `target` property, accessed with
2766
- * `getTarget()` and changed with `setTarget()`. Not all properties are however
2767
- * settable. There are also general-purpose accessors `get()` and `set()`. For
2768
- * example, `get('target')` is equivalent to `getTarget()`.
2769
- *
2770
- * The `set` accessors trigger a change event, and you can monitor this by
2771
- * registering a listener. For example, {@link module:ol/View~View} has a
2772
- * `center` property, so `view.on('change:center', function(evt) {...});` would
2773
- * call the function whenever the value of the center property changes. Within
2774
- * the function, `evt.target` would be the view, so `evt.target.getCenter()`
2775
- * would return the new center.
2776
- *
2777
- * You can add your own observable properties with
2778
- * `object.set('prop', 'value')`, and retrieve that with `object.get('prop')`.
2779
- * You can listen for changes on that property value with
2780
- * `object.on('change:prop', listener)`. You can get a list of all
2781
- * properties with {@link module:ol/Object~BaseObject#getProperties}.
2782
- *
2783
- * Note that the observable properties are separate from standard JS properties.
2784
- * You can, for example, give your map object a title with
2785
- * `map.title='New title'` and with `map.set('title', 'Another title')`. The
2786
- * first will be a `hasOwnProperty`; the second will appear in
2787
- * `getProperties()`. Only the second is observable.
2788
- *
2789
- * Properties can be deleted by using the unset method. E.g.
2790
- * object.unset('foo').
2791
- *
2792
- * @fires ObjectEvent
2793
- * @api
2825
+ * @const
2826
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
2794
2827
  */
2795
- class BaseObject extends Observable$1 {
2796
- /**
2797
- * @param {Object<string, *>} [values] An object with key-value pairs.
2798
- */
2799
- constructor(values) {
2800
- super();
2801
-
2802
- /***
2803
- * @type {ObjectOnSignature<import("./events").EventsKey>}
2804
- */
2805
- this.on;
2806
-
2807
- /***
2808
- * @type {ObjectOnSignature<import("./events").EventsKey>}
2809
- */
2810
- this.once;
2811
-
2812
- /***
2813
- * @type {ObjectOnSignature<void>}
2814
- */
2815
- this.un;
2816
-
2817
- // Call {@link module:ol/util.getUid} to ensure that the order of objects' ids is
2818
- // the same as the order in which they were created. This also helps to
2819
- // ensure that object properties are always added in the same order, which
2820
- // helps many JavaScript engines generate faster code.
2821
- getUid(this);
2822
-
2823
- /**
2824
- * @private
2825
- * @type {Object<string, *>}
2826
- */
2827
- this.values_ = null;
2828
-
2829
- if (values !== undefined) {
2830
- this.setProperties(values);
2831
- }
2832
- }
2833
-
2834
- /**
2835
- * Gets a value.
2836
- * @param {string} key Key name.
2837
- * @return {*} Value.
2838
- * @api
2839
- */
2840
- get(key) {
2841
- let value;
2842
- if (this.values_ && this.values_.hasOwnProperty(key)) {
2843
- value = this.values_[key];
2844
- }
2845
- return value;
2846
- }
2847
-
2848
- /**
2849
- * Get a list of object property names.
2850
- * @return {Array<string>} List of property names.
2851
- * @api
2852
- */
2853
- getKeys() {
2854
- return (this.values_ && Object.keys(this.values_)) || [];
2855
- }
2856
-
2857
- /**
2858
- * Get an object of all property names and values.
2859
- * @return {Object<string, *>} Object.
2860
- * @api
2861
- */
2862
- getProperties() {
2863
- return (this.values_ && Object.assign({}, this.values_)) || {};
2864
- }
2865
-
2866
- /**
2867
- * @return {boolean} The object has properties.
2868
- */
2869
- hasProperties() {
2870
- return !!this.values_;
2871
- }
2872
-
2873
- /**
2874
- * @param {string} key Key name.
2875
- * @param {*} oldValue Old value.
2876
- */
2877
- notify(key, oldValue) {
2878
- let eventType;
2879
- eventType = `change:${key}`;
2880
- if (this.hasListener(eventType)) {
2881
- this.dispatchEvent(new ObjectEvent(eventType, key, oldValue));
2882
- }
2883
- eventType = ObjectEventType.PROPERTYCHANGE;
2884
- if (this.hasListener(eventType)) {
2885
- this.dispatchEvent(new ObjectEvent(eventType, key, oldValue));
2886
- }
2887
- }
2888
-
2889
- /**
2890
- * @param {string} key Key name.
2891
- * @param {import("./events.js").Listener} listener Listener.
2892
- */
2893
- addChangeListener(key, listener) {
2894
- this.addEventListener(`change:${key}`, listener);
2895
- }
2896
-
2897
- /**
2898
- * @param {string} key Key name.
2899
- * @param {import("./events.js").Listener} listener Listener.
2900
- */
2901
- removeChangeListener(key, listener) {
2902
- this.removeEventListener(`change:${key}`, listener);
2903
- }
2904
-
2905
- /**
2906
- * Sets a value.
2907
- * @param {string} key Key name.
2908
- * @param {*} value Value.
2909
- * @param {boolean} [silent] Update without triggering an event.
2910
- * @api
2911
- */
2912
- set(key, value, silent) {
2913
- const values = this.values_ || (this.values_ = {});
2914
- if (silent) {
2915
- values[key] = value;
2916
- } else {
2917
- const oldValue = values[key];
2918
- values[key] = value;
2919
- if (oldValue !== value) {
2920
- this.notify(key, oldValue);
2921
- }
2922
- }
2923
- }
2924
-
2925
- /**
2926
- * Sets a collection of key-value pairs. Note that this changes any existing
2927
- * properties and adds new ones (it does not remove any existing properties).
2928
- * @param {Object<string, *>} values Values.
2929
- * @param {boolean} [silent] Update without triggering an event.
2930
- * @api
2931
- */
2932
- setProperties(values, silent) {
2933
- for (const key in values) {
2934
- this.set(key, values[key], silent);
2935
- }
2936
- }
2937
-
2938
- /**
2939
- * Apply any properties from another object without triggering events.
2940
- * @param {BaseObject} source The source object.
2941
- * @protected
2942
- */
2943
- applyProperties(source) {
2944
- if (!source.values_) {
2945
- return;
2946
- }
2947
- Object.assign(this.values_ || (this.values_ = {}), source.values_);
2948
- }
2949
-
2950
- /**
2951
- * Unsets a property.
2952
- * @param {string} key Key name.
2953
- * @param {boolean} [silent] Unset without triggering an event.
2954
- * @api
2955
- */
2956
- unset(key, silent) {
2957
- if (this.values_ && key in this.values_) {
2958
- const oldValue = this.values_[key];
2959
- delete this.values_[key];
2960
- if (isEmpty(this.values_)) {
2961
- this.values_ = null;
2962
- }
2963
- if (!silent) {
2964
- this.notify(key, oldValue);
2965
- }
2966
- }
2967
- }
2968
- }
2969
-
2970
- var BaseObject$1 = BaseObject;
2828
+ // @ts-ignore
2829
+ const ADDRESS_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2830
+ 'DeliveryPoint': xml_js.makeObjectPropertySetter(xsd_js.readString),
2831
+ 'City': xml_js.makeObjectPropertySetter(xsd_js.readString),
2832
+ 'AdministrativeArea': xml_js.makeObjectPropertySetter(xsd_js.readString),
2833
+ 'PostalCode': xml_js.makeObjectPropertySetter(xsd_js.readString),
2834
+ 'Country': xml_js.makeObjectPropertySetter(xsd_js.readString),
2835
+ 'ElectronicMailAddress': xml_js.makeObjectPropertySetter(xsd_js.readString),
2836
+ });
2971
2837
 
2972
2838
  /**
2973
- * @module ol/extent
2839
+ * @const
2840
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
2974
2841
  */
2842
+ // @ts-ignore
2843
+ const FEATURE_TYPE_LIST_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2844
+ 'FeatureType': xml_js.makeArrayPusher(readFeatureType),
2845
+ });
2975
2846
 
2976
2847
  /**
2977
- * Check if one extent contains another.
2978
- *
2979
- * An extent is deemed contained if it lies completely within the other extent,
2980
- * including if they share one or more edges.
2981
- *
2982
- * @param {Extent} extent1 Extent 1.
2983
- * @param {Extent} extent2 Extent 2.
2984
- * @return {boolean} The second extent is contained by or on the edge of the
2985
- * first.
2986
- * @api
2848
+ * @const
2849
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
2987
2850
  */
2988
- function containsExtent(extent1, extent2) {
2989
- return (
2990
- extent1[0] <= extent2[0] &&
2991
- extent2[2] <= extent1[2] &&
2992
- extent1[1] <= extent2[1] &&
2993
- extent2[3] <= extent1[3]
2994
- );
2995
- }
2851
+ // @ts-ignore
2852
+ const FEATURE_TYPE_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2853
+ 'Name': xml_js.makeObjectPropertySetter(xsd_js.readString),
2854
+ 'Title': xml_js.makeObjectPropertySetter(xsd_js.readString),
2855
+ 'Abstract': xml_js.makeObjectPropertySetter(xsd_js.readString),
2856
+ 'Keywords': xml_js.makeObjectPropertySetter(readKeywordList),
2857
+ 'DefaultCRS': xml_js.makeObjectPropertySetter(xsd_js.readString),
2858
+ 'WGS84BoundingBox': xml_js.makeObjectPropertySetter(readWGS84BoundingBox),
2859
+ 'MetadataURL': xml_js.makeObjectPropertySetter(xlink_js.readHref),
2860
+ });
2996
2861
 
2997
2862
  /**
2998
- * Get the current computed width for the given element including margin,
2999
- * padding and border.
3000
- * Equivalent to jQuery's `$(el).outerWidth(true)`.
3001
- * @param {!HTMLElement} element Element.
3002
- * @return {number} The width.
2863
+ * @const
2864
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3003
2865
  */
3004
- function outerWidth(element) {
3005
- let width = element.offsetWidth;
3006
- const style = getComputedStyle(element);
3007
- width += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10);
3008
-
3009
- return width;
3010
- }
2866
+ // @ts-ignore
2867
+ const OPERATION_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2868
+ 'DCP': xml_js.makeObjectPropertySetter(readDCP),
2869
+ 'Parameter': xml_js.makeObjectPropertyPusher(readNamedParameter),
2870
+ });
3011
2871
 
3012
2872
  /**
3013
- * Get the current computed height for the given element including margin,
3014
- * padding and border.
3015
- * Equivalent to jQuery's `$(el).outerHeight(true)`.
3016
- * @param {!HTMLElement} element Element.
3017
- * @return {number} The height.
2873
+ * @const
2874
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3018
2875
  */
3019
- function outerHeight(element) {
3020
- let height = element.offsetHeight;
3021
- const style = getComputedStyle(element);
3022
- height += parseInt(style.marginTop, 10) + parseInt(style.marginBottom, 10);
3023
-
3024
- return height;
3025
- }
2876
+ // @ts-ignore
2877
+ const PARAMETER_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2878
+ 'AllowedValues': xml_js.makeObjectPropertySetter(readValueList),
2879
+ });
3026
2880
 
3027
2881
  /**
3028
- * @param {Node} node The node to remove.
3029
- * @return {Node|null} The node that was removed or null.
2882
+ * @const
2883
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3030
2884
  */
3031
- function removeNode(node) {
3032
- return node && node.parentNode ? node.parentNode.removeChild(node) : null;
3033
- }
2885
+ // @ts-ignore
2886
+ const CONSTRAINT_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2887
+ 'NoValues': xml_js.makeObjectPropertySetter(xsd_js.readString),
2888
+ 'DefaultValue': xml_js.makeObjectPropertySetter(xsd_js.readString),
2889
+ 'AllowedValues': xml_js.makeObjectPropertySetter(readValueList),
2890
+ });
3034
2891
 
3035
2892
  /**
3036
- * @param {Node} node The node to remove the children from.
2893
+ * @const
2894
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3037
2895
  */
3038
- function removeChildren(node) {
3039
- while (node.lastChild) {
3040
- node.removeChild(node.lastChild);
3041
- }
3042
- }
2896
+ // @ts-ignore
2897
+ const HTTP_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2898
+ 'Get': xml_js.makeObjectPropertySetter(xlink_js.readHref),
2899
+ 'Post': xml_js.makeObjectPropertySetter(xlink_js.readHref),
2900
+ });
3043
2901
 
3044
2902
  /**
3045
- * @module ol/css
2903
+ * @const
2904
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3046
2905
  */
2906
+ // @ts-ignore
2907
+ const WGS84_BOUNDINGBOX_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2908
+ 'LowerCorner': xml_js.makeObjectPropertySetter(readStringCoords),
2909
+ 'UpperCorner': xml_js.makeObjectPropertySetter(readStringCoords),
2910
+ });
3047
2911
 
3048
2912
  /**
3049
- * The CSS class that we'll give the DOM elements to have them selectable.
3050
- *
3051
2913
  * @const
3052
- * @type {string}
2914
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3053
2915
  */
3054
- const CLASS_SELECTABLE = 'ol-selectable';
2916
+ // @ts-ignore
2917
+ const DCP_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2918
+ 'HTTP': xml_js.makeObjectPropertySetter(readHTTP),
2919
+ });
3055
2920
 
3056
2921
  /**
3057
- * @module ol/MapEventType
2922
+ * @const
2923
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3058
2924
  */
2925
+ // @ts-ignore
2926
+ const KEYWORDLIST_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2927
+ 'Keyword': xml_js.makeArrayPusher(xsd_js.readString),
2928
+ });
3059
2929
 
3060
2930
  /**
3061
- * @enum {string}
2931
+ * @const
2932
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3062
2933
  */
3063
- var MapEventType = {
3064
- /**
3065
- * Triggered after a map frame is rendered.
3066
- * @event module:ol/MapEvent~MapEvent#postrender
3067
- * @api
3068
- */
3069
- POSTRENDER: 'postrender',
3070
-
3071
- /**
3072
- * Triggered when the map starts moving.
3073
- * @event module:ol/MapEvent~MapEvent#movestart
3074
- * @api
3075
- */
3076
- MOVESTART: 'movestart',
3077
-
3078
- /**
3079
- * Triggered after the map is moved.
3080
- * @event module:ol/MapEvent~MapEvent#moveend
3081
- * @api
3082
- */
3083
- MOVEEND: 'moveend',
3084
-
3085
- /**
3086
- * Triggered when loading of additional map data (tiles, images, features) starts.
3087
- * @event module:ol/MapEvent~MapEvent#loadstart
3088
- * @api
3089
- */
3090
- LOADSTART: 'loadstart',
3091
-
3092
- /**
3093
- * Triggered when loading of additional map data has completed.
3094
- * @event module:ol/MapEvent~MapEvent#loadend
3095
- * @api
3096
- */
3097
- LOADEND: 'loadend',
3098
- };
2934
+ // @ts-ignore
2935
+ const VALUELIST_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2936
+ 'Value': xml_js.makeArrayPusher(xsd_js.readString),
2937
+ });
3099
2938
 
3100
- /***
3101
- * @typedef {'postrender'|'movestart'|'moveend'|'loadstart'|'loadend'} Types
2939
+ /**
2940
+ * @const
2941
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3102
2942
  */
2943
+ // @ts-ignore
2944
+ const FILTER_CAPABILITIES_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2945
+ 'Conformance': xml_js.makeObjectPropertySetter(readConformance),
2946
+ 'Id_Capabilities': xml_js.makeObjectPropertySetter(readId_Capabilities),
2947
+ 'Scalar_Capabilities': xml_js.makeObjectPropertySetter(readScalarCapabilities),
2948
+ 'Spatial_Capabilities': xml_js.makeObjectPropertySetter(readSpatialCapabilities),
2949
+ 'Temporal_Capabilities': xml_js.makeObjectPropertySetter(readTemporalCapabilities),
2950
+ 'Functions': xml_js.makeObjectPropertySetter(readFunctions),
2951
+ });
3103
2952
 
3104
2953
  /**
3105
- * @module ol/Overlay
2954
+ * @const
2955
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3106
2956
  */
2957
+ // @ts-ignore
2958
+ const CONFORMANCE_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2959
+ 'Constraint': xml_js.makeObjectPropertyPusher(readNamedConstraint),
2960
+ });
3107
2961
 
3108
2962
  /**
3109
- * @typedef {'bottom-left' | 'bottom-center' | 'bottom-right' | 'center-left' | 'center-center' | 'center-right' | 'top-left' | 'top-center' | 'top-right'} Positioning
3110
- * The overlay position: `'bottom-left'`, `'bottom-center'`, `'bottom-right'`,
3111
- * `'center-left'`, `'center-center'`, `'center-right'`, `'top-left'`,
3112
- * `'top-center'`, or `'top-right'`.
2963
+ * @const
2964
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3113
2965
  */
2966
+ // @ts-ignore
2967
+ const ID_CAPABILITIES_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2968
+ 'ResourceIdentifier': xml_js.makeObjectPropertySetter(readNamedResourceIdentifier),
2969
+ });
3114
2970
 
3115
2971
  /**
3116
- * @typedef {Object} Options
3117
- * @property {number|string} [id] Set the overlay id. The overlay id can be used
3118
- * with the {@link module:ol/Map~Map#getOverlayById} method.
3119
- * @property {HTMLElement} [element] The overlay element.
3120
- * @property {Array<number>} [offset=[0, 0]] Offsets in pixels used when positioning
3121
- * the overlay. The first element in the
3122
- * array is the horizontal offset. A positive value shifts the overlay right.
3123
- * The second element in the array is the vertical offset. A positive value
3124
- * shifts the overlay down.
3125
- * @property {import("./coordinate.js").Coordinate} [position] The overlay position
3126
- * in map projection.
3127
- * @property {Positioning} [positioning='top-left'] Defines how
3128
- * the overlay is actually positioned with respect to its `position` property.
3129
- * Possible values are `'bottom-left'`, `'bottom-center'`, `'bottom-right'`,
3130
- * `'center-left'`, `'center-center'`, `'center-right'`, `'top-left'`,
3131
- * `'top-center'`, and `'top-right'`.
3132
- * @property {boolean} [stopEvent=true] Whether event propagation to the map
3133
- * viewport should be stopped. If `true` the overlay is placed in the same
3134
- * container as that of the controls (CSS class name
3135
- * `ol-overlaycontainer-stopevent`); if `false` it is placed in the container
3136
- * with CSS class name specified by the `className` property.
3137
- * @property {boolean} [insertFirst=true] Whether the overlay is inserted first
3138
- * in the overlay container, or appended. If the overlay is placed in the same
3139
- * container as that of the controls (see the `stopEvent` option) you will
3140
- * probably set `insertFirst` to `true` so the overlay is displayed below the
3141
- * controls.
3142
- * @property {PanIntoViewOptions|boolean} [autoPan=false] Pan the map when calling
3143
- * `setPosition`, so that the overlay is entirely visible in the current viewport.
3144
- * @property {string} [className='ol-overlay-container ol-selectable'] CSS class
3145
- * name.
2972
+ * @const
2973
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3146
2974
  */
2975
+ // @ts-ignore
2976
+ const SCALAR_CAPABILITIES_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2977
+ 'LogicalOperators': xml_js.makeObjectPropertySetter(readLogicalOperators),
2978
+ 'ComparisonOperators': xml_js.makeObjectPropertySetter(readComparisonOperators),
2979
+ });
3147
2980
 
3148
2981
  /**
3149
- * @typedef {Object} PanOptions
3150
- * @property {number} [duration=1000] The duration of the animation in
3151
- * milliseconds.
3152
- * @property {function(number):number} [easing] The easing function to use. Can
3153
- * be one from {@link module:ol/easing} or a custom function.
3154
- * Default is {@link module:ol/easing.inAndOut}.
2982
+ * @const
2983
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3155
2984
  */
2985
+ // @ts-ignore
2986
+ const SPATIAL_CAPABILITIES_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2987
+ 'GeometryOperands': xml_js.makeObjectPropertySetter(readGeometryOperands),
2988
+ 'SpatialOperators': xml_js.makeObjectPropertySetter(readSpatialOperators),
2989
+ });
3156
2990
 
3157
2991
  /**
3158
- * @typedef {Object} PanIntoViewOptions
3159
- * @property {PanOptions} [animation={}] The animation parameters for the pan
3160
- * @property {number} [margin=20] The margin (in pixels) between the
3161
- * overlay and the borders of the map when panning into view.
2992
+ * @const
2993
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3162
2994
  */
2995
+ // @ts-ignore
2996
+ const TEMPORAL_CAPABILITIES_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
2997
+ 'TemporalOperands': xml_js.makeObjectPropertySetter(readTemporalOperands),
2998
+ 'TemporalOperators': xml_js.makeObjectPropertySetter(readTemporalOperators),
2999
+ });
3163
3000
 
3164
3001
  /**
3165
- * @enum {string}
3166
- * @protected
3002
+ * @const
3003
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3167
3004
  */
3168
- const Property = {
3169
- ELEMENT: 'element',
3170
- MAP: 'map',
3171
- OFFSET: 'offset',
3172
- POSITION: 'position',
3173
- POSITIONING: 'positioning',
3174
- };
3005
+ // @ts-ignore
3006
+ const FUNCTIONS_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
3007
+ 'Function': xml_js.makeArrayPusher(readNamedFunction),
3008
+ });
3175
3009
 
3176
3010
  /**
3177
- * @typedef {import("./ObjectEventType").Types|'change:element'|'change:map'|'change:offset'|'change:position'|
3178
- * 'change:positioning'} OverlayObjectEventTypes
3011
+ * @const
3012
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3179
3013
  */
3014
+ // @ts-ignore
3015
+ const FUNCTION_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
3016
+ 'Returns': xml_js.makeObjectPropertySetter(xsd_js.readString),
3017
+ 'Arguments': xml_js.makeObjectPropertySetter(readArguments),
3018
+ });
3180
3019
 
3181
- /***
3182
- * @template Return
3183
- * @typedef {import("./Observable").OnSignature<import("./Observable").EventTypes, import("./events/Event.js").default, Return> &
3184
- * import("./Observable").OnSignature<OverlayObjectEventTypes, import("./Object").ObjectEvent, Return> &
3185
- * import("./Observable").CombinedOnSignature<import("./Observable").EventTypes|OverlayObjectEventTypes, Return>} OverlayOnSignature
3020
+ /**
3021
+ * @const
3022
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3186
3023
  */
3024
+ // @ts-ignore
3025
+ const ARGUMENTS_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
3026
+ 'Argument': xml_js.makeArrayPusher(readNamedArgument),
3027
+ });
3187
3028
 
3188
3029
  /**
3189
- * @classdesc
3190
- * An element to be displayed over the map and attached to a single map
3191
- * location. Like {@link module:ol/control/Control~Control}, Overlays are
3192
- * visible widgets. Unlike Controls, they are not in a fixed position on the
3193
- * screen, but are tied to a geographical coordinate, so panning the map will
3194
- * move an Overlay but not a Control.
3195
- *
3196
- * Example:
3197
- *
3198
- * import Overlay from 'ol/Overlay.js';
3199
- *
3200
- * // ...
3201
- * const popup = new Overlay({
3202
- * element: document.getElementById('popup'),
3203
- * });
3204
- * popup.setPosition(coordinate);
3205
- * map.addOverlay(popup);
3206
- *
3207
- * @api
3030
+ * @const
3031
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3208
3032
  */
3209
- class Overlay extends BaseObject$1 {
3210
- /**
3211
- * @param {Options} options Overlay options.
3212
- */
3213
- constructor(options) {
3214
- super();
3215
-
3216
- /***
3217
- * @type {OverlayOnSignature<import("./events").EventsKey>}
3218
- */
3219
- this.on;
3220
-
3221
- /***
3222
- * @type {OverlayOnSignature<import("./events").EventsKey>}
3223
- */
3224
- this.once;
3225
-
3226
- /***
3227
- * @type {OverlayOnSignature<void>}
3228
- */
3229
- this.un;
3230
-
3231
- /**
3232
- * @protected
3233
- * @type {Options}
3234
- */
3235
- this.options = options;
3236
-
3237
- /**
3238
- * @protected
3239
- * @type {number|string|undefined}
3240
- */
3241
- this.id = options.id;
3242
-
3243
- /**
3244
- * @protected
3245
- * @type {boolean}
3246
- */
3247
- this.insertFirst =
3248
- options.insertFirst !== undefined ? options.insertFirst : true;
3249
-
3250
- /**
3251
- * @protected
3252
- * @type {boolean}
3253
- */
3254
- this.stopEvent = options.stopEvent !== undefined ? options.stopEvent : true;
3255
-
3256
- /**
3257
- * @protected
3258
- * @type {HTMLElement}
3259
- */
3260
- this.element = document.createElement('div');
3261
- this.element.className =
3262
- options.className !== undefined
3263
- ? options.className
3264
- : 'ol-overlay-container ' + CLASS_SELECTABLE;
3265
- this.element.style.position = 'absolute';
3266
- this.element.style.pointerEvents = 'auto';
3267
-
3268
- /**
3269
- * @protected
3270
- * @type {PanIntoViewOptions|undefined}
3271
- */
3272
- this.autoPan = options.autoPan === true ? {} : options.autoPan || undefined;
3273
-
3274
- /**
3275
- * @protected
3276
- * @type {{transform_: string,
3277
- * visible: boolean}}
3278
- */
3279
- this.rendered = {
3280
- transform_: '',
3281
- visible: true,
3282
- };
3283
-
3284
- /**
3285
- * @protected
3286
- * @type {?import("./events.js").EventsKey}
3287
- */
3288
- this.mapPostrenderListenerKey = null;
3289
-
3290
- this.addChangeListener(Property.ELEMENT, this.handleElementChanged);
3291
- this.addChangeListener(Property.MAP, this.handleMapChanged);
3292
- this.addChangeListener(Property.OFFSET, this.handleOffsetChanged);
3293
- this.addChangeListener(Property.POSITION, this.handlePositionChanged);
3294
- this.addChangeListener(Property.POSITIONING, this.handlePositioningChanged);
3295
-
3296
- if (options.element !== undefined) {
3297
- this.setElement(options.element);
3298
- }
3299
-
3300
- this.setOffset(options.offset !== undefined ? options.offset : [0, 0]);
3301
-
3302
- this.setPositioning(options.positioning || 'top-left');
3303
-
3304
- if (options.position !== undefined) {
3305
- this.setPosition(options.position);
3306
- }
3307
- }
3308
-
3309
- /**
3310
- * Get the DOM element of this overlay.
3311
- * @return {HTMLElement|undefined} The Element containing the overlay.
3312
- * @observable
3313
- * @api
3314
- */
3315
- getElement() {
3316
- return /** @type {HTMLElement|undefined} */ (this.get(Property.ELEMENT));
3317
- }
3318
-
3319
- /**
3320
- * Get the overlay identifier which is set on constructor.
3321
- * @return {number|string|undefined} Id.
3322
- * @api
3323
- */
3324
- getId() {
3325
- return this.id;
3326
- }
3327
-
3328
- /**
3329
- * Get the map associated with this overlay.
3330
- * @return {import("./Map.js").default|null} The map that the
3331
- * overlay is part of.
3332
- * @observable
3333
- * @api
3334
- */
3335
- getMap() {
3336
- return /** @type {import("./Map.js").default|null} */ (
3337
- this.get(Property.MAP) || null
3338
- );
3339
- }
3033
+ // @ts-ignore
3034
+ const ARGUMENT_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
3035
+ 'Type': xml_js.makeObjectPropertySetter(xsd_js.readString),
3036
+ });
3340
3037
 
3341
- /**
3342
- * Get the offset of this overlay.
3343
- * @return {Array<number>} The offset.
3344
- * @observable
3345
- * @api
3346
- */
3347
- getOffset() {
3348
- return /** @type {Array<number>} */ (this.get(Property.OFFSET));
3349
- }
3038
+ /**
3039
+ * @const
3040
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3041
+ */
3042
+ // @ts-ignore
3043
+ const LOGICAL_OPERATORS_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
3044
+ 'LogicalOperator': xml_js.makeArrayPusher(readNamedOnly),
3045
+ });
3350
3046
 
3351
- /**
3352
- * Get the current position of this overlay.
3353
- * @return {import("./coordinate.js").Coordinate|undefined} The spatial point that the overlay is
3354
- * anchored at.
3355
- * @observable
3356
- * @api
3357
- */
3358
- getPosition() {
3359
- return /** @type {import("./coordinate.js").Coordinate|undefined} */ (
3360
- this.get(Property.POSITION)
3361
- );
3362
- }
3047
+ /**
3048
+ * @const
3049
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3050
+ */
3051
+ // @ts-ignore
3052
+ const COMPARISON_OPERATORS_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
3053
+ 'ComparisonOperator': xml_js.makeArrayPusher(readNamedOnly),
3054
+ });
3363
3055
 
3364
- /**
3365
- * Get the current positioning of this overlay.
3366
- * @return {Positioning} How the overlay is positioned
3367
- * relative to its point on the map.
3368
- * @observable
3369
- * @api
3370
- */
3371
- getPositioning() {
3372
- return /** @type {Positioning} */ (this.get(Property.POSITIONING));
3373
- }
3056
+ /**
3057
+ * @const
3058
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3059
+ */
3060
+ // @ts-ignore
3061
+ const GEOMETRY_OPERANDS_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
3062
+ 'GeometryOperand': xml_js.makeArrayPusher(readNamedOnly),
3063
+ });
3374
3064
 
3375
- /**
3376
- * @protected
3377
- */
3378
- handleElementChanged() {
3379
- removeChildren(this.element);
3380
- const element = this.getElement();
3381
- if (element) {
3382
- this.element.appendChild(element);
3383
- }
3384
- }
3065
+ /**
3066
+ * @const
3067
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3068
+ */
3069
+ // @ts-ignore
3070
+ const SPATIAL_OPERATORS_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
3071
+ 'SpatialOperator': xml_js.makeArrayPusher(readNamedOnly),
3072
+ });
3385
3073
 
3386
- /**
3387
- * @protected
3388
- */
3389
- handleMapChanged() {
3390
- if (this.mapPostrenderListenerKey) {
3391
- removeNode(this.element);
3392
- unlistenByKey(this.mapPostrenderListenerKey);
3393
- this.mapPostrenderListenerKey = null;
3394
- }
3395
- const map = this.getMap();
3396
- if (map) {
3397
- this.mapPostrenderListenerKey = listen(
3398
- map,
3399
- MapEventType.POSTRENDER,
3400
- this.render,
3401
- this
3402
- );
3403
- this.updatePixelPosition();
3404
- const container = this.stopEvent
3405
- ? map.getOverlayContainerStopEvent()
3406
- : map.getOverlayContainer();
3407
- if (this.insertFirst) {
3408
- container.insertBefore(this.element, container.childNodes[0] || null);
3409
- } else {
3410
- container.appendChild(this.element);
3411
- }
3412
- this.performAutoPan();
3413
- }
3414
- }
3074
+ /**
3075
+ * @const
3076
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3077
+ */
3078
+ // @ts-ignore
3079
+ const TEMPORAL_OPERANDS_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
3080
+ 'TemporalOperand': xml_js.makeArrayPusher(readNamedOnly),
3081
+ });
3415
3082
 
3416
- /**
3417
- * @protected
3418
- */
3419
- render() {
3420
- this.updatePixelPosition();
3421
- }
3083
+ /**
3084
+ * @const
3085
+ * @type {Object<string, Object<string, import("ol/xml.js").Parser>>}
3086
+ */
3087
+ // @ts-ignore
3088
+ const TEMPORAL_OPERATORS_PARSERS = xml_js.makeStructureNS(NAMESPACE_URIS, {
3089
+ 'TemporalOperator': xml_js.makeArrayPusher(readNamedOnly),
3090
+ });
3422
3091
 
3423
- /**
3424
- * @protected
3425
- */
3426
- handleOffsetChanged() {
3427
- this.updatePixelPosition();
3428
- }
3092
+ /**
3093
+ * @param {Element} node Node.
3094
+ * @param {Array<*>} objectStack Object stack.
3095
+ * @return {Object|undefined} Service Identification object.
3096
+ */
3097
+ function readServiceIdentification(node, objectStack) {
3098
+ return xml_js.pushParseAndPop({}, SERVICE_IDENTIFICATION_PARSERS, node, objectStack);
3099
+ }
3429
3100
 
3430
- /**
3431
- * @protected
3432
- */
3433
- handlePositionChanged() {
3434
- this.updatePixelPosition();
3435
- this.performAutoPan();
3436
- }
3101
+ /**
3102
+ * @param {Element} node Node.
3103
+ * @param {Array<*>} objectStack Object stack.
3104
+ * @return {Object|undefined} Service Provider object.
3105
+ */
3106
+ function readServiceProvider(node, objectStack) {
3107
+ return xml_js.pushParseAndPop({}, SERVICE_PROVIDER_PARSERS, node, objectStack);
3108
+ }
3437
3109
 
3438
- /**
3439
- * @protected
3440
- */
3441
- handlePositioningChanged() {
3442
- this.updatePixelPosition();
3443
- }
3110
+ /**
3111
+ * @param {Element} node Node.
3112
+ * @param {Array<*>} objectStack Object stack.
3113
+ * @return {Object|undefined} Operations Metadata object.
3114
+ */
3115
+ function readOperationsMetadata(node, objectStack) {
3116
+ return xml_js.pushParseAndPop({}, OPERATIONS_METADATA_PARSERS, node, objectStack);
3117
+ }
3444
3118
 
3445
- /**
3446
- * Set the DOM element to be associated with this overlay.
3447
- * @param {HTMLElement|undefined} element The Element containing the overlay.
3448
- * @observable
3449
- * @api
3450
- */
3451
- setElement(element) {
3452
- this.set(Property.ELEMENT, element);
3453
- }
3119
+ /**
3120
+ * @param {Element} node Node.
3121
+ * @param {Array<*>} objectStack Object stack.
3122
+ * @return {Object|undefined} FeatureType list.
3123
+ */
3124
+ function readFeatureTypeList(node, objectStack) {
3125
+ return xml_js.pushParseAndPop([], FEATURE_TYPE_LIST_PARSERS, node, objectStack);
3126
+ }
3454
3127
 
3455
- /**
3456
- * Set the map to be associated with this overlay.
3457
- * @param {import("./Map.js").default|null} map The map that the
3458
- * overlay is part of. Pass `null` to just remove the overlay from the current map.
3459
- * @observable
3460
- * @api
3461
- */
3462
- setMap(map) {
3463
- this.set(Property.MAP, map);
3464
- }
3128
+ /**
3129
+ * @param {Element} node Node.
3130
+ * @param {Array<*>} objectStack Object stack.
3131
+ * @return {Object|undefined} Serrvice contact object.
3132
+ */
3133
+ function readServiceContact(node, objectStack) {
3134
+ return xml_js.pushParseAndPop({}, SERVICE_CONTACT_PARSERS, node, objectStack);
3135
+ }
3465
3136
 
3466
- /**
3467
- * Set the offset for this overlay.
3468
- * @param {Array<number>} offset Offset.
3469
- * @observable
3470
- * @api
3471
- */
3472
- setOffset(offset) {
3473
- this.set(Property.OFFSET, offset);
3474
- }
3137
+ /**
3138
+ * @param {Element} node Node.
3139
+ * @param {Array<*>} objectStack Object stack.
3140
+ * @return {Object|undefined} Contact info object.
3141
+ */
3142
+ function readContactInfo(node, objectStack) {
3143
+ return xml_js.pushParseAndPop({}, CONTACT_INFO_PARSERS, node, objectStack);
3144
+ }
3475
3145
 
3476
- /**
3477
- * Set the position for this overlay. If the position is `undefined` the
3478
- * overlay is hidden.
3479
- * @param {import("./coordinate.js").Coordinate|undefined} position The spatial point that the overlay
3480
- * is anchored at.
3481
- * @observable
3482
- * @api
3483
- */
3484
- setPosition(position) {
3485
- this.set(Property.POSITION, position);
3486
- }
3146
+ /**
3147
+ * @param {Element} node Node.
3148
+ * @param {Array<*>} objectStack Object stack.
3149
+ * @return {Object|undefined} Contact Phone object.
3150
+ */
3151
+ function readPhone(node, objectStack) {
3152
+ return xml_js.pushParseAndPop({}, PHONE_PARSERS, node, objectStack);
3153
+ }
3487
3154
 
3488
- /**
3489
- * Pan the map so that the overlay is entirely visible in the current viewport
3490
- * (if necessary) using the configured autoPan parameters
3491
- * @protected
3492
- */
3493
- performAutoPan() {
3494
- if (this.autoPan) {
3495
- this.panIntoView(this.autoPan);
3496
- }
3497
- }
3155
+ /**
3156
+ * @param {Element} node Node.
3157
+ * @param {Array<*>} objectStack Object stack.
3158
+ * @return {Object|undefined} Contact address object.
3159
+ */
3160
+ function readAddress(node, objectStack) {
3161
+ return xml_js.pushParseAndPop({}, ADDRESS_PARSERS, node, objectStack);
3162
+ }
3498
3163
 
3499
- /**
3500
- * Pan the map so that the overlay is entirely visible in the current viewport
3501
- * (if necessary).
3502
- * @param {PanIntoViewOptions} [panIntoViewOptions] Options for the pan action
3503
- * @api
3504
- */
3505
- panIntoView(panIntoViewOptions) {
3506
- const map = this.getMap();
3164
+ /**
3165
+ * @param {Element} node Node.
3166
+ * @param {Array<*>} objectStack Object stack.
3167
+ * @return {Object|undefined} DCP object.
3168
+ */
3169
+ function readDCP(node, objectStack) {
3170
+ return xml_js.pushParseAndPop({}, DCP_PARSERS, node, objectStack);
3171
+ }
3507
3172
 
3508
- if (!map || !map.getTargetElement() || !this.get(Property.POSITION)) {
3509
- return;
3510
- }
3173
+ /**
3174
+ * @param {Element} node Node.
3175
+ * @param {Array<*>} objectStack Object stack.
3176
+ * @return {Object|undefined} Operation object.
3177
+ */
3178
+ function readOperation(node, objectStack) {
3179
+ return xml_js.pushParseAndPop({}, OPERATION_PARSERS, node, objectStack);
3180
+ }
3511
3181
 
3512
- const mapRect = this.getRect(map.getTargetElement(), map.getSize());
3513
- const element = this.getElement();
3514
- const overlayRect = this.getRect(element, [
3515
- outerWidth(element),
3516
- outerHeight(element),
3517
- ]);
3518
-
3519
- panIntoViewOptions = panIntoViewOptions || {};
3520
-
3521
- const myMargin =
3522
- panIntoViewOptions.margin === undefined ? 20 : panIntoViewOptions.margin;
3523
- if (!containsExtent(mapRect, overlayRect)) {
3524
- // the overlay is not completely inside the viewport, so pan the map
3525
- const offsetLeft = overlayRect[0] - mapRect[0];
3526
- const offsetRight = mapRect[2] - overlayRect[2];
3527
- const offsetTop = overlayRect[1] - mapRect[1];
3528
- const offsetBottom = mapRect[3] - overlayRect[3];
3529
-
3530
- const delta = [0, 0];
3531
- if (offsetLeft < 0) {
3532
- // move map to the left
3533
- delta[0] = offsetLeft - myMargin;
3534
- } else if (offsetRight < 0) {
3535
- // move map to the right
3536
- delta[0] = Math.abs(offsetRight) + myMargin;
3537
- }
3538
- if (offsetTop < 0) {
3539
- // move map up
3540
- delta[1] = offsetTop - myMargin;
3541
- } else if (offsetBottom < 0) {
3542
- // move map down
3543
- delta[1] = Math.abs(offsetBottom) + myMargin;
3544
- }
3182
+ /**
3183
+ * @param {Element} node Node.
3184
+ * @param {Array<*>} objectStack Object stack.
3185
+ * @return {Object|undefined} Parameter object.
3186
+ */
3187
+ function readParameter(node, objectStack) {
3188
+ return xml_js.pushParseAndPop({}, PARAMETER_PARSERS, node, objectStack);
3189
+ }
3545
3190
 
3546
- if (delta[0] !== 0 || delta[1] !== 0) {
3547
- const center = /** @type {import("./coordinate.js").Coordinate} */ (
3548
- map.getView().getCenterInternal()
3549
- );
3550
- const centerPx = map.getPixelFromCoordinateInternal(center);
3551
- if (!centerPx) {
3552
- return;
3553
- }
3554
- const newCenterPx = [centerPx[0] + delta[0], centerPx[1] + delta[1]];
3191
+ /**
3192
+ * @param {Element} node Node.
3193
+ * @param {Array<*>} objectStack Object stack.
3194
+ * @return {Object|undefined} Constraint object.
3195
+ */
3196
+ function readConstraint(node, objectStack) {
3197
+ return xml_js.pushParseAndPop({}, CONSTRAINT_PARSERS, node, objectStack);
3198
+ }
3555
3199
 
3556
- const panOptions = panIntoViewOptions.animation || {};
3557
- map.getView().animateInternal({
3558
- center: map.getCoordinateFromPixelInternal(newCenterPx),
3559
- duration: panOptions.duration,
3560
- easing: panOptions.easing,
3561
- });
3562
- }
3563
- }
3564
- }
3200
+ /**
3201
+ * @param {Element} node Node.
3202
+ * @param {Array<*>} objectStack Object stack.
3203
+ * @return {Object|undefined} HTTP object.
3204
+ */
3205
+ function readHTTP(node, objectStack) {
3206
+ return xml_js.pushParseAndPop({}, HTTP_PARSERS, node, objectStack);
3207
+ }
3565
3208
 
3566
- /**
3567
- * Get the extent of an element relative to the document
3568
- * @param {HTMLElement} element The element.
3569
- * @param {import("./size.js").Size} size The size of the element.
3570
- * @return {import("./extent.js").Extent} The extent.
3571
- * @protected
3572
- */
3573
- getRect(element, size) {
3574
- const box = element.getBoundingClientRect();
3575
- const offsetX = box.left + window.pageXOffset;
3576
- const offsetY = box.top + window.pageYOffset;
3577
- return [offsetX, offsetY, offsetX + size[0], offsetY + size[1]];
3209
+ /**
3210
+ * @param {Element} node Node.
3211
+ * @param {Array<*>} objectStack Object stack.
3212
+ * @return {Object|undefined} Named operation object.
3213
+ */
3214
+ function readNamedOperation(node, objectStack) {
3215
+ const operation = readOperation(node, objectStack);
3216
+ if (operation) {
3217
+ operation['name'] = node.getAttribute('name');
3218
+ return operation;
3578
3219
  }
3220
+ return undefined;
3221
+ }
3579
3222
 
3580
- /**
3581
- * Set the positioning for this overlay.
3582
- * @param {Positioning} positioning how the overlay is
3583
- * positioned relative to its point on the map.
3584
- * @observable
3585
- * @api
3586
- */
3587
- setPositioning(positioning) {
3588
- this.set(Property.POSITIONING, positioning);
3223
+ /**
3224
+ * @param {Element} node Node.
3225
+ * @param {Array<*>} objectStack Object stack.
3226
+ * @return {Object|undefined} Named Function object.
3227
+ */
3228
+ function readNamedFunction(node, objectStack) {
3229
+ const func = readFunction(node, objectStack);
3230
+ if (func) {
3231
+ func['name'] = node.getAttribute('name');
3232
+ return func;
3589
3233
  }
3234
+ return undefined;
3235
+ }
3590
3236
 
3591
- /**
3592
- * Modify the visibility of the element.
3593
- * @param {boolean} visible Element visibility.
3594
- * @protected
3595
- */
3596
- setVisible(visible) {
3597
- if (this.rendered.visible !== visible) {
3598
- this.element.style.display = visible ? '' : 'none';
3599
- this.rendered.visible = visible;
3600
- }
3237
+ /**
3238
+ * @param {Element} node Node.
3239
+ * @param {Array<*>} objectStack Object stack.
3240
+ * @return {Object|undefined} Named argument object.
3241
+ */
3242
+ function readNamedArgument(node, objectStack) {
3243
+ const argument = readArgument(node, objectStack);
3244
+ if (argument) {
3245
+ argument['name'] = node.getAttribute('name');
3246
+ return argument;
3601
3247
  }
3248
+ return undefined;
3249
+ }
3602
3250
 
3603
- /**
3604
- * Update pixel position.
3605
- * @protected
3606
- */
3607
- updatePixelPosition() {
3608
- const map = this.getMap();
3609
- const position = this.getPosition();
3610
- if (!map || !map.isRendered() || !position) {
3611
- this.setVisible(false);
3612
- return;
3613
- }
3614
-
3615
- const pixel = map.getPixelFromCoordinate(position);
3616
- const mapSize = map.getSize();
3617
- this.updateRenderedPosition(pixel, mapSize);
3251
+ /**
3252
+ * @param {Element} node Node.
3253
+ * @param {Array<*>} objectStack Object stack.
3254
+ * @return {Object|undefined} Named Parameter object.
3255
+ */
3256
+ function readNamedParameter(node, objectStack) {
3257
+ const parameter = readParameter(node, objectStack);
3258
+ if (parameter) {
3259
+ parameter['name'] = node.getAttribute('name');
3260
+ return parameter;
3618
3261
  }
3262
+ return undefined;
3263
+ }
3619
3264
 
3620
- /**
3621
- * @param {import("./pixel.js").Pixel} pixel The pixel location.
3622
- * @param {import("./size.js").Size|undefined} mapSize The map size.
3623
- * @protected
3624
- */
3625
- updateRenderedPosition(pixel, mapSize) {
3626
- const style = this.element.style;
3627
- const offset = this.getOffset();
3628
-
3629
- const positioning = this.getPositioning();
3630
-
3631
- this.setVisible(true);
3632
-
3633
- const x = Math.round(pixel[0] + offset[0]) + 'px';
3634
- const y = Math.round(pixel[1] + offset[1]) + 'px';
3635
- let posX = '0%';
3636
- let posY = '0%';
3637
- if (
3638
- positioning == 'bottom-right' ||
3639
- positioning == 'center-right' ||
3640
- positioning == 'top-right'
3641
- ) {
3642
- posX = '-100%';
3643
- } else if (
3644
- positioning == 'bottom-center' ||
3645
- positioning == 'center-center' ||
3646
- positioning == 'top-center'
3647
- ) {
3648
- posX = '-50%';
3649
- }
3650
- if (
3651
- positioning == 'bottom-left' ||
3652
- positioning == 'bottom-center' ||
3653
- positioning == 'bottom-right'
3654
- ) {
3655
- posY = '-100%';
3656
- } else if (
3657
- positioning == 'center-left' ||
3658
- positioning == 'center-center' ||
3659
- positioning == 'center-right'
3660
- ) {
3661
- posY = '-50%';
3662
- }
3663
- const transform = `translate(${posX}, ${posY}) translate(${x}, ${y})`;
3664
- if (this.rendered.transform_ != transform) {
3665
- this.rendered.transform_ = transform;
3666
- style.transform = transform;
3667
- }
3265
+ /**
3266
+ * @param {Element} node Node.
3267
+ * @param {Array<*>} objectStack Object stack.
3268
+ * @return {Object|undefined} Named Constraint object.
3269
+ */
3270
+ function readNamedConstraint(node, objectStack) {
3271
+ const constraint = readConstraint(node, objectStack);
3272
+ if (constraint) {
3273
+ constraint['name'] = node.getAttribute('name');
3274
+ return constraint;
3668
3275
  }
3276
+ return undefined;
3277
+ }
3669
3278
 
3670
- /**
3671
- * returns the options this Overlay has been created with
3672
- * @return {Options} overlay options
3673
- */
3674
- getOptions() {
3675
- return this.options;
3676
- }
3279
+ /**
3280
+ * @param {Element} node Node.
3281
+ * @return {string|undefined} Node name attribute string.
3282
+ */
3283
+ function readNamedOnly(node) {
3284
+ return node.getAttribute('name') || undefined;
3677
3285
  }
3678
3286
 
3679
- var Overlay$1 = Overlay;
3287
+ /**
3288
+ * @param {Element} node Node.
3289
+ * @return {Object|undefined} Named Resource Identifier object.
3290
+ */
3291
+ function readNamedResourceIdentifier(node) {
3292
+ return {
3293
+ name: node.getAttribute('name'),
3294
+ };
3295
+ }
3680
3296
 
3681
- function createElement(tagName, attrs = {}, ...children) {
3682
- if (typeof tagName === 'function')
3683
- return tagName(attrs, children);
3684
- const elem = tagName === null
3685
- ? new DocumentFragment()
3686
- : document.createElement(tagName);
3687
- Object.entries(attrs || {}).forEach(([name, value]) => {
3688
- if (typeof value !== undefined &&
3689
- value !== null &&
3690
- value !== undefined) {
3691
- if (name.startsWith('on') && name.toLowerCase() in window)
3692
- elem.addEventListener(name.toLowerCase().substr(2), value);
3693
- else {
3694
- if (name === 'className')
3695
- elem.setAttribute('class', value.toString());
3696
- else if (name === 'htmlFor')
3697
- elem.setAttribute('for', value.toString());
3698
- else
3699
- elem.setAttribute(name, value.toString());
3700
- }
3701
- }
3702
- });
3703
- for (const child of children) {
3704
- if (!child)
3705
- continue;
3706
- if (Array.isArray(child))
3707
- elem.append(...child);
3708
- else {
3709
- if (child.nodeType === undefined)
3710
- elem.innerHTML += child;
3711
- else
3712
- elem.appendChild(child);
3713
- }
3714
- }
3715
- return elem;
3297
+ /**
3298
+ * @param {Element} node Node.
3299
+ * @param {Array<*>} objectStack Object stack.
3300
+ * @return {Object|undefined} WGS84 BoundingBox resource object.
3301
+ */
3302
+ function readWGS84BoundingBox(node, objectStack) {
3303
+ return xml_js.pushParseAndPop({}, WGS84_BOUNDINGBOX_PARSERS, node, objectStack);
3716
3304
  }
3717
3305
 
3718
- 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";
3306
+ /**
3307
+ * @param {Element} node Node.
3308
+ * @param {Array<*>} objectStack Object stack.
3309
+ * @return {Array<string>|undefined} Keyword list.
3310
+ */
3311
+ function readKeywordList(node, objectStack) {
3312
+ return xml_js.pushParseAndPop([], KEYWORDLIST_PARSERS, node, objectStack);
3313
+ }
3719
3314
 
3720
- 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";
3315
+ /**
3316
+ * @param {Element} node Node.
3317
+ * @param {Array<*>} objectStack Object stack.
3318
+ * @return {Array<string>|undefined} Value list.
3319
+ */
3320
+ function readValueList(node, objectStack) {
3321
+ return xml_js.pushParseAndPop([], VALUELIST_PARSERS, node, objectStack);
3322
+ }
3721
3323
 
3722
- 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";
3324
+ /**
3325
+ * @param {Element} node Node.
3326
+ * @param {Array<*>} objectStack Object stack.
3327
+ * @return {Object|undefined} FeatureTyoe object.
3328
+ */
3329
+ function readFeatureType(node, objectStack) {
3330
+ return xml_js.pushParseAndPop({}, FEATURE_TYPE_PARSERS, node, objectStack);
3331
+ }
3723
3332
 
3724
- 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";
3333
+ /**
3334
+ * @param {Element} node Node.
3335
+ * @param {Array<*>} objectStack Object stack.
3336
+ * @return {Object|undefined} FilterCapabilities object.
3337
+ */
3338
+ function readFilter_Capabilities(node, objectStack) {
3339
+ return xml_js.pushParseAndPop({}, FILTER_CAPABILITIES_PARSERS, node, objectStack);
3340
+ }
3725
3341
 
3726
- /**
3727
- * Removes in the DOM the class of the tools
3728
- * @private
3729
- */
3730
- const resetStateButtons = () => {
3731
- const activeBtn = document.querySelector('.ol-wfst--tools-control-btn.wfst--active');
3732
- if (activeBtn) {
3733
- activeBtn.classList.remove('wfst--active');
3734
- }
3735
- };
3736
- const activateModeButtons = () => {
3737
- const btn = document.querySelector('.ol-wfst--tools-control-btn-edit');
3738
- if (btn) {
3739
- btn.classList.add('wfst--active');
3740
- }
3741
- };
3742
- const activateDrawButton = () => {
3743
- const btn = document.querySelector('.ol-wfst--tools-control-btn-draw');
3744
- if (btn) {
3745
- btn.classList.add('wfst--active');
3746
- }
3747
- };
3748
- class LayersControl extends Observable$1 {
3749
- _uploads;
3750
- _uploadFormats;
3751
- constructor(uploads, uploadFormats) {
3752
- super();
3753
- this._uploads = uploads;
3754
- this._uploadFormats = uploadFormats;
3755
- }
3756
- /**
3757
- *
3758
- * @param layer
3759
- * @public
3760
- */
3761
- addLayerEl(layer) {
3762
- const container = document.querySelector('.wfst--tools-control--select-layers');
3763
- const layerName = layer.get(BaseLayerProperty.NAME);
3764
- const checked = layer === getActiveLayerToInsertEls() ? { checked: 'checked' } : {};
3765
- 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) }));
3766
- const layerDom = (createElement("div", { className: `wfst--layer-control
3767
- ${layer.getVisible() ? 'ol-wfst--visible-on' : ''}
3768
- ${layer === getActiveLayerToInsertEls()
3769
- ? 'ol-wfst--selected-on'
3770
- : ''}`, "data-layer": layerName },
3771
- createElement("div", { className: "ol-wfst--tools-control-visible" },
3772
- createElement("span", { className: "ol-wfst--tools-control-visible-btn ol-wfst--visible-btn-on", title: I18N.labels.toggleVisibility, onclick: (evt) => this._visibilityClickHandler(evt) },
3773
- createElement("img", { src: img$3 })),
3774
- createElement("span", { className: "ol-wfst--tools-control-visible-btn ol-wfst--visible-btn-off", title: I18N.labels.toggleVisibility, onclick: (evt) => this._visibilityClickHandler(evt) },
3775
- createElement("img", { src: img$2 }))),
3776
- createElement("label", { htmlFor: `wfst--${layerName}` },
3777
- input,
3778
- createElement("span", { title: layer.getDescribeFeatureType()._parsed.geomType }, layer.get(BaseLayerProperty.LABEL)))));
3779
- container.appendChild(layerDom);
3780
- if (layer === getActiveLayerToInsertEls()) {
3781
- input.dispatchEvent(new Event('change'));
3782
- }
3783
- return layerDom;
3784
- }
3785
- /**
3786
- * Update geom Types availibles to select for this layer
3787
- *
3788
- * @param layerName
3789
- * @param geomDrawTypeSelected
3790
- * @private
3791
- */
3792
- _changeStateSelect(layer, geomDrawTypeSelected = null) {
3793
- /**
3794
- * Set the geometry type in the select according to the geometry of
3795
- * the layer in the geoserver and disable what does not correspond.
3796
- *
3797
- * @param value
3798
- * @param options
3799
- * @private
3800
- */
3801
- const setSelectState = (value, options) => {
3802
- Array.from(selectDraw.options).forEach((option) => {
3803
- option.selected = option.value === value ? true : false;
3804
- option.disabled =
3805
- options === 'all'
3806
- ? false
3807
- : options.includes(option.value)
3808
- ? false
3809
- : true;
3810
- option.title = option.disabled
3811
- ? I18N.labels.geomTypeNotSupported
3812
- : '';
3813
- });
3814
- };
3815
- const selectDraw = document.querySelector('.wfst--tools-control--select-draw');
3816
- let drawType;
3817
- if (selectDraw) {
3818
- const geomLayer = layer.getDescribeFeatureType()._parsed.geomType;
3819
- if (geomDrawTypeSelected) {
3820
- drawType = selectDraw.value;
3821
- }
3822
- else {
3823
- if (geomLayer === GeometryType.GeometryCollection) {
3824
- drawType = GeometryType.LineString; // Default drawing type for GeometryCollection
3825
- setSelectState(drawType, 'all');
3826
- }
3827
- else if (geomLayer === GeometryType.LinearRing) {
3828
- drawType = GeometryType.LineString; // Default drawing type for GeometryCollection
3829
- setSelectState(drawType, [
3830
- GeometryType.Circle,
3831
- GeometryType.LinearRing,
3832
- GeometryType.Polygon
3833
- ]);
3834
- selectDraw.value = drawType;
3835
- }
3836
- else {
3837
- drawType = geomLayer;
3838
- setSelectState(drawType, [geomLayer]);
3839
- }
3840
- }
3841
- }
3842
- return drawType;
3843
- }
3844
- _visibilityClickHandler(evt) {
3845
- const btn = evt.currentTarget;
3846
- const parentDiv = btn.closest('.wfst--layer-control');
3847
- const layerName = parentDiv.dataset['layer'];
3848
- parentDiv.classList.toggle('ol-wfst--visible-on');
3849
- const layer = getStoredMapLayers()[layerName];
3850
- if (parentDiv.classList.contains('ol-wfst--visible-on')) {
3851
- layer.setVisible(true);
3852
- }
3853
- else {
3854
- layer.setVisible(false);
3855
- }
3856
- }
3857
- _layerChangeHandler(evt, layer) {
3858
- const radioInput = evt.currentTarget;
3859
- const parentDiv = radioInput.closest('.wfst--layer-control');
3860
- // Deselect DOM previous layer
3861
- const selected = document.querySelector('.ol-wfst--selected-on');
3862
- if (selected)
3863
- selected.classList.remove('ol-wfst--selected-on');
3864
- // Select this layer
3865
- parentDiv.classList.add('ol-wfst--selected-on');
3866
- setActiveLayerToInsertEls(layer);
3867
- this._changeStateSelect(layer);
3868
- }
3869
- render() {
3870
- return (createElement(null, null,
3871
- createElement("div", { className: "wfst--tools-control--head" },
3872
- this._uploads && (createElement("div", null,
3873
- createElement("input", { id: "ol-wfst--upload", type: "file", accept: this._uploadFormats, onchange: (evt) => this._uploads.process(evt) }),
3874
- createElement("label", { className: "ol-wfst--tools-control-btn ol-wfst--tools-control-btn-upload", htmlFor: "ol-wfst--upload", title: I18N.labels.uploadToLayer },
3875
- createElement("img", { src: img$5 })))),
3876
- createElement("div", { className: "ol-wfst--tools-control-draw-cnt" },
3877
- createElement("button", { className: "ol-wfst--tools-control-btn ol-wfst--tools-control-btn-draw", type: "button", title: I18N.labels.addElement, onclick: () => {
3878
- this.dispatchEvent('drawMode');
3879
- } },
3880
- createElement("img", { src: img$4 })),
3881
- createElement("select", { title: I18N.labels.selectDrawType, className: "wfst--tools-control--select-draw", onchange: (evt) => {
3882
- const selectedValue = evt.target
3883
- .value;
3884
- this._changeStateSelect(getActiveLayerToInsertEls(), selectedValue);
3885
- this.dispatchEvent('changeGeom');
3886
- } }, [
3887
- GeometryType.Point,
3888
- GeometryType.MultiPoint,
3889
- GeometryType.LineString,
3890
- GeometryType.MultiLineString,
3891
- GeometryType.Polygon,
3892
- GeometryType.MultiPolygon,
3893
- GeometryType.Circle
3894
- ].map((type) => {
3895
- // Show all options, but enable only the accepted ones
3896
- return createElement("option", { value: type }, type);
3897
- })))),
3898
- createElement("div", { className: "wfst--tools-control--select-layers" })));
3899
- }
3342
+ /**
3343
+ * @param {Element} node Node.
3344
+ * @param {Array<*>} objectStack Object stack.
3345
+ * @return {Object|undefined} Conformance object.
3346
+ */
3347
+ function readConformance(node, objectStack) {
3348
+ return xml_js.pushParseAndPop({}, CONFORMANCE_PARSERS, node, objectStack);
3900
3349
  }
3901
3350
 
3902
- let editLayer = new VectorLayer({
3903
- source: new VectorSource(),
3904
- zIndex: 100
3905
- });
3906
- const getEditLayer = () => {
3907
- return editLayer;
3908
- };
3351
+ /**
3352
+ * @param {Element} node Node.
3353
+ * @param {Array<*>} objectStack Object stack.
3354
+ * @return {Object|undefined} Id Capabilities object.
3355
+ */
3356
+ function readId_Capabilities(node, objectStack) {
3357
+ return xml_js.pushParseAndPop({}, ID_CAPABILITIES_PARSERS, node, objectStack);
3358
+ }
3909
3359
 
3910
- // Ol
3911
- class Uploads extends Observable$1 {
3912
- _options;
3913
- // Formats
3914
- _formatWFS;
3915
- _formatGeoJSON;
3916
- _formatKml;
3917
- _xs;
3918
- _processUpload;
3919
- constructor(options) {
3920
- super();
3921
- this._options = options;
3922
- this._processUpload = options.processUpload;
3923
- // Formats
3924
- this._formatWFS = new format.WFS();
3925
- this._formatGeoJSON = new format.GeoJSON();
3926
- this._formatKml = new format.KML({
3927
- extractStyles: false,
3928
- showPointNames: false
3929
- });
3930
- this._xs = new XMLSerializer();
3931
- }
3932
- /**
3933
- * Parse and check geometry of uploaded files
3934
- *
3935
- * @param evt
3936
- * @public
3937
- */
3938
- async process(evt) {
3939
- const map = getMap();
3940
- const view = map.getView();
3941
- const file = evt.target.files[0];
3942
- let features;
3943
- if (!file) {
3944
- return;
3945
- }
3946
- const extension = file.name.split('.').pop().toLowerCase();
3947
- try {
3948
- // If the user uses a custom fucntion...
3949
- if (this._processUpload) {
3950
- features = this._processUpload(file);
3951
- }
3952
- // If the user functions return features, we dont process anything more
3953
- if (!features) {
3954
- const string = await this._fileReader(file);
3955
- if (extension === 'geojson' || extension === 'json') {
3956
- features = this._formatGeoJSON.readFeatures(string, {
3957
- featureProjection: view.getProjection().getCode()
3958
- });
3959
- }
3960
- else if (extension === 'kml') {
3961
- features = this._formatKml.readFeatures(string, {
3962
- featureProjection: view.getProjection().getCode()
3963
- });
3964
- }
3965
- else {
3966
- showError(I18N.errors.badFormat);
3967
- }
3968
- }
3969
- let invalidFeaturesCount = 0;
3970
- let validFeaturesCount = 0;
3971
- const featuresToInsert = [];
3972
- for (let feature of features) {
3973
- // If the geometry doesn't correspond to the layer, try to fixit.
3974
- // If we can't, don't use it
3975
- if (!this._checkGeometry(feature)) {
3976
- feature = this._fixGeometry(feature);
3977
- }
3978
- if (feature) {
3979
- featuresToInsert.push(feature);
3980
- validFeaturesCount++;
3981
- }
3982
- else {
3983
- invalidFeaturesCount++;
3984
- continue;
3985
- }
3986
- }
3987
- if (!validFeaturesCount) {
3988
- showError(I18N.errors.noValidGeometry);
3989
- }
3990
- else {
3991
- resetStateButtons();
3992
- this.dispatchEvent(new VectorSource.VectorSourceEvent('loadedFeatures', null, featuresToInsert));
3993
- const content = `
3994
- ${I18N.labels.validFeatures}: ${validFeaturesCount}<br>
3995
- ${invalidFeaturesCount
3996
- ? `${I18N.labels.invalidFeatures}: ${invalidFeaturesCount}`
3997
- : ''}`;
3998
- this._initModal(content, featuresToInsert);
3999
- }
4000
- // Reset the input to allow another onChange trigger
4001
- evt.target.value = null;
4002
- }
4003
- catch (err) {
4004
- showError(I18N.errors.badFile, err);
4005
- }
4006
- }
4007
- /**
4008
- * Read data file
4009
- * @param file
4010
- * @public
4011
- */
4012
- async _fileReader(file) {
4013
- return new Promise((resolve, reject) => {
4014
- const reader = new FileReader();
4015
- reader.addEventListener('load', async (e) => {
4016
- const fileData = e.target.result;
4017
- resolve(fileData);
4018
- });
4019
- reader.addEventListener('error', (err) => {
4020
- console.error('Error' + err);
4021
- reject();
4022
- });
4023
- reader.readAsText(file);
4024
- });
4025
- }
4026
- /**
4027
- * Attemp to change the geometry feature to the layer
4028
- * @param feature
4029
- * @private
4030
- */
4031
- _fixGeometry(feature) {
4032
- // Geometry of the layer
4033
- const geomTypeLayer = getActiveLayerToInsertEls().getDescribeFeatureType()._parsed
4034
- .geomType;
4035
- const geomTypeFeature = feature.getGeometry().getType();
4036
- let geom$1;
4037
- switch (geomTypeFeature) {
4038
- case GeometryType.Point: {
4039
- if (geomTypeLayer === GeometryType.MultiPoint) {
4040
- const coords = feature.getGeometry().getCoordinates();
4041
- geom$1 = new geom.MultiPoint([coords]);
4042
- }
4043
- break;
4044
- }
4045
- case GeometryType.LineString:
4046
- if (geomTypeLayer === GeometryType.MultiLineString) {
4047
- const coords = feature.getGeometry().getCoordinates();
4048
- geom$1 = new geom.MultiLineString([coords]);
4049
- }
4050
- break;
4051
- case GeometryType.Polygon:
4052
- if (geomTypeLayer === GeometryType.MultiPolygon) {
4053
- const coords = feature.getGeometry().getCoordinates();
4054
- geom$1 = new geom.MultiPolygon([coords]);
4055
- }
4056
- break;
4057
- default:
4058
- geom$1 = null;
4059
- }
4060
- if (!geom$1) {
4061
- return null;
4062
- }
4063
- feature.setGeometry(geom$1);
4064
- return feature;
4065
- }
4066
- /**
4067
- * Check if the feature has the same geometry as the target layer
4068
- * @param feature
4069
- * @private
4070
- */
4071
- _checkGeometry(feature) {
4072
- // Geometry of the layer
4073
- const geomTypeLayer = getActiveLayerToInsertEls().getDescribeFeatureType()._parsed
4074
- .geomType;
4075
- const geomTypeFeature = feature.getGeometry().getType();
4076
- // This geom accepts every type of geometry
4077
- if (geomTypeLayer === GeometryType.GeometryCollection) {
4078
- return true;
4079
- }
4080
- return geomTypeFeature === geomTypeLayer;
4081
- }
4082
- /**
4083
- * Confirm modal before transact to the GeoServer the features in the file
4084
- *
4085
- * @param content
4086
- * @param featuresToInsert
4087
- * @private
4088
- */
4089
- _initModal(content, featuresToInsert) {
4090
- const footer = `
4091
- <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">
4092
- ${I18N.labels.cancel}
4093
- </button>
4094
- <button type="button" class="btn btn-sm btn-primary" data-action="save" data-dismiss="modal">
4095
- ${I18N.labels.upload}
4096
- </button>
4097
- `;
4098
- const modal = new Modal({
4099
- ...this._options.modal,
4100
- header: true,
4101
- headerClose: false,
4102
- title: I18N.labels.uploadFeatures +
4103
- ' ' +
4104
- getActiveLayerToInsertEls().get(BaseLayerProperty.NAME),
4105
- content: content,
4106
- backdrop: 'static',
4107
- footer: footer
4108
- }).show();
4109
- modal.on('dismiss', (modal, event) => {
4110
- // On saving changes
4111
- if (event.target.dataset.action === 'save') {
4112
- this.dispatchEvent(new VectorSource.VectorSourceEvent('addedFeatures', null, featuresToInsert));
4113
- }
4114
- else {
4115
- // On cancel button
4116
- getEditLayer().getSource().clear();
4117
- }
4118
- });
4119
- }
3360
+ /**
3361
+ * @param {Element} node Node.
3362
+ * @param {Array<*>} objectStack Object stack.
3363
+ * @return {Object|undefined} Scalar Capabilities object.
3364
+ */
3365
+ function readScalarCapabilities(node, objectStack) {
3366
+ return xml_js.pushParseAndPop({}, SCALAR_CAPABILITIES_PARSERS, node, objectStack);
4120
3367
  }
4121
3368
 
4122
- /**
4123
- * @param target
4124
- * @param sources
4125
- * @returns
4126
- */
4127
- const deepObjectAssign = (target, ...sources) => {
4128
- sources.forEach((source) => {
4129
- Object.keys(source).forEach((key) => {
4130
- const s_val = source[key];
4131
- const t_val = target[key];
4132
- target[key] =
4133
- t_val &&
4134
- s_val &&
4135
- typeof t_val === 'object' &&
4136
- typeof s_val === 'object' &&
4137
- !Array.isArray(t_val) // Don't merge arrays
4138
- ? deepObjectAssign(t_val, s_val)
4139
- : s_val;
4140
- });
4141
- });
4142
- return target;
4143
- };
3369
+ /**
3370
+ * @param {Element} node Node.
3371
+ * @param {Array<*>} objectStack Object stack.
3372
+ * @return {Object|undefined} Spatial Capabilities object.
3373
+ */
3374
+ function readSpatialCapabilities(node, objectStack) {
3375
+ return xml_js.pushParseAndPop({}, SPATIAL_CAPABILITIES_PARSERS, node, objectStack);
3376
+ }
4144
3377
 
4145
- const DEFAULT_LANGUAGE = 'en';
4146
- const getDefaultOptions = () => {
4147
- return {
4148
- layers: null,
4149
- evtType: 'singleclick',
4150
- active: true,
4151
- showControl: true,
4152
- language: DEFAULT_LANGUAGE,
4153
- uploadFormats: '.geojson,.json,.kml',
4154
- processUpload: null,
4155
- modal: {
4156
- animateClass: 'fade',
4157
- animateInClass: 'show',
4158
- transition: 300,
4159
- backdropTransition: 150,
4160
- templates: {
4161
- dialog: '<div class="modal-dialog modal-dialog-centered"></div>',
4162
- headerClose: `<button type="button" class="btn-close" data-dismiss="modal" aria-label="${I18N.labels.close}"><span aria-hidden="true">×</span></button>`
4163
- }
4164
- }
4165
- };
4166
- };
3378
+ /**
3379
+ * @param {Element} node Node.
3380
+ * @param {Array<*>} objectStack Object stack.
3381
+ * @return {Object|undefined} Temporal Capabilities object.
3382
+ */
3383
+ function readTemporalCapabilities(node, objectStack) {
3384
+ return xml_js.pushParseAndPop({}, TEMPORAL_CAPABILITIES_PARSERS, node, objectStack);
3385
+ }
3386
+
3387
+ /**
3388
+ * @param {Element} node Node.
3389
+ * @param {Array<*>} objectStack Object stack.
3390
+ * @return {Array<string>|undefined} Functions array.
3391
+ */
3392
+ function readFunctions(node, objectStack) {
3393
+ return xml_js.pushParseAndPop([], FUNCTIONS_PARSERS, node, objectStack);
3394
+ }
3395
+
3396
+ /**
3397
+ * @param {Element} node Node.
3398
+ * @param {Array<*>} objectStack Object stack.
3399
+ * @return {Object|undefined} Function object.
3400
+ */
3401
+ function readFunction(node, objectStack) {
3402
+ return xml_js.pushParseAndPop({}, FUNCTION_PARSERS, node, objectStack);
3403
+ }
3404
+
3405
+ /**
3406
+ * @param {Element} node Node.
3407
+ * @param {Array<*>} objectStack Object stack.
3408
+ * @return {Array<string>|undefined} Logical Operators array.
3409
+ */
3410
+ function readLogicalOperators(node, objectStack) {
3411
+ return xml_js.pushParseAndPop([], LOGICAL_OPERATORS_PARSERS, node, objectStack);
3412
+ }
4167
3413
 
4168
- class EditControlChangesEl extends control.Control {
4169
- constructor(feature) {
4170
- super({
4171
- element: (createElement("div", { className: "ol-wfst--changes-control" },
4172
- createElement("div", { className: "ol-wfst--changes-control-el" },
4173
- createElement("div", { className: "ol-wfst--changes-control-id" },
4174
- createElement("b", null, I18N.labels.editMode),
4175
- " -",
4176
- ' ',
4177
- createElement("i", null, String(feature.getId()))),
4178
- createElement("button", { type: "button", className: "btn btn-sm btn-secondary", onclick: () => {
4179
- this.dispatchEvent(new VectorSource.VectorSourceEvent('cancel', feature));
4180
- } }, I18N.labels.cancel),
4181
- createElement("button", { type: "button", className: "btn btn-sm btn-primary", onclick: () => {
4182
- this.dispatchEvent(new VectorSource.VectorSourceEvent('apply', feature));
4183
- } }, I18N.labels.apply),
4184
- createElement("button", { type: "button", className: "btn btn-sm btn-danger-outline", onclick: () => {
4185
- this.dispatchEvent(new VectorSource.VectorSourceEvent('delete', feature));
4186
- } }, I18N.labels.delete))))
4187
- });
4188
- }
3414
+ /**
3415
+ * @param {Element} node Node.
3416
+ * @param {Array<*>} objectStack Object stack.
3417
+ * @return {Array<string>|undefined} Comparison Operators array.
3418
+ */
3419
+ function readComparisonOperators(node, objectStack) {
3420
+ return xml_js.pushParseAndPop([], COMPARISON_OPERATORS_PARSERS, node, objectStack);
4189
3421
  }
4190
3422
 
4191
- // Ol
4192
- /**
4193
- * Master style that handles two modes on the Edit Layer:
4194
- * - one is the basic, showing only the vertices
4195
- * - and the other when modify is active, showing bigger vertices
4196
- *
4197
- * @param feature
4198
- * @private
4199
- */
4200
- function styleFunction(feature) {
4201
- const getVertexs = (feature) => {
4202
- let geometry = feature.getGeometry();
4203
- if (geometry instanceof geom.GeometryCollection) {
4204
- geometry = geometry.getGeometries()[0];
4205
- }
4206
- const coordinates = geometry.getCoordinates();
4207
- let flatCoordinates = null;
4208
- if (geometry instanceof geom.Polygon ||
4209
- geometry instanceof geom.MultiLineString) {
4210
- flatCoordinates = coordinates.flat(1);
4211
- }
4212
- else if (geometry instanceof geom.MultiPolygon) {
4213
- flatCoordinates = coordinates.flat(2);
4214
- }
4215
- else {
4216
- flatCoordinates = coordinates;
4217
- }
4218
- if (!flatCoordinates || !flatCoordinates.length) {
4219
- return;
4220
- }
4221
- return new geom.MultiPoint(flatCoordinates);
4222
- };
4223
- let geometry = feature.getGeometry();
4224
- let type = geometry.getType();
4225
- if (geometry instanceof geom.GeometryCollection) {
4226
- geometry = geometry.getGeometries()[0];
4227
- type = geometry.getType();
4228
- }
4229
- switch (type) {
4230
- case GeometryType.Point:
4231
- case GeometryType.MultiPoint:
4232
- if (getMode() === Modes.Edit) {
4233
- return [
4234
- new style.Style({
4235
- image: new style.Circle({
4236
- radius: 6,
4237
- fill: new style.Fill({
4238
- color: '#000000'
4239
- })
4240
- })
4241
- }),
4242
- new style.Style({
4243
- image: new style.Circle({
4244
- radius: 4,
4245
- fill: new style.Fill({
4246
- color: '#ff0000'
4247
- })
4248
- })
4249
- })
4250
- ];
4251
- }
4252
- else {
4253
- return [
4254
- new style.Style({
4255
- image: new style.Circle({
4256
- radius: 5,
4257
- fill: new style.Fill({
4258
- color: '#ff0000'
4259
- })
4260
- })
4261
- }),
4262
- new style.Style({
4263
- image: new style.Circle({
4264
- radius: 2,
4265
- fill: new style.Fill({
4266
- color: '#000000'
4267
- })
4268
- })
4269
- })
4270
- ];
4271
- }
4272
- default:
4273
- // If editing mode is active, show bigger vertex
4274
- if (getMode() == Modes.Draw || getMode() == Modes.Edit) {
4275
- return [
4276
- new style.Style({
4277
- stroke: new style.Stroke({
4278
- color: 'rgba( 255, 0, 0, 1)',
4279
- width: 4
4280
- }),
4281
- fill: new style.Fill({
4282
- color: 'rgba(255, 0, 0, 0.7)'
4283
- })
4284
- }),
4285
- new style.Style({
4286
- image: new style.Circle({
4287
- radius: 4,
4288
- fill: new style.Fill({
4289
- color: '#ff0000'
4290
- }),
4291
- stroke: new style.Stroke({
4292
- width: 2,
4293
- color: 'rgba(5, 5, 5, 0.9)'
4294
- })
4295
- }),
4296
- geometry: (feature) => getVertexs(feature)
4297
- }),
4298
- new style.Style({
4299
- stroke: new style.Stroke({
4300
- color: 'rgba(255, 255, 255, 0.7)',
4301
- width: 2
4302
- })
4303
- })
4304
- ];
4305
- }
4306
- else {
4307
- return [
4308
- new style.Style({
4309
- image: new style.Circle({
4310
- radius: 2,
4311
- fill: new style.Fill({
4312
- color: '#000000'
4313
- })
4314
- }),
4315
- geometry: (feature) => getVertexs(feature)
4316
- }),
4317
- new style.Style({
4318
- stroke: new style.Stroke({
4319
- color: '#ff0000',
4320
- width: 4
4321
- }),
4322
- fill: new style.Fill({
4323
- color: 'rgba(255, 0, 0, 0.7)'
4324
- })
4325
- })
4326
- ];
4327
- }
4328
- }
3423
+ /**
3424
+ * @param {Element} node Node.
3425
+ * @param {Array<*>} objectStack Object stack.
3426
+ * @return {Array<string>|undefined} Geometry Operands array.
3427
+ */
3428
+ function readGeometryOperands(node, objectStack) {
3429
+ return xml_js.pushParseAndPop([], GEOMETRY_OPERANDS_PARSERS, node, objectStack);
4329
3430
  }
4330
3431
 
4331
- // Ol
4332
- /**
4333
- * Shows a fields form in a modal window to allow changes in the properties of the feature.
4334
- *
4335
- * @param feature
4336
- * @private
4337
- */
4338
- class EditFieldsModal extends Observable$1 {
4339
- _options;
4340
- _modal;
4341
- _feature;
4342
- constructor(options) {
4343
- super();
4344
- this._options = options;
4345
- const footer = `
4346
- <button type="button" class="btn btn-sm btn-link btn-third" data-action="delete" data-dismiss="modal">
4347
- ${I18N.labels.delete}
4348
- </button>
4349
- <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">
4350
- ${I18N.labels.cancel}
4351
- </button>
4352
- <button type="button" class="btn btn-sm btn-primary" data-action="save" data-dismiss="modal">
4353
- ${I18N.labels.save}
4354
- </button>
4355
- `;
4356
- this._modal = new Modal({
4357
- ...this._options,
4358
- header: true,
4359
- headerClose: true,
4360
- title: '',
4361
- content: '<div></div>',
4362
- footer: footer
4363
- });
4364
- this._modal.on('dismiss', (modal, event) => {
4365
- // On saving changes
4366
- if (event.target.dataset.action === 'save') {
4367
- const inputs = modal.el.querySelectorAll('input');
4368
- inputs.forEach((el) => {
4369
- const value = el.value;
4370
- const field = el.name;
4371
- this._feature.set(field, value, /*isSilent = */ true);
4372
- });
4373
- this._feature.changed();
4374
- addFeatureToEditedList(this._feature);
4375
- this.dispatchEvent(new VectorSource.VectorSourceEvent('save', this._feature));
4376
- }
4377
- else if (event.target.dataset.action === 'delete') {
4378
- this.dispatchEvent(new VectorSource.VectorSourceEvent('delete', this._feature));
4379
- }
4380
- });
4381
- }
4382
- show(feature) {
4383
- this._feature = feature;
4384
- const title = `${I18N.labels.editElement} ${feature.getId()} `;
4385
- const properties = feature.getProperties();
4386
- const layerName = feature.get('_layerName_');
4387
- // Data schema from the geoserver
4388
- const layer = getStoredLayer(layerName);
4389
- const dataSchema = layer.getDescribeFeatureType()._parsed.properties;
4390
- let content = '<form autocomplete="false">';
4391
- Object.keys(properties).forEach((key) => {
4392
- // If the feature field exists in the geoserver and is not added by openlayers
4393
- const field = dataSchema.find((data) => data.name === key);
4394
- if (field) {
4395
- const typeXsd = field.type;
4396
- let type;
4397
- switch (typeXsd) {
4398
- case 'xsd:string':
4399
- type = 'text';
4400
- break;
4401
- case 'xsd:number':
4402
- case 'xsd:int':
4403
- type = 'number';
4404
- break;
4405
- case 'xsd:date-time':
4406
- type = 'datetime';
4407
- break;
4408
- default:
4409
- type = 'text';
4410
- }
4411
- if (type) {
4412
- content += `
4413
- <div class="ol-wfst--input-field-container">
4414
- <label class="ol-wfst--input-field-label" for="${key}">${key}</label>
4415
- <input placeholder="NULL" class="ol-wfst--input-field-input" type="${type}" name="${key}" value="${properties[key] || ''}">
4416
- </div>`;
4417
- }
4418
- }
4419
- });
4420
- content += '</form>';
4421
- this._modal._html.body.innerHTML = content;
4422
- this._modal._html.header.innerHTML = title;
4423
- this._modal.show();
4424
- }
3432
+ /**
3433
+ * @param {Element} node Node.
3434
+ * @param {Array<*>} objectStack Object stack.
3435
+ * @return {Array<string>|undefined} Spatials Operators array.
3436
+ */
3437
+ function readSpatialOperators(node, objectStack) {
3438
+ return xml_js.pushParseAndPop([], SPATIAL_OPERATORS_PARSERS, node, objectStack);
3439
+ }
3440
+
3441
+ /**
3442
+ * @param {Element} node Node.
3443
+ * @param {Array<*>} objectStack Object stack.
3444
+ * @return {Array<string>|undefined} Temporal Operands array.
3445
+ */
3446
+ function readTemporalOperands(node, objectStack) {
3447
+ return xml_js.pushParseAndPop([], TEMPORAL_OPERANDS_PARSERS, node, objectStack);
3448
+ }
3449
+
3450
+ /**
3451
+ * @param {Element} node Node.
3452
+ * @param {Array<*>} objectStack Object stack.
3453
+ * @return {Array<string>|undefined} Temporal Operators array.
3454
+ */
3455
+ function readTemporalOperators(node, objectStack) {
3456
+ return xml_js.pushParseAndPop([], TEMPORAL_OPERATORS_PARSERS, node, objectStack);
3457
+ }
3458
+
3459
+ /**
3460
+ * @param {Element} node Node.
3461
+ * @param {Array<*>} objectStack Object stack.
3462
+ * @return {Array<string>|undefined} Arguments array.
3463
+ */
3464
+ function readArguments(node, objectStack) {
3465
+ return xml_js.pushParseAndPop([], ARGUMENTS_PARSERS, node, objectStack);
3466
+ }
3467
+
3468
+ /**
3469
+ * @param {Element} node Node.
3470
+ * @param {Array<*>} objectStack Object stack.
3471
+ * @return {Object|undefined} Argument object.
3472
+ */
3473
+ function readArgument(node, objectStack) {
3474
+ return xml_js.pushParseAndPop({}, ARGUMENT_PARSERS, node, objectStack);
3475
+ }
3476
+
3477
+ /**
3478
+ * @param {Element} node Node.
3479
+ * @return {Array<number>|undefined} Coordinates array.
3480
+ */
3481
+ function readStringCoords(node) {
3482
+ const coords = xml_js.getAllTextContent(node, false).split(' ');
3483
+ if (coords.length) {
3484
+ return coords.map((c) => Number(c));
3485
+ }
3486
+ return undefined;
4425
3487
  }
4426
3488
 
4427
3489
  // Ol
4428
3490
  // https://docs.geoserver.org/latest/en/user/services/wfs/axis_order.html
4429
3491
  // Axis ordering: latitude/longitude
4430
3492
  const DEFAULT_GEOSERVER_SRS = 'EPSG:3857';
3493
+ const parser = new WFSCapabilities();
4431
3494
  /**
4432
3495
  * @fires change:capabilities
4433
3496
  * @extends {ol/Object~BaseObject}
4434
3497
  * @param options
4435
3498
  */
4436
- class Geoserver extends BaseObject$2 {
4437
- _options;
4438
- _countRequests;
4439
- _insertFeatures;
4440
- _updateFeatures;
4441
- _deleteFeatures;
4442
- // Formats
4443
- _formatWFS;
4444
- _formatGeoJSON;
4445
- _formatKml;
4446
- _xs;
4447
- state_;
3499
+ class Geoserver extends BaseObject {
4448
3500
  constructor(options) {
4449
3501
  super();
4450
3502
  const defaults = {
4451
3503
  url: null,
4452
3504
  advanced: {
4453
- getCapabilitiesVersion: '1.3.0',
3505
+ getCapabilitiesVersion: '2.0.0',
4454
3506
  getFeatureVersion: '1.0.0',
4455
3507
  describeFeatureTypeVersion: '1.1.0',
4456
3508
  lockFeatureVersion: '1.1.0',
@@ -4485,7 +3537,7 @@
4485
3537
  });
4486
3538
  this._xs = new XMLSerializer();
4487
3539
  this.getAndUpdateCapabilities();
4488
- this.on('change:capabilities', () => {
3540
+ this.on('change:parsedCapabilities', () => {
4489
3541
  this._checkGeoserverCapabilities();
4490
3542
  });
4491
3543
  }
@@ -4497,6 +3549,14 @@
4497
3549
  getCapabilities() {
4498
3550
  return this.get(GeoserverProperty.CAPABILITIES);
4499
3551
  }
3552
+ /**
3553
+ * Only work for `2.0.0` getCapabilities version
3554
+ * @returns
3555
+ * @public
3556
+ */
3557
+ getParsedCapabilities() {
3558
+ return this.get(GeoserverProperty.PARSED_CAPABILITIES);
3559
+ }
4500
3560
  /**
4501
3561
  *
4502
3562
  * @param url
@@ -4637,6 +3697,8 @@
4637
3697
  const data = await response.text();
4638
3698
  const capabilities = new window.DOMParser().parseFromString(data, 'text/xml');
4639
3699
  this.set(GeoserverProperty.CAPABILITIES, capabilities);
3700
+ const parsedCapabilities = parser.read(data);
3701
+ this.set(GeoserverProperty.PARSED_CAPABILITIES, parsedCapabilities);
4640
3702
  this.state_ = capabilities ? 'ready' : 'error';
4641
3703
  return capabilities;
4642
3704
  }
@@ -4651,19 +3713,38 @@
4651
3713
  * @private
4652
3714
  */
4653
3715
  _checkGeoserverCapabilities() {
4654
- // Available operations in the geoserver
4655
- const operations = this.getCapabilities().getElementsByTagName('ows:Operation');
4656
- Array.from(operations).forEach((operation) => {
4657
- if (operation.getAttribute('name') === 'Transaction') {
4658
- this.set(GeoserverProperty.HASTRASNACTION, true);
4659
- }
4660
- else if (operation.getAttribute('name') === 'LockFeature') {
4661
- this.set(GeoserverProperty.HASLOCKFEATURE, true);
4662
- }
4663
- else if (operation.getAttribute('name') === 'DescribeFeatureType') {
4664
- this.set(GeoserverProperty.HASDESCRIBEFEATURETYPE, true);
3716
+ var _a, _b;
3717
+ if (this.getAdvanced().getCapabilitiesVersion === '2.0.0') {
3718
+ // Available operations in the geoserver
3719
+ const operations = (_b = (_a = this.getParsedCapabilities()) === null || _a === void 0 ? void 0 : _a.OperationsMetadata) === null || _b === void 0 ? void 0 : _b.Operation;
3720
+ if (operations) {
3721
+ operations.forEach((operation) => {
3722
+ if (operation.name === 'Transaction') {
3723
+ this.set(GeoserverProperty.HASTRASNACTION, true);
3724
+ }
3725
+ else if (operation.name === 'LockFeature') {
3726
+ this.set(GeoserverProperty.HASLOCKFEATURE, true);
3727
+ }
3728
+ else if (operation.name === 'DescribeFeatureType') {
3729
+ this.set(GeoserverProperty.HASDESCRIBEFEATURETYPE, true);
3730
+ }
3731
+ });
4665
3732
  }
4666
- });
3733
+ }
3734
+ else {
3735
+ const operations = this.getCapabilities().getElementsByTagName('ows:Operation');
3736
+ Array.from(operations).forEach((operation) => {
3737
+ if (operation.getAttribute('name') === 'Transaction') {
3738
+ this.set(GeoserverProperty.HASTRASNACTION, true);
3739
+ }
3740
+ else if (operation.getAttribute('name') === 'LockFeature') {
3741
+ this.set(GeoserverProperty.HASLOCKFEATURE, true);
3742
+ }
3743
+ else if (operation.getAttribute('name') === 'DescribeFeatureType') {
3744
+ this.set(GeoserverProperty.HASDESCRIBEFEATURETYPE, true);
3745
+ }
3746
+ });
3747
+ }
4667
3748
  if (!this.hasTransaction()) {
4668
3749
  throw I18N.errors.wfst;
4669
3750
  }
@@ -4784,10 +3865,7 @@
4784
3865
  transactionType !== TransactionType.Insert) {
4785
3866
  payload = payload.replace(`</Transaction>`, `<LockId>${this._options.advanced.lockFeatureParams.lockId}</LockId></Transaction>`);
4786
3867
  }
4787
- const headers = {
4788
- 'Content-Type': 'text/xml',
4789
- ...this.getHeaders()
4790
- };
3868
+ const headers = Object.assign({ 'Content-Type': 'text/xml' }, this.getHeaders());
4791
3869
  const response = await fetch(this.getUrl(), {
4792
3870
  method: 'POST',
4793
3871
  body: payload,
@@ -4845,7 +3923,7 @@
4845
3923
  * @private
4846
3924
  */
4847
3925
  _transformCircleToPolygon(feature, geom) {
4848
- const geomConverted = Polygon.fromCircle(geom);
3926
+ const geomConverted = Polygon_js.fromCircle(geom);
4849
3927
  feature.setGeometry(geomConverted);
4850
3928
  }
4851
3929
  /**
@@ -4857,7 +3935,7 @@
4857
3935
  _transformGeoemtryCollectionToGeometries(feature, geom) {
4858
3936
  let geomConverted = geom.getGeometries()[0];
4859
3937
  if (geomConverted instanceof Circle) {
4860
- geomConverted = Polygon.fromCircle(geomConverted);
3938
+ geomConverted = Polygon_js.fromCircle(geomConverted);
4861
3939
  }
4862
3940
  feature.setGeometry(geomConverted);
4863
3941
  }
@@ -4954,6 +4032,7 @@
4954
4032
  var GeoserverProperty;
4955
4033
  (function (GeoserverProperty) {
4956
4034
  GeoserverProperty["CAPABILITIES"] = "capabilities";
4035
+ GeoserverProperty["PARSED_CAPABILITIES"] = "parsedCapabilities";
4957
4036
  GeoserverProperty["URL"] = "url";
4958
4037
  GeoserverProperty["HEADERS"] = "headers";
4959
4038
  GeoserverProperty["CREDENTIALS"] = "credentials";
@@ -4969,21 +4048,21 @@
4969
4048
 
4970
4049
  var img = "data:image/svg+xml,%3csvg version='1.1' xmlns='http://www.w3.org/2000/svg' width='541' height='512' viewBox='0 0 541 512'%3e %3cpath fill='black' d='M103.306 228.483l129.493-125.249c-17.662-4.272-31.226-18.148-34.98-35.663l-0.055-0.307-129.852 125.248c17.812 4.15 31.53 18.061 35.339 35.662l0.056 0.308z'%3e%3c/path%3e %3cpath fill='black' d='M459.052 393.010c-13.486-8.329-22.346-23.018-22.373-39.779v-0.004c-0.053-0.817-0.082-1.772-0.082-2.733s0.030-1.916 0.089-2.863l-0.007 0.13-149.852 71.94c9.598 8.565 15.611 20.969 15.611 34.779 0 0.014 0 0.029 0 0.043v-0.002c-0.048 5.164-0.94 10.104-2.544 14.711l0.098-0.322z'%3e%3c/path%3e %3cpath fill='black' d='M290.207 57.553c-0.009 15.55-7.606 29.324-19.289 37.819l-0.135 0.093 118.054 46.69c-0.216-1.608-0.346-3.48-0.36-5.379v-0.017c0.033-16.948 9.077-31.778 22.596-39.953l0.209-0.118-122.298-48.056c0.659 2.633 1.098 5.693 1.221 8.834l0.002 0.087z'%3e%3c/path%3e %3cpath fill='black' d='M241.36 410.132l-138.629-160.067c-4.734 17.421-18.861 30.61-36.472 33.911l-0.29 0.045 143.881 166.255c1.668-18.735 14.197-34.162 31.183-40.044l0.327-0.099z'%3e%3c/path%3e %3cpath fill='black' d='M243.446 115.105c-31.785 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.785 0 57.552 25.767 57.552 57.553v0c0 31.786-25.767 57.553-57.553 57.553v0zM243.446 21.582c-19.866 0-35.97 16.105-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c0-19.866-16.104-35.97-35.97-35.97v0z'%3e%3c/path%3e %3cpath fill='black' d='M483.224 410.78c-31.786 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.786 0 57.552 25.767 57.552 57.553v0c0 31.786-25.767 57.553-57.553 57.553v0zM483.224 317.257c-19.866 0-35.97 16.104-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c0-19.866-16.105-35.97-35.97-35.97v0z'%3e%3c/path%3e %3cpath fill='black' d='M57.553 295.531c-31.785 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.785 0 57.553 25.767 57.553 57.553v0c0 31.786-25.767 57.553-57.553 57.553v0zM57.553 202.008c-19.866 0-35.97 16.105-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c-0.041-19.835-16.13-35.898-35.97-35.898 0 0 0 0 0 0v0z'%3e%3c/path%3e %3cpath fill='black' d='M256.036 512.072c-31.786 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.786 0 57.553 25.767 57.553 57.553v0c0 31.786-25.767 57.553-57.553 57.553v0zM256.036 418.55c-19.866 0-35.97 16.104-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c0-19.866-16.105-35.97-35.97-35.97v0z'%3e%3c/path%3e %3cpath fill='black' d='M435.24 194.239c-31.786 0-57.553-25.767-57.553-57.553s25.767-57.553 57.553-57.553c31.786 0 57.553 25.767 57.553 57.553v0c0 31.785-25.767 57.553-57.553 57.553v0zM435.24 100.716c-19.866 0-35.97 16.105-35.97 35.97s16.105 35.97 35.97 35.97c19.866 0 35.97-16.105 35.97-35.97v0c0-19.866-16.105-35.97-35.97-35.97v0z'%3e%3c/path%3e%3c/svg%3e";
4971
4050
 
4972
- class EditOverlay extends Overlay$1 {
4051
+ class EditOverlay extends Overlay {
4973
4052
  constructor(feature, coordinate = null) {
4974
4053
  super({
4975
4054
  id: feature.getId(),
4976
- position: coordinate || extent.getCenter(feature.getGeometry().getExtent()),
4055
+ position: coordinate || extent_js.getCenter(feature.getGeometry().getExtent()),
4977
4056
  positioning: 'center-center',
4978
4057
  offset: [0, -40],
4979
4058
  stopEvent: true,
4980
4059
  element: (createElement("div", null,
4981
- createElement("div", { className: "ol-wfst--edit-button-cnt", onclick: () => {
4060
+ createElement("div", { className: "ol-wfst--edit-button-cnt", onClick: () => {
4982
4061
  this.dispatchEvent('editFields');
4983
4062
  } },
4984
4063
  createElement("button", { className: "ol-wfst--edit-button", type: "button", title: I18N.labels.editFields },
4985
4064
  createElement("img", { src: img$1, alt: I18N.labels.editFields }))),
4986
- createElement("div", { className: "ol-wfst--edit-button-cnt", onclick: () => {
4065
+ createElement("div", { className: "ol-wfst--edit-button-cnt", onClick: () => {
4987
4066
  this.dispatchEvent('editGeom');
4988
4067
  } },
4989
4068
  createElement("button", { class: "ol-wfst--edit-button", type: "button", title: I18N.labels.editGeom },
@@ -5011,38 +4090,6 @@
5011
4090
  * @param options Wfst options, see [Wfst Options](#options) for more details.
5012
4091
  */
5013
4092
  class Wfst extends Control {
5014
- _options;
5015
- _i18n;
5016
- // Ol
5017
- _map;
5018
- _view;
5019
- _viewport;
5020
- _initialized = false;
5021
- _layersControl;
5022
- _overlay;
5023
- // Interactions
5024
- _interactionWfsSelect;
5025
- _interactionSelectModify;
5026
- _collectionModify;
5027
- _interactionModify;
5028
- _interactionSnap;
5029
- _interactionDraw;
5030
- // Obserbable keys
5031
- _keyClickWms;
5032
- _keyRemove;
5033
- _keySelect;
5034
- // Controls
5035
- _controlApplyDiscardChanges;
5036
- _controlWidgetToolsDiv;
5037
- _selectDraw;
5038
- // State
5039
- _currentZoom;
5040
- _lastZoom;
5041
- // Editing
5042
- _editFeature;
5043
- _editFeatureOriginal;
5044
- _uploads;
5045
- _editFields;
5046
4093
  constructor(options) {
5047
4094
  super({
5048
4095
  target: null,
@@ -5052,6 +4099,7 @@
5052
4099
  this._init();
5053
4100
  }
5054
4101
  });
4102
+ this._initialized = false;
5055
4103
  setLang(options.language, options.i18n);
5056
4104
  const defaultOptions = getDefaultOptions();
5057
4105
  this._options = deepObjectAssign(defaultOptions, options);
@@ -5095,7 +4143,7 @@
5095
4143
  layers.forEach((layer) => {
5096
4144
  if (layer.getVisible())
5097
4145
  layersNumber++;
5098
- layer.on('layerRendered', () => {
4146
+ layer.once('layerRendered', () => {
5099
4147
  layerRendered++;
5100
4148
  if (layerRendered >= layersNumber) {
5101
4149
  // run only once
@@ -5208,7 +4256,7 @@
5208
4256
  this._interactionWfsSelect = new Select({
5209
4257
  hitTolerance: 10,
5210
4258
  style: (feature) => styleFunction(feature),
5211
- toggleCondition: condition.never,
4259
+ toggleCondition: condition_js.never,
5212
4260
  filter: (feature, layer) => {
5213
4261
  return (getMode() !== Modes.Edit &&
5214
4262
  layer &&
@@ -5249,7 +4297,7 @@
5249
4297
  this._interactionSelectModify = new Select({
5250
4298
  style: (feature) => styleFunction(feature),
5251
4299
  layers: [getEditLayer()],
5252
- toggleCondition: condition.never,
4300
+ toggleCondition: condition_js.never,
5253
4301
  removeCondition: () => (getMode() === Modes.Edit ? true : false) // Prevent deselect on clicking outside the feature
5254
4302
  });
5255
4303
  this._map.addInteraction(this._interactionSelectModify);
@@ -5305,7 +4353,7 @@
5305
4353
  },
5306
4354
  features: this._collectionModify,
5307
4355
  condition: (evt) => {
5308
- return condition.primaryAction(evt) && getMode() === Modes.Edit;
4356
+ return condition_js.primaryAction(evt) && getMode() === Modes.Edit;
5309
4357
  }
5310
4358
  });
5311
4359
  this._map.addInteraction(this._interactionModify);
@@ -5492,7 +4540,7 @@
5492
4540
  return;
5493
4541
  }
5494
4542
  if (this._keySelect) {
5495
- Observable$2.unByKey(this._keySelect);
4543
+ Observable.unByKey(this._keySelect);
5496
4544
  }
5497
4545
  const layerName = feature.get('_layerName_');
5498
4546
  const ll = this.getLayerByName(layerName);
@@ -5560,9 +4608,7 @@
5560
4608
  }
5561
4609
  };
5562
4610
  if (confirm) {
5563
- const confirmModal = Modal.confirm(I18N.labels.confirmDelete, {
5564
- ...this._options.modal
5565
- });
4611
+ const confirmModal = Modal.confirm(I18N.labels.confirmDelete, Object.assign({}, this._options.modal));
5566
4612
  confirmModal.show().once('dismiss', function (modal, ev, button) {
5567
4613
  if (button && button.value) {
5568
4614
  deleteEl();
@@ -5704,9 +4750,7 @@
5704
4750
  this._map.removeOverlay(overlay);
5705
4751
  }
5706
4752
  }
5707
- class WfstEvent extends BaseEvent$1 {
5708
- data;
5709
- layer;
4753
+ class WfstEvent extends BaseEvent {
5710
4754
  constructor(options) {
5711
4755
  super(options.type);
5712
4756
  this.layer = options.layer;
@@ -5714,11 +4758,12 @@
5714
4758
  }
5715
4759
  }
5716
4760
 
5717
- var utils = {
5718
- WfsLayer: WfsLayer,
5719
- WmsLayer: WmsLayer,
5720
- Geoserver: Geoserver
5721
- };
4761
+ const utils = {
4762
+ WfsLayer,
4763
+ WmsLayer,
4764
+ Geoserver
4765
+ };
4766
+
5722
4767
  Object.assign(Wfst, utils);
5723
4768
 
5724
4769
  return Wfst;