@opengeoweb/webmap-react 8.2.0 → 8.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js CHANGED
@@ -319,13 +319,16 @@ class CanvasComponent extends Component {
319
319
  overflow: 'hidden',
320
320
  display: 'block',
321
321
  border: 'none'
322
- }
322
+ },
323
+ "data-testid": "canvas-container"
323
324
  }, /*#__PURE__*/React__default.createElement("div", {
324
325
  style: {
325
326
  overflow: 'visible',
326
327
  width: 0,
327
328
  height: 0
328
- }
329
+ },
330
+ role: "presentation",
331
+ "aria-label": "canvas"
329
332
  }, /*#__PURE__*/React__default.createElement("canvas", {
330
333
  ref: canvas => {
331
334
  this.canvas = canvas;
@@ -49824,8 +49827,6 @@ function intersect(poly1, poly2, options) {
49824
49827
  return multiPolygon(intersection, options.properties);
49825
49828
  }
49826
49829
 
49827
- function n(n){for(var r=arguments.length,t=Array(r>1?r-1:0),e=1;e<r;e++)t[e-1]=arguments[e];if("production"!==process.env.NODE_ENV){var i=Y[n],o=i?"function"==typeof i?i.apply(null,t):i:"unknown error nr: "+n;throw Error("[Immer] "+o)}throw Error("[Immer] minified error nr: "+n+(t.length?" "+t.map((function(n){return "'"+n+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function r(n){return !!n&&!!n[Q]}function t(n){var r;return !!n&&(function(n){if(!n||"object"!=typeof n)return !1;var r=Object.getPrototypeOf(n);if(null===r)return !0;var t=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return t===Object||"function"==typeof t&&Function.toString.call(t)===Z}(n)||Array.isArray(n)||!!n[L]||!!(null===(r=n.constructor)||void 0===r?void 0:r[L])||s(n)||v(n))}function i(n,r,t){void 0===t&&(t=!1),0===o(n)?(t?Object.keys:nn)(n).forEach((function(e){t&&"symbol"==typeof e||r(e,n[e],n);})):n.forEach((function(t,e){return r(e,t,n)}));}function o(n){var r=n[Q];return r?r.i>3?r.i-4:r.i:Array.isArray(n)?1:s(n)?2:v(n)?3:0}function u(n,r){return 2===o(n)?n.has(r):Object.prototype.hasOwnProperty.call(n,r)}function a(n,r){return 2===o(n)?n.get(r):n[r]}function f(n,r,t){var e=o(n);2===e?n.set(r,t):3===e?n.add(t):n[r]=t;}function c(n,r){return n===r?0!==n||1/n==1/r:n!=n&&r!=r}function s(n){return X&&n instanceof Map}function v(n){return q&&n instanceof Set}function p(n){return n.o||n.t}function l(n){if(Array.isArray(n))return Array.prototype.slice.call(n);var r=rn(n);delete r[Q];for(var t=nn(r),e=0;e<t.length;e++){var i=t[e],o=r[i];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:n[i]});}return Object.create(Object.getPrototypeOf(n),r)}function d(n,e){return void 0===e&&(e=!1),y(n)||r(n)||!t(n)||(o(n)>1&&(n.set=n.add=n.clear=n.delete=h),Object.freeze(n),e&&i(n,(function(n,r){return d(r,!0)}),!0)),n}function h(){n(2);}function y(n){return null==n||"object"!=typeof n||Object.isFrozen(n)}function b(r){var t=tn[r];return t||n(18,r),t}function _(){return "production"===process.env.NODE_ENV||U||n(0),U}function j(n,r){r&&(b("Patches"),n.u=[],n.s=[],n.v=r);}function g(n){O(n),n.p.forEach(S),n.p=null;}function O(n){n===U&&(U=n.l);}function w(n){return U={p:[],l:U,h:n,m:!0,_:0}}function S(n){var r=n[Q];0===r.i||1===r.i?r.j():r.g=!0;}function P(r,e){e._=e.p.length;var i=e.p[0],o=void 0!==r&&r!==i;return e.h.O||b("ES5").S(e,r,o),o?(i[Q].P&&(g(e),n(4)),t(r)&&(r=M(e,r),e.l||x(e,r)),e.u&&b("Patches").M(i[Q].t,r,e.u,e.s)):r=M(e,i,[]),g(e),e.u&&e.v(e.u,e.s),r!==H?r:void 0}function M(n,r,t){if(y(r))return r;var e=r[Q];if(!e)return i(r,(function(i,o){return A(n,e,r,i,o,t)}),!0),r;if(e.A!==n)return r;if(!e.P)return x(n,e.t,!0),e.t;if(!e.I){e.I=!0,e.A._--;var o=4===e.i||5===e.i?e.o=l(e.k):e.o,u=o,a=!1;3===e.i&&(u=new Set(o),o.clear(),a=!0),i(u,(function(r,i){return A(n,e,o,r,i,t,a)})),x(n,o,!1),t&&n.u&&b("Patches").N(e,t,n.u,n.s);}return e.o}function A(e,i,o,a,c,s,v){if("production"!==process.env.NODE_ENV&&c===o&&n(5),r(c)){var p=M(e,c,s&&i&&3!==i.i&&!u(i.R,a)?s.concat(a):void 0);if(f(o,a,p),!r(p))return;e.m=!1;}else v&&o.add(c);if(t(c)&&!y(c)){if(!e.h.D&&e._<1)return;M(e,c),i&&i.A.l||x(e,c);}}function x(n,r,t){void 0===t&&(t=!1),!n.l&&n.h.D&&n.m&&d(r,t);}function z(n,r){var t=n[Q];return (t?p(t):n)[r]}function I(n,r){if(r in n)for(var t=Object.getPrototypeOf(n);t;){var e=Object.getOwnPropertyDescriptor(t,r);if(e)return e;t=Object.getPrototypeOf(t);}}function k(n){n.P||(n.P=!0,n.l&&k(n.l));}function E(n){n.o||(n.o=l(n.t));}function N(n,r,t){var e=s(r)?b("MapSet").F(r,t):v(r)?b("MapSet").T(r,t):n.O?function(n,r){var t=Array.isArray(n),e={i:t?1:0,A:r?r.A:_(),P:!1,I:!1,R:{},l:r,t:n,k:null,o:null,j:null,C:!1},i=e,o=en;t&&(i=[e],o=on);var u=Proxy.revocable(i,o),a=u.revoke,f=u.proxy;return e.k=f,e.j=a,f}(r,t):b("ES5").J(r,t);return (t?t.A:_()).p.push(e),e}function R(e){return r(e)||n(22,e),function n(r){if(!t(r))return r;var e,u=r[Q],c=o(r);if(u){if(!u.P&&(u.i<4||!b("ES5").K(u)))return u.t;u.I=!0,e=D(r,c),u.I=!1;}else e=D(r,c);return i(e,(function(r,t){u&&a(u.t,r)===t||f(e,r,n(t));})),3===c?new Set(e):e}(e)}function D(n,r){switch(r){case 2:return new Map(n);case 3:return Array.from(n)}return l(n)}var G,U,W="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),X="undefined"!=typeof Map,q="undefined"!=typeof Set,B="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,H=W?Symbol.for("immer-nothing"):((G={})["immer-nothing"]=!0,G),L=W?Symbol.for("immer-draftable"):"__$immer_draftable",Q=W?Symbol.for("immer-state"):"__$immer_state",Y={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(n){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(n){return "Cannot apply patch, path doesn't resolve: "+n},16:'Sets cannot have "replace" patches.',17:function(n){return "Unsupported patch operation: "+n},18:function(n){return "The plugin for '"+n+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+n+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(n){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+n+"'"},22:function(n){return "'current' expects a draft, got: "+n},23:function(n){return "'original' expects a draft, got: "+n},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Z=""+Object.prototype.constructor,nn="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames,rn=Object.getOwnPropertyDescriptors||function(n){var r={};return nn(n).forEach((function(t){r[t]=Object.getOwnPropertyDescriptor(n,t);})),r},tn={},en={get:function(n,r){if(r===Q)return n;var e=p(n);if(!u(e,r))return function(n,r,t){var e,i=I(r,t);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(n.k):void 0}(n,e,r);var i=e[r];return n.I||!t(i)?i:i===z(n.t,r)?(E(n),n.o[r]=N(n.A.h,i,n)):i},has:function(n,r){return r in p(n)},ownKeys:function(n){return Reflect.ownKeys(p(n))},set:function(n,r,t){var e=I(p(n),r);if(null==e?void 0:e.set)return e.set.call(n.k,t),!0;if(!n.P){var i=z(p(n),r),o=null==i?void 0:i[Q];if(o&&o.t===t)return n.o[r]=t,n.R[r]=!1,!0;if(c(t,i)&&(void 0!==t||u(n.t,r)))return !0;E(n),k(n);}return n.o[r]===t&&(void 0!==t||r in n.o)||Number.isNaN(t)&&Number.isNaN(n.o[r])||(n.o[r]=t,n.R[r]=!0),!0},deleteProperty:function(n,r){return void 0!==z(n.t,r)||r in n.t?(n.R[r]=!1,E(n),k(n)):delete n.R[r],n.o&&delete n.o[r],!0},getOwnPropertyDescriptor:function(n,r){var t=p(n),e=Reflect.getOwnPropertyDescriptor(t,r);return e?{writable:!0,configurable:1!==n.i||"length"!==r,enumerable:e.enumerable,value:t[r]}:e},defineProperty:function(){n(11);},getPrototypeOf:function(n){return Object.getPrototypeOf(n.t)},setPrototypeOf:function(){n(12);}},on={};i(en,(function(n,r){on[n]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)};})),on.deleteProperty=function(r,t){return "production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&n(13),on.set.call(this,r,t,void 0)},on.set=function(r,t,e){return "production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&n(14),en.set.call(this,r[0],t,e,r[0])};var un=function(){function e(r){var e=this;this.O=B,this.D=!0,this.produce=function(r,i,o){if("function"==typeof r&&"function"!=typeof i){var u=i;i=r;var a=e;return function(n){var r=this;void 0===n&&(n=u);for(var t=arguments.length,e=Array(t>1?t-1:0),o=1;o<t;o++)e[o-1]=arguments[o];return a.produce(n,(function(n){var t;return (t=i).call.apply(t,[r,n].concat(e))}))}}var f;if("function"!=typeof i&&n(6),void 0!==o&&"function"!=typeof o&&n(7),t(r)){var c=w(e),s=N(e,r,void 0),v=!0;try{f=i(s),v=!1;}finally{v?g(c):O(c);}return "undefined"!=typeof Promise&&f instanceof Promise?f.then((function(n){return j(c,o),P(n,c)}),(function(n){throw g(c),n})):(j(c,o),P(f,c))}if(!r||"object"!=typeof r){if(void 0===(f=i(r))&&(f=r),f===H&&(f=void 0),e.D&&d(f,!0),o){var p=[],l=[];b("Patches").M(r,f,p,l),o(p,l);}return f}n(21,r);},this.produceWithPatches=function(n,r){if("function"==typeof n)return function(r){for(var t=arguments.length,i=Array(t>1?t-1:0),o=1;o<t;o++)i[o-1]=arguments[o];return e.produceWithPatches(r,(function(r){return n.apply(void 0,[r].concat(i))}))};var t,i,o=e.produce(n,r,(function(n,r){t=n,i=r;}));return "undefined"!=typeof Promise&&o instanceof Promise?o.then((function(n){return [n,t,i]})):[o,t,i]},"boolean"==typeof(null==r?void 0:r.useProxies)&&this.setUseProxies(r.useProxies),"boolean"==typeof(null==r?void 0:r.autoFreeze)&&this.setAutoFreeze(r.autoFreeze);}var i=e.prototype;return i.createDraft=function(e){t(e)||n(8),r(e)&&(e=R(e));var i=w(this),o=N(this,e,void 0);return o[Q].C=!0,O(i),o},i.finishDraft=function(r,t){var e=r&&r[Q];"production"!==process.env.NODE_ENV&&(e&&e.C||n(9),e.I&&n(10));var i=e.A;return j(i,t),P(void 0,i)},i.setAutoFreeze=function(n){this.D=n;},i.setUseProxies=function(r){r&&!B&&n(20),this.O=r;},i.applyPatches=function(n,t){var e;for(e=t.length-1;e>=0;e--){var i=t[e];if(0===i.path.length&&"replace"===i.op){n=i.value;break}}e>-1&&(t=t.slice(e+1));var o=b("Patches").$;return r(n)?o(n,t):this.produce(n,(function(n){return o(n,t)}))},e}(),an=new un,fn=an.produce;an.produceWithPatches.bind(an);an.setAutoFreeze.bind(an);an.setUseProxies.bind(an);an.applyPatches.bind(an);an.createDraft.bind(an);an.finishDraft.bind(an);var produce = fn;
49828
-
49829
49830
  /* *
49830
49831
  * Licensed under the Apache License, Version 2.0 (the "License");
49831
49832
  * you may not use this file except in compliance with the License.
@@ -49842,67 +49843,6 @@ function n(n){for(var r=arguments.length,t=Array(r>1?r-1:0),e=1;e<r;e++)t[e-1]=a
49842
49843
  * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
49843
49844
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
49844
49845
  * */
49845
- const defaultGeoJSONStyleProperties = {
49846
- fill: '#ff7800',
49847
- 'fill-opacity': 0.2,
49848
- stroke: '#ff7800',
49849
- 'stroke-width': 2,
49850
- 'stroke-opacity': 1
49851
- };
49852
- const emptyGeoJSON = {
49853
- type: 'FeatureCollection',
49854
- features: []
49855
- };
49856
- const featurePoint = {
49857
- type: 'Feature',
49858
- properties: {},
49859
- geometry: {
49860
- type: 'Point',
49861
- coordinates: []
49862
- }
49863
- };
49864
- const featureMultiPoint = {
49865
- type: 'Feature',
49866
- properties: {},
49867
- geometry: {
49868
- type: 'MultiPoint',
49869
- coordinates: [[]]
49870
- }
49871
- };
49872
- const featurePolygon = {
49873
- type: 'Feature',
49874
- properties: {},
49875
- geometry: {
49876
- type: 'Polygon',
49877
- coordinates: [[]]
49878
- }
49879
- };
49880
- const featureBox = {
49881
- type: 'Feature',
49882
- properties: {
49883
- _type: 'box'
49884
- },
49885
- geometry: {
49886
- type: 'Polygon',
49887
- coordinates: [[]]
49888
- }
49889
- };
49890
- const lineString = {
49891
- type: 'FeatureCollection',
49892
- features: [{
49893
- type: 'Feature',
49894
- properties: {
49895
- stroke: '#66F',
49896
- 'stroke-width': 5,
49897
- 'stroke-opacity': '1'
49898
- },
49899
- geometry: {
49900
- type: 'LineString',
49901
- coordinates: [[]]
49902
- }
49903
- }]
49904
- };
49905
-
49906
49846
  /* Function which calculates the distance between two points */
49907
49847
  const distance = (a, b) => {
49908
49848
  return Math.sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
@@ -50048,119 +49988,85 @@ const registerDrawFunction = (drawFunction = () => {}) => {
50048
49988
  drawFunctionStore.push(newFunction);
50049
49989
  return id;
50050
49990
  };
50051
- /**
50052
- * Adds properties to the first geojson feature based on the given property object.
50053
- * It only extends or changes the properties which are defined in styleConfig,
50054
- * all other properties in the geojson are left unchanged.
50055
- * @param geojson
50056
- * @param featureProperties
50057
- */
50058
- const addFeatureProperties = (geojson, featureProperties, featureIndex = 0) => {
50059
- if (!geojson) {
50060
- return null;
50061
- }
50062
- return produce(geojson, draft => {
50063
- if (draft.features && draft.features.length > 0 && draft.features[featureIndex] !== undefined && draft.features[featureIndex].properties) {
50064
- Object.keys(featureProperties).forEach(key => {
50065
- draft.features[featureIndex].properties[key] = featureProperties[key];
50066
- });
50067
- }
50068
- });
50069
- };
50070
- /**
50071
- * Returns the intersection of two features. In case of a polygon, only the first feature is used.
50072
- * @param a Feature A
50073
- * @param b Feature B
50074
- * @returns The intersection of the two features.
50075
- */
50076
- const intersectGeoJSONS = (a, b, geoJSONProperties = {
50077
- stroke: '#FF0000',
50078
- 'stroke-width': 10.0,
50079
- 'stroke-opacity': 1,
50080
- fill: '#0000FF',
50081
- 'fill-opacity': 1.0
50082
- }) => {
50083
- const featureA = feature(a.features[0].geometry);
50084
- const featureB = feature(b.features[0].geometry);
50085
- const options = {
50086
- tolerance: 0.001,
50087
- highQuality: true
50088
- };
50089
- const simplifiedA = simplify$1(featureA, options);
50090
- const simplifiedB = simplify$1(featureB, options);
50091
- const intersection = intersect(simplifiedA, simplifiedB);
50092
- return addFeatureProperties({
50093
- type: 'FeatureCollection',
50094
- features: intersection === null ? [{
50095
- type: 'Feature',
50096
- properties: {
50097
- selectionType: 'poly'
50098
- },
50099
- geometry: {
50100
- type: 'Polygon',
50101
- coordinates: [[]]
50102
- }
50103
- }] : [intersection]
50104
- }, geoJSONProperties);
49991
+ const NEW_LINESTRING_CREATED = 'new point in LineString created';
49992
+ const NEW_FEATURE_CREATED = 'new feature created';
49993
+ const NEW_POINT_CREATED = 'new point created';
49994
+
49995
+ /* *
49996
+ * Licensed under the Apache License, Version 2.0 (the "License");
49997
+ * you may not use this file except in compliance with the License.
49998
+ * You may obtain a copy of the License at
49999
+ *
50000
+ * http://www.apache.org/licenses/LICENSE-2.0
50001
+ *
50002
+ * Unless required by applicable law or agreed to in writing, software
50003
+ * distributed under the License is distributed on an "AS IS" BASIS,
50004
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
50005
+ * See the License for the specific language governing permissions and
50006
+ * limitations under the License.
50007
+ *
50008
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
50009
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
50010
+ * */
50011
+ const defaultGeoJSONStyleProperties = {
50012
+ fill: '#ff7800',
50013
+ 'fill-opacity': 0.2,
50014
+ stroke: '#ff7800',
50015
+ 'stroke-width': 2,
50016
+ 'stroke-opacity': 1
50105
50017
  };
50106
- /**
50107
- * Adds the intersectionStart and intersectionEnd properties to the GeoJSONS structure
50108
- * @param geoJSONs
50109
- * @returns GeoJSONS extend with intersections
50110
- */
50111
- const createInterSections = (geojson, otherGeoJSON, geoJSONproperties = {
50112
- stroke: '#f24a00',
50113
- 'stroke-width': 1.5,
50114
- 'stroke-opacity': 1,
50115
- fill: '#f24a00',
50116
- 'fill-opacity': 0.5
50117
- }) => {
50118
- const intersections = produce(geojson, () => {
50119
- try {
50120
- return addFeatureProperties(intersectGeoJSONS(geojson, otherGeoJSON), geoJSONproperties);
50121
- } catch (error) {
50122
- return addFeatureProperties(geojson, geoJSONproperties);
50123
- }
50124
- });
50125
- return intersections;
50018
+ const emptyGeoJSON = {
50019
+ type: 'FeatureCollection',
50020
+ features: []
50126
50021
  };
50127
- const getGeoJson = (geojson, shouldAllowMultipleshapes) => {
50128
- if (shouldAllowMultipleshapes) {
50129
- return geojson;
50130
- }
50131
- const {
50132
- geometry
50133
- } = geojson.features[0];
50134
- if (geometry.type === 'Point' || geometry.type === 'LineString') {
50135
- return geojson;
50022
+ const featurePoint = {
50023
+ type: 'Feature',
50024
+ properties: {},
50025
+ geometry: {
50026
+ type: 'Point',
50027
+ coordinates: []
50136
50028
  }
50137
- return geometry.coordinates.length > 1 ? produce(geojson, draft => {
50138
- const draftFeature = draft.features[0];
50139
- draftFeature.geometry.coordinates = [draftFeature.geometry.coordinates[1]];
50140
- }) : geojson;
50141
50029
  };
50142
- const getFeatureCollection = (geoJSONFeature, shouldAllowMultipleshapes, geoJSONFeatureCollection = emptyGeoJSON) => {
50143
- if (geoJSONFeature.type === 'FeatureCollection') {
50144
- return geoJSONFeature;
50030
+ const featureMultiPoint = {
50031
+ type: 'Feature',
50032
+ properties: {},
50033
+ geometry: {
50034
+ type: 'MultiPoint',
50035
+ coordinates: [[]]
50145
50036
  }
50146
- if (shouldAllowMultipleshapes) {
50147
- return Object.assign(Object.assign({}, geoJSONFeatureCollection), {
50148
- features: geoJSONFeatureCollection.features.concat(geoJSONFeature)
50149
- });
50037
+ };
50038
+ const featurePolygon = {
50039
+ type: 'Feature',
50040
+ properties: {},
50041
+ geometry: {
50042
+ type: 'Polygon',
50043
+ coordinates: [[]]
50150
50044
  }
50151
- return Object.assign(Object.assign({}, geoJSONFeatureCollection), {
50152
- features: [geoJSONFeature]
50153
- });
50154
50045
  };
50155
- // compares 2 geoJSONs and returns true if both have properties.selectionType with the same value
50156
- const isGeoJSONFeatureCreatedByTool = (existingJSON, newGeoJSON) => {
50157
- var _a, _b, _c;
50158
- if (!existingJSON.features.length) {
50159
- return false;
50046
+ const featureBox = {
50047
+ type: 'Feature',
50048
+ properties: {
50049
+ _type: 'box'
50050
+ },
50051
+ geometry: {
50052
+ type: 'Polygon',
50053
+ coordinates: [[]]
50160
50054
  }
50161
- const lastUsedTool = (_a = existingJSON.features[0].properties) === null || _a === void 0 ? void 0 : _a.selectionType;
50162
- const newTool = newGeoJSON.type === 'Feature' ? (_b = newGeoJSON.properties) === null || _b === void 0 ? void 0 : _b.selectionType : (_c = newGeoJSON.features[0].properties) === null || _c === void 0 ? void 0 : _c.selectionType;
50163
- return lastUsedTool !== undefined && newTool !== undefined ? lastUsedTool === newTool : false;
50055
+ };
50056
+ const lineString = {
50057
+ type: 'FeatureCollection',
50058
+ features: [{
50059
+ type: 'Feature',
50060
+ properties: {
50061
+ stroke: '#66F',
50062
+ 'stroke-width': 5,
50063
+ 'stroke-opacity': '1'
50064
+ },
50065
+ geometry: {
50066
+ type: 'LineString',
50067
+ coordinates: [[]]
50068
+ }
50069
+ }]
50164
50070
  };
50165
50071
 
50166
50072
  const colors = {
@@ -50221,12 +50127,12 @@ class MapDraw extends React.PureComponent {
50221
50127
  super(props);
50222
50128
  this.handleGeoJSONUpdate = newGeoJSON => {
50223
50129
  const {
50224
- featureNrToEdit
50130
+ selectedFeatureIndex
50225
50131
  } = this.props;
50226
50132
  this.geojson = lodash.exports.cloneDeep(newGeoJSON);
50227
50133
  /* Ensure that this.snappedPolygonIndex is still within the coordinates array */
50228
- if (this.geojson && this.geojson.features && featureNrToEdit < this.geojson.features.length) {
50229
- const feature = this.geojson.features[featureNrToEdit];
50134
+ if (this.geojson && this.geojson.features && selectedFeatureIndex < this.geojson.features.length) {
50135
+ const feature = this.geojson.features[selectedFeatureIndex];
50230
50136
  if (feature.geometry) {
50231
50137
  const {
50232
50138
  coordinates
@@ -50529,7 +50435,7 @@ class MapDraw extends React.PureComponent {
50529
50435
  mouseMove(event) {
50530
50436
  const {
50531
50437
  isInEditMode,
50532
- featureNrToEdit,
50438
+ selectedFeatureIndex,
50533
50439
  onHoverFeature
50534
50440
  } = this.props;
50535
50441
  if (event && event.rightButton === true) {
@@ -50576,7 +50482,7 @@ class MapDraw extends React.PureComponent {
50576
50482
  if (isInEditMode === false) {
50577
50483
  return undefined;
50578
50484
  }
50579
- const feature = this.geojson.features[featureNrToEdit];
50485
+ const feature = this.geojson.features[selectedFeatureIndex];
50580
50486
  if (!feature) {
50581
50487
  return undefined;
50582
50488
  }
@@ -50679,7 +50585,7 @@ class MapDraw extends React.PureComponent {
50679
50585
  } = event;
50680
50586
  const {
50681
50587
  mapId,
50682
- featureNrToEdit
50588
+ selectedFeatureIndex
50683
50589
  } = this.props;
50684
50590
  const webmapjs = webmapUtils.getWMJSMapById(mapId);
50685
50591
  if (this.myDrawMode === DRAWMODE.POLYGON) {
@@ -50688,7 +50594,7 @@ class MapDraw extends React.PureComponent {
50688
50594
  x: mouseX,
50689
50595
  y: mouseY
50690
50596
  });
50691
- const feature = this.geojson.features[featureNrToEdit];
50597
+ const feature = this.geojson.features[selectedFeatureIndex];
50692
50598
  if (this.checkIfFeatureIsBox(feature)) {
50693
50599
  return false;
50694
50600
  }
@@ -50708,7 +50614,7 @@ class MapDraw extends React.PureComponent {
50708
50614
  x: mouseX,
50709
50615
  y: mouseY
50710
50616
  });
50711
- const feature = this.geojson.features[featureNrToEdit];
50617
+ const feature = this.geojson.features[selectedFeatureIndex];
50712
50618
  if (this.checkIfFeatureIsBox(feature)) {
50713
50619
  return false;
50714
50620
  }
@@ -50732,14 +50638,14 @@ class MapDraw extends React.PureComponent {
50732
50638
  } = event;
50733
50639
  const {
50734
50640
  mapId,
50735
- featureNrToEdit
50641
+ selectedFeatureIndex
50736
50642
  } = this.props;
50737
50643
  const webmapjs = webmapUtils.getWMJSMapById(mapId);
50738
50644
  if (this.myEditMode === EDITMODE.EMPTY) {
50739
50645
  this.myEditMode = EDITMODE.ADD_FEATURE;
50740
- let feature = this.geojson.features[featureNrToEdit];
50646
+ let feature = this.geojson.features[selectedFeatureIndex];
50741
50647
  // eslint-disable-next-line no-multi-assign
50742
- feature = this.geojson.features[featureNrToEdit] = this.initializeFeature(feature, this.myDrawMode);
50648
+ feature = this.geojson.features[selectedFeatureIndex] = this.initializeFeature(feature, this.myDrawMode);
50743
50649
  this.mouseGeoCoord = webmapjs.getLatLongFromPixelCoord({
50744
50650
  x: mouseX,
50745
50651
  y: mouseY
@@ -50765,7 +50671,7 @@ class MapDraw extends React.PureComponent {
50765
50671
  this.snappedPolygonIndex = pointGeometry.coordinates.length - 1;
50766
50672
  /* For type POINT it is not possible to add multiple points to the same feature */
50767
50673
  this.myEditMode = EDITMODE.EMPTY;
50768
- this.featureHasChanged('new point created');
50674
+ this.featureHasChanged(NEW_POINT_CREATED);
50769
50675
  }
50770
50676
  if (this.myDrawMode === DRAWMODE.MULTIPOINT) {
50771
50677
  this.myEditMode = EDITMODE.EMPTY;
@@ -50813,7 +50719,7 @@ class MapDraw extends React.PureComponent {
50813
50719
  } else {
50814
50720
  this.mouseIsOverVertexNr = featureCoords.length - 1;
50815
50721
  }
50816
- this.featureHasChanged('new feature created');
50722
+ this.featureHasChanged(NEW_FEATURE_CREATED);
50817
50723
  }
50818
50724
  if (this.myDrawMode === DRAWMODE.LINESTRING) {
50819
50725
  this.myEditMode = EDITMODE.EMPTY;
@@ -50828,7 +50734,7 @@ class MapDraw extends React.PureComponent {
50828
50734
  }
50829
50735
  featureCoords.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
50830
50736
  this.snappedPolygonIndex = 0;
50831
- this.featureHasChanged('new point in LineString created');
50737
+ this.featureHasChanged(NEW_LINESTRING_CREATED);
50832
50738
  this.mouseIsOverVertexNr = featureCoords.length - 1;
50833
50739
  }
50834
50740
  webmapjs.draw('MapDraw::mouseDown');
@@ -50848,7 +50754,7 @@ class MapDraw extends React.PureComponent {
50848
50754
  } = event;
50849
50755
  const {
50850
50756
  mapId,
50851
- featureNrToEdit
50757
+ selectedFeatureIndex
50852
50758
  } = this.props;
50853
50759
  const webmapjs = webmapUtils.getWMJSMapById(mapId);
50854
50760
  if (this.myDrawMode === DRAWMODE.MULTIPOINT) {
@@ -50857,7 +50763,7 @@ class MapDraw extends React.PureComponent {
50857
50763
  x: mouseX,
50858
50764
  y: mouseY
50859
50765
  });
50860
- const feature = this.geojson.features[featureNrToEdit];
50766
+ const feature = this.geojson.features[selectedFeatureIndex];
50861
50767
  const featureCoords = feature.geometry.coordinates;
50862
50768
  featureCoords.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
50863
50769
  this.featureHasChanged('point added to multipoint');
@@ -50875,7 +50781,7 @@ class MapDraw extends React.PureComponent {
50875
50781
  } = event;
50876
50782
  const {
50877
50783
  mapId,
50878
- featureNrToEdit
50784
+ selectedFeatureIndex
50879
50785
  } = this.props;
50880
50786
  const webmapjs = webmapUtils.getWMJSMapById(mapId);
50881
50787
  if (this.myDrawMode === DRAWMODE.POLYGON) {
@@ -50884,7 +50790,7 @@ class MapDraw extends React.PureComponent {
50884
50790
  x: mouseX,
50885
50791
  y: mouseY
50886
50792
  });
50887
- const feature = this.geojson.features[featureNrToEdit];
50793
+ const feature = this.geojson.features[selectedFeatureIndex];
50888
50794
  const featureCoords = feature.geometry.coordinates[this.snappedPolygonIndex];
50889
50795
  featureCoords.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
50890
50796
  this.featureHasChanged('vertex added to polygon');
@@ -50902,7 +50808,7 @@ class MapDraw extends React.PureComponent {
50902
50808
  } = event;
50903
50809
  const {
50904
50810
  mapId,
50905
- featureNrToEdit
50811
+ selectedFeatureIndex
50906
50812
  } = this.props;
50907
50813
  const webmapjs = webmapUtils.getWMJSMapById(mapId);
50908
50814
  if (this.myDrawMode === DRAWMODE.LINESTRING) {
@@ -50911,7 +50817,7 @@ class MapDraw extends React.PureComponent {
50911
50817
  x: mouseX,
50912
50818
  y: mouseY
50913
50819
  });
50914
- const feature = this.geojson.features[featureNrToEdit];
50820
+ const feature = this.geojson.features[selectedFeatureIndex];
50915
50821
  const featureCoords = feature.geometry.coordinates;
50916
50822
  featureCoords.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
50917
50823
  this.featureHasChanged('vertex added to LineString');
@@ -50976,10 +50882,10 @@ class MapDraw extends React.PureComponent {
50976
50882
 
50977
50883
  deletePolygon(index) {
50978
50884
  const {
50979
- featureNrToEdit,
50885
+ selectedFeatureIndex,
50980
50886
  deletePolygonCallback
50981
50887
  } = this.props;
50982
- const feature = this.geojson.features[featureNrToEdit];
50888
+ const feature = this.geojson.features[selectedFeatureIndex];
50983
50889
  feature.geometry.coordinates.splice(index, 1);
50984
50890
  if (deletePolygonCallback) {
50985
50891
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -50991,13 +50897,13 @@ class MapDraw extends React.PureComponent {
50991
50897
  /* Deletes any features under the mousecursor */
50992
50898
  const {
50993
50899
  mapId,
50994
- featureNrToEdit
50900
+ selectedFeatureIndex
50995
50901
  } = this.props;
50996
50902
  const webmapjs = webmapUtils.getWMJSMapById(mapId);
50997
50903
  if (this.mouseIsOverVertexNr === VERTEX.NONE) {
50998
50904
  return;
50999
50905
  }
51000
- const feature = this.geojson.features[featureNrToEdit];
50906
+ const feature = this.geojson.features[selectedFeatureIndex];
51001
50907
  const featureCoords = feature.geometry.coordinates[this.snappedPolygonIndex];
51002
50908
  if (featureCoords === undefined) {
51003
50909
  return;
@@ -51082,7 +50988,7 @@ class MapDraw extends React.PureComponent {
51082
50988
  cancelEdit(cancelLastPoint) {
51083
50989
  const {
51084
50990
  isInEditMode,
51085
- featureNrToEdit
50991
+ selectedFeatureIndex
51086
50992
  } = this.props;
51087
50993
  if (isInEditMode === false) {
51088
50994
  return;
@@ -51098,7 +51004,7 @@ class MapDraw extends React.PureComponent {
51098
51004
  if (this.snappedPolygonIndex === SNAPPEDFEATURE.NONE) {
51099
51005
  return;
51100
51006
  }
51101
- const feature = this.geojson.features[featureNrToEdit];
51007
+ const feature = this.geojson.features[selectedFeatureIndex];
51102
51008
  const {
51103
51009
  coordinates
51104
51010
  } = feature.geometry;
@@ -51120,7 +51026,7 @@ class MapDraw extends React.PureComponent {
51120
51026
  }
51121
51027
  }
51122
51028
  if (this.myDrawMode === DRAWMODE.LINESTRING) {
51123
- const feature = this.geojson.features[featureNrToEdit];
51029
+ const feature = this.geojson.features[selectedFeatureIndex];
51124
51030
  const featureCoords = feature.geometry.coordinates;
51125
51031
  featureCoords.pop();
51126
51032
  }
@@ -51359,7 +51265,7 @@ class MapDraw extends React.PureComponent {
51359
51265
  You are free to draw anything you like on the canvas.
51360
51266
  */
51361
51267
  const {
51362
- featureNrToEdit,
51268
+ selectedFeatureIndex,
51363
51269
  isInEditMode
51364
51270
  } = this.props;
51365
51271
  if (!this.geojson || !this.geojson.features || !this.geojson.features.length) {
@@ -51385,7 +51291,7 @@ class MapDraw extends React.PureComponent {
51385
51291
  continue;
51386
51292
  }
51387
51293
  for (let j = 0; j < XYCoords.length; j += 1) {
51388
- this.drawPoint(ctx, XYCoords[j], this.mouseIsOverVertexNr === j && featureNrToEdit === featureIndex, false, isInEditMode && featureNrToEdit === featureIndex, feature, featureIndex);
51294
+ this.drawPoint(ctx, XYCoords[j], this.mouseIsOverVertexNr === j && selectedFeatureIndex === featureIndex, false, isInEditMode && selectedFeatureIndex === featureIndex, feature, featureIndex);
51389
51295
  }
51390
51296
  }
51391
51297
  if (featureType === 'MultiPoint') {
@@ -51396,7 +51302,7 @@ class MapDraw extends React.PureComponent {
51396
51302
  continue;
51397
51303
  }
51398
51304
  for (let j = 0; j < XYCoords.length; j += 1) {
51399
- this.drawPoint(ctx, XYCoords[j], this.mouseIsOverVertexNr === j && featureNrToEdit === featureIndex, false, isInEditMode && featureNrToEdit === featureIndex, feature, featureIndex);
51305
+ this.drawPoint(ctx, XYCoords[j], this.mouseIsOverVertexNr === j && selectedFeatureIndex === featureIndex, false, isInEditMode && selectedFeatureIndex === featureIndex, feature, featureIndex);
51400
51306
  }
51401
51307
  }
51402
51308
  if (featureType === 'MultiPolygon') {
@@ -51420,11 +51326,11 @@ class MapDraw extends React.PureComponent {
51420
51326
  if (isInEditMode) {
51421
51327
  /* Draw all vertices on the edges of the polygons */
51422
51328
  for (let j = 0; j < XYCoords.length; j += 1) {
51423
- this.drawVertice(ctx, XYCoords[j], this.snappedPolygonIndex === polygonIndex && this.mouseIsOverVertexNr === j && featureNrToEdit === featureIndex, false, isInEditMode && featureNrToEdit === featureIndex);
51329
+ this.drawVertice(ctx, XYCoords[j], this.snappedPolygonIndex === polygonIndex && this.mouseIsOverVertexNr === j && selectedFeatureIndex === featureIndex, false, isInEditMode && selectedFeatureIndex === featureIndex);
51424
51330
  }
51425
51331
  if (middle && isInEditMode === true && XYCoords.length >= 3) {
51426
51332
  /* Draw middle vertice for the poly if poly covers an area, e.g. when it contains more than three points */
51427
- this.drawVertice(ctx, middle, this.snappedPolygonIndex === polygonIndex && this.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE && featureNrToEdit === featureIndex, true, isInEditMode && featureNrToEdit === featureIndex);
51333
+ this.drawVertice(ctx, middle, this.snappedPolygonIndex === polygonIndex && this.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE && selectedFeatureIndex === featureIndex, true, isInEditMode && selectedFeatureIndex === featureIndex);
51428
51334
  }
51429
51335
  }
51430
51336
  }
@@ -51463,11 +51369,11 @@ class MapDraw extends React.PureComponent {
51463
51369
  if (isInEditMode) {
51464
51370
  /* Draw all vertices on the edges of the polygons */
51465
51371
  for (let j = 0; j < XYCoords.length; j += 1) {
51466
- this.drawVertice(ctx, XYCoords[j], this.snappedPolygonIndex === polygonIndex && this.mouseIsOverVertexNr === j && featureNrToEdit === featureIndex, false, isInEditMode && featureNrToEdit === featureIndex);
51372
+ this.drawVertice(ctx, XYCoords[j], this.snappedPolygonIndex === polygonIndex && this.mouseIsOverVertexNr === j && selectedFeatureIndex === featureIndex, false, isInEditMode && selectedFeatureIndex === featureIndex);
51467
51373
  }
51468
51374
  if (middle && isInEditMode === true && XYCoords.length >= 3) {
51469
51375
  /* Draw middle vertice for the poly if poly covers an area, e.g. when it contains more than three points */
51470
- this.drawVertice(ctx, middle, this.snappedPolygonIndex === polygonIndex && this.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE && featureNrToEdit === featureIndex, true, isInEditMode && featureNrToEdit === featureIndex);
51376
+ this.drawVertice(ctx, middle, this.snappedPolygonIndex === polygonIndex && this.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE && selectedFeatureIndex === featureIndex, true, isInEditMode && selectedFeatureIndex === featureIndex);
51471
51377
  }
51472
51378
  }
51473
51379
  }
@@ -51496,14 +51402,14 @@ class MapDraw extends React.PureComponent {
51496
51402
  if (isInEditMode) {
51497
51403
  /* Draw all vertices on the edges of the polygons */
51498
51404
  for (let j = 0; j < XYCoords.length; j += 1) {
51499
- this.drawVertice(ctx, XYCoords[j], this.mouseIsOverVertexNr === j && featureNrToEdit === featureIndex, false, isInEditMode && featureNrToEdit === featureIndex);
51405
+ this.drawVertice(ctx, XYCoords[j], this.mouseIsOverVertexNr === j && selectedFeatureIndex === featureIndex, false, isInEditMode && selectedFeatureIndex === featureIndex);
51500
51406
  }
51501
51407
  }
51502
51408
  }
51503
51409
  }
51504
51410
  /* Higlight polygon with mousehover */
51505
- if (isInEditMode === true && this.mouseOverPolygonFeatureIndex === featureNrToEdit && this.mouseIsOverVertexNr === VERTEX.NONE && this.snappedPolygonIndex === SNAPPEDFEATURE.NONE && this.selectedEdge === EDGE.NONE || this.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE) {
51506
- const feature = this.geojson.features[featureNrToEdit];
51411
+ if (isInEditMode === true && this.mouseOverPolygonFeatureIndex === selectedFeatureIndex && this.mouseIsOverVertexNr === VERTEX.NONE && this.snappedPolygonIndex === SNAPPEDFEATURE.NONE && this.selectedEdge === EDGE.NONE || this.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE) {
51412
+ const feature = this.geojson.features[selectedFeatureIndex];
51507
51413
  const featureProperties = feature.properties;
51508
51414
  if (this.mouseOverPolygonCoordinates.length >= 2) {
51509
51415
  ctx.beginPath();
@@ -51756,7 +51662,7 @@ class MapDraw extends React.PureComponent {
51756
51662
  drawLine(ctx, XYCoords, featureIndex, lineStringIndex) {
51757
51663
  const {
51758
51664
  isInEditMode,
51759
- featureNrToEdit
51665
+ selectedFeatureIndex
51760
51666
  } = this.props;
51761
51667
  const feature = this.geojson.features[featureIndex];
51762
51668
  if (!feature || !feature.geometry) {
@@ -51809,7 +51715,7 @@ class MapDraw extends React.PureComponent {
51809
51715
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
51810
51716
  // @ts-ignore
51811
51717
  middle.y = parseInt(middle.y / (XYCoords.length - 1), 10);
51812
- if (isInEditMode === true && this.snappedPolygonIndex === lineStringIndex && this.selectedEdge !== EDGE.NONE && featureNrToEdit === featureIndex) {
51718
+ if (isInEditMode === true && this.snappedPolygonIndex === lineStringIndex && this.selectedEdge !== EDGE.NONE && selectedFeatureIndex === featureIndex) {
51813
51719
  /* Higlight selected edge of a LineString, previousely detected by mouseover event */
51814
51720
  ctx.beginPath();
51815
51721
  ctx.strokeStyle = '#FF0';
@@ -51830,7 +51736,7 @@ class MapDraw extends React.PureComponent {
51830
51736
  drawPolygon(ctx, XYCoords, featureIndex, polygonIndex) {
51831
51737
  const {
51832
51738
  isInEditMode,
51833
- featureNrToEdit
51739
+ selectedFeatureIndex
51834
51740
  } = this.props;
51835
51741
  const feature = this.geojson.features[featureIndex];
51836
51742
  if (!feature || !feature.geometry) {
@@ -51884,7 +51790,7 @@ class MapDraw extends React.PureComponent {
51884
51790
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
51885
51791
  // @ts-ignore
51886
51792
  middle.y = parseInt(middle.y / (XYCoords.length - 1), 10);
51887
- if (isInEditMode === true && this.snappedPolygonIndex === polygonIndex && this.selectedEdge !== EDGE.NONE && featureNrToEdit === featureIndex) {
51793
+ if (isInEditMode === true && this.snappedPolygonIndex === polygonIndex && this.selectedEdge !== EDGE.NONE && selectedFeatureIndex === featureIndex) {
51888
51794
  /* Higlight selected edge of a polygon, previousely detected by mouseover event */
51889
51795
  ctx.strokeStyle = '#FF0';
51890
51796
  ctx.lineWidth = 5;
@@ -51987,7 +51893,7 @@ class MapDraw extends React.PureComponent {
51987
51893
  const {
51988
51894
  updateGeojson
51989
51895
  } = this.props;
51990
- if (text !== 'new feature created') {
51896
+ if (text !== NEW_FEATURE_CREATED) {
51991
51897
  this.validatePolys(text === 'cancelEdit');
51992
51898
  }
51993
51899
  if (updateGeojson && this.geojson) {
@@ -52003,7 +51909,7 @@ MapDraw.defaultProps = {
52003
51909
  isInEditMode: false,
52004
51910
  isInDeleteMode: false,
52005
51911
  webmapjs: undefined,
52006
- featureNrToEdit: 0
51912
+ selectedFeatureIndex: 0
52007
51913
  };
52008
51914
 
52009
51915
  const MapDrawContainer = ({
@@ -52032,9 +51938,9 @@ const MapDrawContainer = ({
52032
51938
  layer.onClickFeature(hoverInfo);
52033
51939
  }
52034
51940
  },
52035
- updateGeojson: geojson => {
51941
+ updateGeojson: (geojson, reason) => {
52036
51942
  if (layer.updateGeojson) {
52037
- layer.updateGeojson(geojson);
51943
+ layer.updateGeojson(geojson, reason);
52038
51944
  }
52039
51945
  },
52040
51946
  exitDrawModeCallback: reason => {
@@ -52042,7 +51948,7 @@ const MapDrawContainer = ({
52042
51948
  layer.exitDrawModeCallback(reason);
52043
51949
  }
52044
51950
  },
52045
- featureNrToEdit: parseInt(layer.featureNrToEdit || '0', 10)
51951
+ selectedFeatureIndex: parseInt(layer.selectedFeatureIndex || '0', 10)
52046
51952
  }));
52047
51953
  }));
52048
51954
 
@@ -52097,7 +52003,7 @@ const FeatureLayers = ({
52097
52003
  }) => {
52098
52004
  const featureLayerList = geojson ? Array.from(Array(geojson.features.length).keys()).map(index => ({
52099
52005
  key: index,
52100
- value: `layer ${index + 1}: ${geojson.features[index].geometry.type}`
52006
+ value: `feature ${index + 1}: ${geojson.features[index].geometry.type}`
52101
52007
  })) : [];
52102
52008
  return /*#__PURE__*/React__default.createElement(Grid$1, {
52103
52009
  item: true,
@@ -52110,7 +52016,7 @@ const FeatureLayers = ({
52110
52016
  }
52111
52017
  }, /*#__PURE__*/React__default.createElement(InputLabel$1, {
52112
52018
  id: "demo-feature-number"
52113
- }, "Feature layers"), /*#__PURE__*/React__default.createElement(Select$1, {
52019
+ }, "Features"), /*#__PURE__*/React__default.createElement(Select$1, {
52114
52020
  labelId: "demo-feature-type",
52115
52021
  value: (featureLayerList.length ? activeFeatureLayerIndex : '').toString(),
52116
52022
  onChange: event => {
@@ -52555,6 +52461,264 @@ const useGeoJSON = () => {
52555
52461
  };
52556
52462
  };
52557
52463
 
52464
+ /* *
52465
+ * Licensed under the Apache License, Version 2.0 (the "License");
52466
+ * you may not use this file except in compliance with the License.
52467
+ * You may obtain a copy of the License at
52468
+ *
52469
+ * http://www.apache.org/licenses/LICENSE-2.0
52470
+ *
52471
+ * Unless required by applicable law or agreed to in writing, software
52472
+ * distributed under the License is distributed on an "AS IS" BASIS,
52473
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
52474
+ * See the License for the specific language governing permissions and
52475
+ * limitations under the License.
52476
+ *
52477
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
52478
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
52479
+ * */
52480
+ const StoryLayoutGrid = ({
52481
+ mapComponent,
52482
+ children
52483
+ }) => {
52484
+ return /*#__PURE__*/React__default.createElement(Paper$1, null, /*#__PURE__*/React__default.createElement(Box$1, {
52485
+ sx: {
52486
+ display: 'grid',
52487
+ gridTemplateColumns: '70% 30%',
52488
+ gridTemplateRows: '150px 1fr',
52489
+ gridTemplateAreas: "'map controls'\n'map textarea'",
52490
+ width: '100%',
52491
+ height: '100vh'
52492
+ }
52493
+ }, /*#__PURE__*/React__default.createElement(Box$1, {
52494
+ sx: {
52495
+ gridArea: 'map',
52496
+ width: '100%',
52497
+ height: '100%'
52498
+ }
52499
+ }, mapComponent), /*#__PURE__*/React__default.createElement(Box$1, {
52500
+ sx: {
52501
+ gridArea: 'controls',
52502
+ width: '100%',
52503
+ height: '100%',
52504
+ padding: 2
52505
+ }
52506
+ }, /*#__PURE__*/React__default.createElement(Grid$1, {
52507
+ spacing: 2,
52508
+ container: true
52509
+ }, children))));
52510
+ };
52511
+
52512
+ const SelectField = ({
52513
+ label,
52514
+ value,
52515
+ onChangeValue,
52516
+ options: _options = [],
52517
+ width: _width = '50%',
52518
+ showValueAsColor: _showValueAsColor = false,
52519
+ labelSuffix: _labelSuffix = ''
52520
+ }) => {
52521
+ const onChange = event => {
52522
+ const {
52523
+ value
52524
+ } = event.target;
52525
+ onChangeValue(value);
52526
+ };
52527
+ const getLabel = currentValue => `${currentValue}${_labelSuffix}`;
52528
+ return /*#__PURE__*/React__default.createElement(FormControl$1, {
52529
+ variant: "filled",
52530
+ sx: {
52531
+ width: _width
52532
+ }
52533
+ }, /*#__PURE__*/React__default.createElement(InputLabel$1, null, label), /*#__PURE__*/React__default.createElement(Select$1, {
52534
+ value: value,
52535
+ onChange: onChange
52536
+ }, _options.map(value => /*#__PURE__*/React__default.createElement(MenuItem$1, {
52537
+ value: value,
52538
+ key: value
52539
+ }, _showValueAsColor ? /*#__PURE__*/React__default.createElement(Box$1, {
52540
+ sx: {
52541
+ backgroundColor: value,
52542
+ width: 20,
52543
+ height: 20
52544
+ }
52545
+ }) : getLabel(value.toString())))));
52546
+ };
52547
+
52548
+ function n(n){for(var r=arguments.length,t=Array(r>1?r-1:0),e=1;e<r;e++)t[e-1]=arguments[e];if("production"!==process.env.NODE_ENV){var i=Y[n],o=i?"function"==typeof i?i.apply(null,t):i:"unknown error nr: "+n;throw Error("[Immer] "+o)}throw Error("[Immer] minified error nr: "+n+(t.length?" "+t.map((function(n){return "'"+n+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function r(n){return !!n&&!!n[Q]}function t(n){var r;return !!n&&(function(n){if(!n||"object"!=typeof n)return !1;var r=Object.getPrototypeOf(n);if(null===r)return !0;var t=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return t===Object||"function"==typeof t&&Function.toString.call(t)===Z}(n)||Array.isArray(n)||!!n[L]||!!(null===(r=n.constructor)||void 0===r?void 0:r[L])||s(n)||v(n))}function i(n,r,t){void 0===t&&(t=!1),0===o(n)?(t?Object.keys:nn)(n).forEach((function(e){t&&"symbol"==typeof e||r(e,n[e],n);})):n.forEach((function(t,e){return r(e,t,n)}));}function o(n){var r=n[Q];return r?r.i>3?r.i-4:r.i:Array.isArray(n)?1:s(n)?2:v(n)?3:0}function u(n,r){return 2===o(n)?n.has(r):Object.prototype.hasOwnProperty.call(n,r)}function a(n,r){return 2===o(n)?n.get(r):n[r]}function f(n,r,t){var e=o(n);2===e?n.set(r,t):3===e?n.add(t):n[r]=t;}function c(n,r){return n===r?0!==n||1/n==1/r:n!=n&&r!=r}function s(n){return X&&n instanceof Map}function v(n){return q&&n instanceof Set}function p(n){return n.o||n.t}function l(n){if(Array.isArray(n))return Array.prototype.slice.call(n);var r=rn(n);delete r[Q];for(var t=nn(r),e=0;e<t.length;e++){var i=t[e],o=r[i];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:n[i]});}return Object.create(Object.getPrototypeOf(n),r)}function d(n,e){return void 0===e&&(e=!1),y(n)||r(n)||!t(n)||(o(n)>1&&(n.set=n.add=n.clear=n.delete=h),Object.freeze(n),e&&i(n,(function(n,r){return d(r,!0)}),!0)),n}function h(){n(2);}function y(n){return null==n||"object"!=typeof n||Object.isFrozen(n)}function b(r){var t=tn[r];return t||n(18,r),t}function _(){return "production"===process.env.NODE_ENV||U||n(0),U}function j(n,r){r&&(b("Patches"),n.u=[],n.s=[],n.v=r);}function g(n){O(n),n.p.forEach(S),n.p=null;}function O(n){n===U&&(U=n.l);}function w(n){return U={p:[],l:U,h:n,m:!0,_:0}}function S(n){var r=n[Q];0===r.i||1===r.i?r.j():r.g=!0;}function P(r,e){e._=e.p.length;var i=e.p[0],o=void 0!==r&&r!==i;return e.h.O||b("ES5").S(e,r,o),o?(i[Q].P&&(g(e),n(4)),t(r)&&(r=M(e,r),e.l||x(e,r)),e.u&&b("Patches").M(i[Q].t,r,e.u,e.s)):r=M(e,i,[]),g(e),e.u&&e.v(e.u,e.s),r!==H?r:void 0}function M(n,r,t){if(y(r))return r;var e=r[Q];if(!e)return i(r,(function(i,o){return A(n,e,r,i,o,t)}),!0),r;if(e.A!==n)return r;if(!e.P)return x(n,e.t,!0),e.t;if(!e.I){e.I=!0,e.A._--;var o=4===e.i||5===e.i?e.o=l(e.k):e.o,u=o,a=!1;3===e.i&&(u=new Set(o),o.clear(),a=!0),i(u,(function(r,i){return A(n,e,o,r,i,t,a)})),x(n,o,!1),t&&n.u&&b("Patches").N(e,t,n.u,n.s);}return e.o}function A(e,i,o,a,c,s,v){if("production"!==process.env.NODE_ENV&&c===o&&n(5),r(c)){var p=M(e,c,s&&i&&3!==i.i&&!u(i.R,a)?s.concat(a):void 0);if(f(o,a,p),!r(p))return;e.m=!1;}else v&&o.add(c);if(t(c)&&!y(c)){if(!e.h.D&&e._<1)return;M(e,c),i&&i.A.l||x(e,c);}}function x(n,r,t){void 0===t&&(t=!1),!n.l&&n.h.D&&n.m&&d(r,t);}function z(n,r){var t=n[Q];return (t?p(t):n)[r]}function I(n,r){if(r in n)for(var t=Object.getPrototypeOf(n);t;){var e=Object.getOwnPropertyDescriptor(t,r);if(e)return e;t=Object.getPrototypeOf(t);}}function k(n){n.P||(n.P=!0,n.l&&k(n.l));}function E(n){n.o||(n.o=l(n.t));}function N(n,r,t){var e=s(r)?b("MapSet").F(r,t):v(r)?b("MapSet").T(r,t):n.O?function(n,r){var t=Array.isArray(n),e={i:t?1:0,A:r?r.A:_(),P:!1,I:!1,R:{},l:r,t:n,k:null,o:null,j:null,C:!1},i=e,o=en;t&&(i=[e],o=on);var u=Proxy.revocable(i,o),a=u.revoke,f=u.proxy;return e.k=f,e.j=a,f}(r,t):b("ES5").J(r,t);return (t?t.A:_()).p.push(e),e}function R(e){return r(e)||n(22,e),function n(r){if(!t(r))return r;var e,u=r[Q],c=o(r);if(u){if(!u.P&&(u.i<4||!b("ES5").K(u)))return u.t;u.I=!0,e=D(r,c),u.I=!1;}else e=D(r,c);return i(e,(function(r,t){u&&a(u.t,r)===t||f(e,r,n(t));})),3===c?new Set(e):e}(e)}function D(n,r){switch(r){case 2:return new Map(n);case 3:return Array.from(n)}return l(n)}var G,U,W="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),X="undefined"!=typeof Map,q="undefined"!=typeof Set,B="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,H=W?Symbol.for("immer-nothing"):((G={})["immer-nothing"]=!0,G),L=W?Symbol.for("immer-draftable"):"__$immer_draftable",Q=W?Symbol.for("immer-state"):"__$immer_state",Y={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(n){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(n){return "Cannot apply patch, path doesn't resolve: "+n},16:'Sets cannot have "replace" patches.',17:function(n){return "Unsupported patch operation: "+n},18:function(n){return "The plugin for '"+n+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+n+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(n){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+n+"'"},22:function(n){return "'current' expects a draft, got: "+n},23:function(n){return "'original' expects a draft, got: "+n},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Z=""+Object.prototype.constructor,nn="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames,rn=Object.getOwnPropertyDescriptors||function(n){var r={};return nn(n).forEach((function(t){r[t]=Object.getOwnPropertyDescriptor(n,t);})),r},tn={},en={get:function(n,r){if(r===Q)return n;var e=p(n);if(!u(e,r))return function(n,r,t){var e,i=I(r,t);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(n.k):void 0}(n,e,r);var i=e[r];return n.I||!t(i)?i:i===z(n.t,r)?(E(n),n.o[r]=N(n.A.h,i,n)):i},has:function(n,r){return r in p(n)},ownKeys:function(n){return Reflect.ownKeys(p(n))},set:function(n,r,t){var e=I(p(n),r);if(null==e?void 0:e.set)return e.set.call(n.k,t),!0;if(!n.P){var i=z(p(n),r),o=null==i?void 0:i[Q];if(o&&o.t===t)return n.o[r]=t,n.R[r]=!1,!0;if(c(t,i)&&(void 0!==t||u(n.t,r)))return !0;E(n),k(n);}return n.o[r]===t&&(void 0!==t||r in n.o)||Number.isNaN(t)&&Number.isNaN(n.o[r])||(n.o[r]=t,n.R[r]=!0),!0},deleteProperty:function(n,r){return void 0!==z(n.t,r)||r in n.t?(n.R[r]=!1,E(n),k(n)):delete n.R[r],n.o&&delete n.o[r],!0},getOwnPropertyDescriptor:function(n,r){var t=p(n),e=Reflect.getOwnPropertyDescriptor(t,r);return e?{writable:!0,configurable:1!==n.i||"length"!==r,enumerable:e.enumerable,value:t[r]}:e},defineProperty:function(){n(11);},getPrototypeOf:function(n){return Object.getPrototypeOf(n.t)},setPrototypeOf:function(){n(12);}},on={};i(en,(function(n,r){on[n]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)};})),on.deleteProperty=function(r,t){return "production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&n(13),on.set.call(this,r,t,void 0)},on.set=function(r,t,e){return "production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&n(14),en.set.call(this,r[0],t,e,r[0])};var un=function(){function e(r){var e=this;this.O=B,this.D=!0,this.produce=function(r,i,o){if("function"==typeof r&&"function"!=typeof i){var u=i;i=r;var a=e;return function(n){var r=this;void 0===n&&(n=u);for(var t=arguments.length,e=Array(t>1?t-1:0),o=1;o<t;o++)e[o-1]=arguments[o];return a.produce(n,(function(n){var t;return (t=i).call.apply(t,[r,n].concat(e))}))}}var f;if("function"!=typeof i&&n(6),void 0!==o&&"function"!=typeof o&&n(7),t(r)){var c=w(e),s=N(e,r,void 0),v=!0;try{f=i(s),v=!1;}finally{v?g(c):O(c);}return "undefined"!=typeof Promise&&f instanceof Promise?f.then((function(n){return j(c,o),P(n,c)}),(function(n){throw g(c),n})):(j(c,o),P(f,c))}if(!r||"object"!=typeof r){if(void 0===(f=i(r))&&(f=r),f===H&&(f=void 0),e.D&&d(f,!0),o){var p=[],l=[];b("Patches").M(r,f,p,l),o(p,l);}return f}n(21,r);},this.produceWithPatches=function(n,r){if("function"==typeof n)return function(r){for(var t=arguments.length,i=Array(t>1?t-1:0),o=1;o<t;o++)i[o-1]=arguments[o];return e.produceWithPatches(r,(function(r){return n.apply(void 0,[r].concat(i))}))};var t,i,o=e.produce(n,r,(function(n,r){t=n,i=r;}));return "undefined"!=typeof Promise&&o instanceof Promise?o.then((function(n){return [n,t,i]})):[o,t,i]},"boolean"==typeof(null==r?void 0:r.useProxies)&&this.setUseProxies(r.useProxies),"boolean"==typeof(null==r?void 0:r.autoFreeze)&&this.setAutoFreeze(r.autoFreeze);}var i=e.prototype;return i.createDraft=function(e){t(e)||n(8),r(e)&&(e=R(e));var i=w(this),o=N(this,e,void 0);return o[Q].C=!0,O(i),o},i.finishDraft=function(r,t){var e=r&&r[Q];"production"!==process.env.NODE_ENV&&(e&&e.C||n(9),e.I&&n(10));var i=e.A;return j(i,t),P(void 0,i)},i.setAutoFreeze=function(n){this.D=n;},i.setUseProxies=function(r){r&&!B&&n(20),this.O=r;},i.applyPatches=function(n,t){var e;for(e=t.length-1;e>=0;e--){var i=t[e];if(0===i.path.length&&"replace"===i.op){n=i.value;break}}e>-1&&(t=t.slice(e+1));var o=b("Patches").$;return r(n)?o(n,t):this.produce(n,(function(n){return o(n,t)}))},e}(),an=new un,fn=an.produce;an.produceWithPatches.bind(an);an.setAutoFreeze.bind(an);an.setUseProxies.bind(an);an.applyPatches.bind(an);an.createDraft.bind(an);an.finishDraft.bind(an);var produce = fn;
52549
+
52550
+ /**
52551
+ * Adds properties to the first geojson feature based on the given property object.
52552
+ * It only extends or changes the properties which are defined in styleConfig,
52553
+ * all other properties in the geojson are left unchanged.
52554
+ * @param geojson
52555
+ * @param featureProperties
52556
+ */
52557
+ const addFeatureProperties = (geojson, featureProperties, featureIndex = 0) => {
52558
+ if (!geojson) {
52559
+ return null;
52560
+ }
52561
+ return produce(geojson, draft => {
52562
+ if (draft.features && draft.features.length > 0 && draft.features[featureIndex] !== undefined && draft.features[featureIndex].properties) {
52563
+ Object.keys(featureProperties).forEach(key => {
52564
+ draft.features[featureIndex].properties[key] = featureProperties[key];
52565
+ });
52566
+ }
52567
+ });
52568
+ };
52569
+ const getGeoJSONPropertyValue = (property, properties, polygonDrawMode, defaultProperties = defaultGeoJSONStyleProperties) => {
52570
+ // if a shape is set, extract the style from there
52571
+ if (properties[property] !== undefined) {
52572
+ return properties[property];
52573
+ }
52574
+ // if active polygon tool is preset, retreive style from there
52575
+ if (polygonDrawMode) {
52576
+ const polygonDrawModeProperty = polygonDrawMode.shape.type === 'Feature' && polygonDrawMode.shape.properties[property];
52577
+ if (polygonDrawModeProperty !== undefined) {
52578
+ return polygonDrawModeProperty;
52579
+ }
52580
+ }
52581
+ // otherwise get values from defaultStyle
52582
+ return defaultProperties[property];
52583
+ };
52584
+ /**
52585
+ * moves geoJSON feature as new feature. Mutates newGeoJSON
52586
+ * @constructor
52587
+ * @param {GeoJSON.FeatureCollection} currentGeoJSON - current geoJSON
52588
+ * @param {GeoJSON.FeatureCollection} newGeoJSON - new geoJSON
52589
+ * @param {number} featureLayerIndex - feature layer index
52590
+ * @param {string} text - reason of change
52591
+ */
52592
+ const moveFeature = (currentGeoJSON, newGeoJSON, featureLayerIndex, reason) => {
52593
+ const feature = newGeoJSON.features[featureLayerIndex];
52594
+ const currentFeature = currentGeoJSON.features[featureLayerIndex];
52595
+ if (feature) {
52596
+ const {
52597
+ geometry
52598
+ } = feature;
52599
+ if (geometry.type === 'Polygon' && geometry.coordinates.length > 1 && reason === NEW_FEATURE_CREATED) {
52600
+ const lastCoordinate = geometry.coordinates.pop();
52601
+ const copyFeature = Object.assign(Object.assign({}, feature), {
52602
+ geometry: Object.assign(Object.assign({}, geometry), {
52603
+ coordinates: [lastCoordinate]
52604
+ })
52605
+ });
52606
+ newGeoJSON.features.push(copyFeature);
52607
+ return newGeoJSON.features.length - 1;
52608
+ }
52609
+ if (geometry.type === 'LineString' && geometry.coordinates.length > 2 && reason === NEW_LINESTRING_CREATED) {
52610
+ const lastCoordinate = geometry.coordinates.pop();
52611
+ const copyFeature = Object.assign(Object.assign({}, feature), {
52612
+ geometry: Object.assign(Object.assign({}, geometry), {
52613
+ coordinates: [lastCoordinate, lastCoordinate]
52614
+ })
52615
+ });
52616
+ newGeoJSON.features.push(copyFeature);
52617
+ return newGeoJSON.features.length - 1;
52618
+ }
52619
+ if (geometry.type === 'Point' && currentFeature && currentFeature.geometry.type === 'Point' && currentFeature.geometry.coordinates.length > 0 && reason === NEW_POINT_CREATED) {
52620
+ newGeoJSON.features.push(currentFeature);
52621
+ return newGeoJSON.features.length - 1;
52622
+ }
52623
+ }
52624
+ return undefined;
52625
+ };
52626
+ /**
52627
+ * Returns the intersection of two features. In case of a polygon, only the first feature is used.
52628
+ * @param a Feature A
52629
+ * @param b Feature B
52630
+ * @returns The intersection of the two features.
52631
+ */
52632
+ const intersectGeoJSONS = (a, b, geoJSONProperties = {
52633
+ stroke: '#FF0000',
52634
+ 'stroke-width': 10.0,
52635
+ 'stroke-opacity': 1,
52636
+ fill: '#0000FF',
52637
+ 'fill-opacity': 1.0
52638
+ }) => {
52639
+ const featureA = feature(a.features[0].geometry);
52640
+ const featureB = feature(b.features[0].geometry);
52641
+ const options = {
52642
+ tolerance: 0.001,
52643
+ highQuality: true
52644
+ };
52645
+ const simplifiedA = simplify$1(featureA, options);
52646
+ const simplifiedB = simplify$1(featureB, options);
52647
+ const intersection = intersect(simplifiedA, simplifiedB);
52648
+ return addFeatureProperties({
52649
+ type: 'FeatureCollection',
52650
+ features: intersection === null ? [{
52651
+ type: 'Feature',
52652
+ properties: {
52653
+ selectionType: 'poly'
52654
+ },
52655
+ geometry: {
52656
+ type: 'Polygon',
52657
+ coordinates: [[]]
52658
+ }
52659
+ }] : [intersection]
52660
+ }, geoJSONProperties);
52661
+ };
52662
+ /**
52663
+ * Adds the intersectionStart and intersectionEnd properties to the GeoJSONS structure
52664
+ * @param geoJSONs
52665
+ * @returns GeoJSONS extend with intersections
52666
+ */
52667
+ const createInterSections = (geojson, otherGeoJSON, geoJSONproperties = {
52668
+ stroke: '#f24a00',
52669
+ 'stroke-width': 1.5,
52670
+ 'stroke-opacity': 1,
52671
+ fill: '#f24a00',
52672
+ 'fill-opacity': 0.5
52673
+ }) => {
52674
+ const intersections = produce(geojson, () => {
52675
+ try {
52676
+ return addFeatureProperties(intersectGeoJSONS(geojson, otherGeoJSON), geoJSONproperties);
52677
+ } catch (error) {
52678
+ return addFeatureProperties(geojson, geoJSONproperties);
52679
+ }
52680
+ });
52681
+ return intersections;
52682
+ };
52683
+ const getGeoJson = (geojson, shouldAllowMultipleShapes) => {
52684
+ if (shouldAllowMultipleShapes || !geojson.features.length) {
52685
+ return geojson;
52686
+ }
52687
+ const {
52688
+ geometry
52689
+ } = geojson.features[0];
52690
+ if (geometry.type === 'Point' || geometry.type === 'LineString') {
52691
+ return geojson;
52692
+ }
52693
+ return geometry.coordinates.length > 1 ? produce(geojson, draft => {
52694
+ const draftFeature = draft.features[0];
52695
+ draftFeature.geometry.coordinates = [draftFeature.geometry.coordinates[1]];
52696
+ }) : geojson;
52697
+ };
52698
+ const getFeatureCollection = (geoJSONFeature, shouldAllowMultipleShapes, geoJSONFeatureCollection = emptyGeoJSON) => {
52699
+ if (geoJSONFeature.type === 'FeatureCollection') {
52700
+ return geoJSONFeature;
52701
+ }
52702
+ if (shouldAllowMultipleShapes) {
52703
+ return Object.assign(Object.assign({}, geoJSONFeatureCollection), {
52704
+ features: geoJSONFeatureCollection.features.concat(geoJSONFeature)
52705
+ });
52706
+ }
52707
+ return Object.assign(Object.assign({}, geoJSONFeatureCollection), {
52708
+ features: [geoJSONFeature]
52709
+ });
52710
+ };
52711
+ // compares 2 geoJSONs and returns true if both have properties.selectionType with the same value
52712
+ const isGeoJSONFeatureCreatedByTool = (existingJSON, newGeoJSON) => {
52713
+ var _a, _b, _c;
52714
+ if (!existingJSON.features.length) {
52715
+ return false;
52716
+ }
52717
+ const lastUsedTool = (_a = existingJSON.features[0].properties) === null || _a === void 0 ? void 0 : _a.selectionType;
52718
+ const newTool = newGeoJSON.type === 'Feature' ? (_b = newGeoJSON.properties) === null || _b === void 0 ? void 0 : _b.selectionType : (_c = newGeoJSON.features[0].properties) === null || _c === void 0 ? void 0 : _c.selectionType;
52719
+ return lastUsedTool !== undefined && newTool !== undefined ? lastUsedTool === newTool : false;
52720
+ };
52721
+
52558
52722
  const defaultIntersectionStyleProperties = Object.assign(Object.assign({}, defaultGeoJSONStyleProperties), {
52559
52723
  'fill-opacity': 0.5
52560
52724
  });
@@ -52636,8 +52800,8 @@ const defaultDelete = {
52636
52800
  const defaultModes = [defaultPoint, defaultPolygon, defaultBox, defaultLineString, defaultDelete];
52637
52801
  const currentlySupportedDrawModes = [defaultPolygon, defaultDelete];
52638
52802
  const useMapDrawTool = ({
52639
- defaultEditModes: _defaultEditModes = defaultModes,
52640
- shouldAllowMultipleshapes: _shouldAllowMultipleshapes = false,
52803
+ defaultDrawModes: _defaultDrawModes = defaultModes,
52804
+ shouldAllowMultipleShapes: _shouldAllowMultipleShapes = false,
52641
52805
  defaultGeoJSON: _defaultGeoJSON = emptyGeoJSON,
52642
52806
  defaultGeoJSONIntersection: _defaultGeoJSONIntersection = emptyIntersectionShape,
52643
52807
  defaultGeoJSONIntersectionBounds,
@@ -52648,14 +52812,14 @@ const useMapDrawTool = ({
52648
52812
  const [geoJSONIntersection, setGeoJSONIntersection] = React__default.useState(_defaultGeoJSONIntersection);
52649
52813
  const [geoJSONIntersectionBounds, setGeoJSONIntersectionBounds] = React__default.useState(defaultGeoJSONIntersectionBounds);
52650
52814
  // state
52651
- const [editModes, setEditModes] = React__default.useState(_defaultEditModes);
52815
+ const [drawModes, setDrawModes] = React__default.useState(_defaultDrawModes);
52652
52816
  const [activeTool, setActiveTool] = React__default.useState('');
52653
52817
  const [drawMode, setDrawMode] = React__default.useState('');
52654
52818
  const [isInEditMode, setEditMode] = React__default.useState(false);
52655
52819
  const [featureLayerIndex, setFeatureLayerIndex] = React__default.useState(0);
52656
52820
  const changeProperties = styleProperties => {
52657
52821
  // update all modes with new properties
52658
- const newModes = editModes.map(mode => {
52822
+ const newModes = drawModes.map(mode => {
52659
52823
  const shape = mode.shape.type === 'Feature' ? Object.assign(Object.assign({}, mode.shape), {
52660
52824
  properties: Object.assign(Object.assign({}, mode.shape.properties), styleProperties)
52661
52825
  }) : addFeatureProperties(mode.shape, styleProperties);
@@ -52663,7 +52827,7 @@ const useMapDrawTool = ({
52663
52827
  shape
52664
52828
  });
52665
52829
  });
52666
- setEditModes(newModes);
52830
+ setDrawModes(newModes);
52667
52831
  // update current geoJSON with new properties
52668
52832
  const updateGeoJSON = addFeatureProperties(geoJSON, styleProperties, featureLayerIndex);
52669
52833
  setGeoJSON(updateGeoJSON);
@@ -52684,7 +52848,7 @@ const useMapDrawTool = ({
52684
52848
  setActiveTool(newMode.drawModeId);
52685
52849
  // updates shape
52686
52850
  const isNewSelectedTool = !isGeoJSONFeatureCreatedByTool(geoJSON, newMode.shape);
52687
- const shouldUpdateShape = !geoJSON.features.length || _shouldAllowMultipleshapes || isNewSelectedTool;
52851
+ const shouldUpdateShape = !geoJSON.features.length || _shouldAllowMultipleShapes || isNewSelectedTool;
52688
52852
  if (shouldUpdateShape) {
52689
52853
  const updatedGeoJSON = changeGeoJSON(newMode.shape);
52690
52854
  setFeatureLayerIndex(updatedGeoJSON.features.length - 1);
@@ -52693,9 +52857,15 @@ const useMapDrawTool = ({
52693
52857
  setDrawMode(newMode.value);
52694
52858
  setEditMode(!!newMode.value);
52695
52859
  };
52696
- const changeGeoJSON = updatedGeoJSON => {
52697
- const geoJSONFeatureCollection = getFeatureCollection(updatedGeoJSON, _shouldAllowMultipleshapes, geoJSON);
52698
- const newGeoJSON = getGeoJson(geoJSONFeatureCollection, _shouldAllowMultipleshapes);
52860
+ const changeGeoJSON = (updatedGeoJSON, reason = '') => {
52861
+ const geoJSONFeatureCollection = getFeatureCollection(updatedGeoJSON, _shouldAllowMultipleShapes, geoJSON);
52862
+ const newGeoJSON = getGeoJson(geoJSONFeatureCollection, _shouldAllowMultipleShapes);
52863
+ if (_shouldAllowMultipleShapes) {
52864
+ const newFeatureIndex = moveFeature(geoJSON, newGeoJSON, featureLayerIndex, reason);
52865
+ if (newFeatureIndex !== undefined) {
52866
+ setFeatureLayerIndex(newFeatureIndex);
52867
+ }
52868
+ }
52699
52869
  setGeoJSON(newGeoJSON);
52700
52870
  if (geoJSONIntersectionBounds) {
52701
52871
  setGeoJSONIntersection(createInterSections(newGeoJSON, geoJSONIntersectionBounds, _defaultGeoJSONIntersectionProperties));
@@ -52710,7 +52880,7 @@ const useMapDrawTool = ({
52710
52880
  };
52711
52881
  const onSetDrawMode = drawMode => {
52712
52882
  setDrawMode(drawMode);
52713
- const newActiveTool = editModes.find(mode => mode.value === drawMode);
52883
+ const newActiveTool = drawModes.find(mode => mode.value === drawMode);
52714
52884
  if (newActiveTool) {
52715
52885
  setActiveTool(newActiveTool.drawModeId);
52716
52886
  }
@@ -52737,7 +52907,7 @@ const useMapDrawTool = ({
52737
52907
  isInEditMode,
52738
52908
  drawMode,
52739
52909
  updateGeojson: changeGeoJSON,
52740
- featureNrToEdit: featureLayerIndex
52910
+ selectedFeatureIndex: featureLayerIndex
52741
52911
  };
52742
52912
  }
52743
52913
  // intersections
@@ -52754,7 +52924,7 @@ const useMapDrawTool = ({
52754
52924
  geoJSONIntersectionBounds,
52755
52925
  setGeoJSON: changeGeoJSON,
52756
52926
  setGeoJSONIntersectionBounds: onSetGeoJSONIntersectionBounds,
52757
- editModes,
52927
+ drawModes,
52758
52928
  isInEditMode,
52759
52929
  changeDrawMode: onSetDrawMode,
52760
52930
  setEditMode,
@@ -52766,12 +52936,66 @@ const useMapDrawTool = ({
52766
52936
  layers,
52767
52937
  getLayer,
52768
52938
  deactivateTool,
52769
- setEditModes,
52939
+ setDrawModes,
52770
52940
  changeProperties,
52771
52941
  getProperties
52772
52942
  };
52773
52943
  };
52774
52944
 
52945
+ // custom buttons
52946
+ const shapeButtonNL = {
52947
+ drawModeId: 'tool-fir',
52948
+ value: DRAWMODE.POLYGON,
52949
+ title: 'Custom FIR NL polygon',
52950
+ shape: intersectionFeatureNL,
52951
+ isSelectable: false
52952
+ };
52953
+ const customLineButton = {
52954
+ drawModeId: 'tool-custom-line',
52955
+ value: DRAWMODE.LINESTRING,
52956
+ title: 'Custom LineString',
52957
+ shape: {
52958
+ type: 'Feature',
52959
+ geometry: {
52960
+ type: 'LineString',
52961
+ coordinates: [[4.136829504703722, 50.944730810381465], [4.450134704406403, 53.81224530783831], [2.5703035061903217, 53.78911570560625], [5.252979278644519, 56.722490281934554], [8.758081200318252, 53.85846624679025], [6.290802752659646, 53.84691579421783], [6.623689527343743, 51.0556380592049], [4.136829504703722, 50.95706693142843]]
52962
+ },
52963
+ properties: defaultGeoJSONStyleProperties
52964
+ },
52965
+ isSelectable: false
52966
+ };
52967
+ // example options
52968
+ const basicExampleDrawOptions = {
52969
+ defaultGeoJSON: {
52970
+ type: 'FeatureCollection',
52971
+ features: [{
52972
+ type: 'Feature',
52973
+ properties: Object.assign(Object.assign({}, defaultGeoJSONStyleProperties), {
52974
+ selectionType: 'box'
52975
+ }),
52976
+ geometry: {
52977
+ type: 'Polygon',
52978
+ coordinates: [[[9.451665078283622, 53.21804334226515], [4.734608638338736, 53.21804334226515], [4.734608638338736, 54.57650543915101], [9.451665078283622, 54.57650543915101], [9.451665078283622, 53.21804334226515]]]
52979
+ }
52980
+ }]
52981
+ }
52982
+ };
52983
+ const basicExampleMultipleShapeDrawOptions = {
52984
+ shouldAllowMultipleShapes: true,
52985
+ // add multiple tools, and update all with custom color
52986
+ defaultDrawModes: [...defaultModes, shapeButtonNL, customLineButton].map(mode => Object.assign(Object.assign({}, mode), {
52987
+ shape: Object.assign(Object.assign({}, mode.shape), {
52988
+ properties: Object.assign(Object.assign({}, mode.shape.properties), {
52989
+ stroke: '#8F8',
52990
+ 'stroke-width': 4,
52991
+ 'stroke-opacity': 1,
52992
+ fill: '#33ccFF',
52993
+ 'fill-opacity': 0.5
52994
+ })
52995
+ })
52996
+ }))
52997
+ };
52998
+
52775
52999
  var fails$5 = fails$j;
52776
53000
  var global$4 = global$h;
52777
53001
 
@@ -54503,6 +54727,8 @@ class ReactMapView extends React.Component {
54503
54727
  zIndex: 10
54504
54728
  }
54505
54729
  }, /*#__PURE__*/React.createElement("div", {
54730
+ role: "application",
54731
+ "aria-label": "map",
54506
54732
  ref: this.adagucWebMapJSRef
54507
54733
  })), /*#__PURE__*/React.createElement("div", {
54508
54734
  style: {
@@ -56348,4 +56574,4 @@ var publicLayers = /*#__PURE__*/Object.freeze({
56348
56574
  msgNaturalEUMETSAT: msgNaturalEUMETSAT
56349
56575
  });
56350
56576
 
56351
- export { CanvasComponent, DRAWMODE, EDITMODE, EditModeButton as EditModeButtonField, FeatureLayers, GeoJSONTextField, Legend, LegendDialog, LegendLayout, MapControlButton, MapControls, MapDrawContainer, MapTime, MapView, MapViewLayer, MapWarningProperties, ORIGIN_REACTMAPVIEW_ONMAPCHANGEDIMENSION, ORIGIN_REACTMAPVIEW_ONUPDATELAYERINFO, ReactMapView, ReactMapViewLayer, ZoomControls, addFeatureProperties, checkHoverFeatures, createInterSections, currentlySupportedDrawModes, defaultBox, defaultDelete, defaultGeoJSONStyleProperties, defaultIntersectionStyleProperties, defaultLayers, defaultModes, defaultPoint, defaultPolygon, defaultTimeFormat, distance, drawPolyStoryStyles, emptyGeoJSON, featureBox, featureMultiPoint, featurePoint, featurePolygon, formatTime, getDrawFunctionFromStore, getFeatureCollection, getGeoJson, getIcon, getTimeDimension, intersectGeoJSONS, intersectionFeatureBE, intersectionFeatureNL, isGeoJSONFeatureCreatedByTool, lineString, publicLayers, publicServices, registerDrawFunction, simpleBoxGeoJSON, simpleFlightRouteLineStringGeoJSON, simpleFlightRoutePointsGeoJSON, simpleLineStringGeoJSON, simpleMultiPolygon, simplePointsGeojson, simplePolygonGeoJSON, simpleSmallLineStringGeoJSON, useGeoJSON, useMapDrawTool };
56577
+ export { CanvasComponent, DRAWMODE, EDITMODE, EditModeButton as EditModeButtonField, FeatureLayers, GeoJSONTextField, Legend, LegendDialog, LegendLayout, MapControlButton, MapControls, MapDrawContainer, MapTime, MapView, MapViewLayer, MapWarningProperties, NEW_FEATURE_CREATED, NEW_LINESTRING_CREATED, NEW_POINT_CREATED, ORIGIN_REACTMAPVIEW_ONMAPCHANGEDIMENSION, ORIGIN_REACTMAPVIEW_ONUPDATELAYERINFO, ReactMapView, ReactMapViewLayer, SelectField, StoryLayoutGrid, ZoomControls, addFeatureProperties, basicExampleDrawOptions, basicExampleMultipleShapeDrawOptions, checkHoverFeatures, createInterSections, currentlySupportedDrawModes, defaultBox, defaultDelete, defaultGeoJSONStyleProperties, defaultIntersectionStyleProperties, defaultLayers, defaultModes, defaultPoint, defaultPolygon, defaultTimeFormat, distance, drawPolyStoryStyles, emptyGeoJSON, featureBox, featureMultiPoint, featurePoint, featurePolygon, formatTime, getDrawFunctionFromStore, getFeatureCollection, getGeoJSONPropertyValue, getGeoJson, getIcon, getTimeDimension, intersectGeoJSONS, intersectionFeatureBE, intersectionFeatureNL, isGeoJSONFeatureCreatedByTool, lineString, moveFeature, publicLayers, publicServices, registerDrawFunction, simpleBoxGeoJSON, simpleFlightRouteLineStringGeoJSON, simpleFlightRoutePointsGeoJSON, simpleLineStringGeoJSON, simpleMultiPolygon, simplePointsGeojson, simplePolygonGeoJSON, simpleSmallLineStringGeoJSON, useGeoJSON, useMapDrawTool };