@opengeoweb/webmap-react 9.8.0 → 9.9.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
@@ -8,9 +8,8 @@ import proj4 from 'proj4';
8
8
  import * as turf from '@turf/turf';
9
9
  import { polygonToLineString, booleanClockwise, rewind } from '@turf/turf';
10
10
  import { Delete, Edit, DrawRegion, DrawPolygon, Location, DrawFIRLand, ArrowUp, Home, Add, Minus } from '@opengeoweb/theme';
11
- import produce from 'immer';
11
+ import { produce } from 'immer';
12
12
  import { debounce } from 'throttle-debounce';
13
- import { differenceInMinutes } from 'date-fns';
14
13
  import { useResizeDetector } from 'react-resize-detector';
15
14
 
16
15
  /* *
@@ -3053,12 +3052,14 @@ class MapDraw extends React.PureComponent {
3053
3052
  isInEditMode,
3054
3053
  isInDeleteMode,
3055
3054
  drawMode,
3056
- mapId
3055
+ mapId,
3056
+ selectedFeatureIndex
3057
3057
  } = this.props;
3058
3058
  const prevGeojson = prevProps && prevProps.geojson;
3059
3059
  const prevIsInEditMode = prevProps && prevProps.isInEditMode;
3060
3060
  const prevIsInDeleteMode = prevProps && prevProps.isInDeleteMode;
3061
3061
  const prevDrawMode = prevProps && prevProps.drawMode;
3062
+ const prevSelectedFeatureIndex = prevProps && prevProps.selectedFeatureIndex;
3062
3063
  /* Handle geojson update */
3063
3064
  if (geojson !== prevGeojson) {
3064
3065
  this.handleGeoJSONUpdate(geojson);
@@ -3087,6 +3088,9 @@ class MapDraw extends React.PureComponent {
3087
3088
  this.myEditMode = EDITMODE.EMPTY;
3088
3089
  }
3089
3090
  }
3091
+ if (selectedFeatureIndex !== prevSelectedFeatureIndex) {
3092
+ webmapUtils.getWMJSMapById(mapId).draw('MapDraw::componentDidUpdateSelectedFeatureIndex');
3093
+ }
3090
3094
  /* Handle new drawmode */
