@opengeoweb/core 2.4.1 → 2.5.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
@@ -17,6 +17,7 @@ import withStyles from '@mui/styles/withStyles';
17
17
  import { debounce as debounce$1 } from 'throttle-debounce';
18
18
  import cloneDeep from 'lodash.clonedeep';
19
19
  import proj4 from 'proj4';
20
+ import * as turf from '@turf/turf';
20
21
  import { createStore, DynamicModuleLoader } from 'redux-dynamic-modules';
21
22
  import { getSagaExtension } from 'redux-dynamic-modules-saga';
22
23
  import { ThemeWrapper, lightTheme } from '@opengeoweb/theme';
@@ -4866,7 +4867,8 @@ var setServiceMetadata = function setServiceMetadata(wmLayer, mapId, webMapJSIns
4866
4867
  id: wmLayer.service,
4867
4868
  name: wmLayer.title,
4868
4869
  service: wmLayer.service,
4869
- layers: layers
4870
+ layers: layers,
4871
+ isUserAddedService: false
4870
4872
  },
4871
4873
  layerStyle: {
4872
4874
  origin: origin,
@@ -6560,7 +6562,20 @@ var reducer$2 = function reducer() {
6560
6562
  case GENERIC_SYNC_SETBBOX:
6561
6563
  {
6562
6564
  return produce$1(state, function (draft) {
6563
- action.payload.targets.forEach(function (payload) {
6565
+ var _action$payload21 = action.payload,
6566
+ targetsFromAction = _action$payload21.targets,
6567
+ source = _action$payload21.source;
6568
+ /* Because we want backwards compatibility with the previous code, we also need to listen to the original source action */
6569
+
6570
+ var targets = [{
6571
+ targetId: source.payload.sourceId,
6572
+ bbox: source.payload.bbox,
6573
+ srs: source.payload.srs
6574
+ }];
6575
+ /* And then append the targets form the action */
6576
+
6577
+ targets.push.apply(targets, _toConsumableArray(targetsFromAction));
6578
+ targets.forEach(function (payload) {
6564
6579
  var targetId = payload.targetId,
6565
6580
  bbox = payload.bbox,
6566
6581
  srs = payload.srs;
@@ -6578,9 +6593,9 @@ var reducer$2 = function reducer() {
6578
6593
 
6579
6594
  case WEBMAP_TOGGLE_AUTO_UPDATE:
6580
6595
  {
6581
- var _action$payload21 = action.payload,
6582
- _mapId23 = _action$payload21.mapId,
6583
- shouldAutoUpdate = _action$payload21.shouldAutoUpdate;
6596
+ var _action$payload22 = action.payload,
6597
+ _mapId23 = _action$payload22.mapId,
6598
+ shouldAutoUpdate = _action$payload22.shouldAutoUpdate;
6584
6599
 
6585
6600
  if (!state.byId[_mapId23]) {
6586
6601
  return state;
@@ -6593,9 +6608,9 @@ var reducer$2 = function reducer() {
6593
6608
 
6594
6609
  case WEBMAP_TOGGLE_LOOP:
6595
6610
  {
6596
- var _action$payload22 = action.payload,
6597
- _mapId24 = _action$payload22.mapId,
6598
- shouldLoop = _action$payload22.shouldLoop;
6611
+ var _action$payload23 = action.payload,
6612
+ _mapId24 = _action$payload23.mapId,
6613
+ shouldLoop = _action$payload23.shouldLoop;
6599
6614
 
6600
6615
  if (!state.byId[_mapId24]) {
6601
6616
  return state;
@@ -6608,9 +6623,9 @@ var reducer$2 = function reducer() {
6608
6623
 
6609
6624
  case WEBMAP_TOGGLE_TIMESTEP_AUTO:
6610
6625
  {
6611
- var _action$payload23 = action.payload,
6612
- _mapId25 = _action$payload23.mapId,
6613
- timestepAuto = _action$payload23.timestepAuto;
6626
+ var _action$payload24 = action.payload,
6627
+ _mapId25 = _action$payload24.mapId,
6628
+ timestepAuto = _action$payload24.timestepAuto;
6614
6629
 
6615
6630
  if (!state.byId[_mapId25]) {
6616
6631
  return state;
@@ -6623,9 +6638,9 @@ var reducer$2 = function reducer() {
6623
6638
 
6624
6639
  case WEBMAP_TOGGLE_TIME_SLIDER_HOVER:
6625
6640
  {
6626
- var _action$payload24 = action.payload,
6627
- _mapId26 = _action$payload24.mapId,
6628
- isTimeSliderHoverOn = _action$payload24.isTimeSliderHoverOn;
6641
+ var _action$payload25 = action.payload,
6642
+ _mapId26 = _action$payload25.mapId,
6643
+ isTimeSliderHoverOn = _action$payload25.isTimeSliderHoverOn;
6629
6644
 
6630
6645
  if (!state.byId[_mapId26]) {
6631
6646
  return state;
@@ -6638,9 +6653,9 @@ var reducer$2 = function reducer() {
6638
6653
 
6639
6654
  case WEBMAP_SET_PIN:
6640
6655
  {
6641
- var _action$payload25 = action.payload,
6642
- _mapId27 = _action$payload25.mapId,
6643
- mapPinLocation = _action$payload25.mapPinLocation;
6656
+ var _action$payload26 = action.payload,
6657
+ _mapId27 = _action$payload26.mapId,
6658
+ mapPinLocation = _action$payload26.mapPinLocation;
6644
6659
 
6645
6660
  if (!state.byId[_mapId27]) {
6646
6661
  return state;
@@ -6653,9 +6668,9 @@ var reducer$2 = function reducer() {
6653
6668
 
6654
6669
  case WEBMAP_DISABLE_PIN:
6655
6670
  {
6656
- var _action$payload26 = action.payload,
6657
- _mapId28 = _action$payload26.mapId,
6658
- disableMapPin = _action$payload26.disableMapPin;
6671
+ var _action$payload27 = action.payload,
6672
+ _mapId28 = _action$payload27.mapId,
6673
+ disableMapPin = _action$payload27.disableMapPin;
6659
6674
 
6660
6675
  if (!state.byId[_mapId28]) {
6661
6676
  return state;
@@ -6674,9 +6689,9 @@ var reducer$2 = function reducer() {
6674
6689
  * These targets can be used as payloads in new Layer actions.
6675
6690
  * These actions are here handled via the layer reducer, as it is the same logic
6676
6691
  */
6677
- var _action$payload27 = action.payload,
6678
- targets = _action$payload27.targets,
6679
- source = _action$payload27.source;
6692
+ var _action$payload28 = action.payload,
6693
+ targets = _action$payload28.targets,
6694
+ source = _action$payload28.source;
6680
6695
  return targets.reduce(function (prevState, target) {
6681
6696
  var action = {
6682
6697
  payload: target,
@@ -7504,6 +7519,39 @@ var enableOnlyOneKeyword = function enableOnlyOneKeyword(payload) {
7504
7519
  };
7505
7520
  };
7506
7521
 
7522
+ /* *
7523
+ * Licensed under the Apache License, Version 2.0 (the "License");
7524
+ * you may not use this file except in compliance with the License.
7525
+ * You may obtain a copy of the License at
7526
+ *
7527
+ * http://www.apache.org/licenses/LICENSE-2.0
7528
+ *
7529
+ * Unless required by applicable law or agreed to in writing, software
7530
+ * distributed under the License is distributed on an "AS IS" BASIS,
7531
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7532
+ * See the License for the specific language governing permissions and
7533
+ * limitations under the License.
7534
+ *
7535
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
7536
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
7537
+ * */
7538
+ var getUserAddedServices = function getUserAddedServices() {
7539
+ try {
7540
+ return JSON.parse(window.localStorage.getItem('userAddedServices')) || {};
7541
+ } catch (e) {
7542
+ console.error('Unable to read services from localStorage: ', e);
7543
+ }
7544
+
7545
+ return {};
7546
+ };
7547
+ var setUserAddedServices = function setUserAddedServices(services) {
7548
+ try {
7549
+ window.localStorage.setItem('userAddedServices', JSON.stringify(services));
7550
+ } catch (e) {
7551
+ console.error('Unable to write services to localStorage: ', e);
7552
+ }
7553
+ };
7554
+
7507
7555
  var _marked = /*#__PURE__*/regeneratorRuntime.mark(newServiceAddedSaga),
7508
7556
  _marked2 = /*#__PURE__*/regeneratorRuntime.mark(layerSelectServiceRemovedSaga),
7509
7557
  _marked3 = /*#__PURE__*/regeneratorRuntime.mark(rootSaga);
@@ -7551,6 +7599,23 @@ function layerSelectServiceRemovedSaga(capturedAction) {
7551
7599
  }
7552
7600
  }, _marked2);
7553
7601
  }
7602
+ function addServiceToLocalStorageSaga(_ref) {
7603
+ var payload = _ref.payload;
7604
+ var id = payload.id,
7605
+ isUserAddedService = payload.isUserAddedService,
7606
+ name = payload.name,
7607
+ service = payload.service;
7608
+ if (!isUserAddedService) return;
7609
+ var localStorageServices = getUserAddedServices();
7610
+ setUserAddedServices({
7611
+ byId: Object.assign(Object.assign({}, localStorageServices.byId), _defineProperty({}, service, {
7612
+ id: id,
7613
+ name: name,
7614
+ service: service
7615
+ })),
7616
+ allIds: _toConsumableArray(new Set([].concat(_toConsumableArray(localStorageServices.allIds || []), [service])))
7617
+ });
7618
+ }
7554
7619
  function rootSaga() {
7555
7620
  return regeneratorRuntime.wrap(function rootSaga$(_context3) {
7556
7621
  while (1) {
@@ -7564,6 +7629,10 @@ function rootSaga() {
7564
7629
  return takeEvery(MAP_SERVICES_REMOVE_SERVICE, layerSelectServiceRemovedSaga);
7565
7630
 
7566
7631
  case 4:
7632
+ _context3.next = 6;
7633
+ return takeEvery(MAP_SERVICES_SET_LAYERS, addServiceToLocalStorageSaga);
7634
+
7635
+ case 6:
7567
7636
  case "end":
7568
7637
  return _context3.stop();
7569
7638
  }
@@ -10923,7 +10992,8 @@ var ServicePopup = function ServicePopup(_ref) {
10923
10992
  id: serviceUrl,
10924
10993
  name: serviceName,
10925
10994
  service: serviceUrl,
10926
- layers: serviceLayers
10995
+ layers: serviceLayers,
10996
+ isUserAddedService: true
10927
10997
  });
10928
10998
  setIsLoading(false);
10929
10999
  closePopupAndResetState();
@@ -12692,7 +12762,8 @@ var LayerSelectConnect = function LayerSelectConnect(_ref) {
12692
12762
  id: service.id,
12693
12763
  name: service.name,
12694
12764
  service: service.url,
12695
- layers: layers
12765
+ layers: layers,
12766
+ isUserAddedService: false
12696
12767
  });
12697
12768
  }
12698
12769
  })["catch"](function () {
@@ -18229,6 +18300,172 @@ var tileRenderSettings = {
18229
18300
  }
18230
18301
  };
18231
18302
 
18303
+ /* *
18304
+ * Licensed under the Apache License, Version 2.0 (the "License");
18305
+ * you may not use this file except in compliance with the License.
18306
+ * You may obtain a copy of the License at
18307
+ *
18308
+ * http://www.apache.org/licenses/LICENSE-2.0
18309
+ *
18310
+ * Unless required by applicable law or agreed to in writing, software
18311
+ * distributed under the License is distributed on an "AS IS" BASIS,
18312
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18313
+ * See the License for the specific language governing permissions and
18314
+ * limitations under the License.
18315
+ *
18316
+ * Copyright 2020 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
18317
+ * Copyright 2020 - Finnish Meteorological Institute (FMI)
18318
+ * */
18319
+ /* Function which calculates the distance between two points */
18320
+ // eslint-disable-next-line class-methods-use-this
18321
+
18322
+ var distance = function distance(a, b) {
18323
+ return Math.sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
18324
+ };
18325
+
18326
+ var checkHoverVertice = function checkHoverVertice(feature, mouseX, mouseY, convertGeoCoordsToScreenCoords) {
18327
+ var maxDistance = 20;
18328
+
18329
+ if (feature.geometry.type === 'Point') {
18330
+ var featureCoords = feature.geometry.coordinates;
18331
+ /* Get all vertexes */
18332
+
18333
+ var XYCoords = convertGeoCoordsToScreenCoords([featureCoords]);
18334
+
18335
+ if (XYCoords.length > 0 && distance(XYCoords[0], {
18336
+ x: mouseX,
18337
+ y: mouseY
18338
+ }) < maxDistance) {
18339
+ return {
18340
+ coordinateIndexInFeature: 0
18341
+ };
18342
+ }
18343
+ }
18344
+
18345
+ if (feature.geometry.type === 'MultiPoint') {
18346
+ for (var polygonIndex = feature.geometry.coordinates.length - 1; polygonIndex >= 0; polygonIndex -= 1) {
18347
+ var _featureCoords = feature.geometry.coordinates[polygonIndex];
18348
+
18349
+ if (_featureCoords === undefined) {
18350
+ // eslint-disable-next-line no-continue
18351
+ continue;
18352
+ }
18353
+ /* Get all vertexes */
18354
+
18355
+
18356
+ var _XYCoords = convertGeoCoordsToScreenCoords([_featureCoords]);
18357
+
18358
+ if (_XYCoords.length > 0 && distance(_XYCoords[0], {
18359
+ x: mouseX,
18360
+ y: mouseY
18361
+ }) < maxDistance) {
18362
+ return {
18363
+ coordinateIndexInFeature: polygonIndex
18364
+ };
18365
+ }
18366
+ }
18367
+ }
18368
+
18369
+ if (feature.geometry.type === 'Polygon') {
18370
+ var point = [mouseX, mouseY];
18371
+
18372
+ for (var _polygonIndex = feature.geometry.coordinates.length - 1; _polygonIndex >= 0; _polygonIndex -= 1) {
18373
+ var _featureCoords2 = feature.geometry.coordinates[_polygonIndex];
18374
+
18375
+ if (_featureCoords2 === undefined) {
18376
+ // eslint-disable-next-line no-continue
18377
+ continue;
18378
+ }
18379
+ /* Get all vertexes */
18380
+
18381
+
18382
+ var poly = [convertGeoCoordsToScreenCoords(_featureCoords2).map(function (coord) {
18383
+ return [coord.x, coord.y];
18384
+ })];
18385
+
18386
+ try {
18387
+ var isPointInPoly = turf.booleanPointInPolygon(turf.point(point), turf.polygon(poly));
18388
+
18389
+ if (isPointInPoly) {
18390
+ return {
18391
+ coordinateIndexInFeature: _polygonIndex
18392
+ };
18393
+ } // eslint-disable-next-line no-empty
18394
+
18395
+ } catch (e) {}
18396
+ }
18397
+ }
18398
+
18399
+ if (feature.geometry.type === 'MultiPolygon') {
18400
+ var _point = [mouseX, mouseY];
18401
+
18402
+ for (var _polygonIndex2 = feature.geometry.coordinates.length - 1; _polygonIndex2 >= 0; _polygonIndex2 -= 1) {
18403
+ var _featureCoords3 = feature.geometry.coordinates[_polygonIndex2][0];
18404
+
18405
+ if (_featureCoords3 === undefined) {
18406
+ // eslint-disable-next-line no-continue
18407
+ continue;
18408
+ }
18409
+
18410
+ var _poly = [convertGeoCoordsToScreenCoords(_featureCoords3).map(function (coord) {
18411
+ return [coord.x, coord.y];
18412
+ })];
18413
+
18414
+ try {
18415
+ var _isPointInPoly = turf.booleanPointInPolygon(turf.point(_point), turf.polygon(_poly));
18416
+
18417
+ if (_isPointInPoly) {
18418
+ return {
18419
+ coordinateIndexInFeature: _polygonIndex2
18420
+ };
18421
+ } // eslint-disable-next-line no-empty
18422
+
18423
+ } catch (e) {}
18424
+ }
18425
+ }
18426
+
18427
+ if (feature.geometry.type === 'LineString') {
18428
+ var _featureCoords4 = feature.geometry.coordinates;
18429
+ /* Get all vertexes */
18430
+
18431
+ var _XYCoords2 = convertGeoCoordsToScreenCoords(_featureCoords4);
18432
+ /* Snap to the vertex closer than specified pixels */
18433
+
18434
+
18435
+ for (var j = 0; j < _XYCoords2.length; j += 1) {
18436
+ var coord = _XYCoords2[j];
18437
+
18438
+ if (distance(coord, {
18439
+ x: mouseX,
18440
+ y: mouseY
18441
+ }) < maxDistance) {
18442
+ return {
18443
+ coordinateIndexInFeature: j
18444
+ };
18445
+ }
18446
+ }
18447
+ }
18448
+
18449
+ return null;
18450
+ };
18451
+
18452
+ var checkHoverFeatures = function checkHoverFeatures(geojson, mouseX, mouseY, convertGeoCoordsToScreenCoords) {
18453
+ for (var j = 0; j < geojson.features.length; j += 1) {
18454
+ var feature = geojson.features[j];
18455
+ var hoverResult = checkHoverVertice(feature, mouseX, mouseY, convertGeoCoordsToScreenCoords);
18456
+
18457
+ if (hoverResult != null) {
18458
+ return {
18459
+ coordinateIndexInFeature: hoverResult.coordinateIndexInFeature,
18460
+ featureIndex: j,
18461
+ feature: feature
18462
+ };
18463
+ }
18464
+ }
18465
+
18466
+ return null;
18467
+ };
18468
+
18232
18469
  var Proj4js = proj4; // Cache for for storing and reusing Proj4 instances
18233
18470
 
18234
18471
  var projectorCache = {}; // Ensure that you have a Proj4 object, pulling from the cache if necessary
@@ -18840,9 +19077,12 @@ var AdagucMapDraw = /*#__PURE__*/function (_React$PureComponent) {
18840
19077
  }, {
18841
19078
  key: "adagucMouseMove",
18842
19079
  value: function adagucMouseMove(event) {
19080
+ var _this2 = this;
19081
+
18843
19082
  var _this$props2 = this.props,
18844
19083
  isInEditMode = _this$props2.isInEditMode,
18845
- featureNrToEdit = _this$props2.featureNrToEdit;
19084
+ featureNrToEdit = _this$props2.featureNrToEdit,
19085
+ onHoverFeature = _this$props2.onHoverFeature;
18846
19086
  if (event && event.rightButton === true) return;
18847
19087
  /* adagucMouseMove is an event callback function which is triggered when the mouse moves over the map
18848
19088
  This event is only triggered if the map is in hover state.
@@ -18855,6 +19095,29 @@ var AdagucMapDraw = /*#__PURE__*/function (_React$PureComponent) {
18855
19095
  this.mouseX = mouseX;
18856
19096
  this.mouseY = mouseY;
18857
19097
 
19098
+ if (onHoverFeature) {
19099
+ var handleMouseStoppedTimer = function handleMouseStoppedTimer() {
19100
+ var result = checkHoverFeatures(_this2.geojson, mouseX, mouseY, function (coordinates) {
19101
+ return _this2.convertGeoCoordsToScreenCoords(coordinates);
19102
+ });
19103
+
19104
+ if (result) {
19105
+ var featureEvent = {
19106
+ coordinateIndexInFeature: result.coordinateIndexInFeature,
19107
+ featureIndex: result.featureIndex,
19108
+ mouseX: mouseX,
19109
+ mouseY: mouseY,
19110
+ isInEditMode: isInEditMode,
19111
+ feature: result.feature
19112
+ };
19113
+ onHoverFeature(featureEvent);
19114
+ }
19115
+ };
19116
+
19117
+ window.clearTimeout(this.mouseStoppedTimer);
19118
+ this.mouseStoppedTimer = window.setTimeout(handleMouseStoppedTimer, 20);
19119
+ }
19120
+
18858
19121
  if (isInEditMode === false) {
18859
19122
  return;
18860
19123
  }
@@ -18932,14 +19195,14 @@ var AdagucMapDraw = /*#__PURE__*/function (_React$PureComponent) {
18932
19195
  }, {
18933
19196
  key: "triggerMouseDownTimer",
18934
19197
  value: function triggerMouseDownTimer(event) {
18935
- var _this2 = this;
19198
+ var _this3 = this;
18936
19199
 
18937
19200
  if (!this.doubleClickTimer) this.doubleClickTimer = {};
18938
19201
  var mouseX = event.mouseX,
18939
19202
  mouseY = event.mouseY;
18940
19203
 
18941
19204
  var checkTimeOut = function checkTimeOut() {
18942
- _this2.doubleClickTimer.isRunning = false;
19205
+ _this3.doubleClickTimer.isRunning = false;
18943
19206
  };
18944
19207
  /* Reset the timer */
18945
19208
 
@@ -19374,9 +19637,35 @@ var AdagucMapDraw = /*#__PURE__*/function (_React$PureComponent) {
19374
19637
  }, {
19375
19638
  key: "adagucMouseUp",
19376
19639
  value: function adagucMouseUp(event) {
19377
- var isInEditMode = this.props.isInEditMode;
19640
+ var _this4 = this;
19641
+
19642
+ var _this$props10 = this.props,
19643
+ isInEditMode = _this$props10.isInEditMode,
19644
+ onClickFeature = _this$props10.onClickFeature;
19378
19645
  if (event && event.rightButton === true) return;
19379
19646
 
19647
+ if (onClickFeature) {
19648
+ var mouseX = event.mouseX,
19649
+ mouseY = event.mouseY;
19650
+ var result = checkHoverFeatures(this.geojson, mouseX, mouseY, function (coordinates) {
19651
+ return _this4.convertGeoCoordsToScreenCoords(coordinates);
19652
+ });
19653
+
19654
+ if (result) {
19655
+ var featureEvent = {
19656
+ coordinateIndexInFeature: result.coordinateIndexInFeature,
19657
+ featureIndex: result.featureIndex,
19658
+ mouseX: mouseX,
19659
+ mouseY: mouseY,
19660
+ isInEditMode: isInEditMode,
19661
+ feature: result.feature
19662
+ };
19663
+ onClickFeature(featureEvent);
19664
+ } else {
19665
+ onClickFeature(null);
19666
+ }
19667
+ }
19668
+
19380
19669
  if (isInEditMode === false) {
19381
19670
  return;
19382
19671
  }
@@ -19410,9 +19699,9 @@ var AdagucMapDraw = /*#__PURE__*/function (_React$PureComponent) {
19410
19699
  }, {
19411
19700
  key: "cancelEdit",
19412
19701
  value: function cancelEdit(cancelLastPoint) {
19413
- var _this$props10 = this.props,
19414
- isInEditMode = _this$props10.isInEditMode,
19415
- featureNrToEdit = _this$props10.featureNrToEdit;
19702
+ var _this$props11 = this.props,
19703
+ isInEditMode = _this$props11.isInEditMode,
19704
+ featureNrToEdit = _this$props11.featureNrToEdit;
19416
19705
 
19417
19706
  if (isInEditMode === false) {
19418
19707
  return;
@@ -19585,14 +19874,14 @@ var AdagucMapDraw = /*#__PURE__*/function (_React$PureComponent) {
19585
19874
  just before adagucviewer will flip the back canvas buffer to the front.
19586
19875
  You are free to draw anything you like on the canvas.
19587
19876
  */
19588
- var _this$props11 = this.props,
19589
- featureNrToEdit = _this$props11.featureNrToEdit,
19590
- isInEditMode = _this$props11.isInEditMode,
19591
- hoverFeatureCallback = _this$props11.hoverFeatureCallback;
19877
+ var _this$props12 = this.props,
19878
+ featureNrToEdit = _this$props12.featureNrToEdit,
19879
+ isInEditMode = _this$props12.isInEditMode;
19592
19880
  if (!this.geojson || !this.geojson.features || !this.geojson.features.length) return;
19593
19881
  this.textPositions = [];
19594
19882
  this.mouseOverPolygonCoordinates = [];
19595
19883
  this.mouseOverPolygonFeatureIndex = -1;
19884
+ this.mouseOverPolygonIndex = -1;
19596
19885
  /* Current selected feature from GeoJSON */
19597
19886
 
19598
19887
  for (var featureIndex = 0; featureIndex < this.geojson.features.length; featureIndex += 1) {
@@ -19785,19 +20074,6 @@ var AdagucMapDraw = /*#__PURE__*/function (_React$PureComponent) {
19785
20074
  ctx.globalAlpha = 1;
19786
20075
  ctx.stroke();
19787
20076
  }
19788
- } // if (isInEditMode === true &&
19789
- // this.mouseOverPolygonFeatureIndex === this.props.featureNrToEdit &&
19790
-
19791
-
19792
- if (hoverFeatureCallback) {
19793
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
19794
- // @ts-ignore
19795
- hoverFeatureCallback({
19796
- polygonIndex: this.mouseOverPolygonFeatureIndex,
19797
- featureIndex: this.mouseOverPolygonFeatureIndex,
19798
- mouseX: this.mouseX,
19799
- mouseY: this.mouseY
19800
- });
19801
20077
  }
19802
20078
  /* Draw labels */
19803
20079
 
@@ -20075,9 +20351,9 @@ var AdagucMapDraw = /*#__PURE__*/function (_React$PureComponent) {
20075
20351
  }, {
20076
20352
  key: "drawLine",
20077
20353
  value: function drawLine(ctx, XYCoords, featureIndex, lineStringIndex) {
20078
- var _this$props12 = this.props,
20079
- isInEditMode = _this$props12.isInEditMode,
20080
- featureNrToEdit = _this$props12.featureNrToEdit;
20354
+ var _this$props13 = this.props,
20355
+ isInEditMode = _this$props13.isInEditMode,
20356
+ featureNrToEdit = _this$props13.featureNrToEdit;
20081
20357
  var feature = this.geojson.features[featureIndex];
20082
20358
  if (!feature || !feature.geometry) return;
20083
20359
  if (feature.geometry.type !== 'LineString') return;
@@ -20121,7 +20397,8 @@ var AdagucMapDraw = /*#__PURE__*/function (_React$PureComponent) {
20121
20397
  // if (test) {
20122
20398
 
20123
20399
  this.mouseOverPolygonCoordinates = 0;
20124
- this.mouseOverPolygonFeatureIndex = 0; // }
20400
+ this.mouseOverPolygonFeatureIndex = 0;
20401
+ this.mouseOverPolygonIndex = 0; // }
20125
20402
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
20126
20403
  // @ts-ignore
20127
20404
 
@@ -20150,9 +20427,9 @@ var AdagucMapDraw = /*#__PURE__*/function (_React$PureComponent) {
20150
20427
  }, {
20151
20428
  key: "drawPolygon",
20152
20429
  value: function drawPolygon(ctx, XYCoords, featureIndex, polygonIndex) {
20153
- var _this$props13 = this.props,
20154
- isInEditMode = _this$props13.isInEditMode,
20155
- featureNrToEdit = _this$props13.featureNrToEdit;
20430
+ var _this$props14 = this.props,
20431
+ isInEditMode = _this$props14.isInEditMode,
20432
+ featureNrToEdit = _this$props14.featureNrToEdit;
20156
20433
  var feature = this.geojson.features[featureIndex];
20157
20434
  if (!feature || !feature.geometry) return;
20158
20435
  if (feature.geometry.type !== 'Polygon' && feature.geometry.type !== 'MultiPolygon') return;
@@ -20199,6 +20476,7 @@ var AdagucMapDraw = /*#__PURE__*/function (_React$PureComponent) {
20199
20476
  if (test) {
20200
20477
  this.mouseOverPolygonCoordinates = XYCoords;
20201
20478
  this.mouseOverPolygonFeatureIndex = featureIndex;
20479
+ this.mouseOverPolygonIndex = polygonIndex;
20202
20480
  } // eslint-disable-next-line @typescript-eslint/ban-ts-comment
20203
20481
  // @ts-ignore
20204
20482
 
@@ -20353,9 +20631,9 @@ var AdagucMapDraw = /*#__PURE__*/function (_React$PureComponent) {
20353
20631
  }, {
20354
20632
  key: "render",
20355
20633
  value: function render() {
20356
- var _this$props14 = this.props,
20357
- webmapjs = _this$props14.webmapjs,
20358
- isInDeleteMode = _this$props14.isInDeleteMode;
20634
+ var _this$props15 = this.props,
20635
+ webmapjs = _this$props15.webmapjs,
20636
+ isInDeleteMode = _this$props15.isInDeleteMode;
20359
20637
 
20360
20638
  if (this.disabled === undefined) {
20361
20639
  this.disabled = isInDeleteMode;
@@ -20420,9 +20698,14 @@ var AdagucMapDrawContainer = function AdagucMapDrawContainer(_ref) {
20420
20698
  isInDeleteMode: layer.isInDeleteMode,
20421
20699
  drawMode: layer.drawMode,
20422
20700
  webmapjs: webMapJS,
20423
- hoverFeatureCallback: function hoverFeatureCallback(hoverInfo) {
20424
- if (layer.hoverFeatureCallback) {
20425
- layer.hoverFeatureCallback(hoverInfo);
20701
+ onHoverFeature: function onHoverFeature(hoverInfo) {
20702
+ if (layer.onHoverFeature) {
20703
+ layer.onHoverFeature(hoverInfo);
20704
+ }
20705
+ },
20706
+ onClickFeature: function onClickFeature(hoverInfo) {
20707
+ if (layer.onClickFeature) {
20708
+ layer.onClickFeature(hoverInfo);
20426
20709
  }
20427
20710
  },
20428
20711
  updateGeojson: function updateGeojson(geojson) {
package/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reselect'), require('moment'), require('lodash'), require('react'), require('immer'), require('redux-saga/effects'), require('@opengeoweb/webmap'), require('@mui/material'), require('react-redux'), require('@mui/styles/makeStyles'), require('@opengeoweb/shared'), require('@mui/icons-material'), require('react-sortablejs'), require('@mui/styles/createStyles'), require('@mui/styles/withStyles'), require('throttle-debounce'), require('lodash.clonedeep'), require('proj4'), require('redux-dynamic-modules'), require('redux-dynamic-modules-saga'), require('@opengeoweb/theme')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'reselect', 'moment', 'lodash', 'react', 'immer', 'redux-saga/effects', '@opengeoweb/webmap', '@mui/material', 'react-redux', '@mui/styles/makeStyles', '@opengeoweb/shared', '@mui/icons-material', 'react-sortablejs', '@mui/styles/createStyles', '@mui/styles/withStyles', 'throttle-debounce', 'lodash.clonedeep', 'proj4', 'redux-dynamic-modules', 'redux-dynamic-modules-saga', '@opengeoweb/theme'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Core = {}, global.reselect, global.moment, global._, global.React, global.produce, global.effects, global.webmap, global.material, global.reactRedux, global.makeStyles, global.shared, global.iconsMaterial, global.reactSortablejs, global.createStyles, global.withStyles, global.throttleDebounce, global.cloneDeep, global.proj4, global.reduxDynamicModules, global.reduxDynamicModulesSaga, global.theme));
5
- })(this, (function (exports, reselect, moment, _, React, produce, effects, webmap, material, reactRedux, makeStyles, shared, iconsMaterial, reactSortablejs, createStyles, withStyles, throttleDebounce, cloneDeep, proj4, reduxDynamicModules, reduxDynamicModulesSaga, theme) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reselect'), require('moment'), require('lodash'), require('react'), require('immer'), require('redux-saga/effects'), require('@opengeoweb/webmap'), require('@mui/material'), require('react-redux'), require('@mui/styles/makeStyles'), require('@opengeoweb/shared'), require('@mui/icons-material'), require('react-sortablejs'), require('@mui/styles/createStyles'), require('@mui/styles/withStyles'), require('throttle-debounce'), require('lodash.clonedeep'), require('proj4'), require('@turf/turf'), require('redux-dynamic-modules'), require('redux-dynamic-modules-saga'), require('@opengeoweb/theme')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'reselect', 'moment', 'lodash', 'react', 'immer', 'redux-saga/effects', '@opengeoweb/webmap', '@mui/material', 'react-redux', '@mui/styles/makeStyles', '@opengeoweb/shared', '@mui/icons-material', 'react-sortablejs', '@mui/styles/createStyles', '@mui/styles/withStyles', 'throttle-debounce', 'lodash.clonedeep', 'proj4', '@turf/turf', 'redux-dynamic-modules', 'redux-dynamic-modules-saga', '@opengeoweb/theme'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Core = {}, global.reselect, global.moment, global._, global.React, global.produce, global.effects, global.webmap, global.material, global.reactRedux, global.makeStyles, global.shared, global.iconsMaterial, global.reactSortablejs, global.createStyles, global.withStyles, global.throttleDebounce, global.cloneDeep, global.proj4, global.turf, global.reduxDynamicModules, global.reduxDynamicModulesSaga, global.theme));
5
+ })(this, (function (exports, reselect, moment, _, React, produce, effects, webmap, material, reactRedux, makeStyles, shared, iconsMaterial, reactSortablejs, createStyles, withStyles, throttleDebounce, cloneDeep, proj4, turf, reduxDynamicModules, reduxDynamicModulesSaga, theme) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -34,6 +34,7 @@
34
34
  var withStyles__default = /*#__PURE__*/_interopDefaultLegacy(withStyles);
35
35
  var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
36
36
  var proj4__default = /*#__PURE__*/_interopDefaultLegacy(proj4);
37
+ var turf__namespace = /*#__PURE__*/_interopNamespace(turf);
37
38
 
38
39
  /* *
39
40
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -4733,7 +4734,8 @@
4733
4734
  id: wmLayer.service,
4734
4735
  name: wmLayer.title,
4735
4736
  service: wmLayer.service,
4736
- layers: layers
4737
+ layers: layers,
4738
+ isUserAddedService: false
4737
4739
  },
4738
4740
  layerStyle: {
4739
4741
  origin: origin,
@@ -6616,7 +6618,20 @@
6616
6618
  case GENERIC_SYNC_SETBBOX:
6617
6619
  {
6618
6620
  return produce.produce(state, function (draft) {
6619
- action.payload.targets.forEach(function (payload) {
6621
+ var _a = action.payload,
6622
+ targetsFromAction = _a.targets,
6623
+ source = _a.source;
6624
+ /* Because we want backwards compatibility with the previous code, we also need to listen to the original source action */
6625
+
6626
+ var targets = [{
6627
+ targetId: source.payload.sourceId,
6628
+ bbox: source.payload.bbox,
6629
+ srs: source.payload.srs
6630
+ }];
6631
+ /* And then append the targets form the action */
6632
+
6633
+ targets.push.apply(targets, __spreadArray([], __read(targetsFromAction)));
6634
+ targets.forEach(function (payload) {
6620
6635
  var targetId = payload.targetId,
6621
6636
  bbox = payload.bbox,
6622
6637
  srs = payload.srs;
@@ -7661,6 +7676,39 @@
7661
7676
  };
7662
7677
  };
7663
7678
 
7679
+ /* *
7680
+ * Licensed under the Apache License, Version 2.0 (the "License");
7681
+ * you may not use this file except in compliance with the License.
7682
+ * You may obtain a copy of the License at
7683
+ *
7684
+ * http://www.apache.org/licenses/LICENSE-2.0
7685
+ *
7686
+ * Unless required by applicable law or agreed to in writing, software
7687
+ * distributed under the License is distributed on an "AS IS" BASIS,
7688
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7689
+ * See the License for the specific language governing permissions and
7690
+ * limitations under the License.
7691
+ *
7692
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
7693
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
7694
+ * */
7695
+ var getUserAddedServices = function getUserAddedServices() {
7696
+ try {
7697
+ return JSON.parse(window.localStorage.getItem('userAddedServices')) || {};
7698
+ } catch (e) {
7699
+ console.error('Unable to read services from localStorage: ', e);
7700
+ }
7701
+
7702
+ return {};
7703
+ };
7704
+ var setUserAddedServices = function setUserAddedServices(services) {
7705
+ try {
7706
+ window.localStorage.setItem('userAddedServices', JSON.stringify(services));
7707
+ } catch (e) {
7708
+ console.error('Unable to write services to localStorage: ', e);
7709
+ }
7710
+ };
7711
+
7664
7712
  /* *
7665
7713
  * Licensed under the Apache License, Version 2.0 (the "License");
7666
7714
  * you may not use this file except in compliance with the License.
@@ -7725,6 +7773,25 @@
7725
7773
  }
7726
7774
  });
7727
7775
  }
7776
+ function addServiceToLocalStorageSaga(_a) {
7777
+ var _b;
7778
+
7779
+ var payload = _a.payload;
7780
+ var id = payload.id,
7781
+ isUserAddedService = payload.isUserAddedService,
7782
+ name = payload.name,
7783
+ service = payload.service;
7784
+ if (!isUserAddedService) return;
7785
+ var localStorageServices = getUserAddedServices();
7786
+ setUserAddedServices({
7787
+ byId: __assign(__assign({}, localStorageServices.byId), (_b = {}, _b[service] = {
7788
+ id: id,
7789
+ name: name,
7790
+ service: service
7791
+ }, _b)),
7792
+ allIds: __spreadArray([], __read(new Set(__spreadArray(__spreadArray([], __read(localStorageServices.allIds || [])), [service]))))
7793
+ });
7794
+ }
7728
7795
  function rootSaga() {
7729
7796
  return __generator(this, function (_a) {
7730
7797
  switch (_a.label) {
@@ -7743,6 +7810,13 @@
7743
7810
  case 2:
7744
7811
  _a.sent();
7745
7812
 
7813
+ return [4
7814
+ /*yield*/
7815
+ , effects.takeEvery(MAP_SERVICES_SET_LAYERS, addServiceToLocalStorageSaga)];
7816
+
7817
+ case 3:
7818
+ _a.sent();
7819
+
7746
7820
  return [2
7747
7821
  /*return*/
7748
7822
  ];
@@ -11239,7 +11313,8 @@
11239
11313
  id: serviceUrl,
11240
11314
  name: serviceName,
11241
11315
  service: serviceUrl,
11242
- layers: serviceLayers
11316
+ layers: serviceLayers,
11317
+ isUserAddedService: true
11243
11318
  });
11244
11319
  setIsLoading(false);
11245
11320
  closePopupAndResetState();
@@ -13111,7 +13186,8 @@
13111
13186
  id: service.id,
13112
13187
  name: service.name,
13113
13188
  service: service.url,
13114
- layers: layers
13189
+ layers: layers,
13190
+ isUserAddedService: false
13115
13191
  });
13116
13192
  }
13117
13193
  })["catch"](function () {
@@ -18766,6 +18842,171 @@
18766
18842
  }
18767
18843
  };
18768
18844
 
18845
+ /* *
18846
+ * Licensed under the Apache License, Version 2.0 (the "License");
18847
+ * you may not use this file except in compliance with the License.
18848
+ * You may obtain a copy of the License at
18849
+ *
18850
+ * http://www.apache.org/licenses/LICENSE-2.0
18851
+ *
18852
+ * Unless required by applicable law or agreed to in writing, software
18853
+ * distributed under the License is distributed on an "AS IS" BASIS,
18854
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18855
+ * See the License for the specific language governing permissions and
18856
+ * limitations under the License.
18857
+ *
18858
+ * Copyright 2020 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
18859
+ * Copyright 2020 - Finnish Meteorological Institute (FMI)
18860
+ * */
18861
+ /* Function which calculates the distance between two points */
18862
+ // eslint-disable-next-line class-methods-use-this
18863
+
18864
+ var distance = function distance(a, b) {
18865
+ return Math.sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
18866
+ };
18867
+
18868
+ var checkHoverVertice = function checkHoverVertice(feature, mouseX, mouseY, convertGeoCoordsToScreenCoords) {
18869
+ var maxDistance = 20;
18870
+
18871
+ if (feature.geometry.type === 'Point') {
18872
+ var featureCoords = feature.geometry.coordinates;
18873
+ /* Get all vertexes */
18874
+
18875
+ var XYCoords = convertGeoCoordsToScreenCoords([featureCoords]);
18876
+
18877
+ if (XYCoords.length > 0 && distance(XYCoords[0], {
18878
+ x: mouseX,
18879
+ y: mouseY
18880
+ }) < maxDistance) {
18881
+ return {
18882
+ coordinateIndexInFeature: 0
18883
+ };
18884
+ }
18885
+ }
18886
+
18887
+ if (feature.geometry.type === 'MultiPoint') {
18888
+ for (var polygonIndex = feature.geometry.coordinates.length - 1; polygonIndex >= 0; polygonIndex -= 1) {
18889
+ var featureCoords = feature.geometry.coordinates[polygonIndex];
18890
+
18891
+ if (featureCoords === undefined) {
18892
+ // eslint-disable-next-line no-continue
18893
+ continue;
18894
+ }
18895
+ /* Get all vertexes */
18896
+
18897
+
18898
+ var XYCoords = convertGeoCoordsToScreenCoords([featureCoords]);
18899
+
18900
+ if (XYCoords.length > 0 && distance(XYCoords[0], {
18901
+ x: mouseX,
18902
+ y: mouseY
18903
+ }) < maxDistance) {
18904
+ return {
18905
+ coordinateIndexInFeature: polygonIndex
18906
+ };
18907
+ }
18908
+ }
18909
+ }
18910
+
18911
+ if (feature.geometry.type === 'Polygon') {
18912
+ var point = [mouseX, mouseY];
18913
+
18914
+ for (var polygonIndex = feature.geometry.coordinates.length - 1; polygonIndex >= 0; polygonIndex -= 1) {
18915
+ var featureCoords = feature.geometry.coordinates[polygonIndex];
18916
+
18917
+ if (featureCoords === undefined) {
18918
+ // eslint-disable-next-line no-continue
18919
+ continue;
18920
+ }
18921
+ /* Get all vertexes */
18922
+
18923
+
18924
+ var poly = [convertGeoCoordsToScreenCoords(featureCoords).map(function (coord) {
18925
+ return [coord.x, coord.y];
18926
+ })];
18927
+
18928
+ try {
18929
+ var isPointInPoly = turf__namespace.booleanPointInPolygon(turf__namespace.point(point), turf__namespace.polygon(poly));
18930
+
18931
+ if (isPointInPoly) {
18932
+ return {
18933
+ coordinateIndexInFeature: polygonIndex
18934
+ };
18935
+ } // eslint-disable-next-line no-empty
18936
+
18937
+ } catch (e) {}
18938
+ }
18939
+ }
18940
+
18941
+ if (feature.geometry.type === 'MultiPolygon') {
18942
+ var point = [mouseX, mouseY];
18943
+
18944
+ for (var polygonIndex = feature.geometry.coordinates.length - 1; polygonIndex >= 0; polygonIndex -= 1) {
18945
+ var featureCoords = feature.geometry.coordinates[polygonIndex][0];
18946
+
18947
+ if (featureCoords === undefined) {
18948
+ // eslint-disable-next-line no-continue
18949
+ continue;
18950
+ }
18951
+
18952
+ var poly = [convertGeoCoordsToScreenCoords(featureCoords).map(function (coord) {
18953
+ return [coord.x, coord.y];
18954
+ })];
18955
+
18956
+ try {
18957
+ var isPointInPoly = turf__namespace.booleanPointInPolygon(turf__namespace.point(point), turf__namespace.polygon(poly));
18958
+
18959
+ if (isPointInPoly) {
18960
+ return {
18961
+ coordinateIndexInFeature: polygonIndex
18962
+ };
18963
+ } // eslint-disable-next-line no-empty
18964
+
18965
+ } catch (e) {}
18966
+ }
18967
+ }
18968
+
18969
+ if (feature.geometry.type === 'LineString') {
18970
+ var featureCoords = feature.geometry.coordinates;
18971
+ /* Get all vertexes */
18972
+
18973
+ var XYCoords = convertGeoCoordsToScreenCoords(featureCoords);
18974
+ /* Snap to the vertex closer than specified pixels */
18975
+
18976
+ for (var j = 0; j < XYCoords.length; j += 1) {
18977
+ var coord = XYCoords[j];
18978
+
18979
+ if (distance(coord, {
18980
+ x: mouseX,
18981
+ y: mouseY
18982
+ }) < maxDistance) {
18983
+ return {
18984
+ coordinateIndexInFeature: j
18985
+ };
18986
+ }
18987
+ }
18988
+ }
18989
+
18990
+ return null;
18991
+ };
18992
+
18993
+ var checkHoverFeatures = function checkHoverFeatures(geojson, mouseX, mouseY, convertGeoCoordsToScreenCoords) {
18994
+ for (var j = 0; j < geojson.features.length; j += 1) {
18995
+ var feature = geojson.features[j];
18996
+ var hoverResult = checkHoverVertice(feature, mouseX, mouseY, convertGeoCoordsToScreenCoords);
18997
+
18998
+ if (hoverResult != null) {
18999
+ return {
19000
+ coordinateIndexInFeature: hoverResult.coordinateIndexInFeature,
19001
+ featureIndex: j,
19002
+ feature: feature
19003
+ };
19004
+ }
19005
+ }
19006
+
19007
+ return null;
19008
+ };
19009
+
18769
19010
  /* *
18770
19011
  * Licensed under the Apache License, Version 2.0 (the "License");
18771
19012
  * you may not use this file except in compliance with the License.
@@ -19376,9 +19617,12 @@
19376
19617
  };
19377
19618
 
19378
19619
  AdagucMapDraw.prototype.adagucMouseMove = function (event) {
19620
+ var _this = this;
19621
+
19379
19622
  var _a = this.props,
19380
19623
  isInEditMode = _a.isInEditMode,
19381
- featureNrToEdit = _a.featureNrToEdit;
19624
+ featureNrToEdit = _a.featureNrToEdit,
19625
+ onHoverFeature = _a.onHoverFeature;
19382
19626
  if (event && event.rightButton === true) return;
19383
19627
  /* adagucMouseMove is an event callback function which is triggered when the mouse moves over the map
19384
19628
  This event is only triggered if the map is in hover state.
@@ -19391,6 +19635,29 @@
19391
19635
  this.mouseX = mouseX;
19392
19636
  this.mouseY = mouseY;
19393
19637
 
19638
+ if (onHoverFeature) {
19639
+ var handleMouseStoppedTimer = function handleMouseStoppedTimer() {
19640
+ var result = checkHoverFeatures(_this.geojson, mouseX, mouseY, function (coordinates) {
19641
+ return _this.convertGeoCoordsToScreenCoords(coordinates);
19642
+ });
19643
+
19644
+ if (result) {
19645
+ var featureEvent = {
19646
+ coordinateIndexInFeature: result.coordinateIndexInFeature,
19647
+ featureIndex: result.featureIndex,
19648
+ mouseX: mouseX,
19649
+ mouseY: mouseY,
19650
+ isInEditMode: isInEditMode,
19651
+ feature: result.feature
19652
+ };
19653
+ onHoverFeature(featureEvent);
19654
+ }
19655
+ };
19656
+
19657
+ window.clearTimeout(this.mouseStoppedTimer);
19658
+ this.mouseStoppedTimer = window.setTimeout(handleMouseStoppedTimer, 20);
19659
+ }
19660
+
19394
19661
  if (isInEditMode === false) {
19395
19662
  return;
19396
19663
  }
@@ -19891,9 +20158,35 @@
19891
20158
  };
19892
20159
 
19893
20160
  AdagucMapDraw.prototype.adagucMouseUp = function (event) {
19894
- var isInEditMode = this.props.isInEditMode;
20161
+ var _this = this;
20162
+
20163
+ var _a = this.props,
20164
+ isInEditMode = _a.isInEditMode,
20165
+ onClickFeature = _a.onClickFeature;
19895
20166
  if (event && event.rightButton === true) return;
19896
20167
 
20168
+ if (onClickFeature) {
20169
+ var mouseX = event.mouseX,
20170
+ mouseY = event.mouseY;
20171
+ var result = checkHoverFeatures(this.geojson, mouseX, mouseY, function (coordinates) {
20172
+ return _this.convertGeoCoordsToScreenCoords(coordinates);
20173
+ });
20174
+
20175
+ if (result) {
20176
+ var featureEvent = {
20177
+ coordinateIndexInFeature: result.coordinateIndexInFeature,
20178
+ featureIndex: result.featureIndex,
20179
+ mouseX: mouseX,
20180
+ mouseY: mouseY,
20181
+ isInEditMode: isInEditMode,
20182
+ feature: result.feature
20183
+ };
20184
+ onClickFeature(featureEvent);
20185
+ } else {
20186
+ onClickFeature(null);
20187
+ }
20188
+ }
20189
+
19897
20190
  if (isInEditMode === false) {
19898
20191
  return;
19899
20192
  }
@@ -20099,12 +20392,12 @@
20099
20392
  */
20100
20393
  var _a = this.props,
20101
20394
  featureNrToEdit = _a.featureNrToEdit,
20102
- isInEditMode = _a.isInEditMode,
20103
- hoverFeatureCallback = _a.hoverFeatureCallback;
20395
+ isInEditMode = _a.isInEditMode;
20104
20396
  if (!this.geojson || !this.geojson.features || !this.geojson.features.length) return;
20105
20397
  this.textPositions = [];
20106
20398
  this.mouseOverPolygonCoordinates = [];
20107
20399
  this.mouseOverPolygonFeatureIndex = -1;
20400
+ this.mouseOverPolygonIndex = -1;
20108
20401
  /* Current selected feature from GeoJSON */
20109
20402
 
20110
20403
  for (var featureIndex = 0; featureIndex < this.geojson.features.length; featureIndex += 1) {
@@ -20291,19 +20584,6 @@
20291
20584
  ctx.globalAlpha = 1;
20292
20585
  ctx.stroke();
20293
20586
  }
20294
- } // if (isInEditMode === true &&
20295
- // this.mouseOverPolygonFeatureIndex === this.props.featureNrToEdit &&
20296
-
20297
-
20298
- if (hoverFeatureCallback) {
20299
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
20300
- // @ts-ignore
20301
- hoverFeatureCallback({
20302
- polygonIndex: this.mouseOverPolygonFeatureIndex,
20303
- featureIndex: this.mouseOverPolygonFeatureIndex,
20304
- mouseX: this.mouseX,
20305
- mouseY: this.mouseY
20306
- });
20307
20587
  }
20308
20588
  /* Draw labels */
20309
20589
 
@@ -20618,7 +20898,8 @@
20618
20898
  // if (test) {
20619
20899
 
20620
20900
  this.mouseOverPolygonCoordinates = 0;
20621
- this.mouseOverPolygonFeatureIndex = 0; // }
20901
+ this.mouseOverPolygonFeatureIndex = 0;
20902
+ this.mouseOverPolygonIndex = 0; // }
20622
20903
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
20623
20904
  // @ts-ignore
20624
20905
 
@@ -20695,6 +20976,7 @@
20695
20976
  if (test) {
20696
20977
  this.mouseOverPolygonCoordinates = XYCoords;
20697
20978
  this.mouseOverPolygonFeatureIndex = featureIndex;
20979
+ this.mouseOverPolygonIndex = polygonIndex;
20698
20980
  } // eslint-disable-next-line @typescript-eslint/ban-ts-comment
20699
20981
  // @ts-ignore
20700
20982
 
@@ -20910,9 +21192,14 @@
20910
21192
  isInDeleteMode: layer.isInDeleteMode,
20911
21193
  drawMode: layer.drawMode,
20912
21194
  webmapjs: webMapJS,
20913
- hoverFeatureCallback: function hoverFeatureCallback(hoverInfo) {
20914
- if (layer.hoverFeatureCallback) {
20915
- layer.hoverFeatureCallback(hoverInfo);
21195
+ onHoverFeature: function onHoverFeature(hoverInfo) {
21196
+ if (layer.onHoverFeature) {
21197
+ layer.onHoverFeature(hoverInfo);
21198
+ }
21199
+ },
21200
+ onClickFeature: function onClickFeature(hoverInfo) {
21201
+ if (layer.onClickFeature) {
21202
+ layer.onClickFeature(hoverInfo);
20916
21203
  }
20917
21204
  },
20918
21205
  updateGeojson: function updateGeojson(geojson) {
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import { FeatureEvent } from '../ReactMapView/AdagucMapDraw';
2
3
  interface MapViewLayerProps {
3
4
  id: string;
4
5
  onLayerReady?: (layer: any, webmap?: any) => void;
@@ -9,6 +10,8 @@ interface MapViewLayerProps {
9
10
  updateGeojson?: (geoJson: any) => void;
10
11
  exitDrawModeCallback?: () => void;
11
12
  featureNrToEdit?: number;
13
+ onClickFeature?: (event: FeatureEvent) => void;
14
+ onHoverFeature?: (event: FeatureEvent) => void;
12
15
  }
13
16
  declare const MapViewLayer: React.FC<MapViewLayerProps>;
14
17
  export default MapViewLayer;
@@ -7,8 +7,8 @@ export declare const featureMultiPoint: GeoJSON.Feature<GeoJSON.MultiPoint>;
7
7
  export declare const featurePolygon: GeoJSON.Feature<GeoJSON.Polygon>;
8
8
  export declare const featureBox: GeoJSON.Feature<GeoJSON.Polygon>;
9
9
  export declare const lineString: GeoJSON.FeatureCollection;
10
- declare type GeoJsonFeatureType = GeoJSON.Polygon | GeoJSON.MultiPoint | GeoJSON.Point | GeoJSON.LineString;
11
- declare type GeoJsonFeature = GeoJSON.Feature<GeoJsonFeatureType>;
10
+ export declare type GeoJsonFeatureType = GeoJSON.Polygon | GeoJSON.MultiPoint | GeoJSON.Point | GeoJSON.LineString | GeoJSON.MultiPolygon;
11
+ export declare type GeoJsonFeature = GeoJSON.Feature<GeoJsonFeatureType>;
12
12
  declare type GeoFeatureStyle = {
13
13
  stroke?: string;
14
14
  fill?: string;
@@ -16,7 +16,7 @@ declare type GeoFeatureStyle = {
16
16
  'stroke-opacity'?: number;
17
17
  'fill-opacity'?: number;
18
18
  };
19
- declare type Coordinate = {
19
+ export declare type Coordinate = {
20
20
  x: number;
21
21
  y: number;
22
22
  };
@@ -32,12 +32,14 @@ declare type AdagucInputEvent = {
32
32
  mouseY: number;
33
33
  rightButton: boolean;
34
34
  };
35
- export declare type FeatureEvent = {
36
- polygonIndex: number;
35
+ export interface FeatureEvent {
36
+ coordinateIndexInFeature: number;
37
37
  featureIndex: number;
38
38
  mouseX: number;
39
39
  mouseY: number;
40
- };
40
+ isInEditMode: boolean;
41
+ feature: GeoJsonFeature;
42
+ }
41
43
  export interface AdagucMapDrawProps {
42
44
  webmapjs: WMJSMap;
43
45
  geojson: GeoJSON.FeatureCollection;
@@ -47,7 +49,8 @@ export interface AdagucMapDrawProps {
47
49
  isInEditMode: boolean;
48
50
  isInDeleteMode: boolean;
49
51
  featureNrToEdit: number;
50
- hoverFeatureCallback: (event: FeatureEvent) => void;
52
+ onHoverFeature?: (event: FeatureEvent) => void;
53
+ onClickFeature?: (event: FeatureEvent) => void;
51
54
  updateGeojson: (geoJson: GeometryObject, text: string) => void;
52
55
  }
53
56
  export declare enum EDITMODE {
@@ -100,10 +103,12 @@ export default class AdagucMapDraw extends React.PureComponent<AdagucMapDrawProp
100
103
  mouseX?: number;
101
104
  mouseY?: number;
102
105
  };
106
+ mouseStoppedTimer: number;
103
107
  snappedPolygonIndex: SNAPPEDFEATURE | number;
104
108
  mouseX: number;
105
109
  mouseY: number;
106
110
  mouseOverPolygonFeatureIndex: number;
111
+ mouseOverPolygonIndex: number;
107
112
  drawMode: string;
108
113
  disabled: boolean;
109
114
  static defaultProps: {
@@ -27,3 +27,7 @@ export declare const Map6: {
27
27
  (): React.ReactElement;
28
28
  storyName: string;
29
29
  };
30
+ export declare const Map7: {
31
+ (): React.ReactElement;
32
+ storyName: string;
33
+ };
@@ -10,7 +10,8 @@ export declare type FeatureLayer = {
10
10
  isInDeleteMode?: boolean;
11
11
  geojson?: GeoJSON.FeatureCollection;
12
12
  drawMode?: string;
13
- hoverFeatureCallback?: (feature: FeatureEvent) => void;
13
+ onHoverFeature?: (feature: FeatureEvent) => void;
14
+ onClickFeature?: (feature: FeatureEvent) => void;
14
15
  updateGeojson?: (feature: GeometryObject) => void;
15
16
  exitDrawModeCallback?: () => void;
16
17
  featureNrToEdit?: string;
@@ -0,0 +1,9 @@
1
+ import { Position } from 'geojson';
2
+ import type { Coordinate, GeoJsonFeature } from './AdagucMapDraw';
3
+ export declare type CheckHoverFeaturesResult = {
4
+ coordinateIndexInFeature: number;
5
+ featureIndex: number;
6
+ feature: GeoJsonFeature;
7
+ } | null;
8
+ export declare const distance: (a: Coordinate, b: Coordinate) => number;
9
+ export declare const checkHoverFeatures: (geojson: GeoJSON.FeatureCollection, mouseX: number, mouseY: number, convertGeoCoordsToScreenCoords: (featureCoords: Position[]) => Coordinate[]) => CheckHoverFeaturesResult;
@@ -1,6 +1,7 @@
1
1
  import { SagaIterator } from 'redux-saga';
2
- import { ServiceActions } from '../mapStore/types';
2
+ import { ServiceActions, SetLayersForService } from '../mapStore/types';
3
3
  export declare function newServiceAddedSaga(capturedAction: ServiceActions): SagaIterator;
4
4
  export declare function layerSelectServiceRemovedSaga(capturedAction: ServiceActions): SagaIterator;
5
+ export declare function addServiceToLocalStorageSaga({ payload, }: SetLayersForService): void;
5
6
  export declare function rootSaga(): SagaIterator;
6
7
  export default rootSaga;
@@ -33,8 +33,9 @@ export interface SetLayersForServicePayload {
33
33
  name: string;
34
34
  service: string;
35
35
  layers: ServiceLayer[];
36
+ isUserAddedService: boolean;
36
37
  }
37
- interface SetLayersForService extends Action {
38
+ export interface SetLayersForService extends Action {
38
39
  type: typeof MAP_SERVICES_SET_LAYERS;
39
40
  payload: SetLayersForServicePayload;
40
41
  }
@@ -1,6 +1,6 @@
1
1
  import { Action } from 'redux';
2
2
  import { UI_SET_ACTIVE_MAPID_FOR_DIALOG, UI_REGISTER_DIALOG, UI_TOGGLE_DIALOG, UI_UNREGISTER_DIALOG, UI_ORDER_DIALOG } from './constants';
3
- export declare type DialogType = 'legend' | 'layerManager' | 'layerSelect' | 'dimensionSelect-elevation' | 'dimensionSelect-ensemble_member' | 'keywordFilter' | 'timeSeriesManager' | 'syncGroups';
3
+ export declare type DialogType = 'legend' | 'layerManager' | 'layerSelect' | 'dimensionSelect-elevation' | 'dimensionSelect-ensemble_member' | 'keywordFilter' | 'timeSeriesManager' | 'timeSeriesSelect' | 'syncGroups';
4
4
  export declare type Source = 'app' | 'module';
5
5
  export interface UIType {
6
6
  type: DialogType;
@@ -0,0 +1,3 @@
1
+ import { ServiceState } from '../store/mapStore/types';
2
+ export declare const getUserAddedServices: () => ServiceState;
3
+ export declare const setUserAddedServices: (services: ServiceState) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/core",
3
- "version": "2.4.1",
3
+ "version": "2.5.0",
4
4
  "description": "GeoWeb Core library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -13,30 +13,31 @@
13
13
  "dependencies": {},
14
14
  "peerDependencies": {
15
15
  "react": "^17.0.2",
16
- "@opengeoweb/theme": "2.4.1",
16
+ "@opengeoweb/theme": "2.5.0",
17
17
  "@mui/material": "^5.2.8",
18
18
  "@mui/styles": "^5.2.3",
19
19
  "@mui/icons-material": "^5.2.5",
20
20
  "react-redux": "7.2.2",
21
21
  "moment": "^2.29.0",
22
22
  "react-intl": "^5.17.5",
23
- "@opengeoweb/webmap": "2.4.1",
23
+ "@opengeoweb/webmap": "2.5.0",
24
24
  "throttle-debounce": "^3.0.1",
25
25
  "proj4": "^2.6.2",
26
26
  "react-sortablejs": "^6.0.0",
27
- "@opengeoweb/shared": "2.4.1",
27
+ "@opengeoweb/shared": "2.5.0",
28
28
  "react-draggable": "^4.4.3",
29
29
  "re-resizable": "^6.9.0",
30
30
  "lodash": "^4.17.20",
31
- "@opengeoweb/form-fields": "2.4.1",
31
+ "@opengeoweb/form-fields": "2.5.0",
32
32
  "react-hook-form": "^6.12.1",
33
33
  "moment-timezone": "^0.5.31",
34
34
  "@mui/lab": "^5.0.0-alpha.64",
35
35
  "axios": "^0.25.0",
36
36
  "redux-dynamic-modules": "^5.2.0",
37
37
  "redux": "^4.0.4",
38
- "lodash.clonedeep": "^4.5.0",
39
38
  "immer": "^9.0.6",
39
+ "lodash.clonedeep": "^4.5.0",
40
+ "@turf/turf": "^5.1.6",
40
41
  "reselect": "^4.1.5",
41
42
  "redux-dynamic-modules-saga": "^5.2.0",
42
43
  "redux-saga": "^1.1.3"