3091
3095
  if (drawMode !== prevDrawMode) {
3092
3096
  /* Handle drawmode */
@@ -3137,14 +3141,14 @@ class MapDraw extends React.PureComponent {
3137
3141
  const XYCoords = [];
3138
3142
  const from = getProj4(proj.lonlat);
3139
3143
  const to = getProj4(proj.crs);
3140
- for (let j = 0; j < featureCoords.length; j += 1) {
3141
- if (featureCoords[j].length < 2) {
3144
+ for (const featureCoord of featureCoords) {
3145
+ if (featureCoord.length < 2) {
3142
3146
  // eslint-disable-next-line no-continue
3143
3147
  continue;
3144
3148
  }
3145
3149
  let coordinates = {
3146
- x: featureCoords[j][0],
3147
- y: featureCoords[j][1]
3150
+ x: featureCoord[0],
3151
+ y: featureCoord[1]
3148
3152
  };
3149
3153
  coordinates = proj.proj4.transform(from, to, coordinates);
3150
3154
  const x = width * (coordinates.x - bbox.left) / (bbox.right - bbox.left);
@@ -3876,11 +3880,9 @@ class MapDraw extends React.PureComponent {
3876
3880
  const incY = this.mouseGeoCoord.y - this.snappedGeoCoords.y;
3877
3881
  this.snappedGeoCoords.x = this.mouseGeoCoord.x;
3878
3882
  this.snappedGeoCoords.y = this.mouseGeoCoord.y;
3879
- for (let j = 0; j < featureCoords.length; j += 1) {
3880
- /* eslint-disable-next-line no-param-reassign */
3881
- featureCoords[j][0] += incX;
3882
- /* eslint-disable-next-line no-param-reassign */
3883
- featureCoords[j][1] += incY;
3883
+ for (const featureCoord of featureCoords) {
3884
+ featureCoord[0] += incX;
3885
+ featureCoord[1] += incY;
3884
3886
  }
3885
3887
  if (this.myEditMode !== EDITMODE.ADD_FEATURE) {
3886
3888
  this.somethingWasDragged = DRAGMODE.FEATURE;
@@ -4002,18 +4004,18 @@ class MapDraw extends React.PureComponent {
4002
4004
  if (!this.geojson || !this.geojson.features || !this.geojson.features.length) {
4003
4005
  return;
4004
4006
  }
4005
- for (let featureIndex = 0; featureIndex < this.geojson.features.length; featureIndex += 1) {
4007
+ for (const geoJsonFeature of this.geojson.features) {
4006
4008
  if (!this.geojson.features) {
4007
4009
  this.geojson.features = [];
4008
4010
  }
4009
- const feature = this.geojson.features[featureIndex];
4011
+ const feature = geoJsonFeature;
4010
4012
  this.validateFeature(feature);
4011
4013
  const featureType = feature.geometry.type;
4012
4014
  if (featureType === 'Polygon') {
4013
4015
  /* Loop through all polygons of the same feature */
4014
4016
  const polygonGeometry = feature.geometry;
4015
- for (let polygonIndex = 0; polygonIndex < polygonGeometry.coordinates.length; polygonIndex += 1) {
4016
- let featureCoords = polygonGeometry.coordinates[polygonIndex];
4017
+ for (const polyCoordinates of polygonGeometry.coordinates) {
4018
+ let featureCoords = polyCoordinates;
4017
4019
  /* Remove duplicates */
4018
4020
  if (!this.checkIfFeatureIsBox(feature)) {
4019
4021
  for (let coordIndex = featureCoords.length - 2; coordIndex >= 0; coordIndex -= 1) {
@@ -4131,8 +4133,7 @@ class MapDraw extends React.PureComponent {
4131
4133
  }
4132
4134
  if (featureType === 'MultiPolygon') {
4133
4135
  const multiPolygonGeometry = feature.geometry;
4134
- for (let multiPolygonIndex = 0; multiPolygonIndex < multiPolygonGeometry.coordinates.length; multiPolygonIndex += 1) {
4135
- const multiPoly = multiPolygonGeometry.coordinates[multiPolygonIndex];
4136
+ for (const multiPoly of multiPolygonGeometry.coordinates) {
4136
4137
  for (let polygonIndex = 0; polygonIndex < multiPoly.length; polygonIndex += 1) {
4137
4138
  const featureCoords = multiPoly[polygonIndex];
4138
4139
  const XYCoords = this.getPixelCoordFromGeoCoord(featureCoords);
@@ -4257,12 +4258,12 @@ class MapDraw extends React.PureComponent {
4257
4258
  }
4258
4259
  }
4259
4260
  /* Draw labels */
4260
- for (let j = 0; j < this.textPositions.length; j += 1) {
4261
+ for (const textPosition of this.textPositions) {
4261
4262
  const {
4262
4263
  x,
4263
4264
  y,
4264
4265
  text
4265
- } = this.textPositions[j];
4266
+ } = textPosition;
4266
4267
  ctx.fillStyle = 'black';
4267
4268
  ctx.font = '12px Arial';
4268
4269
  ctx.fillText(text, x, y);
@@ -4641,14 +4642,14 @@ class MapDraw extends React.PureComponent {
4641
4642
  } = this.props;
4642
4643
  const webmapjs = webmapUtils.getWMJSMapById(mapId);
4643
4644
  const XYCoords = [];
4644
- for (let j = 0; j < featureCoords.length; j += 1) {
4645
- if (featureCoords[j].length < 2) {
4645
+ for (const featureCoord of featureCoords) {
4646
+ if (featureCoord.length < 2) {
4646
4647
  // eslint-disable-next-line no-continue
4647
4648
  continue;
4648
4649
  }
4649
4650
  const coord = webmapjs.getPixelCoordFromLatLong({
4650
- x: featureCoords[j][0],
4651
- y: featureCoords[j][1]
4651
+ x: featureCoord[0],
4652
+ y: featureCoord[1]
4652
4653
  });
4653
4654
  XYCoords.push(coord);
4654
4655
  }
@@ -4900,6 +4901,22 @@ const EditModeButton = ({
4900
4901
  }, "press ESC to exit draw mode")))));
4901
4902
  };
4902
4903
 
4904
+ /* *
4905
+ * Licensed under the Apache License, Version 2.0 (the "License");
4906
+ * you may not use this file except in compliance with the License.
4907
+ * You may obtain a copy of the License at
4908
+ *
4909
+ * http://www.apache.org/licenses/LICENSE-2.0
4910
+ *
4911
+ * Unless required by applicable law or agreed to in writing, software
4912
+ * distributed under the License is distributed on an "AS IS" BASIS,
4913
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4914
+ * See the License for the specific language governing permissions and
4915
+ * limitations under the License.
4916
+ *
4917
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4918
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
4919
+ * */
4903
4920
  const simplePolygonGeoJSON = {
4904
4921
  type: 'FeatureCollection',
4905
4922
  features: [{
@@ -5201,9 +5218,7 @@ const intersectionFeatureNL = {
5201
5218
  type: 'Polygon',
5202
5219
  coordinates: [[[5.0, 55.0], [4.331914, 55.332644], [3.368817, 55.764314], [2.761908, 54.379261], [3.15576, 52.913554], [2.000002, 51.500002], [3.370001, 51.369722], [3.370527, 51.36867], [3.362223, 51.320002], [3.36389, 51.313608], [3.373613, 51.309999], [3.952501, 51.214441], [4.397501, 51.452776], [5.078611, 51.391665], [5.848333, 51.139444], [5.651667, 50.824717], [6.011797, 50.757273], [5.934168, 51.036386], [6.222223, 51.361666], [5.94639, 51.811663], [6.405001, 51.830828], [7.053095, 52.237764], [7.031389, 52.268885], [7.063612, 52.346109], [7.065557, 52.385828], [7.133055, 52.888887], [7.14218, 52.898244], [7.191667, 53.3], [6.5, 53.666667], [6.500002, 55.000002], [5.0, 55.0]]]
5203
5220
  },
5204
- properties: Object.assign(Object.assign({}, defaultGeoJSONStyleProperties), {
5205
- selectionType: 'fir'
5206
- })
5221
+ properties: defaultGeoJSONStyleProperties
5207
5222
  };
5208
5223
  const intersectionFeatureBE = {
5209
5224
  type: 'Feature',
@@ -5211,9 +5226,7 @@ const intersectionFeatureBE = {
5211
5226
  type: 'Polygon',
5212
5227
  coordinates: [[[4.83163899984, 51.4375169997], [4.83971700004, 51.4211280003], [4.78471399965, 51.4327609998], [4.7811030004, 51.4302970004], [4.77944200025, 51.4175190002], [4.80665799987, 51.4100140003], [4.88973599992, 51.4160859998], [4.90944699968, 51.4091530002], [4.97808600027, 51.4238780003], [5.01693300026, 51.4755610004], [5.03137199972, 51.4852999999], [5.04139699977, 51.4866750004], [5.05027800013, 51.4747000003], [5.06139400013, 51.4719500003], [5.10058599984, 51.4399779999], [5.07663599975, 51.3988970003], [5.07864199963, 51.3916780001], [5.12780000027, 51.3497389997], [5.14000300004, 51.3208609998], [5.14945799989, 51.3171939998], [5.178908, 51.3166780003], [5.22806699979, 51.3122110002], [5.22523100031, 51.2688940001], [5.25029999985, 51.2633360001], [5.32971099986, 51.2621920004], [5.34724199982, 51.2694670004], [5.38752200024, 51.2677470002], [5.46779400039, 51.2827610001], [5.517222, 51.2958330004], [5.54250799964, 51.2769170004], [5.55780600005, 51.2639109996], [5.55666699968, 51.2558330003], [5.5572329997, 51.2313669998], [5.5591809996, 51.2244330002], [5.64942199993, 51.2016859998], [5.65555300027, 51.1964140004], [5.71055599976, 51.1822219997], [5.73553599969, 51.1916609998], [5.77696099985, 51.180258], [5.77942500016, 51.1694279997], [5.82806899958, 51.1669640003], [5.85500000045, 51.1510939996], [5.85601899978, 51.1473080004], [5.8472219997, 51.1352779996], [5.81695299958, 51.1225030004], [5.84056100009, 51.1058309996], [5.80641099997, 51.0958610003], [5.80280299996, 51.093339], [5.80222800042, 51.0616560003], [5.7752999997, 51.0597080004], [5.77140299985, 51.0475029997], [5.76332499965, 51.0394250004], [5.76303899995, 51.0352999999], [5.7747280003, 51.028594], [5.77696099985, 51.0258470001], [5.76418599978, 50.9899779999], [5.74802800019, 50.9819579997], [5.72276099962, 50.9652829996], [5.72390600026, 50.9577779998], [5.72831700043, 50.9561169996], [5.74418900032, 50.9577779998], [5.72974999996, 50.9141749999], [5.7150249999, 50.9105669999], [5.68406700039, 50.8831669999], [5.66555600021, 50.8769439998], [5.65331699968, 50.8783079997], [5.64776099977, 50.8677670001], [5.63750299976, 50.8502920001], [5.63945299976, 50.8430719999], [5.6472220001, 50.8324999998], [5.70001400015, 50.8069169999], [5.70052799957, 50.8033079999], [5.69806400015, 50.7999859996], [5.69694399977, 50.7897220002], [5.6933110004, 50.762514], [5.69308099969, 50.7591919997], [5.73719699984, 50.7594190003], [5.76195000009, 50.7763810001], [5.7747280003, 50.7816500002], [5.77862200001, 50.7794169998], [5.77999699956, 50.7758639996], [5.79747499977, 50.7694469996], [5.80417800041, 50.7647499997], [5.83888900033, 50.7616669996], [5.84720599986, 50.7669250002], [5.85471099971, 50.7591919997], [5.88307199997, 50.7664109999], [5.89250000037, 50.7544440002], [5.93251899955, 50.756956], [5.99888899983, 50.7538889998], [6.01163300026, 50.7566690003], [6.01611400006, 50.765264], [6.06666700028, 50.7166670001], [6.11666700018, 50.7333329997], [6.16666700008, 50.6666670002], [6.2500000002, 50.6499999996], [6.28333300042, 50.6166670003], [6.2500000002, 50.5999999997], [6.2500000002, 50.583333], [6.2000000003, 50.5499999998], [6.1986110001, 50.5194439999], [6.2500000002, 50.4833330002], [6.35, 50.4666669997], [6.37388899998, 50.4349999999], [6.38333300022, 50.4333330003], [6.40833300017, 50.3333329996], [6.3000000001, 50.316667], [6.29916700036, 50.303056], [6.23166700013, 50.2388889997], [6.1500000004, 50.1499999997], [6.13301100026, 50.1268060003], [6.11655799965, 50.0714689998], [6.12647199998, 50.0711830001], [6.11322499973, 50.0586359998], [6.13316099998, 50.0435579996], [6.14093299956, 49.9935890002], [6.16349999973, 49.9814360001], [6.15971699974, 49.9746389996], [6.17998600005, 49.9583389997], [6.18282499967, 49.9675310001], [6.18998899999, 49.9667970004], [6.21388899958, 49.955556], [6.22060299983, 49.9355170004], [6.22500000025, 49.9083329996], [6.23418300015, 49.897519], [6.30860799956, 49.8644609999], [6.32110000006, 49.8483030003], [6.32195800006, 49.8399940002], [6.34109700043, 49.8475000001], [6.36917200009, 49.8419420001], [6.4435970004, 49.8094560003], [6.50307200017, 49.8072219998], [6.51304200039, 49.8041860001], [6.5222080004, 49.8111170004], [6.52140600029, 49.7974810002], [6.50668100023, 49.7863670003], [6.51751099963, 49.7580609999], [6.49997799959, 49.7419610003], [6.5166500004, 49.7194439997], [6.49779999987, 49.7203029998], [6.50141100002, 49.7060940001], [6.46111099957, 49.6916670003], [6.42085300017, 49.6658169999], [6.42056400033, 49.6602579998], [6.43805600028, 49.6541670004], [6.42499999985, 49.638889], [6.42499999985, 49.6333330001], [6.37944399984, 49.5969440002], [6.3719220001, 49.5872059999], [6.3750139997, 49.5822220002], [6.36137800039, 49.5752889998], [6.37335300044, 49.549161], [6.36779699963, 49.5422280004], [6.36166700023, 49.4543310003], [6.2805329999, 49.4930689997], [6.21666699998, 49.5000000001], [6.15304999986, 49.5025220004], [6.15969699972, 49.4933560004], [6.12251400002, 49.4839029997], [6.11804199974, 49.469692], [6.09054199961, 49.4530749999], [6.06916899965, 49.4633329999], [6.04321399973, 49.4534189996], [5.9999999998, 49.4500000002], [5.95833300017, 49.4833330004], [5.8511029997, 49.5052720004], [5.80858100021, 49.5446939999], [5.75833299967, 49.5361109998], [5.48333300022, 49.5000000001], [5.4000000001, 49.6083330002], [5.31666699998, 49.6166669996], [5.3000000003, 49.6666670004], [5.17499999965, 49.6916670003], [5.06666699958, 49.7583329999], [5.0, 49.7833329998], [4.8500000003, 49.7833329998], [4.85833299967, 49.9166669999], [4.8000000004, 49.9500000001], [4.83888899963, 50.0472220004], [4.87222199985, 50.088889], [4.86749999973, 50.1152780002], [4.87022799962, 50.1267969999], [4.89647500042, 50.1402000001], [4.88140799988, 50.1486169998], [4.87752199964, 50.1560970003], [4.85856400043, 50.1539169996], [4.83766699993, 50.1585920002], [4.82454400001, 50.1676309998], [4.81676900029, 50.1657609999], [4.80753599989, 50.1536059996], [4.76428099987, 50.1377080003], [4.7499999996, 50.1180559997], [4.74027800003, 50.1083330001], [4.73317799996, 50.1093419998], [4.71540300045, 50.0977579998], [4.68333300002, 50.0], [4.48333300042, 49.9333330004], [4.18333300012, 49.9500000001], [4.12499999995, 50.0166669997], [4.14888899993, 50.0347220004], [4.1999999998, 50.0999999998], [4.11666699968, 50.1499999997], [4.16666699958, 50.2500000004], [4.17222200035, 50.2833329997], [4.01666699988, 50.3500000002], [3.9000000004, 50.316667], [3.79166700033, 50.3333329996], [3.7099999997, 50.3083329997], [3.6599999998, 50.3719440004], [3.61666699978, 50.4833330002], [3.40499999995, 50.4633329997], [3.27666700028, 50.5300000002], [3.22499999995, 50.6783330004], [3.11666699988, 50.7833329996], [2.8999999997, 50.7000000004], [2.81666699958, 50.7250000003], [2.71666699978, 50.8000000002], [2.63333299962, 50.8166669999], [2.5500000004, 51.0833329999], [1.9999999997, 51.1166670002], [1.9999999997, 51.4999999997], [3.0000000004, 51.4086179998], [3.10027800043, 51.3994440003], [3.36388899988, 51.3736109997], [3.38724200032, 51.3413280003], [3.38377200038, 51.3313580001], [3.36248900007, 51.3184579996], [3.37401700018, 51.3050059998], [3.36470599978, 51.3019560004], [3.36492800013, 51.2987639998], [3.3813890002, 51.2836109997], [3.42589999969, 51.2589609998], [3.43277200003, 51.2486970004], [3.45504400008, 51.2451440002], [3.49817799991, 51.2463390004], [3.53010600009, 51.2507780001], [3.52079199955, 51.2930780001], [3.52611400036, 51.2955750002], [3.54363099967, 51.2896110003], [3.56447200028, 51.2968220001], [3.58376100037, 51.2897499996], [3.58575599974, 51.3012609998], [3.59285000043, 51.3063919999], [3.6037139996, 51.3037579998], [3.64140600029, 51.2876689998], [3.65204699997, 51.2872530004], [3.65847799976, 51.2835080004], [3.69151399977, 51.2815669999], [3.71390800005, 51.2744940002], [3.73109999967, 51.2727249996], [3.75780600005, 51.2722750004], [3.76866900007, 51.2646470003], [3.77842500031, 51.2670030001], [3.79084200006, 51.2625669997], [3.79061899967, 51.2514719997], [3.79039700022, 51.2199890003], [3.80370000035, 51.2145779999], [3.84560600022, 51.2120829999], [3.86400799987, 51.2141639997], [3.87886100043, 51.2273390002], [3.88846099978, 51.2265610003], [3.88839700042, 51.217214], [3.88462800018, 51.2088920003], [3.91278600007, 51.209725], [3.92298299997, 51.220958], [3.9300779998, 51.2226220003], [3.93916899995, 51.2165219996], [3.94870299984, 51.215828], [3.97109700013, 51.2215139996], [4.10833300027, 51.2708330004], [4.25143300013, 51.3750060002], [4.33391100039, 51.3766670004], [4.34307800045, 51.3647500003], [4.3469750003, 51.3625169999], [4.41859199972, 51.3591360004], [4.43165799972, 51.3644639997], [4.42805599998, 51.3744440004], [4.3966499996, 51.4169469999], [4.40942499966, 51.4375169997], [4.40805000011, 51.440839], [4.39389999959, 51.4502919998], [4.46528900019, 51.4716639997], [4.4986109999, 51.4788890001], [4.51250000007, 51.4805559997], [4.54556100034, 51.4850140002], [4.54498900004, 51.4627830002], [4.53805599958, 51.4524690003], [4.53530599957, 51.4397500002], [4.62361099965, 51.4272219998], [4.67166899992, 51.4274890004], [4.67304400038, 51.4308109998], [4.66863300021, 51.440839], [4.68415800029, 51.4494329997], [4.69859699975, 51.4644440004], [4.76918600033, 51.502775], [4.80833299977, 51.4999999997], [4.8408059999, 51.4830670003], [4.84470299974, 51.4614079998], [4.83696700003, 51.4569389996], [4.83163899984, 51.4375169997]]]
5213
5228
  },
5214
- properties: Object.assign(Object.assign({}, defaultGeoJSONStyleProperties), {
5215
- selectionType: 'fir-be'
5216
- })
5229
+ properties: defaultGeoJSONStyleProperties
5217
5230
  };
5218
5231
 
5219
5232
  const drawPolyStoryStyles = {
@@ -5570,11 +5583,38 @@ const getGeoJson = (geojson, shouldAllowMultipleShapes) => {
5570
5583
  draftFeature.geometry.coordinates = [draftFeature.geometry.coordinates[1]];
5571
5584
  }) : geojson;
5572
5585
  };
5586
+ const hasFeatures = geometry => {
5587
+ if (geometry.type === 'Point') {
5588
+ return geometry.coordinates.length > 0;
5589
+ }
5590
+ if (geometry.type === 'LineString' || geometry.type === 'Polygon') {
5591
+ return geometry.coordinates[0].length > 0;
5592
+ }
5593
+ return false;
5594
+ };
5595
+ const getLastEmptyFeatureIndex = geoJSONFeatureCollection => {
5596
+ const totalFeatures = geoJSONFeatureCollection.features.length;
5597
+ if (totalFeatures > 0) {
5598
+ const lastFeatureIndex = totalFeatures - 1;
5599
+ const lastFeature = geoJSONFeatureCollection.features[lastFeatureIndex];
5600
+ if (!hasFeatures(lastFeature.geometry)) {
5601
+ return lastFeatureIndex;
5602
+ }
5603
+ }
5604
+ return undefined;
5605
+ };
5573
5606
  const getFeatureCollection = (geoJSONFeature, shouldAllowMultipleShapes, geoJSONFeatureCollection = emptyGeoJSON) => {
5574
5607
  if (geoJSONFeature.type === 'FeatureCollection') {
5575
5608
  return geoJSONFeature;
5576
5609
  }
5577
5610
  if (shouldAllowMultipleShapes) {
5611
+ const lastFeatureIndex = getLastEmptyFeatureIndex(geoJSONFeatureCollection);
5612
+ if (lastFeatureIndex !== undefined) {
5613
+ // replace last feature if it's an empty shape
5614
+ return Object.assign(Object.assign({}, geoJSONFeatureCollection), {
5615
+ features: geoJSONFeatureCollection.features.map((feature, index) => index === lastFeatureIndex ? geoJSONFeature : feature)
5616
+ });
5617
+ }
5578
5618
  return Object.assign(Object.assign({}, geoJSONFeatureCollection), {
5579
5619
  features: geoJSONFeatureCollection.features.concat(geoJSONFeature)
5580
5620
  });
@@ -5583,15 +5623,14 @@ const getFeatureCollection = (geoJSONFeature, shouldAllowMultipleShapes, geoJSON
5583
5623
  features: [geoJSONFeature]
5584
5624
  });
5585
5625
  };
5586
- // compares 2 geoJSONs and returns true if both have properties.selectionType with the same value
5587
- const isGeoJSONFeatureCreatedByTool = (existingJSON, newGeoJSON) => {
5588
- var _a, _b, _c;
5626
+ // check if geoJSON has same selectionType in properties as passed selectionType
5627
+ const isGeoJSONFeatureCreatedByTool = (existingJSON, selectionType, featureLayerIndex = 0) => {
5628
+ var _a;
5589
5629
  if (!existingJSON.features.length) {
5590
5630
  return false;
5591
5631
  }
5592
- const lastUsedTool = (_a = existingJSON.features[0].properties) === null || _a === void 0 ? void 0 : _a.selectionType;
5593
- 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;
5594
- return lastUsedTool !== undefined && newTool !== undefined ? lastUsedTool === newTool : false;
5632
+ const lastUsedTool = (_a = existingJSON.features[featureLayerIndex].properties) === null || _a === void 0 ? void 0 : _a.selectionType;
5633
+ return lastUsedTool !== undefined && selectionType !== undefined ? lastUsedTool === selectionType : false;
5595
5634
  };
5596
5635
  const rewindGeometry = geoJSON => {
5597
5636
  return produce(geoJSON, geoJSONDraft => {
@@ -5607,45 +5646,53 @@ const rewindGeometry = geoJSON => {
5607
5646
  }
5608
5647
  });
5609
5648
  };
5649
+ const addGeoJSONPropertiesToFeature = (geoJSONFeature, newProperties) => Object.assign(Object.assign({}, geoJSONFeature), {
5650
+ properties: Object.assign(Object.assign({}, geoJSONFeature.properties), newProperties)
5651
+ });
5652
+ const addGeoJSONProperties = (geoJSON, newProperties) => {
5653
+ if (geoJSON.type === 'Feature') {
5654
+ return addGeoJSONPropertiesToFeature(geoJSON, newProperties);
5655
+ }
5656
+ return Object.assign(Object.assign({}, geoJSON), {
5657
+ features: geoJSON.features.map(feature => addGeoJSONPropertiesToFeature(feature, newProperties))
5658
+ });
5659
+ };
5660
+ const addSelectionTypeToGeoJSON = (geoJSON, selectionType) => {
5661
+ return addGeoJSONProperties(geoJSON, {
5662
+ selectionType
5663
+ });
5664
+ };
5610
5665
 
5611
5666
  const defaultIntersectionStyleProperties = Object.assign(Object.assign({}, defaultGeoJSONStyleProperties), {
5612
5667
  'fill-opacity': 0.5
5613
5668
  });
5614
5669
  const emptyLineString = Object.assign(Object.assign({}, lineString.features[0]), {
5615
- properties: Object.assign(Object.assign({}, defaultGeoJSONStyleProperties), {
5616
- selectionType: 'linestring'
5617
- })
5670
+ properties: defaultGeoJSONStyleProperties
5618
5671
  });
5619
5672
  const emptyPoint = Object.assign(Object.assign({}, featurePoint), {
5620
- properties: Object.assign(Object.assign({}, defaultGeoJSONStyleProperties), {
5621
- selectionType: 'point'
5622
- })
5673
+ properties: defaultGeoJSONStyleProperties
5623
5674
  });
5624
5675
  const emptyPolygon = Object.assign(Object.assign({}, featurePolygon), {
5625
- properties: Object.assign(Object.assign({}, defaultGeoJSONStyleProperties), {
5626
- selectionType: 'poly'
5627
- })
5676
+ properties: defaultGeoJSONStyleProperties
5628
5677
  });
5629
5678
  const emptyBox = Object.assign(Object.assign({}, featurePolygon), {
5630
- properties: Object.assign(Object.assign({}, defaultGeoJSONStyleProperties), {
5631
- selectionType: 'box'
5632
- })
5679
+ properties: defaultGeoJSONStyleProperties
5633
5680
  });
5634
5681
  // TODO: improve this: without a feature, the custom shape does not work on first click
5635
5682
  const emptyIntersectionShape = Object.assign(Object.assign({}, emptyGeoJSON), {
5636
5683
  features: [featurePolygon]
5637
5684
  });
5638
- const getIcon = drawModeId => {
5639
- switch (drawModeId) {
5640
- case 'drawtools-point':
5685
+ const getIcon = selectionType => {
5686
+ switch (selectionType) {
5687
+ case 'point':
5641
5688
  return /*#__PURE__*/React__default.createElement(Location, null);
5642
- case 'drawtools-polygon':
5689
+ case 'poly':
5643
5690
  return /*#__PURE__*/React__default.createElement(DrawPolygon, null);
5644
- case 'drawtools-box':
5691
+ case 'box':
5645
5692
  return /*#__PURE__*/React__default.createElement(DrawRegion, null);
5646
- case 'drawtools-linestring':
5693
+ case 'linestring':
5647
5694
  return /*#__PURE__*/React__default.createElement(Edit, null);
5648
- case 'drawtools-delete':
5695
+ case 'delete':
5649
5696
  return /*#__PURE__*/React__default.createElement(Delete, null);
5650
5697
  default:
5651
5698
  return null;
@@ -5656,35 +5703,40 @@ const defaultPoint = {
5656
5703
  value: DRAWMODE.POINT,
5657
5704
  title: 'Point',
5658
5705
  shape: emptyPoint,
5659
- isSelectable: true
5706
+ isSelectable: true,
5707
+ selectionType: 'point'
5660
5708
  };
5661
5709
  const defaultPolygon = {
5662
5710
  drawModeId: 'drawtools-polygon',
5663
5711
  value: DRAWMODE.POLYGON,
5664
5712
  title: 'Polygon',
5665
5713
  shape: emptyPolygon,
5666
- isSelectable: true
5714
+ isSelectable: true,
5715
+ selectionType: 'poly'
5667
5716
  };
5668
5717
  const defaultBox = {
5669
5718
  drawModeId: 'drawtools-box',
5670
5719
  value: DRAWMODE.BOX,
5671
5720
  title: 'Box',
5672
5721
  shape: emptyBox,
5673
- isSelectable: true
5722
+ isSelectable: true,
5723
+ selectionType: 'box'
5674
5724
  };
5675
5725
  const defaultLineString = {
5676
5726
  drawModeId: 'drawtools-linestring',
5677
5727
  value: DRAWMODE.LINESTRING,
5678
5728
  title: 'LineString',
5679
5729
  shape: emptyLineString,
5680
- isSelectable: true
5730
+ isSelectable: true,
5731
+ selectionType: 'linestring'
5681
5732
  };
5682
5733
  const defaultDelete = {
5683
5734
  drawModeId: 'drawtools-delete',
5684
5735
  value: 'DELETE',
5685
5736
  title: 'Delete',
5686
5737
  shape: emptyGeoJSON,
5687
- isSelectable: false
5738
+ isSelectable: false,
5739
+ selectionType: 'delete'
5688
5740
  };
5689
5741
  const defaultModes = [defaultPoint, defaultPolygon, defaultBox, defaultLineString, defaultDelete];
5690
5742
  const currentlySupportedDrawModes = [defaultPolygon, defaultDelete];
@@ -5712,11 +5764,8 @@ const useMapDrawTool = ({
5712
5764
  const changeProperties = styleProperties => {
5713
5765
  // update all modes with new properties
5714
5766
  const newModes = drawModes.map(mode => {
5715
- const shape = mode.shape.type === 'Feature' ? Object.assign(Object.assign({}, mode.shape), {
5716
- properties: Object.assign(Object.assign({}, mode.shape.properties), styleProperties)
5717
- }) : addFeatureProperties(mode.shape, styleProperties);
5718
5767
  return Object.assign(Object.assign({}, mode), {
5719
- shape
5768
+ shape: addGeoJSONProperties(mode.shape, styleProperties)
5720
5769
  });
5721
5770
  });
5722
5771
  setDrawModes(newModes);
@@ -5739,10 +5788,10 @@ const useMapDrawTool = ({
5739
5788
  }
5740
5789
  setActiveTool(newMode.isSelectable ? newMode.drawModeId : '');
5741
5790
  // updates shape
5742
- const isNewSelectedTool = !isGeoJSONFeatureCreatedByTool(geoJSON, newMode.shape);
5743
- const shouldUpdateShape = !geoJSON.features.length || _shouldAllowMultipleShapes || isNewSelectedTool;
5791
+ const isNewSelectedTool = !isGeoJSONFeatureCreatedByTool(geoJSON, newMode.selectionType, featureLayerIndex);
5792
+ const shouldUpdateShape = !geoJSON.features.length || isNewSelectedTool;
5744
5793
  if (shouldUpdateShape) {
5745
- const updatedGeoJSON = changeGeoJSON(newMode.shape);
5794
+ const updatedGeoJSON = changeGeoJSON(addSelectionTypeToGeoJSON(newMode.shape, newMode.selectionType));
5746
5795
  setFeatureLayerIndex(updatedGeoJSON.features.length - 1);
5747
5796
  }
5748
5797
  // handle modes and update feature layer index
@@ -5777,10 +5826,21 @@ const useMapDrawTool = ({
5777
5826
  setActiveTool(newActiveTool.drawModeId);
5778
5827
  }
5779
5828
  };
5829
+ const removeLastEmptyShape = () => {
5830
+ const lastFeatureIndex = getLastEmptyFeatureIndex(geoJSON);
5831
+ if (lastFeatureIndex !== undefined) {
5832
+ const newGeoJSON = Object.assign(Object.assign({}, geoJSON), {
5833
+ features: geoJSON.features.filter((_feature, index) => index !== lastFeatureIndex)
5834
+ });
5835
+ setGeoJSON(newGeoJSON);
5836
+ setFeatureLayerIndex(newGeoJSON.features.length > 0 ? newGeoJSON.features.length - 1 : 0);
5837
+ }
5838
+ };
5780
5839
  const deactivateTool = () => {
5781
5840
  setEditMode(false);
5782
5841
  setActiveTool('');
5783
5842
  setDrawMode('');
5843
+ removeLastEmptyShape();
5784
5844
  };
5785
5845
  const reset = (shouldClearState = false) => {
5786
5846
  deactivateTool();
@@ -5837,15 +5897,15 @@ const useMapDrawTool = ({
5837
5897
  const opacityOptions = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0];
5838
5898
  const fillOptions = [defaultGeoJSONStyleProperties.fill, '#6e1e91', '#FF00FF', '#33ccFF', '#8F8'];
5839
5899
  const strokeWidthOptions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1];
5840
- const getToolIcon = id => {
5841
- const defaultIcon = getIcon(id);
5900
+ const getToolIcon = selectionType => {
5901
+ const defaultIcon = getIcon(selectionType);
5842
5902
  if (defaultIcon) {
5843
5903
  return defaultIcon;
5844
5904
  }
5845
- if (id === 'tool-fir') {
5905
+ if (selectionType === shapeButtonNL$2.selectionType) {
5846
5906
  return /*#__PURE__*/React__default.createElement(DrawFIRLand, null);
5847
5907
  }
5848
- if (id === 'tool-custom-line') {
5908
+ if (selectionType === customLineButton.selectionType) {
5849
5909
  return /*#__PURE__*/React__default.createElement(ArrowUp, null);
5850
5910
  }
5851
5911
  return /*#__PURE__*/React__default.createElement(DrawFIRLand, null);
@@ -5856,7 +5916,8 @@ const shapeButtonNL$2 = {
5856
5916
  value: DRAWMODE.POLYGON,
5857
5917
  title: 'Custom FIR NL polygon',
5858
5918
  shape: intersectionFeatureNL,
5859
- isSelectable: false
5919
+ isSelectable: false,
5920
+ selectionType: 'custom-fir'
5860
5921
  };
5861
5922
  const customLineButton = {
5862
5923
  drawModeId: 'tool-custom-line',
@@ -5870,7 +5931,8 @@ const customLineButton = {
5870
5931
  },
5871
5932
  properties: defaultGeoJSONStyleProperties
5872
5933
  },
5873
- isSelectable: false
5934
+ isSelectable: false,
5935
+ selectionType: 'custom-line'
5874
5936
  };
5875
5937
  const basicExampleDrawOptions = {
5876
5938
  defaultDrawModes: [...defaultModes, shapeButtonNL$2, customLineButton],
@@ -5904,15 +5966,15 @@ const basicExampleMultipleShapeDrawOptions = {
5904
5966
  }))
5905
5967
  };
5906
5968
 
5907
- const getIntersectionToolIcon = id => {
5908
- const defaultIcon = getIcon(id);
5969
+ const getIntersectionToolIcon = selectionType => {
5970
+ const defaultIcon = getIcon(selectionType);
5909
5971
  if (defaultIcon) {
5910
5972
  return defaultIcon;
5911
5973
  }
5912
- if (id === 'fir-nl') {
5974
+ if (selectionType === shapeButtonNL$1.selectionType) {
5913
5975
  return /*#__PURE__*/React__default.createElement(DrawFIRLand, null);
5914
5976
  }
5915
- if (id === 'fir-be') {
5977
+ if (selectionType === shapeButtonBE$1.selectionType) {
5916
5978
  return /*#__PURE__*/React__default.createElement(DrawFIRLand, {
5917
5979
  sx: {
5918
5980
  transform: `scaleY(-1)`
@@ -5927,14 +5989,16 @@ const shapeButtonNL$1 = {
5927
5989
  value: DRAWMODE.POLYGON,
5928
5990
  title: 'Custom FIR NL polygon',
5929
5991
  shape: intersectionFeatureNL,
5930
- isSelectable: false
5992
+ isSelectable: false,
5993
+ selectionType: 'fir-NL'
5931
5994
  };
5932
5995
  const shapeButtonBE$1 = {
5933
5996
  drawModeId: 'fir-be',
5934
5997
  value: DRAWMODE.POLYGON,
5935
5998
  title: 'Custom FIR BE polygon',
5936
5999
  shape: intersectionFeatureBE,
5937
- isSelectable: false
6000
+ isSelectable: false,
6001
+ selectionType: 'fir-BE'
5938
6002
  };
5939
6003
  const geoJSONIntersectionBoundsStyle$1 = {
5940
6004
  stroke: '#000000',
@@ -6025,7 +6089,7 @@ const exampleIntersectionWithShapeOptions = {
6025
6089
  defaultGeoJSONIntersectionProperties: featurePropsIntersectionEnd
6026
6090
  };
6027
6091
 
6028
- const firButtonDrawId = 'fir-button';
6092
+ const firSelectionType = 'fir';
6029
6093
  // styles and shapes
6030
6094
  const featurePropertiesStart = defaultGeoJSONStyleProperties;
6031
6095
  const featurePropertiesEnd = {
@@ -6045,33 +6109,31 @@ const geoJSONIntersectionBoundsStyle = {
6045
6109
  const intersectionShapeNL = {
6046
6110
  type: 'FeatureCollection',
6047
6111
  features: [Object.assign(Object.assign({}, intersectionFeatureNL), {
6048
- properties: Object.assign(Object.assign({}, geoJSONIntersectionBoundsStyle), {
6049
- selectionType: 'fir'
6050
- })
6112
+ properties: Object.assign({}, geoJSONIntersectionBoundsStyle)
6051
6113
  })]
6052
6114
  };
6053
6115
  const intersectionShapeBE = {
6054
6116
  type: 'FeatureCollection',
6055
6117
  features: [Object.assign(Object.assign({}, intersectionFeatureBE), {
6056
- properties: Object.assign(Object.assign({}, geoJSONIntersectionBoundsStyle), {
6057
- selectionType: 'fir'
6058
- })
6118
+ properties: Object.assign({}, geoJSONIntersectionBoundsStyle)
6059
6119
  })]
6060
6120
  };
6061
6121
  // custom buttons
6062
6122
  const shapeButtonNL = {
6063
- drawModeId: firButtonDrawId,
6123
+ drawModeId: 'fir-tool-NL',
6064
6124
  value: DRAWMODE.POLYGON,
6065
6125
  title: 'Custom FIR NL polygon',
6066
6126
  shape: intersectionShapeNL,
6067
- isSelectable: false
6127
+ isSelectable: false,
6128
+ selectionType: firSelectionType
6068
6129
  };
6069
6130
  const shapeButtonBE = {
6070
- drawModeId: firButtonDrawId,
6131
+ drawModeId: 'fir-tool-BE',
6071
6132
  value: DRAWMODE.POLYGON,
6072
6133
  title: 'Custom FIR BE polygon',
6073
6134
  shape: intersectionShapeBE,
6074
- isSelectable: false
6135
+ isSelectable: false,
6136
+ selectionType: firSelectionType
6075
6137
  };
6076
6138
  const exampleIntersectionsMultiDrawTool = [{
6077
6139
  title: 'NL',
@@ -6082,13 +6144,13 @@ const exampleIntersectionsMultiDrawTool = [{
6082
6144
  }];
6083
6145
  const getDoubleControlToolIcon = drawMode => {
6084
6146
  const {
6085
- drawModeId
6147
+ selectionType
6086
6148
  } = drawMode;
6087
- const defaultIcon = getIcon(drawModeId);
6149
+ const defaultIcon = getIcon(selectionType);
6088
6150
  if (defaultIcon) {
6089
6151
  return defaultIcon;
6090
6152
  }
6091
- if (drawModeId === firButtonDrawId) {
6153
+ if (selectionType === firSelectionType) {
6092
6154
  return /*#__PURE__*/React__default.createElement(DrawFIRLand, {
6093
6155
  sx: Object.assign({}, drawMode.title === shapeButtonBE.title && {
6094
6156
  transform: `scaleY(-1)`
@@ -6121,7 +6183,7 @@ const getFirTitle = isNL => isNL ? shapeButtonNL.title : shapeButtonBE.title;
6121
6183
  const updateEditModeButtonsWithFir = (drawModes, newFirGeoJSON) => {
6122
6184
  const isNL = newFirGeoJSON === intersectionShapeNL;
6123
6185
  return drawModes.map(mode => {
6124
- if (mode.drawModeId === firButtonDrawId) {
6186
+ if (mode.selectionType === firSelectionType) {
6125
6187
  return Object.assign(Object.assign({}, mode), {
6126
6188
  shape: getUpdatedFirShape(isNL),
6127
6189
  title: getFirTitle(isNL)
@@ -7611,7 +7673,7 @@ function getIsInsideAcceptanceTime(acceptanceTimeInMinutes, mapDimensions, layer
7611
7673
  if (acceptanceTimeInMinutes === undefined || !mapCurrentTime || !layerCurrentTime) {
7612
7674
  return true;
7613
7675
  }
7614
- const minutesBetween = differenceInMinutes(new Date(mapCurrentTime), new Date(layerCurrentTime));
7676
+ const minutesBetween = dateUtils.differenceInMinutes(new Date(mapCurrentTime), new Date(layerCurrentTime));
7615
7677
  if (Math.abs(minutesBetween) > acceptanceTimeInMinutes) {
7616
7678
  return false;
7617
7679
  }
@@ -7683,8 +7745,8 @@ const setWMLayerPropsBasedOnChildProps = (child, wmLayer, mapViewProps) => {
7683
7745
  }
7684
7746
  /* Set the dimensions of the ADAGUC WMJSLayer */
7685
7747
  if (child.dimensions !== undefined) {
7686
- for (let d = 0; d < child.dimensions.length; d += 1) {
7687
- const dim = child.dimensions[d];
7748
+ for (const childDimension of child.dimensions) {
7749
+ const dim = childDimension;
7688
7750
  const wmjsDim = wmLayer.getDimension(dim.name);
7689
7751
  if (wmjsDim) {
7690
7752
  if (wmjsDim.currentValue !== dim.currentValue) {
@@ -7778,7 +7840,7 @@ const orderLayers = (wmjsMap, _reactMapViewLayers) => {
7778
7840
  const getDisplayText = currentAdagucTime => {
7779
7841
  const timeFormat = 'eee dd MMM yyyy HH:mm [UTC]';
7780
7842
  const adagucTime = dateUtils.utc(currentAdagucTime);
7781
- const adagucTimeFormatted = dateUtils.dateToString(adagucTime, timeFormat);
7843
+ const adagucTimeFormatted = dateUtils.dateToString(adagucTime, timeFormat) || '';
7782
7844
  return adagucTimeFormatted;
7783
7845
  };
7784
7846
  const ORIGIN_REACTMAPVIEW_ONMAPCHANGEDIMENSION = 'ORIGIN_REACTMAPVIEW_ONMAPCHANGEDIMENSION';
@@ -7980,8 +8042,7 @@ class ReactMapView extends React.Component {
7980
8042
  /* Check map dimensions */
7981
8043
  if (!prevProps || prevProps.dimensions !== props.dimensions) {
7982
8044
  if (props.dimensions) {
7983
- for (let d = 0; d < props.dimensions.length; d += 1) {
7984
- const propDimension = props.dimensions[d];
8045
+ for (const propDimension of props.dimensions) {
7985
8046
  const mapDim = wmjsMap.getDimension(propDimension.name);
7986
8047
  if (mapDim && mapDim.currentValue !== propDimension.currentValue || !mapDim) {
7987
8048
  wmjsMap.setDimension(propDimension.name, propDimension.currentValue, false, false);
@@ -9415,4 +9476,4 @@ var publicLayers = /*#__PURE__*/Object.freeze({
9415
9476
  msgNaturalEUMETSAT: msgNaturalEUMETSAT
9416
9477
  });
9417
9478
 
9418
- export { CanvasComponent, DRAWMODE, EDITMODE, EditModeButton as EditModeButtonField, FeatureLayers, GeoJSONTextField, IntersectionSelect, 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, endToolExampleConfig, exampleIntersectionOptions, exampleIntersectionWithShapeOptions, exampleIntersections, exampleIntersectionsMultiDrawTool, featureBox, featureMultiPoint, featurePoint, featurePolygon, fillOptions, firButtonDrawId, formatTime, getDoubleControlToolIcon, getDrawFunctionFromStore, getFeatureCollection, getFirTitle, getGeoJSONPropertyValue, getGeoJson, getIcon, getIntersectionToolIcon, getTimeDimension, getToolIcon, intersectGeoJSONS, intersectionFeatureBE, intersectionFeatureNL, isGeoJSONFeatureCreatedByTool, lineString, moveFeature, opacityOptions, publicLayers, publicServices, registerDrawFunction, rewindGeometry, simpleBoxGeoJSON, simpleBoxGeoJSONWrongOrder, simpleFlightRouteLineStringGeoJSON, simpleFlightRoutePointsGeoJSON, simpleLineStringGeoJSON, simpleMultiPolygon, simplePointsGeojson, simplePolygonGeoJSON, simpleSmallLineStringGeoJSON, startToolExampleConfig, strokeWidthOptions, updateEditModeButtonsWithFir, useGeoJSON, useMapDrawTool };
9479
+ export { CanvasComponent, DRAWMODE, EDITMODE, EditModeButton as EditModeButtonField, FeatureLayers, GeoJSONTextField, IntersectionSelect, 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, addGeoJSONProperties, addSelectionTypeToGeoJSON, basicExampleDrawOptions, basicExampleMultipleShapeDrawOptions, checkHoverFeatures, createInterSections, currentlySupportedDrawModes, defaultBox, defaultDelete, defaultGeoJSONStyleProperties, defaultIntersectionStyleProperties, defaultLayers, defaultModes, defaultPoint, defaultPolygon, defaultTimeFormat, distance, drawPolyStoryStyles, emptyGeoJSON, endToolExampleConfig, exampleIntersectionOptions, exampleIntersectionWithShapeOptions, exampleIntersections, exampleIntersectionsMultiDrawTool, featureBox, featureMultiPoint, featurePoint, featurePolygon, fillOptions, firSelectionType, formatTime, getDoubleControlToolIcon, getDrawFunctionFromStore, getFeatureCollection, getFirTitle, getGeoJSONPropertyValue, getGeoJson, getIcon, getIntersectionToolIcon, getLastEmptyFeatureIndex, getTimeDimension, getToolIcon, intersectGeoJSONS, intersectionFeatureBE, intersectionFeatureNL, isGeoJSONFeatureCreatedByTool, lineString, moveFeature, opacityOptions, publicLayers, publicServices, registerDrawFunction, rewindGeometry, simpleBoxGeoJSON, simpleBoxGeoJSONWrongOrder, simpleFlightRouteLineStringGeoJSON, simpleFlightRoutePointsGeoJSON, simpleLineStringGeoJSON, simpleMultiPolygon, simplePointsGeojson, simplePolygonGeoJSON, simpleSmallLineStringGeoJSON, startToolExampleConfig, strokeWidthOptions, updateEditModeButtonsWithFir, useGeoJSON, useMapDrawTool };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/webmap-react",
3
- "version": "9.8.0",
3
+ "version": "9.9.0",
4
4
  "description": "GeoWeb react wrapper for webmap",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -16,10 +16,9 @@
16
16
  "lodash": "^4.17.21",
17
17
  "proj4": "^2.9.2",
18
18
  "@turf/turf": "^6.5.0",
19
- "immer": "^9.0.21",
19
+ "immer": "^10.0.3",
20
20
  "react-resize-detector": "^9.1.0",
21
- "throttle-debounce": "^5.0.0",
22
- "date-fns": "^3.3.0"
21
+ "throttle-debounce": "^5.0.0"
23
22
  },
24
23
  "peerDependencies": {
25
24
  "react": "18"
@@ -1,18 +1,18 @@
1
1
  import * as React from 'react';
2
2
  import { GeoJsonProperties, GeometryObject, Position } from 'geojson';
3
3
  import { GeoJsonFeatureType, GeoJsonFeature, GeoFeatureStyle, Coordinate } from './geojsonShapes';
4
- type DrawStyle = {
4
+ interface DrawStyle {
5
5
  x: number;
6
6
  y: number;
7
7
  nr: number;
8
- };
9
- type InputEvent = {
8
+ }
9
+ interface InputEvent {
10
10
  leftButton: boolean;
11
11
  mouseDown: boolean;
12
12
  mouseX: number;
13
13
  mouseY: number;
14
14
  rightButton: boolean;
15
- };
15
+ }
16
16
  export interface FeatureEvent {
17
17
  coordinateIndexInFeature: number;
18
18
  featureIndex: number;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { GeometryObject } from 'geojson';
3
3
  import { DrawModeExitCallback, FeatureEvent } from './MapDraw';
4
- export type FeatureLayer = {
4
+ export interface FeatureLayer {
5
5
  id: string;
6
6
  type: string;
7
7
  features: [];
@@ -14,7 +14,7 @@ export type FeatureLayer = {
14
14
  updateGeojson?: (feature: GeometryObject, reason: string) => void;
15
15
  exitDrawModeCallback?: (reason: DrawModeExitCallback) => void;
16
16
  selectedFeatureIndex?: string;
17
- };
17
+ }
18
18
  interface MapDrawContainerProps {
19
19
  featureLayers: FeatureLayer[];
20
20
  mapId: string;
@@ -7,14 +7,14 @@ export declare const featureBox: GeoJSON.Feature<GeoJSON.Polygon>;
7
7
  export declare const lineString: GeoJSON.FeatureCollection;
8
8
  export type GeoJsonFeatureType = GeoJSON.Polygon | GeoJSON.MultiPoint | GeoJSON.Point | GeoJSON.LineString | GeoJSON.MultiPolygon;
9
9
  export type GeoJsonFeature = GeoJSON.Feature<GeoJsonFeatureType>;
10
- export type GeoFeatureStyle = {
10
+ export interface GeoFeatureStyle {
11
11
  stroke?: string;
12
12
  fill?: string;
13
13
  'stroke-width'?: number;
14
14
  'stroke-opacity'?: number;
15
15
  'fill-opacity'?: number;
16
- };
17
- export type Coordinate = {
16
+ }
17
+ export interface Coordinate {
18
18
  x: number;
19
19
  y: number;
20
- };
20
+ }
@@ -18,10 +18,10 @@ export interface MapDrawDrawFunctionArgs {
18
18
  mouseY: number;
19
19
  isHovered: boolean;
20
20
  }
21
- type DrawFunction = {
21
+ interface DrawFunction {
22
22
  id: string;
23
23
  drawMethod: (args: MapDrawDrawFunctionArgs) => void;
24
- };
24
+ }
25
25
  export declare const getDrawFunctionFromStore: (id: string) => DrawFunction['drawMethod'] | undefined;
26
26
  export declare const registerDrawFunction: (drawFunction?: DrawFunction['drawMethod']) => string;
27
27
  export declare const NEW_LINESTRING_CREATED = "new point in LineString created";
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- type IntersectionElement = {
2
+ interface IntersectionElement {
3
3
  geojson: GeoJSON.FeatureCollection;
4
4
  title: string;
5
- };
5
+ }
6
6
  interface IntersectionSelectProps {
7
7
  intersections: IntersectionElement[];
8
8
  onChangeIntersection: (geojson: GeoJSON.FeatureCollection, title: string) => void;
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
+ import { SelectionType } from './types';
2
3
  import { MapDrawToolOptions } from './useMapDrawTool';
3
4
  export declare const opacityOptions: number[];
4
5
  export declare const fillOptions: any[];
5
6
  export declare const strokeWidthOptions: number[];
6
- export declare const getToolIcon: (id: string) => React.ReactElement;
7
+ export declare const getToolIcon: (selectionType: SelectionType) => React.ReactElement;
7
8
  export declare const basicExampleDrawOptions: MapDrawToolOptions;
8
9
  export declare const basicExampleMultipleShapeDrawOptions: MapDrawToolOptions;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
+ import { SelectionType } from './types';
2
3
  import { MapDrawToolOptions } from './useMapDrawTool';
3
- export declare const getIntersectionToolIcon: (id: string) => React.ReactElement;
4
+ export declare const getIntersectionToolIcon: (selectionType: SelectionType) => React.ReactElement;
4
5
  export declare const exampleIntersections: {
5
6
  title: string;
6
7
  geojson: import("geojson").FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties>;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { DrawMode } from './types';
3
3
  import { MapDrawToolOptions } from './useMapDrawTool';
4
- export declare const firButtonDrawId = "fir-button";
4
+ export declare const firSelectionType = "fir";
5
5
  export declare const exampleIntersectionsMultiDrawTool: {
6
6
  title: string;
7
7
  geojson: import("geojson").FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties>;
@@ -1,9 +1,13 @@
1
1
  import { DRAWMODE } from '../MapDraw/MapDraw';
2
2
  export type DrawModeValue = DRAWMODE | 'DELETE' | '';
3
- export type DrawMode = {
3
+ type DefaultSelectionTypes = 'poly' | 'point' | 'box' | 'linestring';
4
+ export type SelectionType = DefaultSelectionTypes | string;
5
+ export interface DrawMode {
4
6
  drawModeId: string;
5
7
  value: DrawModeValue;
6
8
  shape: GeoJSON.Feature | GeoJSON.FeatureCollection;
7
9
  title: string;
8
10
  isSelectable: boolean;
9
- };
11
+ selectionType: SelectionType;
12
+ }
13
+ export {};
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
- import { DrawMode, DrawModeValue } from './types';
2
+ import { DrawMode, DrawModeValue, SelectionType } from './types';
3
3
  import { MapViewLayerProps } from '../MapView';
4
- import { DRAWMODE } from '../MapDraw/MapDraw';
5
4
  export declare const defaultIntersectionStyleProperties: GeoJSON.GeoJsonProperties;
6
5
  export declare const emptyLineString: GeoJSON.Feature;
7
6
  export declare const emptyPoint: GeoJSON.Feature;
@@ -42,67 +41,13 @@ export interface MapDrawToolOptions {
42
41
  geoJSONIntersectionLayerId?: string;
43
42
  geoJSONIntersectionBoundsLayerId?: string;
44
43
  }
45
- export declare const getIcon: (drawModeId: string) => React.ReactElement | null;
46
- export declare const defaultPoint: {
47
- drawModeId: string;
48
- value: DRAWMODE;
49
- title: string;
50
- shape: import("geojson").Feature<import("geojson").Geometry, import("geojson").GeoJsonProperties>;
51
- isSelectable: boolean;
52
- };
53
- export declare const defaultPolygon: {
54
- drawModeId: string;
55
- value: DRAWMODE;
56
- title: string;
57
- shape: import("geojson").Feature<import("geojson").Geometry, import("geojson").GeoJsonProperties>;
58
- isSelectable: boolean;
59
- };
60
- export declare const defaultBox: {
61
- drawModeId: string;
62
- value: DRAWMODE;
63
- title: string;
64
- shape: import("geojson").Feature<import("geojson").Geometry, import("geojson").GeoJsonProperties>;
65
- isSelectable: boolean;
66
- };
67
- export declare const defaultLineString: {
68
- drawModeId: string;
69
- value: DRAWMODE;
70
- title: string;
71
- shape: import("geojson").Feature<import("geojson").Geometry, import("geojson").GeoJsonProperties>;
72
- isSelectable: boolean;
73
- };
74
- export declare const defaultDelete: {
75
- drawModeId: string;
76
- value: "DELETE";
77
- title: string;
78
- shape: import("geojson").FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties>;
79
- isSelectable: boolean;
80
- };
81
- export declare const defaultModes: ({
82
- drawModeId: string;
83
- value: DRAWMODE;
84
- title: string;
85
- shape: import("geojson").Feature<import("geojson").Geometry, import("geojson").GeoJsonProperties>;
86
- isSelectable: boolean;
87
- } | {
88
- drawModeId: string;
89
- value: "DELETE";
90
- title: string;
91
- shape: import("geojson").FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties>;
92
- isSelectable: boolean;
93
- })[];
94
- export declare const currentlySupportedDrawModes: ({
95
- drawModeId: string;
96
- value: DRAWMODE;
97
- title: string;
98
- shape: import("geojson").Feature<import("geojson").Geometry, import("geojson").GeoJsonProperties>;
99
- isSelectable: boolean;
100
- } | {
101
- drawModeId: string;
102
- value: "DELETE";
103
- title: string;
104
- shape: import("geojson").FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties>;
105
- isSelectable: boolean;
106
- })[];
44
+ export declare const getIcon: (selectionType: SelectionType) => React.ReactElement | null;
45
+ export declare const defaultPoint: DrawMode;
46
+ export declare const defaultPolygon: DrawMode;
47
+ export declare const defaultBox: DrawMode;
48
+ export declare const defaultLineString: DrawMode;
49
+ export declare const defaultDelete: DrawMode;
50
+ export declare const defaultModes: DrawMode[];
51
+ export declare const currentlySupportedDrawModes: DrawMode[];
107
52
  export declare const useMapDrawTool: ({ defaultDrawModes, shouldAllowMultipleShapes, defaultGeoJSON, defaultGeoJSONIntersection, defaultGeoJSONIntersectionBounds, defaultGeoJSONIntersectionProperties, geoJSONLayerId, geoJSONIntersectionLayerId, geoJSONIntersectionBoundsLayerId, }: MapDrawToolOptions) => MapDrawToolProps;
108
53
  export {};
@@ -1,6 +1,6 @@
1
1
  import { Feature } from '@turf/turf';
2
- import { FeatureCollection } from 'geojson';
3
- import { DrawMode } from './types';
2
+ import { FeatureCollection, GeoJsonProperties } from 'geojson';
3
+ import { DrawMode, SelectionType } from './types';
4
4
  /**
5
5
  * Adds properties to the first geojson feature based on the given property object.
6
6
  * It only extends or changes the properties which are defined in styleConfig,
@@ -39,6 +39,9 @@ export declare const intersectGeoJSONS: (a: GeoJSON.FeatureCollection, b: GeoJSO
39
39
  */
40
40
  export declare const createInterSections: (geojson: GeoJSON.FeatureCollection, otherGeoJSON: GeoJSON.FeatureCollection, geoJSONproperties?: GeoJSON.GeoJsonProperties) => GeoJSON.FeatureCollection;
41
41
  export declare const getGeoJson: (geojson: GeoJSON.FeatureCollection, shouldAllowMultipleShapes: boolean) => GeoJSON.FeatureCollection;
42
+ export declare const getLastEmptyFeatureIndex: (geoJSONFeatureCollection: GeoJSON.FeatureCollection) => number | undefined;
42
43
  export declare const getFeatureCollection: (geoJSONFeature: GeoJSON.Feature | GeoJSON.FeatureCollection, shouldAllowMultipleShapes: boolean, geoJSONFeatureCollection?: GeoJSON.FeatureCollection) => GeoJSON.FeatureCollection;
43
- export declare const isGeoJSONFeatureCreatedByTool: (existingJSON: GeoJSON.FeatureCollection, newGeoJSON: GeoJSON.Feature | GeoJSON.FeatureCollection) => boolean;
44
+ export declare const isGeoJSONFeatureCreatedByTool: (existingJSON: GeoJSON.FeatureCollection, selectionType: SelectionType, featureLayerIndex?: number) => boolean;
44
45
  export declare const rewindGeometry: (geoJSON: FeatureCollection) => FeatureCollection;
46
+ export declare const addGeoJSONProperties: (geoJSON: GeoJSON.Feature | GeoJSON.FeatureCollection, newProperties: GeoJsonProperties) => GeoJSON.Feature | GeoJSON.FeatureCollection;
47
+ export declare const addSelectionTypeToGeoJSON: (geoJSON: GeoJSON.Feature | GeoJSON.FeatureCollection, selectionType: SelectionType) => GeoJSON.Feature | GeoJSON.FeatureCollection;