@opengeoweb/webmap-react 12.6.0 → 12.8.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 +204 -3749
- package/package.json +7 -8
- package/src/index.d.ts +0 -2
- package/src/lib/components/MapDimensionSelect/MapDimensionSelect.stories.d.ts +1 -1
- package/src/lib/components/MapDraw/index.d.ts +0 -2
- package/src/lib/components/MapDraw/mapDrawUtils.d.ts +0 -36
- package/src/lib/components/MapDraw/storyComponents/StoryLayout.d.ts +3 -3
- package/src/lib/components/MapDrawTool/types.d.ts +1 -1
- package/src/lib/components/OpenLayers/OpenLayers.FeatureLayerOpacity.stories.d.ts +10 -0
- package/src/lib/components/OpenLayers/controls/OpenLayersGetFeatureInfo.d.ts +1 -0
- package/src/lib/components/OpenLayers/draw/OpenLayersMapDraw.d.ts +1 -1
- package/src/lib/components/OpenLayers/draw/index.d.ts +1 -0
- package/src/lib/components/{MapDraw/MapDrawContainer.d.ts → OpenLayers/draw/types.d.ts} +20 -9
- package/src/lib/components/OpenLayers/layers/FeatureLayer.d.ts +1 -0
- package/src/lib/components/OpenLayers/layers/OpenLayersFeatureLayer.d.ts +1 -0
- package/src/lib/components/OpenLayers/layers/OpenLayersLayer.d.ts +1 -1
- package/src/lib/components/OpenLayers/storyComponents/OlStoryLayout.d.ts +1 -1
- package/src/lib/components/OpenLayers/utils/TimeAwareImageWrapper.d.ts +1 -0
- package/src/lib/components/ReactMapView/index.d.ts +0 -2
- package/src/lib/components/ReactMapView/types.d.ts +1 -41
- package/src/lib/components/ReactMapView/utils.d.ts +2 -10
- package/src/lib/components/index.d.ts +1 -2
- package/src/lib/hooks/useHooksGetCapabilities.d.ts +2 -2
- package/src/lib/components/Axis/ProfileAxis.d.ts +0 -8
- package/src/lib/components/Axis/ProfileAxis.spec.d.ts +0 -1
- package/src/lib/components/Axis/ProfileAxis.stories.d.ts +0 -7
- package/src/lib/components/Axis/profileUtils.d.ts +0 -17
- package/src/lib/components/Axis/profileUtils.spec.d.ts +0 -1
- package/src/lib/components/MapDraw/MapDraw.d.ts +0 -159
- package/src/lib/components/MapDraw/MapDraw.spec.d.ts +0 -1
- package/src/lib/components/MapDraw/MapDraw.stories.d.ts +0 -13
- package/src/lib/components/MapDraw/MapDrawContainer.spec.d.ts +0 -1
- package/src/lib/components/MapDraw/mapDrawUtils.spec.d.ts +0 -1
- package/src/lib/components/MapDraw/storyComponents/FeatureInfo.d.ts +0 -3
- package/src/lib/components/MapDraw/storyComponents/FeatureInfoHTML.d.ts +0 -3
- package/src/lib/components/MapDraw/storyComponents/MapDrawGeoJSON.d.ts +0 -3
- package/src/lib/components/MapDraw/storyComponents/Synops.d.ts +0 -3
- package/src/lib/components/MapDrawTool/MapDrawToolIntersection.stories.d.ts +0 -7
- package/src/lib/components/MapDrawTool/useMapDrawTool.spec.d.ts +0 -1
- package/src/lib/components/MapDrawTool/utils.spec.d.ts +0 -1
- package/src/lib/components/MapView/MapView.d.ts +0 -9
- package/src/lib/components/MapView/MapView.spec.d.ts +0 -1
- package/src/lib/components/MapView/MapViewLayer.d.ts +0 -16
- package/src/lib/components/MapView/index.d.ts +0 -2
- package/src/lib/components/ReactMapView/ReactMapView.d.ts +0 -66
- package/src/lib/components/ReactMapView/ReactMapView.spec.d.ts +0 -2
- package/src/lib/components/ReactMapView/ReactMapViewLayer.d.ts +0 -8
- package/src/lib/components/WMSViewerDemo/WebmapReact.stories.d.ts +0 -6
- package/src/lib/components/WebMapMapView/MapView.VFXData.stories.d.ts +0 -6
- package/src/lib/components/WebMapMapView/WebMapMapView.Error.stories.d.ts +0 -8
- package/src/lib/components/WebMapMapView/WebMapMapView.MapPin.stories.d.ts +0 -6
- package/src/lib/components/WebMapMapView/WebMapMapView.Passive.stories.d.ts +0 -6
- package/src/lib/components/WebMapMapView/WebMapMapView.ProfileSounding.stories.d.ts +0 -6
- package/src/lib/components/WebMapMapView/WebMapMapView.RadarAnimation.stories.d.ts +0 -6
- package/src/lib/components/WebMapMapView/WebMapMapView.RadarData.stories.d.ts +0 -6
- package/src/lib/components/WebMapMapView/WebMapMapView.SetProjectionBBox.stories.d.ts +0 -6
- package/src/lib/components/WebMapMapView/WebMapMapView.SetProjectionBBoxLocalState.stories.d.ts +0 -6
- package/src/lib/components/WebMapMapView/WebMapMapView.ShiftToZoom.stories.d.ts +0 -6
- package/src/lib/components/WebMapMapView/WebMapMapView.ShowLayerInfo.stories.d.ts +0 -6
- package/src/lib/components/WebMapMapView/WebMapMapView.TiledBaseLayers.stories.d.ts +0 -17
- /package/{index.esm.d.ts → index.d.ts} +0 -0
package/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WMImageStore, privateWebMapUtils, webmapUtils, WMLayer, LayerType, WMInvalidDateValues, getCorrectWMSDimName, WMProj4Defs, tilesettings, legendImageStore, WMImageEventType, getLegendGraphicURLForLayer,
|
|
1
|
+
import { WMImageStore, privateWebMapUtils, webmapUtils, WMLayer, LayerType, WMInvalidDateValues, getCorrectWMSDimName, WMProj4Defs, tilesettings, legendImageStore, WMImageEventType, getLegendGraphicURLForLayer, WEBMAP_NAMESPACE } from '@opengeoweb/webmap';
|
|
2
2
|
export { WEBMAP_NAMESPACE, webmapTranslations } from '@opengeoweb/webmap';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import * as React from 'react';
|
|
@@ -9,7 +9,7 @@ import LayerProperty from 'ol/layer/Property';
|
|
|
9
9
|
import ImageSource, { getRequestExtent } from 'ol/source/Image';
|
|
10
10
|
import ImageState from 'ol/ImageState';
|
|
11
11
|
import { fromResolutionLike } from 'ol/resolution';
|
|
12
|
-
import { without, isEqual, throttle, memoize, range, debounce
|
|
12
|
+
import { without, isEqual, throttle, memoize, range, debounce } from 'lodash';
|
|
13
13
|
import ImageWrapper, { load } from 'ol/Image';
|
|
14
14
|
import { getImageSrc, getRequestParams, createLoader } from 'ol/source/wms';
|
|
15
15
|
import { useQuery } from '@tanstack/react-query';
|
|
@@ -21,7 +21,7 @@ import { register } from 'ol/proj/proj4';
|
|
|
21
21
|
import WMTSCapabilities from 'ol/format/WMTSCapabilities';
|
|
22
22
|
import { optionsFromCapabilities } from 'ol/source/WMTS';
|
|
23
23
|
import { View, Map, Feature, Collection } from 'ol';
|
|
24
|
-
import { dateUtils, CustomTooltip, CanvasComponent, useWheelStopPropagation, ToolContainerDraggable, CustomIconButton
|
|
24
|
+
import { dateUtils, CustomTooltip, CanvasComponent, useWheelStopPropagation, ToolContainerDraggable, CustomIconButton } from '@opengeoweb/shared';
|
|
25
25
|
import { Vector } from 'ol/layer';
|
|
26
26
|
import VectorSource from 'ol/source/Vector';
|
|
27
27
|
import GeoJSON from 'ol/format/GeoJSON';
|
|
@@ -34,7 +34,6 @@ import { Home, Add, Minus, List, Delete, Edit, DrawRegion, DrawPolygon, Location
|
|
|
34
34
|
import * as turf from '@turf/turf';
|
|
35
35
|
import { polygonToLine, booleanClockwise, rewind } from '@turf/turf';
|
|
36
36
|
import { produce } from 'immer';
|
|
37
|
-
import { useResizeDetector } from 'react-resize-detector';
|
|
38
37
|
import Box$1 from '@mui/material/Box';
|
|
39
38
|
import Typography$1 from '@mui/material/Typography';
|
|
40
39
|
import { defaults, MouseWheelZoom, Draw, Modify, Translate, Snap } from 'ol/interaction';
|
|
@@ -292,54 +291,6 @@ function _createClass(e, r, t) {
|
|
|
292
291
|
writable: false
|
|
293
292
|
}), e;
|
|
294
293
|
}
|
|
295
|
-
function _createForOfIteratorHelper(r, e) {
|
|
296
|
-
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
297
|
-
if (!t) {
|
|
298
|
-
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
|
|
299
|
-
t && (r = t);
|
|
300
|
-
var n = 0,
|
|
301
|
-
F = function () {};
|
|
302
|
-
return {
|
|
303
|
-
s: F,
|
|
304
|
-
n: function () {
|
|
305
|
-
return n >= r.length ? {
|
|
306
|
-
done: true
|
|
307
|
-
} : {
|
|
308
|
-
done: false,
|
|
309
|
-
value: r[n++]
|
|
310
|
-
};
|
|
311
|
-
},
|
|
312
|
-
e: function (r) {
|
|
313
|
-
throw r;
|
|
314
|
-
},
|
|
315
|
-
f: F
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
319
|
-
}
|
|
320
|
-
var o,
|
|
321
|
-
a = true,
|
|
322
|
-
u = false;
|
|
323
|
-
return {
|
|
324
|
-
s: function () {
|
|
325
|
-
t = t.call(r);
|
|
326
|
-
},
|
|
327
|
-
n: function () {
|
|
328
|
-
var r = t.next();
|
|
329
|
-
return a = r.done, r;
|
|
330
|
-
},
|
|
331
|
-
e: function (r) {
|
|
332
|
-
u = true, o = r;
|
|
333
|
-
},
|
|
334
|
-
f: function () {
|
|
335
|
-
try {
|
|
336
|
-
a || null == t.return || t.return();
|
|
337
|
-
} finally {
|
|
338
|
-
if (u) throw o;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
294
|
function _defineProperty(e, r, t) {
|
|
344
295
|
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
345
296
|
value: t,
|
|
@@ -775,7 +726,7 @@ function _toPrimitive(t, r) {
|
|
|
775
726
|
if ("object" != typeof i) return i;
|
|
776
727
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
777
728
|
}
|
|
778
|
-
return (String )(t);
|
|
729
|
+
return ("string" === r ? String : Number)(t);
|
|
779
730
|
}
|
|
780
731
|
function _toPropertyKey(t) {
|
|
781
732
|
var i = _toPrimitive(t, "string");
|
|
@@ -931,6 +882,9 @@ var TIMEAWAREIMAGEWRAPPER_IMAGEDIDNOTLOADSUCCESFULLY = 'Image did not load succe
|
|
|
931
882
|
var openLayersGetMapImageStore = new WMImageStore(NUM_IMAGES_TO_CACHE, {
|
|
932
883
|
id: 'ol'
|
|
933
884
|
});
|
|
885
|
+
var clearImageCacheForAllMaps = function clearImageCacheForAllMaps() {
|
|
886
|
+
openLayersGetMapImageStore.clear();
|
|
887
|
+
};
|
|
934
888
|
var TimeAwareImageWrapper = /*#__PURE__*/function (_ImageWrapper) {
|
|
935
889
|
function TimeAwareImageWrapper(extent, resolution, pixelRatio) {
|
|
936
890
|
var _this;
|
|
@@ -1492,7 +1446,7 @@ var useGetWMLayerInstance = function useGetWMLayerInstance(serviceUrl, name, id,
|
|
|
1492
1446
|
/**
|
|
1493
1447
|
* Used for querying WMTS GetCapabilities documents
|
|
1494
1448
|
* @param serviceUrl
|
|
1495
|
-
* @returns
|
|
1449
|
+
* @returns {UseQueryResult<string>}
|
|
1496
1450
|
*/
|
|
1497
1451
|
var useQueryWMTSGetCapabilities = function useQueryWMTSGetCapabilities(serviceUrl) {
|
|
1498
1452
|
var uriKey = new URLSearchParams(serviceUrl).toString();
|
|
@@ -3158,7 +3112,8 @@ var FeatureLayer = function FeatureLayer(_ref) {
|
|
|
3158
3112
|
zIndex = _ref.zIndex,
|
|
3159
3113
|
hoverSelect = _ref.hoverSelect,
|
|
3160
3114
|
clickOnFeature = _ref.clickOnFeature,
|
|
3161
|
-
testId = _ref.testId
|
|
3115
|
+
testId = _ref.testId,
|
|
3116
|
+
opacity = _ref.opacity;
|
|
3162
3117
|
var _useContext = useContext(MapContext),
|
|
3163
3118
|
map = _useContext.map;
|
|
3164
3119
|
var _useState = useState(),
|
|
@@ -3179,7 +3134,8 @@ var FeatureLayer = function FeatureLayer(_ref) {
|
|
|
3179
3134
|
style: style,
|
|
3180
3135
|
properties: {
|
|
3181
3136
|
testId: testId
|
|
3182
|
-
}
|
|
3137
|
+
},
|
|
3138
|
+
opacity: opacity
|
|
3183
3139
|
});
|
|
3184
3140
|
layerRef.current = layer;
|
|
3185
3141
|
layer.set('layerType', 'FeatureLayer');
|
|
@@ -3198,6 +3154,13 @@ var FeatureLayer = function FeatureLayer(_ref) {
|
|
|
3198
3154
|
(_layerRef$current = layerRef.current) === null || _layerRef$current === void 0 || _layerRef$current.setStyle(style);
|
|
3199
3155
|
}
|
|
3200
3156
|
}, [style]);
|
|
3157
|
+
useEffect(function () {
|
|
3158
|
+
// Handle opacity:
|
|
3159
|
+
if (layerRef.current && opacity) {
|
|
3160
|
+
var _layerRef$current2;
|
|
3161
|
+
(_layerRef$current2 = layerRef.current) === null || _layerRef$current2 === void 0 || _layerRef$current2.setOpacity(opacity);
|
|
3162
|
+
}
|
|
3163
|
+
}, [opacity]);
|
|
3201
3164
|
useEffect(function () {
|
|
3202
3165
|
if (!source) {
|
|
3203
3166
|
return;
|
|
@@ -3272,7 +3235,8 @@ var OpenLayersFeatureLayer = function OpenLayersFeatureLayer(_ref) {
|
|
|
3272
3235
|
zIndex = _ref.zIndex,
|
|
3273
3236
|
hoverSelect = _ref.hoverSelect,
|
|
3274
3237
|
clickOnFeature = _ref.clickOnFeature,
|
|
3275
|
-
testId = _ref.testId
|
|
3238
|
+
testId = _ref.testId,
|
|
3239
|
+
opacity = _ref.opacity;
|
|
3276
3240
|
var projection = useProjection();
|
|
3277
3241
|
var featureCollectionRef = useRef();
|
|
3278
3242
|
var features = useRef([]);
|
|
@@ -3293,7 +3257,8 @@ var OpenLayersFeatureLayer = function OpenLayersFeatureLayer(_ref) {
|
|
|
3293
3257
|
zIndex: zIndex,
|
|
3294
3258
|
hoverSelect: hoverSelect,
|
|
3295
3259
|
clickOnFeature: clickOnFeature,
|
|
3296
|
-
testId: testId
|
|
3260
|
+
testId: testId,
|
|
3261
|
+
opacity: opacity
|
|
3297
3262
|
});
|
|
3298
3263
|
};
|
|
3299
3264
|
|
|
@@ -9613,7 +9578,7 @@ var LegendDialog = function LegendDialog(_ref) {
|
|
|
9613
9578
|
});
|
|
9614
9579
|
};
|
|
9615
9580
|
|
|
9616
|
-
var _excluded$
|
|
9581
|
+
var _excluded$2 = ["onClick", "children", "title", "placement", "isActive"];
|
|
9617
9582
|
var MapControlButton = function MapControlButton(_ref) {
|
|
9618
9583
|
var onClick = _ref.onClick,
|
|
9619
9584
|
children = _ref.children,
|
|
@@ -9622,7 +9587,7 @@ var MapControlButton = function MapControlButton(_ref) {
|
|
|
9622
9587
|
placement = _ref$placement === void 0 ? 'right' : _ref$placement,
|
|
9623
9588
|
_ref$isActive = _ref.isActive,
|
|
9624
9589
|
isActive = _ref$isActive === void 0 ? false : _ref$isActive,
|
|
9625
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
9590
|
+
props = _objectWithoutProperties(_ref, _excluded$2);
|
|
9626
9591
|
return jsx(CustomIconButton, _objectSpread2(_objectSpread2({
|
|
9627
9592
|
variant: "tool",
|
|
9628
9593
|
tooltipProps: {
|
|
@@ -9662,10 +9627,10 @@ var ZoomControls = function ZoomControls(_ref) {
|
|
|
9662
9627
|
});
|
|
9663
9628
|
};
|
|
9664
9629
|
|
|
9665
|
-
var _excluded$
|
|
9630
|
+
var _excluded$1 = ["children"];
|
|
9666
9631
|
var MapControls = function MapControls(_ref) {
|
|
9667
9632
|
var children = _ref.children,
|
|
9668
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
9633
|
+
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
9669
9634
|
return jsx(Box, _objectSpread2(_objectSpread2({
|
|
9670
9635
|
sx: {
|
|
9671
9636
|
position: 'absolute',
|
|
@@ -9708,6 +9673,23 @@ var LegendButton = function LegendButton(_ref) {
|
|
|
9708
9673
|
});
|
|
9709
9674
|
};
|
|
9710
9675
|
|
|
9676
|
+
/* *
|
|
9677
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9678
|
+
* you may not use this file except in compliance with the License.
|
|
9679
|
+
* You may obtain a copy of the License at
|
|
9680
|
+
*
|
|
9681
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9682
|
+
*
|
|
9683
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
9684
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
9685
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9686
|
+
* See the License for the specific language governing permissions and
|
|
9687
|
+
* limitations under the License.
|
|
9688
|
+
*
|
|
9689
|
+
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
9690
|
+
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
9691
|
+
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
9692
|
+
* */
|
|
9711
9693
|
var Proj4js = proj4;
|
|
9712
9694
|
// Cache for for storing and reusing Proj4 instances
|
|
9713
9695
|
var projectorCache = {};
|
|
@@ -9724,307 +9706,6 @@ var getProj4 = function getProj4(projection) {
|
|
|
9724
9706
|
projectorCache[projection] = new Proj4js.Proj(projection);
|
|
9725
9707
|
return projectorCache[projection];
|
|
9726
9708
|
};
|
|
9727
|
-
/* Function which calculates the distance between two points */
|
|
9728
|
-
var distance = function distance(a, b) {
|
|
9729
|
-
return Math.sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
|
|
9730
|
-
};
|
|
9731
|
-
/* Function which calculates if a point is between two other points */
|
|
9732
|
-
var isBetween = function isBetween(a, c, b) {
|
|
9733
|
-
var da = distance(a, c) + distance(c, b);
|
|
9734
|
-
var db = distance(a, b);
|
|
9735
|
-
return Math.abs(da - db) < 1;
|
|
9736
|
-
};
|
|
9737
|
-
var convertGeoCoordsToScreenCoords = function convertGeoCoordsToScreenCoords(featureCoords, mapId) {
|
|
9738
|
-
var webmapjs = webmapUtils.getWMJSMapById(mapId);
|
|
9739
|
-
if (!webmapjs) {
|
|
9740
|
-
return [];
|
|
9741
|
-
}
|
|
9742
|
-
var XYCoords = [];
|
|
9743
|
-
var _iterator = _createForOfIteratorHelper(featureCoords),
|
|
9744
|
-
_step;
|
|
9745
|
-
try {
|
|
9746
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
9747
|
-
var featureCoord = _step.value;
|
|
9748
|
-
if (featureCoord.length < 2) {
|
|
9749
|
-
// eslint-disable-next-line no-continue
|
|
9750
|
-
continue;
|
|
9751
|
-
}
|
|
9752
|
-
var coord = getPixelCoordFromLatLong(webmapjs, {
|
|
9753
|
-
x: featureCoord[0],
|
|
9754
|
-
y: featureCoord[1]
|
|
9755
|
-
});
|
|
9756
|
-
XYCoords.push(coord);
|
|
9757
|
-
}
|
|
9758
|
-
} catch (err) {
|
|
9759
|
-
_iterator.e(err);
|
|
9760
|
-
} finally {
|
|
9761
|
-
_iterator.f();
|
|
9762
|
-
}
|
|
9763
|
-
return XYCoords;
|
|
9764
|
-
};
|
|
9765
|
-
var getPixelCoordFromGeoCoord = function getPixelCoordFromGeoCoord(featureCoords, mapId) {
|
|
9766
|
-
var webmapjs = webmapUtils.getWMJSMapById(mapId);
|
|
9767
|
-
if (!webmapjs) {
|
|
9768
|
-
return [];
|
|
9769
|
-
}
|
|
9770
|
-
var _webmapjs$getSize = webmapjs.getSize(),
|
|
9771
|
-
width = _webmapjs$getSize.width,
|
|
9772
|
-
height = _webmapjs$getSize.height;
|
|
9773
|
-
var bbox = webmapjs.getDrawBBOX();
|
|
9774
|
-
var proj = webmapjs.getProj4();
|
|
9775
|
-
var XYCoords = [];
|
|
9776
|
-
var from = getProj4(WMJSMAP_LONLAT_EPSGCODE);
|
|
9777
|
-
var to = getProj4(proj.crs);
|
|
9778
|
-
var _iterator2 = _createForOfIteratorHelper(featureCoords),
|
|
9779
|
-
_step2;
|
|
9780
|
-
try {
|
|
9781
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
9782
|
-
var featureCoord = _step2.value;
|
|
9783
|
-
if (featureCoord.length < 2) {
|
|
9784
|
-
// eslint-disable-next-line no-continue
|
|
9785
|
-
continue;
|
|
9786
|
-
}
|
|
9787
|
-
var coordinates = {
|
|
9788
|
-
x: featureCoord[0],
|
|
9789
|
-
y: featureCoord[1]
|
|
9790
|
-
};
|
|
9791
|
-
coordinates = proj.proj4.transform(from, to, coordinates);
|
|
9792
|
-
if (coordinates !== null) {
|
|
9793
|
-
var x = width * (coordinates.x - bbox.left) / (bbox.right - bbox.left);
|
|
9794
|
-
var y = height * (coordinates.y - bbox.top) / (bbox.bottom - bbox.top);
|
|
9795
|
-
XYCoords.push({
|
|
9796
|
-
x: x,
|
|
9797
|
-
y: y
|
|
9798
|
-
});
|
|
9799
|
-
}
|
|
9800
|
-
}
|
|
9801
|
-
} catch (err) {
|
|
9802
|
-
_iterator2.e(err);
|
|
9803
|
-
} finally {
|
|
9804
|
-
_iterator2.f();
|
|
9805
|
-
}
|
|
9806
|
-
return XYCoords;
|
|
9807
|
-
};
|
|
9808
|
-
var findClosestCoords = function findClosestCoords(positions, mouseX, mouseY) {
|
|
9809
|
-
var thresholds = {
|
|
9810
|
-
max: 150,
|
|
9811
|
-
min: 0.5
|
|
9812
|
-
};
|
|
9813
|
-
var closestIndexes = [];
|
|
9814
|
-
var closestDist = Infinity;
|
|
9815
|
-
positions.forEach(function (position, index) {
|
|
9816
|
-
var currentDist = distance(position, {
|
|
9817
|
-
x: mouseX,
|
|
9818
|
-
y: mouseY
|
|
9819
|
-
});
|
|
9820
|
-
if (currentDist < thresholds.min || currentDist > thresholds.max) {
|
|
9821
|
-
return;
|
|
9822
|
-
}
|
|
9823
|
-
if (currentDist < closestDist) {
|
|
9824
|
-
closestDist = currentDist;
|
|
9825
|
-
closestIndexes = [index];
|
|
9826
|
-
} else if (currentDist === closestDist) {
|
|
9827
|
-
closestIndexes.push(index);
|
|
9828
|
-
}
|
|
9829
|
-
});
|
|
9830
|
-
return closestIndexes;
|
|
9831
|
-
};
|
|
9832
|
-
var checkHoverVertice = function checkHoverVertice(feature, mouseX, mouseY, convertGeoCoordsToScreenCoords, ignoreCoordinateIndexInFeature) {
|
|
9833
|
-
var geometry = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : feature.geometry;
|
|
9834
|
-
var maxDistance = 20;
|
|
9835
|
-
if (geometry.type === 'GeometryCollection') {
|
|
9836
|
-
var _iterator3 = _createForOfIteratorHelper(geometry.geometries),
|
|
9837
|
-
_step3;
|
|
9838
|
-
try {
|
|
9839
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
9840
|
-
var geom = _step3.value;
|
|
9841
|
-
var result = checkHoverVertice(feature, mouseX, mouseY, convertGeoCoordsToScreenCoords, ignoreCoordinateIndexInFeature, geom);
|
|
9842
|
-
if (result) {
|
|
9843
|
-
return result;
|
|
9844
|
-
}
|
|
9845
|
-
}
|
|
9846
|
-
} catch (err) {
|
|
9847
|
-
_iterator3.e(err);
|
|
9848
|
-
} finally {
|
|
9849
|
-
_iterator3.f();
|
|
9850
|
-
}
|
|
9851
|
-
}
|
|
9852
|
-
if (geometry.type === 'Point') {
|
|
9853
|
-
var featureCoords = geometry.coordinates;
|
|
9854
|
-
/* Get all vertexes */
|
|
9855
|
-
var XYCoords = convertGeoCoordsToScreenCoords([featureCoords]);
|
|
9856
|
-
var calculatedDistance = XYCoords.length > 0 ? distance(XYCoords[0], {
|
|
9857
|
-
x: mouseX,
|
|
9858
|
-
y: mouseY
|
|
9859
|
-
}) : null;
|
|
9860
|
-
if (calculatedDistance && calculatedDistance < maxDistance) {
|
|
9861
|
-
return {
|
|
9862
|
-
coordinateIndexInFeature: 0,
|
|
9863
|
-
distance: calculatedDistance,
|
|
9864
|
-
screenCoords: _objectSpread2({}, XYCoords[0])
|
|
9865
|
-
};
|
|
9866
|
-
}
|
|
9867
|
-
}
|
|
9868
|
-
if (geometry.type === 'MultiPoint') {
|
|
9869
|
-
for (var polygonIndex = geometry.coordinates.length - 1; polygonIndex >= 0; polygonIndex -= 1) {
|
|
9870
|
-
var _featureCoords = geometry.coordinates[polygonIndex];
|
|
9871
|
-
if (_featureCoords === undefined) {
|
|
9872
|
-
// eslint-disable-next-line no-continue
|
|
9873
|
-
continue;
|
|
9874
|
-
}
|
|
9875
|
-
/* Get all vertexes */
|
|
9876
|
-
var _XYCoords = convertGeoCoordsToScreenCoords([_featureCoords]);
|
|
9877
|
-
var _calculatedDistance = _XYCoords.length > 0 && distance(_XYCoords[0], {
|
|
9878
|
-
x: mouseX,
|
|
9879
|
-
y: mouseY
|
|
9880
|
-
});
|
|
9881
|
-
if (_calculatedDistance && _calculatedDistance < maxDistance) {
|
|
9882
|
-
return {
|
|
9883
|
-
coordinateIndexInFeature: polygonIndex,
|
|
9884
|
-
distance: _calculatedDistance,
|
|
9885
|
-
screenCoords: _objectSpread2({}, _XYCoords[0])
|
|
9886
|
-
};
|
|
9887
|
-
}
|
|
9888
|
-
}
|
|
9889
|
-
}
|
|
9890
|
-
if (geometry.type === 'Polygon') {
|
|
9891
|
-
var point = [mouseX, mouseY];
|
|
9892
|
-
for (var _polygonIndex = geometry.coordinates.length - 1; _polygonIndex >= 0; _polygonIndex -= 1) {
|
|
9893
|
-
var _featureCoords2 = geometry.coordinates[_polygonIndex];
|
|
9894
|
-
if (_featureCoords2 === undefined) {
|
|
9895
|
-
// eslint-disable-next-line no-continue
|
|
9896
|
-
continue;
|
|
9897
|
-
}
|
|
9898
|
-
/* Get all vertexes */
|
|
9899
|
-
var poly = [convertGeoCoordsToScreenCoords(_featureCoords2).map(function (coord) {
|
|
9900
|
-
return [coord.x, coord.y];
|
|
9901
|
-
})];
|
|
9902
|
-
try {
|
|
9903
|
-
var isPointInPoly = turf.booleanPointInPolygon(turf.point(point), turf.polygon(poly));
|
|
9904
|
-
if (isPointInPoly) {
|
|
9905
|
-
if (ignoreCoordinateIndexInFeature) {
|
|
9906
|
-
return {
|
|
9907
|
-
coordinateIndexInFeature: 0,
|
|
9908
|
-
distance: 0,
|
|
9909
|
-
screenCoords: {
|
|
9910
|
-
x: mouseX,
|
|
9911
|
-
y: mouseY
|
|
9912
|
-
}
|
|
9913
|
-
};
|
|
9914
|
-
}
|
|
9915
|
-
return {
|
|
9916
|
-
coordinateIndexInFeature: _polygonIndex,
|
|
9917
|
-
distance: 0,
|
|
9918
|
-
screenCoords: {
|
|
9919
|
-
x: mouseX,
|
|
9920
|
-
y: mouseY
|
|
9921
|
-
}
|
|
9922
|
-
};
|
|
9923
|
-
}
|
|
9924
|
-
} catch (e) {
|
|
9925
|
-
// console.warn(e);
|
|
9926
|
-
}
|
|
9927
|
-
}
|
|
9928
|
-
}
|
|
9929
|
-
if (geometry.type === 'MultiPolygon') {
|
|
9930
|
-
var _point = [mouseX, mouseY];
|
|
9931
|
-
for (var _polygonIndex2 = geometry.coordinates.length - 1; _polygonIndex2 >= 0; _polygonIndex2 -= 1) {
|
|
9932
|
-
var _featureCoords3 = geometry.coordinates[_polygonIndex2][0];
|
|
9933
|
-
if (_featureCoords3 === undefined) {
|
|
9934
|
-
// eslint-disable-next-line no-continue
|
|
9935
|
-
continue;
|
|
9936
|
-
}
|
|
9937
|
-
var _poly = [convertGeoCoordsToScreenCoords(_featureCoords3).map(function (coord) {
|
|
9938
|
-
return [coord.x, coord.y];
|
|
9939
|
-
})];
|
|
9940
|
-
try {
|
|
9941
|
-
var _isPointInPoly = turf.booleanPointInPolygon(turf.point(_point), turf.polygon(_poly));
|
|
9942
|
-
if (_isPointInPoly) {
|
|
9943
|
-
return {
|
|
9944
|
-
coordinateIndexInFeature: _polygonIndex2,
|
|
9945
|
-
distance: 0,
|
|
9946
|
-
screenCoords: {
|
|
9947
|
-
x: mouseX,
|
|
9948
|
-
y: mouseY
|
|
9949
|
-
}
|
|
9950
|
-
};
|
|
9951
|
-
}
|
|
9952
|
-
} catch (e) {
|
|
9953
|
-
console.warn(e);
|
|
9954
|
-
}
|
|
9955
|
-
}
|
|
9956
|
-
}
|
|
9957
|
-
if (geometry.type === 'LineString') {
|
|
9958
|
-
/* Get all vertexes */
|
|
9959
|
-
var _XYCoords2 = convertGeoCoordsToScreenCoords(geometry.coordinates);
|
|
9960
|
-
/* Snap to the vertex closer than specified pixels */
|
|
9961
|
-
for (var j = 0; j < _XYCoords2.length; j += 1) {
|
|
9962
|
-
var coord = _XYCoords2[j];
|
|
9963
|
-
if (distance(coord, {
|
|
9964
|
-
x: mouseX,
|
|
9965
|
-
y: mouseY
|
|
9966
|
-
}) < maxDistance) {
|
|
9967
|
-
return {
|
|
9968
|
-
coordinateIndexInFeature: j,
|
|
9969
|
-
distance: 0,
|
|
9970
|
-
screenCoords: _objectSpread2({}, coord)
|
|
9971
|
-
};
|
|
9972
|
-
}
|
|
9973
|
-
}
|
|
9974
|
-
}
|
|
9975
|
-
return null;
|
|
9976
|
-
};
|
|
9977
|
-
var checkHoverFeatures = function checkHoverFeatures(geojson, mouseX, mouseY, convertGeoCoordsToScreenCoords, ignoreCoordinateIndexInFeature) {
|
|
9978
|
-
var result = [];
|
|
9979
|
-
for (var j = 0; j < geojson.features.length; j += 1) {
|
|
9980
|
-
var feature = geojson.features[j];
|
|
9981
|
-
var hoverResult = checkHoverVertice(feature, mouseX, mouseY, convertGeoCoordsToScreenCoords, ignoreCoordinateIndexInFeature);
|
|
9982
|
-
if (hoverResult != null && hoverResult.distance != null) {
|
|
9983
|
-
result.push({
|
|
9984
|
-
coordinateIndexInFeature: hoverResult.coordinateIndexInFeature,
|
|
9985
|
-
featureIndex: j,
|
|
9986
|
-
feature: feature,
|
|
9987
|
-
distance: hoverResult.distance,
|
|
9988
|
-
screenCoords: _objectSpread2({}, hoverResult.screenCoords)
|
|
9989
|
-
});
|
|
9990
|
-
}
|
|
9991
|
-
}
|
|
9992
|
-
if (result.length === 0) {
|
|
9993
|
-
return null;
|
|
9994
|
-
}
|
|
9995
|
-
/* Sort the list, closest distance on top */
|
|
9996
|
-
result.sort(function (a, b) {
|
|
9997
|
-
var distanceA = a ? a.distance : 0;
|
|
9998
|
-
var distanceB = b ? b.distance : 0;
|
|
9999
|
-
return distanceA - distanceB;
|
|
10000
|
-
}); // b - a for reverse sort
|
|
10001
|
-
return result[0];
|
|
10002
|
-
};
|
|
10003
|
-
var generatedDrawFunctionIds = 0;
|
|
10004
|
-
var generateDrawFunctionId = function generateDrawFunctionId() {
|
|
10005
|
-
generatedDrawFunctionIds += 1;
|
|
10006
|
-
return "drawFunctionId_".concat(generatedDrawFunctionIds);
|
|
10007
|
-
};
|
|
10008
|
-
/**
|
|
10009
|
-
* DrawFunction store for re-use of drawFunctions
|
|
10010
|
-
*/
|
|
10011
|
-
var drawFunctionStore = [];
|
|
10012
|
-
var getDrawFunctionFromStore = function getDrawFunctionFromStore(id) {
|
|
10013
|
-
var drawFunction = drawFunctionStore.find(function (drawFunction) {
|
|
10014
|
-
return drawFunction.id === id;
|
|
10015
|
-
});
|
|
10016
|
-
return drawFunction === null || drawFunction === void 0 ? void 0 : drawFunction.drawMethod;
|
|
10017
|
-
};
|
|
10018
|
-
var registerDrawFunction = function registerDrawFunction() {
|
|
10019
|
-
var drawFunction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
|
|
10020
|
-
var id = generateDrawFunctionId();
|
|
10021
|
-
var newFunction = {
|
|
10022
|
-
id: id,
|
|
10023
|
-
drawMethod: drawFunction
|
|
10024
|
-
};
|
|
10025
|
-
drawFunctionStore.push(newFunction);
|
|
10026
|
-
return id;
|
|
10027
|
-
};
|
|
10028
9709
|
var NEW_LINESTRING_CREATED = 'new point in LineString created';
|
|
10029
9710
|
var NEW_FEATURE_CREATED = 'new feature created';
|
|
10030
9711
|
var NEW_POINT_CREATED = 'new point created';
|
|
@@ -10108,2111 +9789,92 @@ var lineStringCollection = {
|
|
|
10108
9789
|
features: [lineString]
|
|
10109
9790
|
};
|
|
10110
9791
|
|
|
10111
|
-
var
|
|
10112
|
-
|
|
10113
|
-
|
|
10114
|
-
|
|
10115
|
-
|
|
10116
|
-
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
|
|
10131
|
-
|
|
10132
|
-
|
|
10133
|
-
|
|
10134
|
-
|
|
10135
|
-
|
|
10136
|
-
|
|
10137
|
-
|
|
10138
|
-
|
|
10139
|
-
|
|
10140
|
-
|
|
10141
|
-
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
})(DRAGMODE || (DRAGMODE = {}));
|
|
10148
|
-
/**
|
|
10149
|
-
* Initializes a new feature for given type
|
|
10150
|
-
* @param type
|
|
10151
|
-
* @returns
|
|
10152
|
-
*/
|
|
10153
|
-
var getNewFeature = function getNewFeature(type) {
|
|
10154
|
-
switch (type) {
|
|
10155
|
-
case DRAWMODE.POINT:
|
|
10156
|
-
return cloneDeep(featurePoint);
|
|
10157
|
-
case DRAWMODE.MULTIPOINT:
|
|
10158
|
-
return cloneDeep(featureMultiPoint);
|
|
10159
|
-
case DRAWMODE.POLYGON:
|
|
10160
|
-
return cloneDeep(featurePolygon);
|
|
10161
|
-
case DRAWMODE.BOX:
|
|
10162
|
-
return cloneDeep(featureBox);
|
|
10163
|
-
case DRAWMODE.LINESTRING:
|
|
10164
|
-
return cloneDeep(lineString);
|
|
10165
|
-
}
|
|
10166
|
-
return undefined;
|
|
10167
|
-
};
|
|
10168
|
-
var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
|
|
10169
|
-
function MapDraw(props) {
|
|
10170
|
-
var _this;
|
|
10171
|
-
_classCallCheck(this, MapDraw);
|
|
10172
|
-
_this = _callSuper(this, MapDraw, [props]);
|
|
10173
|
-
_this.handleGeoJSONUpdate = function (newGeoJSON) {
|
|
10174
|
-
var _this$geojson;
|
|
10175
|
-
var _this$props = _this.props,
|
|
10176
|
-
selectedFeatureIndex = _this$props.selectedFeatureIndex,
|
|
10177
|
-
mapId = _this$props.mapId;
|
|
10178
|
-
_this.geojson = cloneDeep(newGeoJSON);
|
|
10179
|
-
/* Ensure that this.snappedPolygonIndex is still within the coordinates array */
|
|
10180
|
-
if ((_this$geojson = _this.geojson) !== null && _this$geojson !== void 0 && _this$geojson.features && selectedFeatureIndex < _this.geojson.features.length) {
|
|
10181
|
-
var _feature$geometry;
|
|
10182
|
-
var feature = _this.getSelectedFeature();
|
|
10183
|
-
if (((_feature$geometry = feature.geometry) === null || _feature$geometry === void 0 ? void 0 : _feature$geometry.type) === 'Polygon') {
|
|
10184
|
-
var coordinates = feature.geometry.coordinates;
|
|
10185
|
-
if (Number(_this.snappedPolygonIndex) > coordinates.length - 1) {
|
|
10186
|
-
_this.snappedPolygonIndex = coordinates.length - 1;
|
|
10187
|
-
}
|
|
10188
|
-
} else {
|
|
10189
|
-
_this.snappedPolygonIndex = SNAPPEDFEATURE.NONE;
|
|
10190
|
-
}
|
|
10191
|
-
}
|
|
10192
|
-
var webmapjs = webmapUtils.getWMJSMapById(mapId);
|
|
10193
|
-
webmapjs === null || webmapjs === void 0 || webmapjs.draw('MapDraw::handleGeoJSONUpdate');
|
|
10194
|
-
};
|
|
10195
|
-
_this.handleExitDrawMode = function () {
|
|
10196
|
-
var reason = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'escaped';
|
|
10197
|
-
var exitDrawModeCallback = _this.props.exitDrawModeCallback;
|
|
10198
|
-
// remove last vertice when pressing ESC while drawing a polygon
|
|
10199
|
-
if (_this.myDrawMode === DRAWMODE.POLYGON && _this.myEditMode === EDITMODE.ADD_FEATURE) {
|
|
10200
|
-
var currentFeature = _this.getSelectedFeature();
|
|
10201
|
-
var currentGeometry = currentFeature.geometry;
|
|
10202
|
-
if (currentGeometry.type === 'Polygon') {
|
|
10203
|
-
var coordinates = currentGeometry.coordinates[0];
|
|
10204
|
-
var firstElement = coordinates[0];
|
|
10205
|
-
coordinates[_this.mouseIsOverVertexNr] = cloneDeep(firstElement);
|
|
9792
|
+
var GeoJSONTextField = function GeoJSONTextField(_ref) {
|
|
9793
|
+
var onChangeGeoJSON = _ref.onChangeGeoJSON,
|
|
9794
|
+
geoJSON = _ref.geoJSON,
|
|
9795
|
+
_ref$title = _ref.title,
|
|
9796
|
+
title = _ref$title === void 0 ? 'GeoJSON text' : _ref$title,
|
|
9797
|
+
sx = _ref.sx,
|
|
9798
|
+
_ref$maxRows = _ref.maxRows,
|
|
9799
|
+
maxRows = _ref$maxRows === void 0 ? 18 : _ref$maxRows;
|
|
9800
|
+
var _useState = useState(true),
|
|
9801
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
9802
|
+
isValid = _useState2[0],
|
|
9803
|
+
setValidity = _useState2[1];
|
|
9804
|
+
var onChange = function onChange(event) {
|
|
9805
|
+
try {
|
|
9806
|
+
onChangeGeoJSON(JSON.parse(event.target.value));
|
|
9807
|
+
setValidity(true);
|
|
9808
|
+
} catch (e) {
|
|
9809
|
+
onChangeGeoJSON(null);
|
|
9810
|
+
setValidity(false);
|
|
9811
|
+
}
|
|
9812
|
+
};
|
|
9813
|
+
return jsx(Grid, {
|
|
9814
|
+
size: {
|
|
9815
|
+
xs: 12
|
|
9816
|
+
},
|
|
9817
|
+
sx: sx,
|
|
9818
|
+
children: jsx(TextField, {
|
|
9819
|
+
sx: {
|
|
9820
|
+
padding: 0,
|
|
9821
|
+
border: 'none',
|
|
9822
|
+
width: '100%',
|
|
9823
|
+
height: '100%',
|
|
9824
|
+
fontSize: '10px',
|
|
9825
|
+
'.MuiInputBase-root': {
|
|
9826
|
+
height: '100%',
|
|
9827
|
+
alignItems: 'baseline'
|
|
10206
9828
|
}
|
|
10207
|
-
}
|
|
10208
|
-
|
|
10209
|
-
|
|
10210
|
-
|
|
10211
|
-
|
|
10212
|
-
|
|
10213
|
-
|
|
10214
|
-
|
|
10215
|
-
|
|
10216
|
-
|
|
10217
|
-
|
|
10218
|
-
|
|
10219
|
-
|
|
10220
|
-
|
|
10221
|
-
|
|
10222
|
-
|
|
10223
|
-
|
|
10224
|
-
|
|
10225
|
-
|
|
10226
|
-
|
|
10227
|
-
|
|
10228
|
-
|
|
10229
|
-
|
|
10230
|
-
|
|
10231
|
-
_this.checkDist = _this.checkDist.bind(_this);
|
|
10232
|
-
_this.hoverEdge = _this.hoverEdge.bind(_this);
|
|
10233
|
-
_this.drawPolygon = _this.drawPolygon.bind(_this);
|
|
10234
|
-
_this.moveVertex = _this.moveVertex.bind(_this);
|
|
10235
|
-
_this.featureHasChanged = _this.featureHasChanged.bind(_this);
|
|
10236
|
-
_this.handleKeyDown = _this.handleKeyDown.bind(_this);
|
|
10237
|
-
_this.hoverVertex = _this.hoverVertex.bind(_this);
|
|
10238
|
-
_this.transposePolygon = _this.transposePolygon.bind(_this);
|
|
10239
|
-
_this.transposeVertex = _this.transposeVertex.bind(_this);
|
|
10240
|
-
_this.triggerMouseDownTimer = _this.triggerMouseDownTimer.bind(_this);
|
|
10241
|
-
_this.mouseDoubleClick = _this.mouseDoubleClick.bind(_this);
|
|
10242
|
-
_this.handleDrawMode = _this.handleDrawMode.bind(_this);
|
|
10243
|
-
_this.componentCleanup = _this.componentCleanup.bind(_this);
|
|
10244
|
-
_this.initializeFeatureCoordinates = _this.initializeFeatureCoordinates.bind(_this);
|
|
10245
|
-
_this.validatePolys = _this.validatePolys.bind(_this);
|
|
10246
|
-
_this.insertVertexInEdge = _this.insertVertexInEdge.bind(_this);
|
|
10247
|
-
_this.createNewFeature = _this.createNewFeature.bind(_this);
|
|
10248
|
-
_this.addPointToMultiPointFeature = _this.addPointToMultiPointFeature.bind(_this);
|
|
10249
|
-
_this.addVerticesToPolygonFeature = _this.addVerticesToPolygonFeature.bind(_this);
|
|
10250
|
-
_this.checkIfFeatureIsBox = _this.checkIfFeatureIsBox.bind(_this);
|
|
10251
|
-
_this.handleGeoJSONUpdate = _this.handleGeoJSONUpdate.bind(_this);
|
|
10252
|
-
_this.handleNewFeatureIndex = _this.handleNewFeatureIndex.bind(_this);
|
|
10253
|
-
_this.getSelectedFeature = _this.getSelectedFeature.bind(_this);
|
|
10254
|
-
_this.handleDrawMode(props.drawMode);
|
|
10255
|
-
_this.textPositions = [];
|
|
10256
|
-
_this.mouseOverPolygonCoordinates = [];
|
|
10257
|
-
_this.defaultPolyProps = {
|
|
10258
|
-
stroke: '#000',
|
|
10259
|
-
'stroke-width': 0.4,
|
|
10260
|
-
'stroke-opacity': 1,
|
|
10261
|
-
fill: '#33cc00',
|
|
10262
|
-
'fill-opacity': 1
|
|
10263
|
-
};
|
|
10264
|
-
_this.defaultLineStringProps = {
|
|
10265
|
-
stroke: '#000',
|
|
10266
|
-
'stroke-width': 1.5,
|
|
10267
|
-
'stroke-opacity': 1,
|
|
10268
|
-
fill: '#33cc00',
|
|
10269
|
-
'fill-opacity': 1
|
|
10270
|
-
};
|
|
10271
|
-
_this.defaultIconProps = {
|
|
10272
|
-
imageWidth: 30,
|
|
10273
|
-
imageHeight: 30
|
|
9829
|
+
},
|
|
9830
|
+
multiline: true,
|
|
9831
|
+
error: !isValid,
|
|
9832
|
+
maxRows: maxRows,
|
|
9833
|
+
label: !isValid ? 'GeoJSON not valid' : title,
|
|
9834
|
+
variant: "filled",
|
|
9835
|
+
onChange: onChange,
|
|
9836
|
+
value: JSON.stringify(geoJSON, null, 2),
|
|
9837
|
+
disabled: !onChangeGeoJSON
|
|
9838
|
+
})
|
|
9839
|
+
});
|
|
9840
|
+
};
|
|
9841
|
+
|
|
9842
|
+
var FeatureLayers = function FeatureLayers(_ref) {
|
|
9843
|
+
var geojson = _ref.geojson,
|
|
9844
|
+
onChangeLayerIndex = _ref.onChangeLayerIndex,
|
|
9845
|
+
activeFeatureLayerIndex = _ref.activeFeatureLayerIndex,
|
|
9846
|
+
getToolIcon = _ref.getToolIcon;
|
|
9847
|
+
var featureLayerList = geojson ? Array.from(Array(geojson.features.length).keys()).map(function (index) {
|
|
9848
|
+
var _geojson$features$ind;
|
|
9849
|
+
return {
|
|
9850
|
+
index: index,
|
|
9851
|
+
value: (_geojson$features$ind = geojson.features[index].properties) === null || _geojson$features$ind === void 0 ? void 0 : _geojson$features$ind.selectionType,
|
|
9852
|
+
label: "".concat(index + 1, ": ").concat(geojson.features[index].geometry.type)
|
|
10274
9853
|
};
|
|
10275
|
-
|
|
10276
|
-
|
|
10277
|
-
|
|
10278
|
-
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
|
|
10283
|
-
|
|
10284
|
-
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
|
|
10291
|
-
|
|
10292
|
-
|
|
10293
|
-
|
|
10294
|
-
|
|
10295
|
-
|
|
10296
|
-
|
|
10297
|
-
|
|
10298
|
-
|
|
10299
|
-
if (webmapjs !== undefined && this.listenersInitialized !== true) {
|
|
10300
|
-
this.listenersInitialized = true;
|
|
10301
|
-
webmapjs.addListener('beforecanvasdisplay', this.beforeDraw, true);
|
|
10302
|
-
webmapjs.addListener('beforemousemove', this.mouseMove, true);
|
|
10303
|
-
webmapjs.addListener('beforemousedown', this.mouseDown, true);
|
|
10304
|
-
webmapjs.addListener('beforemouseup', this.mouseUp, true);
|
|
10305
|
-
this.disabled = false;
|
|
10306
|
-
}
|
|
10307
|
-
if (webmapjs !== undefined) {
|
|
10308
|
-
webmapjs.draw();
|
|
10309
|
-
}
|
|
10310
|
-
}
|
|
10311
|
-
}, {
|
|
10312
|
-
key: "componentDidUpdate",
|
|
10313
|
-
value: function componentDidUpdate(prevProps) {
|
|
10314
|
-
var _this$props3 = this.props,
|
|
10315
|
-
geojson = _this$props3.geojson,
|
|
10316
|
-
isInEditMode = _this$props3.isInEditMode,
|
|
10317
|
-
isInDeleteMode = _this$props3.isInDeleteMode,
|
|
10318
|
-
drawMode = _this$props3.drawMode,
|
|
10319
|
-
mapId = _this$props3.mapId,
|
|
10320
|
-
selectedFeatureIndex = _this$props3.selectedFeatureIndex;
|
|
10321
|
-
var prevGeojson = prevProps && prevProps.geojson;
|
|
10322
|
-
var prevIsInEditMode = prevProps && prevProps.isInEditMode;
|
|
10323
|
-
var prevIsInDeleteMode = prevProps && prevProps.isInDeleteMode;
|
|
10324
|
-
var prevDrawMode = prevProps && prevProps.drawMode;
|
|
10325
|
-
var prevSelectedFeatureIndex = prevProps && prevProps.selectedFeatureIndex;
|
|
10326
|
-
/* Handle geojson update */
|
|
10327
|
-
if (geojson !== prevGeojson) {
|
|
10328
|
-
this.handleGeoJSONUpdate(geojson);
|
|
10329
|
-
}
|
|
10330
|
-
/* Handle toggle edit */
|
|
10331
|
-
if (isInEditMode !== prevIsInEditMode) {
|
|
10332
|
-
var _webmapUtils$getWMJSM;
|
|
10333
|
-
if (isInEditMode === false && this.myEditMode !== EDITMODE.EMPTY) {
|
|
10334
|
-
this.cancelEdit(true); /* Throw away last vertice */
|
|
10335
|
-
if (this.myEditMode === EDITMODE.DELETE_FEATURES) {
|
|
10336
|
-
this.myEditMode = EDITMODE.EMPTY;
|
|
10337
|
-
return;
|
|
10338
|
-
}
|
|
10339
|
-
}
|
|
10340
|
-
(_webmapUtils$getWMJSM = webmapUtils.getWMJSMapById(mapId)) === null || _webmapUtils$getWMJSM === void 0 || _webmapUtils$getWMJSM.draw('MapDraw::componentDidUpdateIsInEditMode');
|
|
10341
|
-
}
|
|
10342
|
-
/* Handle toggle delete */
|
|
10343
|
-
if (isInDeleteMode !== prevIsInDeleteMode) {
|
|
10344
|
-
if (isInDeleteMode === true) {
|
|
10345
|
-
this.myEditMode = EDITMODE.DELETE_FEATURES;
|
|
10346
|
-
} else if (this.myEditMode === EDITMODE.DELETE_FEATURES) {
|
|
10347
|
-
this.myEditMode = EDITMODE.EMPTY;
|
|
10348
|
-
}
|
|
10349
|
-
}
|
|
10350
|
-
if (isInEditMode !== prevIsInEditMode || isInDeleteMode !== prevIsInDeleteMode) {
|
|
10351
|
-
if (isInEditMode === false && isInDeleteMode === false) {
|
|
10352
|
-
this.myEditMode = EDITMODE.EMPTY;
|
|
10353
|
-
}
|
|
10354
|
-
}
|
|
10355
|
-
if (selectedFeatureIndex !== prevSelectedFeatureIndex) {
|
|
10356
|
-
this.handleNewFeatureIndex();
|
|
10357
|
-
}
|
|
10358
|
-
/* Handle new drawmode */
|
|
10359
|
-
if (drawMode !== prevDrawMode) {
|
|
10360
|
-
/* Handle drawmode */
|
|
10361
|
-
this.handleDrawMode(drawMode);
|
|
10362
|
-
}
|
|
10363
|
-
}
|
|
10364
|
-
}, {
|
|
10365
|
-
key: "componentWillUnmount",
|
|
10366
|
-
value: function componentWillUnmount() {
|
|
10367
|
-
this.componentCleanup();
|
|
10368
|
-
}
|
|
10369
|
-
}, {
|
|
10370
|
-
key: "handleKeyDown",
|
|
10371
|
-
value: function handleKeyDown(event) {
|
|
10372
|
-
var isInEditMode = this.props.isInEditMode;
|
|
10373
|
-
if (event.key === 'Escape') {
|
|
10374
|
-
this.handleExitDrawMode('escaped');
|
|
10375
|
-
}
|
|
10376
|
-
if (isInEditMode && (event.key === 'Delete' || event.key === 'Backspace')) {
|
|
10377
|
-
this.deleteFeature();
|
|
10378
|
-
}
|
|
10379
|
-
}
|
|
10380
|
-
}, {
|
|
10381
|
-
key: "handleNewFeatureIndex",
|
|
10382
|
-
value: function handleNewFeatureIndex() {
|
|
10383
|
-
var _webmapUtils$getWMJSM2;
|
|
10384
|
-
// Another feature was selected. The mouseIsOverVertexNr should be updated
|
|
10385
|
-
var mapId = this.props.mapId;
|
|
10386
|
-
var feature = this.getSelectedFeature();
|
|
10387
|
-
if (feature && feature.geometry.type !== 'GeometryCollection') {
|
|
10388
|
-
var featureCoords = feature.geometry.coordinates;
|
|
10389
|
-
this.mouseIsOverVertexNr = featureCoords.length - 1;
|
|
10390
|
-
}
|
|
10391
|
-
(_webmapUtils$getWMJSM2 = webmapUtils.getWMJSMapById(mapId)) === null || _webmapUtils$getWMJSM2 === void 0 || _webmapUtils$getWMJSM2.draw('MapDraw::componentDidUpdateSelectedFeatureIndex');
|
|
10392
|
-
}
|
|
10393
|
-
/* Converts string input into right drawmode */
|
|
10394
|
-
}, {
|
|
10395
|
-
key: "handleDrawMode",
|
|
10396
|
-
value: function handleDrawMode(_drawMode) {
|
|
10397
|
-
if (_drawMode) {
|
|
10398
|
-
var drawMode = _drawMode.toUpperCase();
|
|
10399
|
-
if (drawMode === 'POINT') {
|
|
10400
|
-
this.myDrawMode = DRAWMODE.POINT;
|
|
10401
|
-
}
|
|
10402
|
-
if (drawMode === 'MULTIPOINT') {
|
|
10403
|
-
this.myDrawMode = DRAWMODE.MULTIPOINT;
|
|
10404
|
-
}
|
|
10405
|
-
if (drawMode === 'BOX') {
|
|
10406
|
-
this.myDrawMode = DRAWMODE.BOX;
|
|
10407
|
-
}
|
|
10408
|
-
if (drawMode === 'POLYGON') {
|
|
10409
|
-
this.myDrawMode = DRAWMODE.POLYGON;
|
|
10410
|
-
}
|
|
10411
|
-
if (drawMode === 'LINESTRING') {
|
|
10412
|
-
this.myDrawMode = DRAWMODE.LINESTRING;
|
|
10413
|
-
}
|
|
10414
|
-
}
|
|
10415
|
-
}
|
|
10416
|
-
}, {
|
|
10417
|
-
key: "hoverVertex",
|
|
10418
|
-
value: function hoverVertex(feature, mouseX, mouseY) {
|
|
10419
|
-
var mapId = this.props.mapId;
|
|
10420
|
-
var foundVertex = VERTEX.NONE;
|
|
10421
|
-
this.mouseIsOverVertexNr = VERTEX.NONE;
|
|
10422
|
-
if (feature.geometry.type === 'Point') {
|
|
10423
|
-
this.snappedPolygonIndex = SNAPPEDFEATURE.NONE;
|
|
10424
|
-
var featureCoords = feature.geometry.coordinates;
|
|
10425
|
-
/* Get all vertexes */
|
|
10426
|
-
var XYCoords = convertGeoCoordsToScreenCoords([featureCoords], mapId);
|
|
10427
|
-
if (XYCoords.length > 0 && this.checkDist(XYCoords[0], 0, mouseX, mouseY)) {
|
|
10428
|
-
this.mouseIsOverVertexNr = 0;
|
|
10429
|
-
return;
|
|
10430
|
-
}
|
|
10431
|
-
}
|
|
10432
|
-
if (feature.geometry.type === 'MultiPoint') {
|
|
10433
|
-
this.snappedPolygonIndex = SNAPPEDFEATURE.NONE;
|
|
10434
|
-
for (var polygonIndex = feature.geometry.coordinates.length - 1; polygonIndex >= 0; polygonIndex -= 1) {
|
|
10435
|
-
var _featureCoords = feature.geometry.coordinates[polygonIndex];
|
|
10436
|
-
if (_featureCoords === undefined) {
|
|
10437
|
-
// eslint-disable-next-line no-continue
|
|
10438
|
-
continue;
|
|
10439
|
-
}
|
|
10440
|
-
/* Get all vertexes */
|
|
10441
|
-
var _XYCoords = convertGeoCoordsToScreenCoords([_featureCoords], mapId);
|
|
10442
|
-
if (_XYCoords.length > 0 && this.checkDist(_XYCoords[0], polygonIndex, mouseX, mouseY)) {
|
|
10443
|
-
this.mouseIsOverVertexNr = polygonIndex;
|
|
10444
|
-
return;
|
|
10445
|
-
}
|
|
10446
|
-
}
|
|
10447
|
-
}
|
|
10448
|
-
if (feature.geometry.type === 'Polygon') {
|
|
10449
|
-
for (var _polygonIndex = feature.geometry.coordinates.length - 1; _polygonIndex >= 0; _polygonIndex -= 1) {
|
|
10450
|
-
var _featureCoords2 = feature.geometry.coordinates[_polygonIndex];
|
|
10451
|
-
if (_featureCoords2 === undefined) {
|
|
10452
|
-
// eslint-disable-next-line no-continue
|
|
10453
|
-
continue;
|
|
10454
|
-
}
|
|
10455
|
-
/* Get all vertexes */
|
|
10456
|
-
var _XYCoords2 = convertGeoCoordsToScreenCoords(_featureCoords2, mapId);
|
|
10457
|
-
var middle = {
|
|
10458
|
-
x: 0,
|
|
10459
|
-
y: 0
|
|
10460
|
-
};
|
|
10461
|
-
/* Snap to the vertex closer than specified pixels */
|
|
10462
|
-
for (var j = 0; j < _XYCoords2.length - 1; j += 1) {
|
|
10463
|
-
var coord = _XYCoords2[j];
|
|
10464
|
-
middle.x += coord.x;
|
|
10465
|
-
middle.y += coord.y;
|
|
10466
|
-
if (this.checkDist(coord, _polygonIndex, mouseX, mouseY)) {
|
|
10467
|
-
foundVertex = j;
|
|
10468
|
-
break;
|
|
10469
|
-
}
|
|
10470
|
-
}
|
|
10471
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
10472
|
-
// @ts-ignore
|
|
10473
|
-
middle.x = parseInt(middle.x / (_XYCoords2.length - 1), 10);
|
|
10474
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
10475
|
-
// @ts-ignore
|
|
10476
|
-
middle.y = parseInt(middle.y / (_XYCoords2.length - 1), 10);
|
|
10477
|
-
/* Check if the mouse hovers the middle vertex */
|
|
10478
|
-
if (foundVertex === VERTEX.NONE && this.checkDist(middle, _polygonIndex, mouseX, mouseY)) {
|
|
10479
|
-
foundVertex = VERTEX.MIDDLE_POINT_OF_FEATURE;
|
|
10480
|
-
}
|
|
10481
|
-
this.mouseIsOverVertexNr = foundVertex;
|
|
10482
|
-
}
|
|
10483
|
-
}
|
|
10484
|
-
if (feature.geometry.type === 'LineString') {
|
|
10485
|
-
var lineStringIndex = 0;
|
|
10486
|
-
var _featureCoords3 = feature.geometry.coordinates;
|
|
10487
|
-
/* Get all vertexes */
|
|
10488
|
-
var _XYCoords3 = convertGeoCoordsToScreenCoords(_featureCoords3, mapId);
|
|
10489
|
-
/* Snap to the vertex closer than specified pixels */
|
|
10490
|
-
for (var _j = 0; _j < _XYCoords3.length; _j += 1) {
|
|
10491
|
-
var _coord2 = _XYCoords3[_j];
|
|
10492
|
-
// if (!coord || coord.length < 2) continue;
|
|
10493
|
-
if (this.checkDist(_coord2, lineStringIndex, mouseX, mouseY)) {
|
|
10494
|
-
foundVertex = _j;
|
|
10495
|
-
break;
|
|
10496
|
-
}
|
|
10497
|
-
}
|
|
10498
|
-
this.mouseIsOverVertexNr = foundVertex;
|
|
10499
|
-
}
|
|
10500
|
-
}
|
|
10501
|
-
}, {
|
|
10502
|
-
key: "mouseMove",
|
|
10503
|
-
value: function mouseMove(event) {
|
|
10504
|
-
var _this2 = this;
|
|
10505
|
-
var _this$props4 = this.props,
|
|
10506
|
-
isInEditMode = _this$props4.isInEditMode,
|
|
10507
|
-
onHoverFeature = _this$props4.onHoverFeature,
|
|
10508
|
-
mapId = _this$props4.mapId;
|
|
10509
|
-
if ((event === null || event === void 0 ? void 0 : event.rightButton) === true) {
|
|
10510
|
-
return undefined;
|
|
10511
|
-
}
|
|
10512
|
-
/* mouseMove is an event callback function which is triggered when the mouse moves over the map
|
|
10513
|
-
This event is only triggered if the map is in hover state.
|
|
10514
|
-
E.g. when the map is dragging/panning, this event is not triggerd
|
|
10515
|
-
*/
|
|
10516
|
-
var mouseX = event.mouseX,
|
|
10517
|
-
mouseY = event.mouseY,
|
|
10518
|
-
mouseDown = event.mouseDown;
|
|
10519
|
-
this.mouseX = mouseX;
|
|
10520
|
-
this.mouseY = mouseY;
|
|
10521
|
-
if (onHoverFeature) {
|
|
10522
|
-
var handleMouseStoppedTimer = function handleMouseStoppedTimer() {
|
|
10523
|
-
var result = checkHoverFeatures(_this2.geojson, _this2.mouseX, _this2.mouseY, function (coordinates) {
|
|
10524
|
-
return convertGeoCoordsToScreenCoords(coordinates, mapId);
|
|
10525
|
-
});
|
|
10526
|
-
if (result) {
|
|
10527
|
-
_this2.featureEvent = {
|
|
10528
|
-
coordinateIndexInFeature: result.coordinateIndexInFeature,
|
|
10529
|
-
featureIndex: result.featureIndex,
|
|
10530
|
-
mouseX: mouseX,
|
|
10531
|
-
mouseY: mouseY,
|
|
10532
|
-
isInEditMode: isInEditMode,
|
|
10533
|
-
feature: result.feature,
|
|
10534
|
-
screenCoords: result.screenCoords
|
|
10535
|
-
};
|
|
10536
|
-
onHoverFeature(_this2.featureEvent);
|
|
10537
|
-
} else if (_this2.featureEvent) {
|
|
10538
|
-
_this2.featureEvent = undefined;
|
|
10539
|
-
onHoverFeature(undefined);
|
|
10540
|
-
}
|
|
10541
|
-
var webmapjs = webmapUtils.getWMJSMapById(mapId);
|
|
10542
|
-
webmapjs && webmapjs.draw('MapDraw::onHoverFeature');
|
|
10543
|
-
};
|
|
10544
|
-
window.clearTimeout(this.mouseStoppedTimer);
|
|
10545
|
-
this.mouseStoppedTimer = window.setTimeout(handleMouseStoppedTimer, 20);
|
|
10546
|
-
}
|
|
10547
|
-
if (isInEditMode === false) {
|
|
10548
|
-
return undefined;
|
|
10549
|
-
}
|
|
10550
|
-
var feature = this.getSelectedFeature();
|
|
10551
|
-
if (!feature) {
|
|
10552
|
-
return undefined;
|
|
10553
|
-
}
|
|
10554
|
-
var webmapjs = webmapUtils.getWMJSMapById(mapId);
|
|
10555
|
-
if (!webmapjs) {
|
|
10556
|
-
return undefined;
|
|
10557
|
-
}
|
|
10558
|
-
this.mouseGeoCoord = getLatLongFromPixelCoord(webmapjs, {
|
|
10559
|
-
x: mouseX,
|
|
10560
|
-
y: mouseY
|
|
10561
|
-
});
|
|
10562
|
-
/* The mouse is hovering a vertice, and the mousedown is into effect, move vertice accordingly */
|
|
10563
|
-
var ret = this.moveVertex(feature, mouseDown);
|
|
10564
|
-
if (ret === false) {
|
|
10565
|
-
webmapjs.draw('MapDraw::mouseMove');
|
|
10566
|
-
// eslint-disable-next-line consistent-return
|
|
10567
|
-
return false;
|
|
10568
|
-
}
|
|
10569
|
-
/* Check if the mouse hovers any vertice of any polygon */
|
|
10570
|
-
this.hoverVertex(feature, mouseX, mouseY);
|
|
10571
|
-
if (this.mouseIsOverVertexNr !== VERTEX.NONE) {
|
|
10572
|
-
/* We found a vertex */
|
|
10573
|
-
this.selectedEdge = EDGE.NONE; /* We found a vertex, not an edge: reset it */
|
|
10574
|
-
webmapjs.setCursor('move');
|
|
10575
|
-
webmapjs.draw('MapDraw::hoverVertex');
|
|
10576
|
-
// eslint-disable-next-line consistent-return
|
|
10577
|
-
return false;
|
|
10578
|
-
}
|
|
10579
|
-
webmapjs.setCursor();
|
|
10580
|
-
/* Check if the mouse hovers an edge of a polygon */
|
|
10581
|
-
this.selectedEdge = EDGE.NONE;
|
|
10582
|
-
if (this.myEditMode !== EDITMODE.DELETE_FEATURES && !this.checkIfFeatureIsBox(feature)) {
|
|
10583
|
-
var retObj = this.hoverEdge(feature.geometry, mouseX, mouseY);
|
|
10584
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
10585
|
-
// @ts-ignore
|
|
10586
|
-
this.selectedEdge = retObj.selectedEdge;
|
|
10587
|
-
this.snappedPolygonIndex = retObj.snappedPolygonIndex;
|
|
10588
|
-
}
|
|
10589
|
-
if (this.selectedEdge !== EDGE.NONE) {
|
|
10590
|
-
webmapjs.draw('MapDraw::mouseMove');
|
|
10591
|
-
// eslint-disable-next-line consistent-return
|
|
10592
|
-
return false;
|
|
10593
|
-
}
|
|
10594
|
-
if (this.myEditMode === EDITMODE.ADD_FEATURE) {
|
|
10595
|
-
// eslint-disable-next-line consistent-return
|
|
10596
|
-
return false;
|
|
10597
|
-
}
|
|
10598
|
-
/* We did not find anything under the mousecursor,
|
|
10599
|
-
return true means that the map will continue with its own mousehandling
|
|
10600
|
-
*/
|
|
10601
|
-
if (this.mouseIsOverVertexNr === VERTEX.NONE && this.selectedEdge === EDGE.NONE) {
|
|
10602
|
-
webmapjs.draw('MapDraw::mouseMove');
|
|
10603
|
-
// eslint-disable-next-line consistent-return
|
|
10604
|
-
return true; /* False means that this component will take over entire controll.
|
|
10605
|
-
True means that it is still possible to pan and drag the map while editing */
|
|
10606
|
-
}
|
|
10607
|
-
return undefined;
|
|
10608
|
-
}
|
|
10609
|
-
/* Returns true if double click is detected */
|
|
10610
|
-
}, {
|
|
10611
|
-
key: "triggerMouseDownTimer",
|
|
10612
|
-
value: function triggerMouseDownTimer(event) {
|
|
10613
|
-
var _this3 = this;
|
|
10614
|
-
if (!this.doubleClickTimer) {
|
|
10615
|
-
this.doubleClickTimer = {};
|
|
10616
|
-
}
|
|
10617
|
-
var mouseX = event.mouseX,
|
|
10618
|
-
mouseY = event.mouseY;
|
|
10619
|
-
var checkTimeOut = function checkTimeOut() {
|
|
10620
|
-
_this3.doubleClickTimer.isRunning = false;
|
|
10621
|
-
};
|
|
10622
|
-
/* Reset the timer */
|
|
10623
|
-
if (this.doubleClickTimer.timer) {
|
|
10624
|
-
clearTimeout(this.doubleClickTimer.timer);
|
|
10625
|
-
this.doubleClickTimer.timer = null;
|
|
10626
|
-
}
|
|
10627
|
-
/* Check if double click on this location occured */
|
|
10628
|
-
if (this.doubleClickTimer.isRunning === true) {
|
|
10629
|
-
if (mouseX === this.doubleClickTimer.mouseX && mouseY === this.doubleClickTimer.mouseY) {
|
|
10630
|
-
this.doubleClickTimer.isRunning = false;
|
|
10631
|
-
return true;
|
|
10632
|
-
}
|
|
10633
|
-
}
|
|
10634
|
-
/* Create new timer */
|
|
10635
|
-
this.doubleClickTimer.isRunning = true;
|
|
10636
|
-
this.doubleClickTimer.mouseX = mouseX;
|
|
10637
|
-
this.doubleClickTimer.mouseY = mouseY;
|
|
10638
|
-
this.doubleClickTimer.timer = window.setTimeout(checkTimeOut, 300);
|
|
10639
|
-
/* No double click detected, return false */
|
|
10640
|
-
return false;
|
|
10641
|
-
}
|
|
10642
|
-
}, {
|
|
10643
|
-
key: "mouseDoubleClick",
|
|
10644
|
-
value: function mouseDoubleClick() {
|
|
10645
|
-
this.handleExitDrawMode('doubleClicked');
|
|
10646
|
-
}
|
|
10647
|
-
/* Insert a new vertex into an edge, e.g a line is clicked and a point is added */
|
|
10648
|
-
}, {
|
|
10649
|
-
key: "insertVertexInEdge",
|
|
10650
|
-
value: function insertVertexInEdge(event) {
|
|
10651
|
-
var mouseX = event.mouseX,
|
|
10652
|
-
mouseY = event.mouseY;
|
|
10653
|
-
var mapId = this.props.mapId;
|
|
10654
|
-
var webmapjs = webmapUtils.getWMJSMapById(mapId);
|
|
10655
|
-
if (!webmapjs) {
|
|
10656
|
-
return false;
|
|
10657
|
-
}
|
|
10658
|
-
if (this.myDrawMode === DRAWMODE.POLYGON) {
|
|
10659
|
-
if (this.selectedEdge !== EDGE.NONE && this.myEditMode !== EDITMODE.DELETE_FEATURES) {
|
|
10660
|
-
this.mouseGeoCoord = getLatLongFromPixelCoord(webmapjs, {
|
|
10661
|
-
x: mouseX,
|
|
10662
|
-
y: mouseY
|
|
10663
|
-
});
|
|
10664
|
-
var feature = this.getSelectedFeature();
|
|
10665
|
-
if (this.checkIfFeatureIsBox(feature)) {
|
|
10666
|
-
return false;
|
|
10667
|
-
}
|
|
10668
|
-
var featureCoords = feature.geometry.coordinates[this.snappedPolygonIndex];
|
|
10669
|
-
if (featureCoords === undefined) {
|
|
10670
|
-
return false;
|
|
10671
|
-
}
|
|
10672
|
-
featureCoords.splice(this.selectedEdge + 1, 0, [this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
|
|
10673
|
-
this.featureHasChanged('insert vertex into line');
|
|
10674
|
-
this.mouseMove(event);
|
|
10675
|
-
return false;
|
|
10676
|
-
}
|
|
10677
|
-
}
|
|
10678
|
-
if (this.myDrawMode === DRAWMODE.LINESTRING) {
|
|
10679
|
-
if (this.selectedEdge !== EDGE.NONE && this.myEditMode !== EDITMODE.DELETE_FEATURES) {
|
|
10680
|
-
this.mouseGeoCoord = getLatLongFromPixelCoord(webmapjs, {
|
|
10681
|
-
x: mouseX,
|
|
10682
|
-
y: mouseY
|
|
10683
|
-
});
|
|
10684
|
-
var _feature = this.getSelectedFeature();
|
|
10685
|
-
if (this.checkIfFeatureIsBox(_feature)) {
|
|
10686
|
-
return false;
|
|
10687
|
-
}
|
|
10688
|
-
var _featureCoords4 = _feature.geometry.coordinates;
|
|
10689
|
-
if (_featureCoords4 === undefined) {
|
|
10690
|
-
return false;
|
|
10691
|
-
}
|
|
10692
|
-
_featureCoords4.splice(this.selectedEdge + 1, 0, [this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
|
|
10693
|
-
this.featureHasChanged('insert vertex into line');
|
|
10694
|
-
this.mouseMove(event);
|
|
10695
|
-
return false;
|
|
10696
|
-
}
|
|
10697
|
-
}
|
|
10698
|
-
return true;
|
|
10699
|
-
}
|
|
10700
|
-
/**
|
|
10701
|
-
* This creates a new feature in the geojson features array at the selectedFeatureIndex location
|
|
10702
|
-
* @param event
|
|
10703
|
-
* @returns if a new feature is made
|
|
10704
|
-
*/
|
|
10705
|
-
}, {
|
|
10706
|
-
key: "createNewFeature",
|
|
10707
|
-
value: function createNewFeature(event) {
|
|
10708
|
-
var mouseX = event.mouseX,
|
|
10709
|
-
mouseY = event.mouseY;
|
|
10710
|
-
var _this$props5 = this.props,
|
|
10711
|
-
mapId = _this$props5.mapId,
|
|
10712
|
-
selectedFeatureIndex = _this$props5.selectedFeatureIndex;
|
|
10713
|
-
var webmapjs = webmapUtils.getWMJSMapById(mapId);
|
|
10714
|
-
if (!webmapjs) {
|
|
10715
|
-
return false;
|
|
10716
|
-
}
|
|
10717
|
-
if (this.myEditMode === EDITMODE.EMPTY) {
|
|
10718
|
-
this.myEditMode = EDITMODE.ADD_FEATURE;
|
|
10719
|
-
if (!this.geojson.features[selectedFeatureIndex]) {
|
|
10720
|
-
this.geojson.features[selectedFeatureIndex] = getNewFeature(this.myDrawMode);
|
|
10721
|
-
}
|
|
10722
|
-
var feature = this.getSelectedFeature();
|
|
10723
|
-
this.initializeFeatureCoordinates(feature, this.myDrawMode);
|
|
10724
|
-
this.mouseGeoCoord = getLatLongFromPixelCoord(webmapjs, {
|
|
10725
|
-
x: mouseX,
|
|
10726
|
-
y: mouseY
|
|
10727
|
-
});
|
|
10728
|
-
if (this.myDrawMode === DRAWMODE.POINT || this.myDrawMode === DRAWMODE.MULTIPOINT) {
|
|
10729
|
-
/* Create points */
|
|
10730
|
-
var pointGeometry = feature.geometry;
|
|
10731
|
-
if ((pointGeometry === null || pointGeometry === void 0 ? void 0 : pointGeometry.coordinates) === undefined) {
|
|
10732
|
-
pointGeometry.coordinates = [];
|
|
10733
|
-
}
|
|
10734
|
-
var multiPointGeometry = feature.geometry;
|
|
10735
|
-
if ((multiPointGeometry === null || multiPointGeometry === void 0 ? void 0 : multiPointGeometry.coordinates) === undefined) {
|
|
10736
|
-
multiPointGeometry.coordinates = [[]];
|
|
10737
|
-
}
|
|
10738
|
-
if (this.myDrawMode === DRAWMODE.POINT) {
|
|
10739
|
-
var featureCoords = pointGeometry.coordinates;
|
|
10740
|
-
featureCoords[0] = this.mouseGeoCoord.x;
|
|
10741
|
-
featureCoords[1] = this.mouseGeoCoord.y;
|
|
10742
|
-
this.snappedPolygonIndex = pointGeometry.coordinates.length - 1;
|
|
10743
|
-
/* For type POINT it is not possible to add multiple points to the same feature */
|
|
10744
|
-
this.myEditMode = EDITMODE.EMPTY;
|
|
10745
|
-
this.featureHasChanged(NEW_POINT_CREATED);
|
|
10746
|
-
}
|
|
10747
|
-
if (this.myDrawMode === DRAWMODE.MULTIPOINT) {
|
|
10748
|
-
this.myEditMode = EDITMODE.EMPTY;
|
|
10749
|
-
var _featureCoords5 = multiPointGeometry.coordinates;
|
|
10750
|
-
if (_featureCoords5 === undefined) {
|
|
10751
|
-
_featureCoords5 = [];
|
|
10752
|
-
}
|
|
10753
|
-
if (_featureCoords5[0] === undefined || _featureCoords5[0].length === 0) {
|
|
10754
|
-
_featureCoords5[0] = []; /* Used to create the first polygon */
|
|
10755
|
-
} else {
|
|
10756
|
-
_featureCoords5.push([]); /* Used to create extra polygons in the same feature */
|
|
10757
|
-
}
|
|
10758
|
-
// featureCoords.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
|
|
10759
|
-
_featureCoords5[_featureCoords5.length - 1] = [this.mouseGeoCoord.x, this.mouseGeoCoord.y];
|
|
10760
|
-
this.snappedPolygonIndex = multiPointGeometry.coordinates.length - 1;
|
|
10761
|
-
this.featureHasChanged('new point in multipoint created');
|
|
10762
|
-
}
|
|
10763
|
-
}
|
|
10764
|
-
if (this.myDrawMode === DRAWMODE.POLYGON || this.myDrawMode === DRAWMODE.BOX) {
|
|
10765
|
-
/* Create poly's and boxes */
|
|
10766
|
-
this.myEditMode = EDITMODE.ADD_FEATURE;
|
|
10767
|
-
var polygonGeometry = feature.geometry;
|
|
10768
|
-
if ((polygonGeometry === null || polygonGeometry === void 0 ? void 0 : polygonGeometry.coordinates) === undefined) {
|
|
10769
|
-
polygonGeometry.coordinates = [[]];
|
|
10770
|
-
}
|
|
10771
|
-
if (polygonGeometry.coordinates[0] === undefined || polygonGeometry.coordinates[0].length === 0) {
|
|
10772
|
-
polygonGeometry.coordinates[0] = []; /* Used to create the first polygon */
|
|
10773
|
-
} else {
|
|
10774
|
-
this.myEditMode = EDITMODE.EMPTY;
|
|
10775
|
-
return false;
|
|
10776
|
-
}
|
|
10777
|
-
this.snappedPolygonIndex = polygonGeometry.coordinates.length - 1;
|
|
10778
|
-
var _featureCoords6 = polygonGeometry.coordinates[this.snappedPolygonIndex];
|
|
10779
|
-
_featureCoords6.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
|
|
10780
|
-
_featureCoords6.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
|
|
10781
|
-
/* This is triggered when a bounding box is created. Five points are added at once */
|
|
10782
|
-
if (this.myDrawMode === DRAWMODE.BOX) {
|
|
10783
|
-
_featureCoords6.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
|
|
10784
|
-
_featureCoords6.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
|
|
10785
|
-
_featureCoords6.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
|
|
10786
|
-
}
|
|
10787
|
-
if (this.myDrawMode === DRAWMODE.BOX) {
|
|
10788
|
-
this.mouseIsOverVertexNr = 3;
|
|
10789
|
-
} else {
|
|
10790
|
-
this.mouseIsOverVertexNr = _featureCoords6.length - 1;
|
|
10791
|
-
}
|
|
10792
|
-
this.featureHasChanged(NEW_FEATURE_CREATED);
|
|
10793
|
-
}
|
|
10794
|
-
if (this.myDrawMode === DRAWMODE.LINESTRING) {
|
|
10795
|
-
this.myEditMode = EDITMODE.EMPTY;
|
|
10796
|
-
/* Create linestring */
|
|
10797
|
-
this.myEditMode = EDITMODE.ADD_FEATURE;
|
|
10798
|
-
var _featureCoords7 = feature.geometry.coordinates;
|
|
10799
|
-
if (_featureCoords7 === undefined || _featureCoords7.length === 0) {
|
|
10800
|
-
_featureCoords7 = [[this.mouseGeoCoord.x, this.mouseGeoCoord.y]];
|
|
10801
|
-
}
|
|
10802
|
-
if (_featureCoords7[0].length === 0) {
|
|
10803
|
-
_featureCoords7[0] = [this.mouseGeoCoord.x, this.mouseGeoCoord.y];
|
|
10804
|
-
}
|
|
10805
|
-
_featureCoords7.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
|
|
10806
|
-
this.snappedPolygonIndex = 0;
|
|
10807
|
-
this.featureHasChanged(NEW_LINESTRING_CREATED);
|
|
10808
|
-
this.mouseIsOverVertexNr = _featureCoords7.length - 1;
|
|
10809
|
-
}
|
|
10810
|
-
webmapjs.draw('MapDraw::mouseDown');
|
|
10811
|
-
return true;
|
|
10812
|
-
}
|
|
10813
|
-
return false;
|
|
10814
|
-
}
|
|
10815
|
-
/* This is triggered when new points are added during the addmultipoint mode. One point is added per time */
|
|
10816
|
-
}, {
|
|
10817
|
-
key: "addPointToMultiPointFeature",
|
|
10818
|
-
value: function addPointToMultiPointFeature(event) {
|
|
10819
|
-
var mouseX = event.mouseX,
|
|
10820
|
-
mouseY = event.mouseY;
|
|
10821
|
-
var mapId = this.props.mapId;
|
|
10822
|
-
var webmapjs = webmapUtils.getWMJSMapById(mapId);
|
|
10823
|
-
if (!webmapjs) {
|
|
10824
|
-
return false;
|
|
10825
|
-
}
|
|
10826
|
-
if (this.myDrawMode === DRAWMODE.MULTIPOINT) {
|
|
10827
|
-
if (this.myEditMode === EDITMODE.ADD_FEATURE && this.snappedPolygonIndex !== SNAPPEDFEATURE.NONE) {
|
|
10828
|
-
this.mouseGeoCoord = getLatLongFromPixelCoord(webmapjs, {
|
|
10829
|
-
x: mouseX,
|
|
10830
|
-
y: mouseY
|
|
10831
|
-
});
|
|
10832
|
-
var feature = this.getSelectedFeature();
|
|
10833
|
-
if (feature.geometry.type === 'MultiPoint') {
|
|
10834
|
-
var featureCoords = feature.geometry.coordinates;
|
|
10835
|
-
featureCoords.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
|
|
10836
|
-
this.featureHasChanged('point added to multipoint');
|
|
10837
|
-
this.mouseIsOverVertexNr = VERTEX.NONE;
|
|
10838
|
-
this.mouseMove(event);
|
|
10839
|
-
}
|
|
10840
|
-
return false;
|
|
10841
|
-
}
|
|
10842
|
-
}
|
|
10843
|
-
return true;
|
|
10844
|
-
}
|
|
10845
|
-
}, {
|
|
10846
|
-
key: "addVerticesToPolygonFeature",
|
|
10847
|
-
value: function addVerticesToPolygonFeature(event) {
|
|
10848
|
-
var mouseX = event.mouseX,
|
|
10849
|
-
mouseY = event.mouseY;
|
|
10850
|
-
var mapId = this.props.mapId;
|
|
10851
|
-
var webmapjs = webmapUtils.getWMJSMapById(mapId);
|
|
10852
|
-
if (!webmapjs) {
|
|
10853
|
-
return false;
|
|
10854
|
-
}
|
|
10855
|
-
if (this.myDrawMode === DRAWMODE.POLYGON) {
|
|
10856
|
-
if (this.myEditMode === EDITMODE.ADD_FEATURE && this.snappedPolygonIndex !== SNAPPEDFEATURE.NONE) {
|
|
10857
|
-
this.mouseGeoCoord = getLatLongFromPixelCoord(webmapjs, {
|
|
10858
|
-
x: mouseX,
|
|
10859
|
-
y: mouseY
|
|
10860
|
-
});
|
|
10861
|
-
var feature = this.getSelectedFeature();
|
|
10862
|
-
if (feature.geometry.type === 'Polygon') {
|
|
10863
|
-
var featureCoords = feature.geometry.coordinates[this.snappedPolygonIndex];
|
|
10864
|
-
// "featureCoords" is our polygon represented as a list of coordinates. The last element in the list is the ghost node following our cursor.
|
|
10865
|
-
// We therefore extract the last two nodes, which will tell us the distance between the last placed node and the ghost node
|
|
10866
|
-
var _featureCoords$slice = featureCoords.slice(-2),
|
|
10867
|
-
_featureCoords$slice2 = _slicedToArray(_featureCoords$slice, 2),
|
|
10868
|
-
coordA = _featureCoords$slice2[0],
|
|
10869
|
-
coordB = _featureCoords$slice2[1];
|
|
10870
|
-
var coordDistance = distance({
|
|
10871
|
-
x: coordA[0],
|
|
10872
|
-
y: coordA[1]
|
|
10873
|
-
}, {
|
|
10874
|
-
x: coordB[0],
|
|
10875
|
-
y: coordB[1]
|
|
10876
|
-
});
|
|
10877
|
-
if (coordDistance > 0.005) {
|
|
10878
|
-
featureCoords.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
|
|
10879
|
-
this.featureHasChanged('vertex added to polygon');
|
|
10880
|
-
this.mouseIsOverVertexNr = featureCoords.length - 1;
|
|
10881
|
-
this.mouseMove(event);
|
|
10882
|
-
}
|
|
10883
|
-
}
|
|
10884
|
-
return false;
|
|
10885
|
-
}
|
|
10886
|
-
}
|
|
10887
|
-
return undefined;
|
|
10888
|
-
}
|
|
10889
|
-
}, {
|
|
10890
|
-
key: "addPointToLineStringFeature",
|
|
10891
|
-
value: function addPointToLineStringFeature(event) {
|
|
10892
|
-
var mouseX = event.mouseX,
|
|
10893
|
-
mouseY = event.mouseY;
|
|
10894
|
-
var mapId = this.props.mapId;
|
|
10895
|
-
var webmapjs = webmapUtils.getWMJSMapById(mapId);
|
|
10896
|
-
if (!webmapjs) {
|
|
10897
|
-
return false;
|
|
10898
|
-
}
|
|
10899
|
-
if (this.myDrawMode === DRAWMODE.LINESTRING) {
|
|
10900
|
-
if (this.myEditMode === EDITMODE.ADD_FEATURE) {
|
|
10901
|
-
this.mouseGeoCoord = getLatLongFromPixelCoord(webmapjs, {
|
|
10902
|
-
x: mouseX,
|
|
10903
|
-
y: mouseY
|
|
10904
|
-
});
|
|
10905
|
-
var feature = this.getSelectedFeature();
|
|
10906
|
-
var featureCoords = feature.geometry.coordinates;
|
|
10907
|
-
featureCoords.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
|
|
10908
|
-
this.featureHasChanged('vertex added to LineString');
|
|
10909
|
-
this.mouseIsOverVertexNr = featureCoords.length - 1;
|
|
10910
|
-
this.mouseMove(event);
|
|
10911
|
-
return false;
|
|
10912
|
-
}
|
|
10913
|
-
}
|
|
10914
|
-
return true;
|
|
10915
|
-
}
|
|
10916
|
-
}, {
|
|
10917
|
-
key: "mouseDown",
|
|
10918
|
-
value: function mouseDown(event) {
|
|
10919
|
-
var isInEditMode = this.props.isInEditMode;
|
|
10920
|
-
if ((event === null || event === void 0 ? void 0 : event.rightButton) === true) {
|
|
10921
|
-
return;
|
|
10922
|
-
}
|
|
10923
|
-
if (isInEditMode === false) {
|
|
10924
|
-
return;
|
|
10925
|
-
}
|
|
10926
|
-
if (this.triggerMouseDownTimer(event)) {
|
|
10927
|
-
// eslint-disable-next-line consistent-return
|
|
10928
|
-
return this.mouseDoubleClick();
|
|
10929
|
-
}
|
|
10930
|
-
if (this.myEditMode === EDITMODE.ADD_FEATURE && this.myDrawMode === DRAWMODE.BOX) {
|
|
10931
|
-
// eslint-disable-next-line consistent-return
|
|
10932
|
-
return this.mouseDoubleClick();
|
|
10933
|
-
}
|
|
10934
|
-
this.somethingWasDragged = DRAGMODE.NONE;
|
|
10935
|
-
if (this.mouseIsOverVertexNr !== VERTEX.NONE && this.myEditMode === EDITMODE.EMPTY) {
|
|
10936
|
-
// eslint-disable-next-line consistent-return
|
|
10937
|
-
return false;
|
|
10938
|
-
}
|
|
10939
|
-
/* Insert a new vertex into an edge, e.g a line is clicked and a point is added */
|
|
10940
|
-
// eslint-disable-next-line consistent-return
|
|
10941
|
-
if (this.insertVertexInEdge(event) === false) {
|
|
10942
|
-
return false;
|
|
10943
|
-
}
|
|
10944
|
-
/* This checks if a new feature should be created. */
|
|
10945
|
-
if (this.createNewFeature(event)) {
|
|
10946
|
-
/* Start with mouse move from this mouse down location, enables sizing the box while moving the mouse */
|
|
10947
|
-
this.mouseMove(event);
|
|
10948
|
-
return false;
|
|
10949
|
-
}
|
|
10950
|
-
/* This is triggered when new points are added during the addmultipoint mode. One point is added per time */
|
|
10951
|
-
if (this.addPointToMultiPointFeature(event) === false) {
|
|
10952
|
-
return false;
|
|
10953
|
-
}
|
|
10954
|
-
/* This is triggered when new points are added during the addpolygon mode. One point is added per time */
|
|
10955
|
-
if (this.addVerticesToPolygonFeature(event) === false) {
|
|
10956
|
-
return false;
|
|
10957
|
-
}
|
|
10958
|
-
/* This is triggered when new points are added to a linestring */
|
|
10959
|
-
if (this.addPointToLineStringFeature(event) === false) {
|
|
10960
|
-
return false;
|
|
10961
|
-
}
|
|
10962
|
-
return false; /* False means that this component will take over entire controll.
|
|
10963
|
-
True means that it is still possible to pan and drag the map while editing */
|
|
10964
|
-
}
|
|
10965
|
-
}, {
|
|
10966
|
-
key: "deletePolygon",
|
|
10967
|
-
value: function deletePolygon(index) {
|
|
10968
|
-
var deletePolygonCallback = this.props.deletePolygonCallback;
|
|
10969
|
-
var feature = this.getSelectedFeature();
|
|
10970
|
-
if (feature.geometry.type !== 'GeometryCollection') {
|
|
10971
|
-
feature.geometry.coordinates.splice(index, 1);
|
|
10972
|
-
if (deletePolygonCallback) {
|
|
10973
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
10974
|
-
// @ts-ignore
|
|
10975
|
-
deletePolygonCallback();
|
|
10976
|
-
}
|
|
10977
|
-
}
|
|
10978
|
-
}
|
|
10979
|
-
}, {
|
|
10980
|
-
key: "deleteFeature",
|
|
10981
|
-
value: function deleteFeature() {
|
|
10982
|
-
/* Deletes any features under the mousecursor */
|
|
10983
|
-
var _this$props6 = this.props,
|
|
10984
|
-
mapId = _this$props6.mapId,
|
|
10985
|
-
selectedFeatureIndex = _this$props6.selectedFeatureIndex;
|
|
10986
|
-
var webmapjs = webmapUtils.getWMJSMapById(mapId);
|
|
10987
|
-
var feature = this.geojson.features[selectedFeatureIndex]; // Not actually necessarily a polygon
|
|
10988
|
-
var polygonIndex =
|
|
10989
|
-
// This allows us to delete nodes even while not hovering them
|
|
10990
|
-
(feature === null || feature === void 0 ? void 0 : feature.geometry.coordinates.length) === 1 ? 0 : this.snappedPolygonIndex;
|
|
10991
|
-
var featureCoords = feature === null || feature === void 0 ? void 0 : feature.geometry.coordinates[polygonIndex];
|
|
10992
|
-
if (featureCoords === undefined) {
|
|
10993
|
-
return;
|
|
10994
|
-
}
|
|
10995
|
-
if (this.mouseIsOverVertexNr !== VERTEX.MIDDLE_POINT_OF_FEATURE && Array.isArray(featureCoords)) {
|
|
10996
|
-
/* Remove edge of polygon */
|
|
10997
|
-
if (featureCoords.length <= 4) {
|
|
10998
|
-
/* Remove the polygon completely if it can not have an area */
|
|
10999
|
-
this.deletePolygon(polygonIndex);
|
|
11000
|
-
} else {
|
|
11001
|
-
var closestCoords = findClosestCoords(convertGeoCoordsToScreenCoords(featureCoords, mapId), this.mouseX, this.mouseY);
|
|
11002
|
-
var newLength = featureCoords.length - closestCoords.length;
|
|
11003
|
-
/* Remove edge of polygon */
|
|
11004
|
-
closestCoords.sort().reverse().forEach(function (index) {
|
|
11005
|
-
featureCoords.splice(index, 1);
|
|
11006
|
-
});
|
|
11007
|
-
if (closestCoords.length > 1) {
|
|
11008
|
-
featureCoords.push(cloneDeep(featureCoords[0]));
|
|
11009
|
-
}
|
|
11010
|
-
this.mouseIsOverVertexNr = newLength - 1;
|
|
11011
|
-
}
|
|
11012
|
-
} else {
|
|
11013
|
-
/* Remove the polygon completely */
|
|
11014
|
-
this.deletePolygon(polygonIndex);
|
|
11015
|
-
}
|
|
11016
|
-
this.featureHasChanged('deleteFeature');
|
|
11017
|
-
webmapjs === null || webmapjs === void 0 || webmapjs.draw('MapDraw::deletefeatures');
|
|
11018
|
-
}
|
|
11019
|
-
}, {
|
|
11020
|
-
key: "mouseUp",
|
|
11021
|
-
value: function mouseUp(event) {
|
|
11022
|
-
var _this$props7 = this.props,
|
|
11023
|
-
isInEditMode = _this$props7.isInEditMode,
|
|
11024
|
-
onClickFeature = _this$props7.onClickFeature,
|
|
11025
|
-
mapId = _this$props7.mapId;
|
|
11026
|
-
if ((event === null || event === void 0 ? void 0 : event.rightButton) === true) {
|
|
11027
|
-
return;
|
|
11028
|
-
}
|
|
11029
|
-
if (onClickFeature) {
|
|
11030
|
-
var mouseX = event.mouseX,
|
|
11031
|
-
mouseY = event.mouseY;
|
|
11032
|
-
var ignoreCoordinateIndexInFeature = true;
|
|
11033
|
-
var result = checkHoverFeatures(this.geojson, mouseX, mouseY, function (coordinates) {
|
|
11034
|
-
return convertGeoCoordsToScreenCoords(coordinates, mapId);
|
|
11035
|
-
}, ignoreCoordinateIndexInFeature);
|
|
11036
|
-
if (result) {
|
|
11037
|
-
var featureEvent = {
|
|
11038
|
-
coordinateIndexInFeature: result.coordinateIndexInFeature,
|
|
11039
|
-
featureIndex: result.featureIndex,
|
|
11040
|
-
mouseX: mouseX,
|
|
11041
|
-
mouseY: mouseY,
|
|
11042
|
-
isInEditMode: isInEditMode,
|
|
11043
|
-
feature: result.feature,
|
|
11044
|
-
screenCoords: _objectSpread2({}, result.screenCoords)
|
|
11045
|
-
};
|
|
11046
|
-
onClickFeature(featureEvent);
|
|
11047
|
-
} else {
|
|
11048
|
-
onClickFeature(null);
|
|
11049
|
-
}
|
|
11050
|
-
}
|
|
11051
|
-
if (isInEditMode === false) {
|
|
11052
|
-
return;
|
|
11053
|
-
}
|
|
11054
|
-
/* Keep the mouse down to drag a box */
|
|
11055
|
-
if (this.myDrawMode === DRAWMODE.BOX && this.myEditMode === EDITMODE.ADD_FEATURE) {
|
|
11056
|
-
this.cancelEdit(false);
|
|
11057
|
-
return false;
|
|
11058
|
-
}
|
|
11059
|
-
if (this.somethingWasDragged !== DRAGMODE.NONE) {
|
|
11060
|
-
this.featureHasChanged("A ".concat(this.somethingWasDragged.toString(), " was dragged"));
|
|
11061
|
-
}
|
|
11062
|
-
/* Delete a vertex or feature on mouseUp */
|
|
11063
|
-
if (this.myEditMode === EDITMODE.DELETE_FEATURES) {
|
|
11064
|
-
this.deleteFeature();
|
|
11065
|
-
return false;
|
|
11066
|
-
}
|
|
11067
|
-
if (this.mouseIsOverVertexNr !== VERTEX.NONE || this.selectedEdge !== EDGE.NONE) {
|
|
11068
|
-
return false;
|
|
11069
|
-
}
|
|
11070
|
-
if (this.myEditMode === EDITMODE.ADD_FEATURE) {
|
|
11071
|
-
return false;
|
|
11072
|
-
}
|
|
11073
|
-
}
|
|
11074
|
-
}, {
|
|
11075
|
-
key: "cancelEdit",
|
|
11076
|
-
value: function cancelEdit(cancelLastPoint) {
|
|
11077
|
-
var _this$props8 = this.props,
|
|
11078
|
-
isInEditMode = _this$props8.isInEditMode,
|
|
11079
|
-
mapId = _this$props8.mapId;
|
|
11080
|
-
if (isInEditMode === false) {
|
|
11081
|
-
return;
|
|
11082
|
-
}
|
|
11083
|
-
var webmapjs = webmapUtils.getWMJSMapById(mapId);
|
|
11084
|
-
/* When in addpolygon mode, finish the polygon */
|
|
11085
|
-
if (this.myEditMode === EDITMODE.ADD_FEATURE) {
|
|
11086
|
-
this.myEditMode = EDITMODE.EMPTY;
|
|
11087
|
-
if (this.drawMode === DRAWMODE.POLYGON || this.drawMode === DRAWMODE.BOX) {
|
|
11088
|
-
if (this.snappedPolygonIndex === SNAPPEDFEATURE.NONE) {
|
|
11089
|
-
return;
|
|
11090
|
-
}
|
|
11091
|
-
var feature = this.getSelectedFeature();
|
|
11092
|
-
var coordinates = feature.geometry.coordinates;
|
|
11093
|
-
var polygon = coordinates[this.snappedPolygonIndex];
|
|
11094
|
-
if (!polygon) {
|
|
11095
|
-
coordinates[this.snappedPolygonIndex] = [];
|
|
11096
|
-
return;
|
|
11097
|
-
}
|
|
11098
|
-
if (polygon.length === 0) {
|
|
11099
|
-
return;
|
|
11100
|
-
}
|
|
11101
|
-
if (!this.checkIfFeatureIsBox(feature)) {
|
|
11102
|
-
if (cancelLastPoint === true) {
|
|
11103
|
-
polygon.pop();
|
|
11104
|
-
}
|
|
11105
|
-
if (polygon.length < 3) {
|
|
11106
|
-
coordinates.pop();
|
|
11107
|
-
}
|
|
11108
|
-
}
|
|
11109
|
-
}
|
|
11110
|
-
if (this.myDrawMode === DRAWMODE.LINESTRING) {
|
|
11111
|
-
var _feature2 = this.getSelectedFeature();
|
|
11112
|
-
var featureCoords = _feature2.geometry.coordinates;
|
|
11113
|
-
featureCoords.pop();
|
|
11114
|
-
}
|
|
11115
|
-
this.featureHasChanged('cancelEdit');
|
|
11116
|
-
webmapjs === null || webmapjs === void 0 || webmapjs.draw('MapDraw::cancelEdit');
|
|
11117
|
-
} else {
|
|
11118
|
-
/* When in deletefeatures mode, remove any vertex under the mousecursor */
|
|
11119
|
-
// eslint-disable-next-line no-lonely-if
|
|
11120
|
-
if (this.myEditMode === EDITMODE.DELETE_FEATURES) {
|
|
11121
|
-
this.deleteFeature();
|
|
11122
|
-
}
|
|
11123
|
-
}
|
|
11124
|
-
}
|
|
11125
|
-
}, {
|
|
11126
|
-
key: "moveVertex",
|
|
11127
|
-
value: function moveVertex(feature, mouseDown) {
|
|
11128
|
-
var geometryType = feature.geometry.type;
|
|
11129
|
-
if (geometryType === 'GeometryCollection') {
|
|
11130
|
-
return undefined;
|
|
11131
|
-
}
|
|
11132
|
-
var featureCoords = feature.geometry.coordinates[this.snappedPolygonIndex];
|
|
11133
|
-
if (geometryType === 'Point' || geometryType === 'MultiPoint' || geometryType === 'LineString') {
|
|
11134
|
-
featureCoords = feature.geometry.coordinates;
|
|
11135
|
-
}
|
|
11136
|
-
if (!featureCoords) {
|
|
11137
|
-
return undefined;
|
|
11138
|
-
}
|
|
11139
|
-
var vertexSelected = mouseDown === true && this.mouseIsOverVertexNr !== VERTEX.NONE;
|
|
11140
|
-
if (vertexSelected || this.myEditMode === EDITMODE.ADD_FEATURE) {
|
|
11141
|
-
if (geometryType === 'LineString') {
|
|
11142
|
-
this.transposeVertex(featureCoords);
|
|
11143
|
-
// eslint-disable-next-line consistent-return
|
|
11144
|
-
return false;
|
|
11145
|
-
}
|
|
11146
|
-
/* In case middle point is selected, transpose whole polygon */
|
|
11147
|
-
if (this.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE && this.snappedGeoCoords) {
|
|
11148
|
-
this.transposePolygon(featureCoords);
|
|
11149
|
-
} else if (this.mouseIsOverVertexNr !== VERTEX.NONE) {
|
|
11150
|
-
/* Transpose polygon vertex */
|
|
11151
|
-
this.transposeVertex(featureCoords);
|
|
11152
|
-
}
|
|
11153
|
-
// eslint-disable-next-line consistent-return
|
|
11154
|
-
return false;
|
|
11155
|
-
}
|
|
11156
|
-
return undefined;
|
|
11157
|
-
}
|
|
11158
|
-
}, {
|
|
11159
|
-
key: "transposePolygon",
|
|
11160
|
-
value: function transposePolygon(featureCoords) {
|
|
11161
|
-
var incX = this.mouseGeoCoord.x - this.snappedGeoCoords.x;
|
|
11162
|
-
var incY = this.mouseGeoCoord.y - this.snappedGeoCoords.y;
|
|
11163
|
-
this.snappedGeoCoords.x = this.mouseGeoCoord.x;
|
|
11164
|
-
this.snappedGeoCoords.y = this.mouseGeoCoord.y;
|
|
11165
|
-
var _iterator = _createForOfIteratorHelper(featureCoords),
|
|
11166
|
-
_step;
|
|
11167
|
-
try {
|
|
11168
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
11169
|
-
var featureCoord = _step.value;
|
|
11170
|
-
featureCoord[0] += incX;
|
|
11171
|
-
featureCoord[1] += incY;
|
|
11172
|
-
}
|
|
11173
|
-
} catch (err) {
|
|
11174
|
-
_iterator.e(err);
|
|
11175
|
-
} finally {
|
|
11176
|
-
_iterator.f();
|
|
11177
|
-
}
|
|
11178
|
-
if (this.myEditMode !== EDITMODE.ADD_FEATURE) {
|
|
11179
|
-
this.somethingWasDragged = DRAGMODE.FEATURE;
|
|
11180
|
-
}
|
|
11181
|
-
}
|
|
11182
|
-
}, {
|
|
11183
|
-
key: "transposeVertex",
|
|
11184
|
-
value: function transposeVertex(featureCoords) {
|
|
11185
|
-
if (this.myEditMode !== EDITMODE.ADD_FEATURE) {
|
|
11186
|
-
this.somethingWasDragged = DRAGMODE.VERTEX;
|
|
11187
|
-
}
|
|
11188
|
-
if (this.myDrawMode === DRAWMODE.POINT) {
|
|
11189
|
-
/* eslint-disable-next-line no-param-reassign */
|
|
11190
|
-
featureCoords[0] = this.mouseGeoCoord.x;
|
|
11191
|
-
/* eslint-disable-next-line no-param-reassign */
|
|
11192
|
-
featureCoords[1] = this.mouseGeoCoord.y;
|
|
11193
|
-
return;
|
|
11194
|
-
}
|
|
11195
|
-
if (this.myDrawMode === DRAWMODE.LINESTRING) {
|
|
11196
|
-
// eslint-disable-next-line no-param-reassign
|
|
11197
|
-
featureCoords[this.mouseIsOverVertexNr][0] = this.mouseGeoCoord.x;
|
|
11198
|
-
// eslint-disable-next-line no-param-reassign
|
|
11199
|
-
featureCoords[this.mouseIsOverVertexNr][1] = this.mouseGeoCoord.y;
|
|
11200
|
-
return;
|
|
11201
|
-
}
|
|
11202
|
-
if (this.myDrawMode === DRAWMODE.MULTIPOINT) {
|
|
11203
|
-
if (this.mouseIsOverVertexNr !== SNAPPEDFEATURE.NONE) {
|
|
11204
|
-
// eslint-disable-next-line no-param-reassign
|
|
11205
|
-
featureCoords[this.mouseIsOverVertexNr][0] = this.mouseGeoCoord.x;
|
|
11206
|
-
// eslint-disable-next-line no-param-reassign
|
|
11207
|
-
featureCoords[this.mouseIsOverVertexNr][1] = this.mouseGeoCoord.y;
|
|
11208
|
-
}
|
|
11209
|
-
return;
|
|
11210
|
-
}
|
|
11211
|
-
if (this.myDrawMode === DRAWMODE.BOX && (featureCoords.length === 4 || featureCoords.length === 5)) {
|
|
11212
|
-
while (featureCoords.length < 4) {
|
|
11213
|
-
featureCoords.push([this.mouseGeoCoord.x, this.mouseGeoCoord.y]);
|
|
11214
|
-
}
|
|
11215
|
-
if (this.mouseIsOverVertexNr === 0) {
|
|
11216
|
-
featureCoords[0][0] = this.mouseGeoCoord.x;
|
|
11217
|
-
featureCoords[0][1] = this.mouseGeoCoord.y;
|
|
11218
|
-
featureCoords[1][0] = this.mouseGeoCoord.x;
|
|
11219
|
-
featureCoords[3][1] = this.mouseGeoCoord.y;
|
|
11220
|
-
}
|
|
11221
|
-
if (this.mouseIsOverVertexNr === 1) {
|
|
11222
|
-
featureCoords[1][0] = this.mouseGeoCoord.x;
|
|
11223
|
-
featureCoords[1][1] = this.mouseGeoCoord.y;
|
|
11224
|
-
featureCoords[0][0] = this.mouseGeoCoord.x;
|
|
11225
|
-
featureCoords[4][0] = this.mouseGeoCoord.x;
|
|
11226
|
-
featureCoords[2][1] = this.mouseGeoCoord.y;
|
|
11227
|
-
}
|
|
11228
|
-
if (this.mouseIsOverVertexNr === 2) {
|
|
11229
|
-
featureCoords[2][0] = this.mouseGeoCoord.x;
|
|
11230
|
-
featureCoords[2][1] = this.mouseGeoCoord.y;
|
|
11231
|
-
featureCoords[1][1] = this.mouseGeoCoord.y;
|
|
11232
|
-
featureCoords[3][0] = this.mouseGeoCoord.x;
|
|
11233
|
-
}
|
|
11234
|
-
if (this.mouseIsOverVertexNr === 3) {
|
|
11235
|
-
featureCoords[3][0] = this.mouseGeoCoord.x;
|
|
11236
|
-
featureCoords[3][1] = this.mouseGeoCoord.y;
|
|
11237
|
-
featureCoords[0][1] = this.mouseGeoCoord.y;
|
|
11238
|
-
featureCoords[4][1] = this.mouseGeoCoord.y;
|
|
11239
|
-
featureCoords[2][0] = this.mouseGeoCoord.x;
|
|
11240
|
-
}
|
|
11241
|
-
/* Ensure the box square shape */
|
|
11242
|
-
/* A: Left edge should be vertical */
|
|
11243
|
-
var _featureCoords8 = _slicedToArray(featureCoords, 4),
|
|
11244
|
-
_featureCoords8$ = _slicedToArray(_featureCoords8[0], 2),
|
|
11245
|
-
featureCoord0X = _featureCoords8$[0],
|
|
11246
|
-
featureCoord0Y = _featureCoords8$[1],
|
|
11247
|
-
_featureCoords8$2 = _slicedToArray(_featureCoords8[1], 1),
|
|
11248
|
-
featureCoord1X = _featureCoords8$2[0],
|
|
11249
|
-
_featureCoords8$3 = _slicedToArray(_featureCoords8[2], 2),
|
|
11250
|
-
featureCoord2X = _featureCoords8$3[0],
|
|
11251
|
-
featureCoord2Y = _featureCoords8$3[1],
|
|
11252
|
-
_featureCoords8$4 = _slicedToArray(_featureCoords8[3], 2),
|
|
11253
|
-
featureCoord3Y = _featureCoords8$4[1];
|
|
11254
|
-
featureCoords[0][0] = featureCoord1X;
|
|
11255
|
-
/* B: Top edge should be horizontal */
|
|
11256
|
-
featureCoords[0][1] = featureCoord3Y;
|
|
11257
|
-
/* C: Right edge should be vertical */
|
|
11258
|
-
featureCoords[3][0] = featureCoord2X;
|
|
11259
|
-
/* D: Bottom Edge should be horizontal */
|
|
11260
|
-
featureCoords[1][1] = featureCoord2Y;
|
|
11261
|
-
/* Close the box: Last point (point 5 of the box) should have the same coordinates as the starting point */
|
|
11262
|
-
featureCoords[4][0] = featureCoord0X;
|
|
11263
|
-
featureCoords[4][1] = featureCoord0Y;
|
|
11264
|
-
}
|
|
11265
|
-
if (this.myDrawMode === DRAWMODE.POLYGON) {
|
|
11266
|
-
featureCoords[this.mouseIsOverVertexNr][0] = this.mouseGeoCoord.x;
|
|
11267
|
-
featureCoords[this.mouseIsOverVertexNr][1] = this.mouseGeoCoord.y;
|
|
11268
|
-
/* Transpose begin and end vertice */
|
|
11269
|
-
if (this.mouseIsOverVertexNr === 0) {
|
|
11270
|
-
featureCoords[featureCoords.length - 1][0] = this.mouseGeoCoord.x;
|
|
11271
|
-
featureCoords[featureCoords.length - 1][1] = this.mouseGeoCoord.y;
|
|
11272
|
-
}
|
|
11273
|
-
}
|
|
11274
|
-
}
|
|
11275
|
-
}, {
|
|
11276
|
-
key: "componentCleanup",
|
|
11277
|
-
value: function componentCleanup() {
|
|
11278
|
-
// this will hold the cleanup code
|
|
11279
|
-
document.removeEventListener('keydown', this.handleKeyDown);
|
|
11280
|
-
var mapId = this.props.mapId;
|
|
11281
|
-
var webmapjs = webmapUtils.getWMJSMapById(mapId);
|
|
11282
|
-
if (webmapjs !== undefined && this.listenersInitialized === true) {
|
|
11283
|
-
this.listenersInitialized = undefined;
|
|
11284
|
-
webmapjs.removeListener('beforecanvasdisplay', this.beforeDraw);
|
|
11285
|
-
webmapjs.removeListener('beforemousemove', this.mouseMove);
|
|
11286
|
-
webmapjs.removeListener('beforemousedown', this.mouseDown);
|
|
11287
|
-
webmapjs.removeListener('beforemouseup', this.mouseUp);
|
|
11288
|
-
webmapjs.draw();
|
|
11289
|
-
}
|
|
11290
|
-
}
|
|
11291
|
-
// eslint-disable-next-line class-methods-use-this
|
|
11292
|
-
}, {
|
|
11293
|
-
key: "initializeFeature",
|
|
11294
|
-
value: function initializeFeature(feature) {
|
|
11295
|
-
if (!feature.properties) {
|
|
11296
|
-
feature.properties = {};
|
|
11297
|
-
}
|
|
11298
|
-
if (!feature.geometry) {
|
|
11299
|
-
feature.geometry = {};
|
|
11300
|
-
}
|
|
11301
|
-
if (!feature.type) {
|
|
11302
|
-
feature.type = 'Feature';
|
|
11303
|
-
}
|
|
11304
|
-
if (feature.geometry.type !== 'GeometryCollection' && !feature.geometry.coordinates) {
|
|
11305
|
-
feature.geometry.coordinates = [];
|
|
11306
|
-
}
|
|
11307
|
-
}
|
|
11308
|
-
}, {
|
|
11309
|
-
key: "validatePolys",
|
|
11310
|
-
value: function validatePolys(fixPolys) {
|
|
11311
|
-
var _this$geojson2;
|
|
11312
|
-
if (!((_this$geojson2 = this.geojson) !== null && _this$geojson2 !== void 0 && (_this$geojson2 = _this$geojson2.features) !== null && _this$geojson2 !== void 0 && _this$geojson2.length)) {
|
|
11313
|
-
return;
|
|
11314
|
-
}
|
|
11315
|
-
var _iterator2 = _createForOfIteratorHelper(this.geojson.features),
|
|
11316
|
-
_step2;
|
|
11317
|
-
try {
|
|
11318
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
11319
|
-
var geoJsonFeature = _step2.value;
|
|
11320
|
-
var feature = geoJsonFeature;
|
|
11321
|
-
this.initializeFeature(feature);
|
|
11322
|
-
var featureType = feature.geometry.type;
|
|
11323
|
-
if (featureType === 'Polygon') {
|
|
11324
|
-
/* Loop through all polygons of the same feature */
|
|
11325
|
-
var polygonGeometry = feature.geometry;
|
|
11326
|
-
var _iterator3 = _createForOfIteratorHelper(polygonGeometry.coordinates),
|
|
11327
|
-
_step3;
|
|
11328
|
-
try {
|
|
11329
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
11330
|
-
var polyCoordinates = _step3.value;
|
|
11331
|
-
var featureCoords = polyCoordinates;
|
|
11332
|
-
/* Sort clockwise */
|
|
11333
|
-
if (fixPolys) {
|
|
11334
|
-
if (this.checkIfFeatureIsBox(feature)) {
|
|
11335
|
-
// A box should have:
|
|
11336
|
-
// - topleft index 0 and 4
|
|
11337
|
-
// - bottomleft index 1
|
|
11338
|
-
// - bottomright index 2
|
|
11339
|
-
// - topright index 3
|
|
11340
|
-
// This represents counter-clockwise ordering and represents an area (https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.6)
|
|
11341
|
-
// Make sure the coordinate order in a box is always the same
|
|
11342
|
-
var boxCoords = feature.geometry.coordinates[0];
|
|
11343
|
-
if (boxCoords.length === 5) {
|
|
11344
|
-
// Copy the first four coordinates and sort them according Y and then X
|
|
11345
|
-
var sortedYthenX = boxCoords.slice(0, 4).sort(function (a, b) {
|
|
11346
|
-
return b[1] - a[1]; // Sort on Y
|
|
11347
|
-
}).sort(function (a, b) {
|
|
11348
|
-
return a[0] - b[0]; // Sort on X
|
|
11349
|
-
});
|
|
11350
|
-
// Assign the ordered coordinates back to the geometry of the feature
|
|
11351
|
-
feature.geometry.coordinates[0] = [_toConsumableArray(sortedYthenX[0]), _toConsumableArray(sortedYthenX[1]), _toConsumableArray(sortedYthenX[3]), _toConsumableArray(sortedYthenX[2]), _toConsumableArray(sortedYthenX[0])];
|
|
11352
|
-
}
|
|
11353
|
-
} else {
|
|
11354
|
-
var checkClockwiseOrder = function checkClockwiseOrder(featureCoordinates) {
|
|
11355
|
-
var sum = 0;
|
|
11356
|
-
for (var j = 0; j < featureCoordinates.length - 1; j += 1) {
|
|
11357
|
-
var currentPoint = featureCoordinates[j];
|
|
11358
|
-
var nextPoint = featureCoordinates[(j + 1) % featureCoordinates.length];
|
|
11359
|
-
sum += (nextPoint[0] - currentPoint[0]) * (nextPoint[1] + currentPoint[1]);
|
|
11360
|
-
}
|
|
11361
|
-
return sum;
|
|
11362
|
-
};
|
|
11363
|
-
var sum = checkClockwiseOrder(featureCoords);
|
|
11364
|
-
if (sum < 0) {
|
|
11365
|
-
featureCoords = featureCoords.reverse();
|
|
11366
|
-
/* The lastly selected vertex is now aways the second in the array */
|
|
11367
|
-
if (this.mouseIsOverVertexNr !== VERTEX.NONE && this.mouseIsOverVertexNr !== VERTEX.MIDDLE_POINT_OF_FEATURE) {
|
|
11368
|
-
this.mouseIsOverVertexNr = 1;
|
|
11369
|
-
}
|
|
11370
|
-
}
|
|
11371
|
-
}
|
|
11372
|
-
}
|
|
11373
|
-
}
|
|
11374
|
-
} catch (err) {
|
|
11375
|
-
_iterator3.e(err);
|
|
11376
|
-
} finally {
|
|
11377
|
-
_iterator3.f();
|
|
11378
|
-
}
|
|
11379
|
-
}
|
|
11380
|
-
}
|
|
11381
|
-
} catch (err) {
|
|
11382
|
-
_iterator2.e(err);
|
|
11383
|
-
} finally {
|
|
11384
|
-
_iterator2.f();
|
|
11385
|
-
}
|
|
11386
|
-
}
|
|
11387
|
-
}, {
|
|
11388
|
-
key: "beforeDraw",
|
|
11389
|
-
value: function beforeDraw(ctx) {
|
|
11390
|
-
var _this$geojson3,
|
|
11391
|
-
_this4 = this;
|
|
11392
|
-
/* beforeDraw is an event callback function which is triggered
|
|
11393
|
-
just before viewer will flip the back canvas buffer to the front.
|
|
11394
|
-
You are free to draw anything you like on the canvas.
|
|
11395
|
-
*/
|
|
11396
|
-
var _this$props9 = this.props,
|
|
11397
|
-
selectedFeatureIndex = _this$props9.selectedFeatureIndex,
|
|
11398
|
-
isInEditMode = _this$props9.isInEditMode,
|
|
11399
|
-
mapId = _this$props9.mapId,
|
|
11400
|
-
linkedFeatures = _this$props9.linkedFeatures;
|
|
11401
|
-
if (!((_this$geojson3 = this.geojson) !== null && _this$geojson3 !== void 0 && (_this$geojson3 = _this$geojson3.features) !== null && _this$geojson3 !== void 0 && _this$geojson3.length)) {
|
|
11402
|
-
return;
|
|
11403
|
-
}
|
|
11404
|
-
this.textPositions = [];
|
|
11405
|
-
this.mouseOverPolygonCoordinates = [];
|
|
11406
|
-
this.mouseOverPolygonFeatureIndex = -1;
|
|
11407
|
-
var drawFeatureGeometry = function drawFeatureGeometry(feature, featureIndex) {
|
|
11408
|
-
var geometry = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : feature.geometry;
|
|
11409
|
-
if (geometry.type === 'GeometryCollection') {
|
|
11410
|
-
var _iterator4 = _createForOfIteratorHelper(geometry.geometries),
|
|
11411
|
-
_step4;
|
|
11412
|
-
try {
|
|
11413
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
11414
|
-
var geom = _step4.value;
|
|
11415
|
-
drawFeatureGeometry(feature, featureIndex, geom);
|
|
11416
|
-
}
|
|
11417
|
-
} catch (err) {
|
|
11418
|
-
_iterator4.e(err);
|
|
11419
|
-
} finally {
|
|
11420
|
-
_iterator4.f();
|
|
11421
|
-
}
|
|
11422
|
-
}
|
|
11423
|
-
if (geometry.type === 'Point' || geometry.type === 'MultiPoint') {
|
|
11424
|
-
var coordinates = geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates;
|
|
11425
|
-
var XYCoords = getPixelCoordFromGeoCoord(coordinates, mapId);
|
|
11426
|
-
if (XYCoords.length === 0) {
|
|
11427
|
-
return;
|
|
11428
|
-
}
|
|
11429
|
-
for (var j = 0; j < XYCoords.length; j += 1) {
|
|
11430
|
-
_this4.drawPoint(ctx, XYCoords[j], _this4.mouseIsOverVertexNr === j && selectedFeatureIndex === featureIndex, false, isInEditMode && selectedFeatureIndex === featureIndex, feature, featureIndex);
|
|
11431
|
-
}
|
|
11432
|
-
}
|
|
11433
|
-
if (geometry.type === 'MultiPolygon') {
|
|
11434
|
-
var totalMiddle = {
|
|
11435
|
-
x: 0,
|
|
11436
|
-
y: 0,
|
|
11437
|
-
nr: 0
|
|
11438
|
-
};
|
|
11439
|
-
var _iterator5 = _createForOfIteratorHelper(geometry.coordinates),
|
|
11440
|
-
_step5;
|
|
11441
|
-
try {
|
|
11442
|
-
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
11443
|
-
var multiPoly = _step5.value;
|
|
11444
|
-
for (var polygonIndex = 0; polygonIndex < multiPoly.length; polygonIndex += 1) {
|
|
11445
|
-
var ringCoordinates = multiPoly[polygonIndex];
|
|
11446
|
-
var _XYCoords4 = getPixelCoordFromGeoCoord(ringCoordinates, mapId);
|
|
11447
|
-
/* Only draw if there is stuff to show */
|
|
11448
|
-
if (_XYCoords4.length === 0) {
|
|
11449
|
-
// eslint-disable-next-line no-continue
|
|
11450
|
-
continue;
|
|
11451
|
-
}
|
|
11452
|
-
var middle = _this4.drawPolygon(ctx, _XYCoords4, featureIndex, polygonIndex);
|
|
11453
|
-
if (middle) {
|
|
11454
|
-
totalMiddle.x += middle.x * middle.nr;
|
|
11455
|
-
totalMiddle.y += middle.y * middle.nr;
|
|
11456
|
-
totalMiddle.nr += middle.nr;
|
|
11457
|
-
}
|
|
11458
|
-
if (isInEditMode) {
|
|
11459
|
-
/* Draw all vertices on the edges of the polygons */
|
|
11460
|
-
for (var _j2 = 0; _j2 < _XYCoords4.length; _j2 += 1) {
|
|
11461
|
-
_this4.drawVertice(ctx, _XYCoords4[_j2], _this4.snappedPolygonIndex === polygonIndex && _this4.mouseIsOverVertexNr === _j2 && selectedFeatureIndex === featureIndex, false, isInEditMode && selectedFeatureIndex === featureIndex);
|
|
11462
|
-
}
|
|
11463
|
-
if (middle && isInEditMode === true && _XYCoords4.length >= 3) {
|
|
11464
|
-
/* Draw middle vertice for the poly if poly covers an area, e.g. when it contains more than three points */
|
|
11465
|
-
_this4.drawVertice(ctx, middle, _this4.snappedPolygonIndex === polygonIndex && _this4.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE && selectedFeatureIndex === featureIndex, true, isInEditMode && selectedFeatureIndex === featureIndex);
|
|
11466
|
-
}
|
|
11467
|
-
}
|
|
11468
|
-
}
|
|
11469
|
-
}
|
|
11470
|
-
} catch (err) {
|
|
11471
|
-
_iterator5.e(err);
|
|
11472
|
-
} finally {
|
|
11473
|
-
_iterator5.f();
|
|
11474
|
-
}
|
|
11475
|
-
if (totalMiddle.nr > 0) {
|
|
11476
|
-
var _feature$properties;
|
|
11477
|
-
var mx = totalMiddle.x / totalMiddle.nr;
|
|
11478
|
-
var my = totalMiddle.y / totalMiddle.nr;
|
|
11479
|
-
if ((_feature$properties = feature.properties) !== null && _feature$properties !== void 0 && _feature$properties.text) {
|
|
11480
|
-
_this4.textPositions.push({
|
|
11481
|
-
x: mx,
|
|
11482
|
-
y: my,
|
|
11483
|
-
text: feature.properties.text
|
|
11484
|
-
});
|
|
11485
|
-
}
|
|
11486
|
-
}
|
|
11487
|
-
}
|
|
11488
|
-
if (geometry.type === 'Polygon') {
|
|
11489
|
-
/* Loop through all rings of the same polygon */
|
|
11490
|
-
for (var _polygonIndex2 = 0; _polygonIndex2 < geometry.coordinates.length; _polygonIndex2 += 1) {
|
|
11491
|
-
var _feature$properties2;
|
|
11492
|
-
var featureCoords = geometry.coordinates[_polygonIndex2];
|
|
11493
|
-
var _XYCoords5 = getPixelCoordFromGeoCoord(featureCoords, mapId);
|
|
11494
|
-
/* Only draw if there is stuff to show */
|
|
11495
|
-
if (_XYCoords5.length === 0) {
|
|
11496
|
-
// eslint-disable-next-line no-continue
|
|
11497
|
-
continue;
|
|
11498
|
-
}
|
|
11499
|
-
var _middle = _this4.drawPolygon(ctx, _XYCoords5, featureIndex, _polygonIndex2);
|
|
11500
|
-
if (_middle && (_feature$properties2 = feature.properties) !== null && _feature$properties2 !== void 0 && _feature$properties2.text) {
|
|
11501
|
-
_this4.textPositions.push({
|
|
11502
|
-
x: _middle.x,
|
|
11503
|
-
y: _middle.y,
|
|
11504
|
-
text: feature.properties.text
|
|
11505
|
-
});
|
|
11506
|
-
}
|
|
11507
|
-
if (isInEditMode) {
|
|
11508
|
-
/* Draw all vertices on the edges of the polygons */
|
|
11509
|
-
for (var _j3 = 0; _j3 < _XYCoords5.length; _j3 += 1) {
|
|
11510
|
-
_this4.drawVertice(ctx, _XYCoords5[_j3], _this4.snappedPolygonIndex === _polygonIndex2 && _this4.mouseIsOverVertexNr === _j3 && selectedFeatureIndex === featureIndex, false, isInEditMode && selectedFeatureIndex === featureIndex);
|
|
11511
|
-
// Enable the following to debug vertice numbers in the screen
|
|
11512
|
-
// ctx.font = '20px Arial';
|
|
11513
|
-
// ctx.fillText(j, XYCoords[j].x - 10, XYCoords[j].y - 10);
|
|
11514
|
-
}
|
|
11515
|
-
if (_middle && isInEditMode === true && _XYCoords5.length >= 3) {
|
|
11516
|
-
/* Draw middle vertice for the poly if poly covers an area, e.g. when it contains more than three points */
|
|
11517
|
-
_this4.drawVertice(ctx, _middle, _this4.snappedPolygonIndex === _polygonIndex2 && _this4.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE && selectedFeatureIndex === featureIndex, true, isInEditMode && selectedFeatureIndex === featureIndex);
|
|
11518
|
-
}
|
|
11519
|
-
}
|
|
11520
|
-
}
|
|
11521
|
-
}
|
|
11522
|
-
if (geometry.type === 'LineString') {
|
|
11523
|
-
var _feature$properties3;
|
|
11524
|
-
/* Loop through all line pints of the same feature */
|
|
11525
|
-
var _featureCoords9 = geometry.coordinates;
|
|
11526
|
-
if (!_featureCoords9 || !_featureCoords9.length) {
|
|
11527
|
-
return;
|
|
11528
|
-
}
|
|
11529
|
-
var _XYCoords6 = getPixelCoordFromGeoCoord(_featureCoords9, mapId);
|
|
11530
|
-
/* Only draw if there is stuff to show */
|
|
11531
|
-
if (_XYCoords6.length === 0) {
|
|
11532
|
-
return;
|
|
11533
|
-
}
|
|
11534
|
-
var _middle2 = _this4.drawLine(ctx, _XYCoords6, featureIndex, 0);
|
|
11535
|
-
if (_middle2 && (_feature$properties3 = feature.properties) !== null && _feature$properties3 !== void 0 && _feature$properties3.text) {
|
|
11536
|
-
_this4.textPositions.push({
|
|
11537
|
-
x: _middle2.x,
|
|
11538
|
-
y: _middle2.y,
|
|
11539
|
-
text: feature.properties.text
|
|
11540
|
-
});
|
|
11541
|
-
}
|
|
11542
|
-
if (isInEditMode) {
|
|
11543
|
-
/* Draw all vertices on the edges of the polygons */
|
|
11544
|
-
for (var _j4 = 0; _j4 < _XYCoords6.length; _j4 += 1) {
|
|
11545
|
-
_this4.drawVertice(ctx, _XYCoords6[_j4], _this4.mouseIsOverVertexNr === _j4 && selectedFeatureIndex === featureIndex, false, isInEditMode && selectedFeatureIndex === featureIndex);
|
|
11546
|
-
}
|
|
11547
|
-
}
|
|
11548
|
-
}
|
|
11549
|
-
};
|
|
11550
|
-
/* Draw all features */
|
|
11551
|
-
for (var featureIndex = 0; featureIndex < this.geojson.features.length; featureIndex += 1) {
|
|
11552
|
-
var feature = this.geojson.features[featureIndex];
|
|
11553
|
-
/* Do not draw selected feature here, should be done last */
|
|
11554
|
-
if (featureIndex !== selectedFeatureIndex) {
|
|
11555
|
-
drawFeatureGeometry(feature, featureIndex);
|
|
11556
|
-
}
|
|
11557
|
-
}
|
|
11558
|
-
/* Draw selected feature to display it on top */
|
|
11559
|
-
drawFeatureGeometry(this.getSelectedFeature(), selectedFeatureIndex);
|
|
11560
|
-
/* Highlight polygon with mousehover */
|
|
11561
|
-
if (isInEditMode === true && this.mouseOverPolygonFeatureIndex === selectedFeatureIndex && this.mouseIsOverVertexNr === VERTEX.NONE && this.snappedPolygonIndex === SNAPPEDFEATURE.NONE && this.selectedEdge === EDGE.NONE || this.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE || linkedFeatures !== null && linkedFeatures !== void 0 && linkedFeatures.features && linkedFeatures.features.length > 0) {
|
|
11562
|
-
var _feature3$properties;
|
|
11563
|
-
var _feature3 = this.getSelectedFeature();
|
|
11564
|
-
var isLinkedFeature = linkedFeatures === null || linkedFeatures === void 0 ? void 0 : linkedFeatures.features.some(function (linkedFeature) {
|
|
11565
|
-
return linkedFeature.id === _feature3.id;
|
|
11566
|
-
});
|
|
11567
|
-
var shouldHighlight = isLinkedFeature && ((_feature3$properties = _feature3.properties) === null || _feature3$properties === void 0 ? void 0 : _feature3$properties.selectionType) !== 'fir';
|
|
11568
|
-
if (shouldHighlight && this.mouseOverPolygonCoordinates.length >= 2) {
|
|
11569
|
-
var featureProperties = _feature3.properties;
|
|
11570
|
-
ctx.beginPath();
|
|
11571
|
-
ctx.moveTo(this.mouseOverPolygonCoordinates[0].x, this.mouseOverPolygonCoordinates[0].y);
|
|
11572
|
-
for (var j = 1; j < this.mouseOverPolygonCoordinates.length; j += 1) {
|
|
11573
|
-
var coord = this.mouseOverPolygonCoordinates[j];
|
|
11574
|
-
ctx.lineTo(coord.x, coord.y);
|
|
11575
|
-
}
|
|
11576
|
-
var fillOpacity = featureProperties && featureProperties['fill-opacity'] || defaultGeoJSONStyleProperties && defaultGeoJSONStyleProperties['fill-opacity'];
|
|
11577
|
-
ctx.closePath();
|
|
11578
|
-
ctx.strokeStyle = (featureProperties === null || featureProperties === void 0 ? void 0 : featureProperties.stroke) || (defaultGeoJSONStyleProperties === null || defaultGeoJSONStyleProperties === void 0 ? void 0 : defaultGeoJSONStyleProperties.stroke);
|
|
11579
|
-
ctx.lineWidth = defaultGeoJSONStyleProperties && defaultGeoJSONStyleProperties['stroke-width'];
|
|
11580
|
-
ctx.fillStyle = (featureProperties === null || featureProperties === void 0 ? void 0 : featureProperties.fill) || (defaultGeoJSONStyleProperties === null || defaultGeoJSONStyleProperties === void 0 ? void 0 : defaultGeoJSONStyleProperties.fill);
|
|
11581
|
-
ctx.globalAlpha = Number(fillOpacity) + 0.2; // Fill gets +0.2 opacity on hover
|
|
11582
|
-
ctx.fill();
|
|
11583
|
-
ctx.globalAlpha = defaultGeoJSONStyleProperties && defaultGeoJSONStyleProperties['stroke-opacity'];
|
|
11584
|
-
ctx.stroke();
|
|
11585
|
-
}
|
|
11586
|
-
}
|
|
11587
|
-
/* Draw labels */
|
|
11588
|
-
var _iterator6 = _createForOfIteratorHelper(this.textPositions),
|
|
11589
|
-
_step6;
|
|
11590
|
-
try {
|
|
11591
|
-
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
11592
|
-
var textPosition = _step6.value;
|
|
11593
|
-
var x = textPosition.x,
|
|
11594
|
-
y = textPosition.y,
|
|
11595
|
-
text = textPosition.text;
|
|
11596
|
-
ctx.fillStyle = 'black';
|
|
11597
|
-
ctx.font = '12px Arial';
|
|
11598
|
-
ctx.fillText(text, x, y);
|
|
11599
|
-
}
|
|
11600
|
-
/* Draw hovered feature */
|
|
11601
|
-
} catch (err) {
|
|
11602
|
-
_iterator6.e(err);
|
|
11603
|
-
} finally {
|
|
11604
|
-
_iterator6.f();
|
|
11605
|
-
}
|
|
11606
|
-
if (this.featureEvent) {
|
|
11607
|
-
var _feature4$properties;
|
|
11608
|
-
var _this$featureEvent = this.featureEvent,
|
|
11609
|
-
_feature4 = _this$featureEvent.feature,
|
|
11610
|
-
_featureIndex = _this$featureEvent.featureIndex,
|
|
11611
|
-
screenCoords = _this$featureEvent.screenCoords;
|
|
11612
|
-
var drawFunctionId = _feature4 === null || _feature4 === void 0 || (_feature4$properties = _feature4.properties) === null || _feature4$properties === void 0 ? void 0 : _feature4$properties.hoverDrawFunctionId;
|
|
11613
|
-
var drawFunction = getDrawFunctionFromStore(drawFunctionId);
|
|
11614
|
-
if (drawFunction) {
|
|
11615
|
-
drawFunction({
|
|
11616
|
-
context: ctx,
|
|
11617
|
-
featureIndex: _featureIndex,
|
|
11618
|
-
isInEditMode: isInEditMode,
|
|
11619
|
-
feature: _feature4,
|
|
11620
|
-
isHovered: true,
|
|
11621
|
-
coord: screenCoords,
|
|
11622
|
-
selected: _featureIndex === selectedFeatureIndex,
|
|
11623
|
-
mouseX: 0,
|
|
11624
|
-
mouseY: 0
|
|
11625
|
-
});
|
|
11626
|
-
}
|
|
11627
|
-
}
|
|
11628
|
-
}
|
|
11629
|
-
/* Checks if mouse is in proximity of given coordinate */
|
|
11630
|
-
}, {
|
|
11631
|
-
key: "checkDist",
|
|
11632
|
-
value: function checkDist(coord, polygonIndex, mouseX, mouseY) {
|
|
11633
|
-
var VERTEX = distance(coord, {
|
|
11634
|
-
x: mouseX,
|
|
11635
|
-
y: mouseY
|
|
11636
|
-
});
|
|
11637
|
-
if (VERTEX < 10) {
|
|
11638
|
-
this.snappedGeoCoords = _objectSpread2({}, this.mouseGeoCoord);
|
|
11639
|
-
this.snappedPolygonIndex = polygonIndex;
|
|
11640
|
-
return true;
|
|
11641
|
-
}
|
|
11642
|
-
return false;
|
|
11643
|
-
}
|
|
11644
|
-
}, {
|
|
11645
|
-
key: "hoverEdge",
|
|
11646
|
-
value: function hoverEdge(geometry, mouseX, mouseY) {
|
|
11647
|
-
var mapId = this.props.mapId;
|
|
11648
|
-
var geometryType = geometry.type;
|
|
11649
|
-
if (geometryType === 'GeometryCollection') {
|
|
11650
|
-
return {
|
|
11651
|
-
selectedEdge: EDGE.NONE,
|
|
11652
|
-
snappedPolygonIndex: SNAPPEDFEATURE.NONE
|
|
11653
|
-
};
|
|
11654
|
-
}
|
|
11655
|
-
if (geometryType === 'Polygon') {
|
|
11656
|
-
for (var polygonIndex = geometry.coordinates.length - 1; polygonIndex >= 0; polygonIndex -= 1) {
|
|
11657
|
-
var featureCoords = geometry.coordinates[polygonIndex];
|
|
11658
|
-
if (featureCoords === undefined) {
|
|
11659
|
-
// eslint-disable-next-line no-continue
|
|
11660
|
-
continue;
|
|
11661
|
-
}
|
|
11662
|
-
/* Get all vertexes */
|
|
11663
|
-
var XYCoords = convertGeoCoordsToScreenCoords(featureCoords, mapId);
|
|
11664
|
-
for (var j = 0; j < XYCoords.length; j += 1) {
|
|
11665
|
-
var startV = XYCoords[j];
|
|
11666
|
-
var stopV = XYCoords[(j + 1) % XYCoords.length];
|
|
11667
|
-
if (isBetween(startV, {
|
|
11668
|
-
x: mouseX,
|
|
11669
|
-
y: mouseY
|
|
11670
|
-
}, stopV)) {
|
|
11671
|
-
return {
|
|
11672
|
-
selectedEdge: j,
|
|
11673
|
-
snappedPolygonIndex: polygonIndex
|
|
11674
|
-
};
|
|
11675
|
-
}
|
|
11676
|
-
}
|
|
11677
|
-
}
|
|
11678
|
-
return {
|
|
11679
|
-
selectedEdge: EDGE.NONE,
|
|
11680
|
-
snappedPolygonIndex: SNAPPEDFEATURE.NONE
|
|
11681
|
-
};
|
|
11682
|
-
}
|
|
11683
|
-
if (geometryType === 'LineString') {
|
|
11684
|
-
var _featureCoords10 = geometry.coordinates;
|
|
11685
|
-
if (_featureCoords10 === undefined) {
|
|
11686
|
-
return {
|
|
11687
|
-
selectedEdge: EDGE.NONE,
|
|
11688
|
-
snappedPolygonIndex: SNAPPEDFEATURE.NONE
|
|
11689
|
-
};
|
|
11690
|
-
}
|
|
11691
|
-
/* Get all vertexes */
|
|
11692
|
-
var _XYCoords7 = convertGeoCoordsToScreenCoords(_featureCoords10, mapId);
|
|
11693
|
-
for (var _j5 = 0; _j5 < _XYCoords7.length - 1; _j5 += 1) {
|
|
11694
|
-
var _startV = _XYCoords7[_j5];
|
|
11695
|
-
var _stopV = _XYCoords7[(_j5 + 1) % _XYCoords7.length];
|
|
11696
|
-
if (isBetween(_startV, {
|
|
11697
|
-
x: mouseX,
|
|
11698
|
-
y: mouseY
|
|
11699
|
-
}, _stopV)) {
|
|
11700
|
-
return {
|
|
11701
|
-
selectedEdge: _j5,
|
|
11702
|
-
snappedPolygonIndex: 0
|
|
11703
|
-
};
|
|
11704
|
-
}
|
|
11705
|
-
}
|
|
11706
|
-
return {
|
|
11707
|
-
selectedEdge: EDGE.NONE,
|
|
11708
|
-
snappedPolygonIndex: SNAPPEDFEATURE.NONE
|
|
11709
|
-
};
|
|
11710
|
-
}
|
|
11711
|
-
return {
|
|
11712
|
-
selectedEdge: EDGE.NONE,
|
|
11713
|
-
snappedPolygonIndex: SNAPPEDFEATURE.NONE
|
|
11714
|
-
};
|
|
11715
|
-
}
|
|
11716
|
-
// eslint-disable-next-line class-methods-use-this
|
|
11717
|
-
}, {
|
|
11718
|
-
key: "drawVertice",
|
|
11719
|
-
value: function drawVertice(ctx, _coord, selected, middle, isInEditMode) {
|
|
11720
|
-
var w = 7;
|
|
11721
|
-
var coord = {
|
|
11722
|
-
x: parseInt(_coord.x, 10),
|
|
11723
|
-
y: parseInt(_coord.y, 10)
|
|
11724
|
-
};
|
|
11725
|
-
if (isInEditMode === false) {
|
|
11726
|
-
return;
|
|
11727
|
-
}
|
|
11728
|
-
if (selected === false) {
|
|
11729
|
-
if (middle === true) {
|
|
11730
|
-
/* Style for middle editable vertice */
|
|
11731
|
-
ctx.strokeStyle = '#000';
|
|
11732
|
-
ctx.fillStyle = '#D87502';
|
|
11733
|
-
ctx.lineWidth = 1.0;
|
|
11734
|
-
} else {
|
|
11735
|
-
/* Style for standard editable vertice */
|
|
11736
|
-
ctx.strokeStyle = '#000';
|
|
11737
|
-
ctx.fillStyle = colors.vertice;
|
|
11738
|
-
ctx.lineWidth = 1.0;
|
|
11739
|
-
}
|
|
11740
|
-
} else {
|
|
11741
|
-
/* Style for selected editable vertice */
|
|
11742
|
-
ctx.strokeStyle = '#000';
|
|
11743
|
-
ctx.fillStyle = '#FF0';
|
|
11744
|
-
ctx.lineWidth = 1.0;
|
|
11745
|
-
w = 11;
|
|
11746
|
-
}
|
|
11747
|
-
ctx.globalAlpha = 1.0;
|
|
11748
|
-
ctx.fillRect(coord.x - w / 2, coord.y - w / 2, w, w);
|
|
11749
|
-
ctx.strokeRect(coord.x - w / 2, coord.y - w / 2, w, w);
|
|
11750
|
-
if (isInEditMode) {
|
|
11751
|
-
ctx.strokeRect(coord.x - 0.5, coord.y - 0.5, 1, 1);
|
|
11752
|
-
}
|
|
11753
|
-
}
|
|
11754
|
-
}, {
|
|
11755
|
-
key: "drawPoint",
|
|
11756
|
-
value: function drawPoint(ctx, _coord, selected, middle, isInEditMode, feature, featureIndex) {
|
|
11757
|
-
var featureProperties = feature.properties;
|
|
11758
|
-
if (featureProperties !== null && featureProperties !== void 0 && featureProperties.imageURL) {
|
|
11759
|
-
this.drawIcon(ctx, _coord, featureProperties);
|
|
11760
|
-
}
|
|
11761
|
-
var drawStyledMarker = featureProperties ? featureProperties.stroke || featureProperties['stroke-width'] || featureProperties.fill : null;
|
|
11762
|
-
var drawMarkerByDefault = !featureProperties || !featureProperties.imageURL || !featureProperties.drawFunctionId;
|
|
11763
|
-
if (featureProperties.drawFunctionId) {
|
|
11764
|
-
var drawFunction = getDrawFunctionFromStore(featureProperties.drawFunctionId);
|
|
11765
|
-
if (drawFunction) {
|
|
11766
|
-
var isHovered = this.featureEvent && this.featureEvent.feature === feature;
|
|
11767
|
-
drawFunction({
|
|
11768
|
-
context: ctx,
|
|
11769
|
-
featureIndex: featureIndex,
|
|
11770
|
-
coord: _coord,
|
|
11771
|
-
selected: selected,
|
|
11772
|
-
isInEditMode: isInEditMode,
|
|
11773
|
-
feature: feature,
|
|
11774
|
-
mouseX: this.mouseX,
|
|
11775
|
-
mouseY: this.mouseY,
|
|
11776
|
-
isHovered: isHovered
|
|
11777
|
-
});
|
|
11778
|
-
}
|
|
11779
|
-
} else if (drawStyledMarker || drawMarkerByDefault) {
|
|
11780
|
-
this.drawMarker(ctx, _coord, selected, middle, isInEditMode, featureProperties);
|
|
11781
|
-
}
|
|
11782
|
-
}
|
|
11783
|
-
}, {
|
|
11784
|
-
key: "drawIcon",
|
|
11785
|
-
value: function drawIcon(ctx, _coord, featureProperties) {
|
|
11786
|
-
var mapId = this.props.mapId;
|
|
11787
|
-
var webmapjs = webmapUtils.getWMJSMapById(mapId);
|
|
11788
|
-
if (!webmapjs) {
|
|
11789
|
-
return undefined;
|
|
11790
|
-
}
|
|
11791
|
-
var image = webmapjs === null || webmapjs === void 0 ? void 0 : webmapjs.getMapImageStore.getImage(featureProperties.imageURL);
|
|
11792
|
-
if (image.isLoaded() === false && image.hasError() === false && image.isLoading() === false) {
|
|
11793
|
-
image.load();
|
|
11794
|
-
/* After the image is loaded the canvas will be redrawn and drawIcon will be triggered again
|
|
11795
|
-
via the beforecanvasdisplay listener. */
|
|
11796
|
-
return undefined;
|
|
11797
|
-
}
|
|
11798
|
-
if (image.isLoaded()) {
|
|
11799
|
-
var imageWidth = featureProperties && featureProperties.imageWidth || this.defaultIconProps.imageWidth;
|
|
11800
|
-
var imageHeight = featureProperties && featureProperties.imageHeight || this.defaultIconProps.imageHeight;
|
|
11801
|
-
ctx.drawImage(image.getElement(), parseInt(_coord.x, 10) - imageWidth / 2, parseInt(_coord.y, 10) - imageHeight / 2, imageWidth, imageHeight);
|
|
11802
|
-
if (featureProperties.imageBorderWidth && featureProperties.imageBorderWidth > 0) {
|
|
11803
|
-
ctx.lineWidth = featureProperties.imageBorderWidth;
|
|
11804
|
-
ctx.strokeRect(parseInt(_coord.x, 10) - imageWidth / 2, parseInt(_coord.y, 10) - imageHeight / 2, imageWidth, imageHeight);
|
|
11805
|
-
}
|
|
11806
|
-
}
|
|
11807
|
-
return undefined;
|
|
11808
|
-
}
|
|
11809
|
-
}, {
|
|
11810
|
-
key: "drawMarker",
|
|
11811
|
-
value: function drawMarker(ctx, _coord, selected, middle, isInEditMode, featureProperties) {
|
|
11812
|
-
var strokeStyle = featureProperties && featureProperties.stroke || this.defaultPolyProps.stroke;
|
|
11813
|
-
var lineWidth = featureProperties && featureProperties['stroke-width'] || this.defaultPolyProps['stroke-width'];
|
|
11814
|
-
var fillStyle = featureProperties && featureProperties.fill || this.defaultPolyProps.fill;
|
|
11815
|
-
if (isInEditMode === false) {
|
|
11816
|
-
/* Standard style, no editing, just display location of vertices */
|
|
11817
|
-
ctx.strokeStyle = strokeStyle;
|
|
11818
|
-
ctx.fillStyle = fillStyle;
|
|
11819
|
-
ctx.lineWidth = lineWidth;
|
|
11820
|
-
} else if (selected === false) {
|
|
11821
|
-
/* Style for standard editable vertice */
|
|
11822
|
-
ctx.strokeStyle = '#000';
|
|
11823
|
-
ctx.fillStyle = colors.main;
|
|
11824
|
-
ctx.lineWidth = 1.0;
|
|
11825
|
-
} else {
|
|
11826
|
-
/* Style for selected editable vertice */
|
|
11827
|
-
ctx.strokeStyle = '#000';
|
|
11828
|
-
ctx.fillStyle = '#FF0';
|
|
11829
|
-
ctx.lineWidth = 1.0;
|
|
11830
|
-
}
|
|
11831
|
-
var coord = {
|
|
11832
|
-
x: parseInt(_coord.x, 10),
|
|
11833
|
-
y: parseInt(_coord.y, 10)
|
|
11834
|
-
};
|
|
11835
|
-
ctx.globalAlpha = 1.0;
|
|
11836
|
-
ctx.beginPath();
|
|
11837
|
-
var topRadius = 9;
|
|
11838
|
-
var topHeight = 2.5 * topRadius;
|
|
11839
|
-
ctx.arc(coord.x, coord.y - topHeight, topRadius, Math.PI, Math.PI * 2);
|
|
11840
|
-
ctx.bezierCurveTo(coord.x + topRadius, coord.y - topHeight, coord.x + topRadius / 1.6, coord.y - topRadius, coord.x, coord.y);
|
|
11841
|
-
ctx.bezierCurveTo(coord.x, coord.y, coord.x - topRadius / 1.6, coord.y - topRadius, coord.x - topRadius, coord.y - topHeight);
|
|
11842
|
-
ctx.stroke();
|
|
11843
|
-
ctx.fill();
|
|
11844
|
-
/* Fill center circle */
|
|
11845
|
-
ctx.fillStyle = '#FFF';
|
|
11846
|
-
ctx.beginPath();
|
|
11847
|
-
ctx.arc(coord.x, coord.y - topHeight, topRadius / 2, Math.PI * 2, 0);
|
|
11848
|
-
ctx.fill();
|
|
11849
|
-
/* Fill marker exact location */
|
|
11850
|
-
ctx.fillStyle = '#000';
|
|
11851
|
-
ctx.beginPath();
|
|
11852
|
-
ctx.arc(coord.x, coord.y, 2, Math.PI * 2, 0);
|
|
11853
|
-
ctx.fill();
|
|
11854
|
-
}
|
|
11855
|
-
}, {
|
|
11856
|
-
key: "drawLine",
|
|
11857
|
-
value: function drawLine(ctx, XYCoords, featureIndex, lineStringIndex) {
|
|
11858
|
-
var _this$props10 = this.props,
|
|
11859
|
-
isInEditMode = _this$props10.isInEditMode,
|
|
11860
|
-
selectedFeatureIndex = _this$props10.selectedFeatureIndex;
|
|
11861
|
-
var feature = this.geojson.features[featureIndex];
|
|
11862
|
-
if (!(feature !== null && feature !== void 0 && feature.geometry)) {
|
|
11863
|
-
return;
|
|
11864
|
-
}
|
|
11865
|
-
if (feature.geometry.type !== 'LineString') {
|
|
11866
|
-
return;
|
|
11867
|
-
}
|
|
11868
|
-
var lineProps = feature.properties;
|
|
11869
|
-
if (!lineProps) {
|
|
11870
|
-
lineProps = this.defaultLineStringProps;
|
|
11871
|
-
}
|
|
11872
|
-
/* Draw polygons and calculate center of poly */
|
|
11873
|
-
var middle = {
|
|
11874
|
-
x: 0,
|
|
11875
|
-
y: 0,
|
|
11876
|
-
nr: 0
|
|
11877
|
-
};
|
|
11878
|
-
ctx.beginPath();
|
|
11879
|
-
ctx.strokeStyle = lineProps.stroke || this.defaultLineStringProps.stroke;
|
|
11880
|
-
ctx.lineWidth = lineProps['stroke-width'] || this.defaultLineStringProps['stroke-width'];
|
|
11881
|
-
ctx.fillStyle = lineProps.fill || this.defaultLineStringProps.fill;
|
|
11882
|
-
var startCoord = XYCoords[0];
|
|
11883
|
-
ctx.moveTo(startCoord.x, startCoord.y);
|
|
11884
|
-
middle.x += startCoord.x;
|
|
11885
|
-
middle.y += startCoord.y;
|
|
11886
|
-
for (var j = 1; j < XYCoords.length; j += 1) {
|
|
11887
|
-
var coord = XYCoords[j];
|
|
11888
|
-
ctx.lineTo(coord.x, coord.y);
|
|
11889
|
-
if (j < XYCoords.length - 1) {
|
|
11890
|
-
middle.x += coord.x;
|
|
11891
|
-
middle.y += coord.y;
|
|
11892
|
-
}
|
|
11893
|
-
}
|
|
11894
|
-
ctx.globalAlpha = lineProps['fill-opacity'] || this.defaultLineStringProps['fill-opacity'];
|
|
11895
|
-
if (lineProps['fill-opacity'] === 0) {
|
|
11896
|
-
ctx.globalAlpha = 0;
|
|
11897
|
-
}
|
|
11898
|
-
// ctx.fill();
|
|
11899
|
-
ctx.globalAlpha = lineProps['stroke-opacity'] || this.defaultLineStringProps['stroke-opacity'];
|
|
11900
|
-
ctx.stroke();
|
|
11901
|
-
// let test = ctx.isPointInPath(this.mouseX, this.mouseY);
|
|
11902
|
-
// if (test) {
|
|
11903
|
-
this.mouseOverPolygonCoordinates = 0;
|
|
11904
|
-
this.mouseOverPolygonFeatureIndex = 0;
|
|
11905
|
-
// }
|
|
11906
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11907
|
-
// @ts-ignore
|
|
11908
|
-
middle.x = parseInt(middle.x / (XYCoords.length - 1), 10);
|
|
11909
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11910
|
-
// @ts-ignore
|
|
11911
|
-
middle.y = parseInt(middle.y / (XYCoords.length - 1), 10);
|
|
11912
|
-
if (isInEditMode === true && this.snappedPolygonIndex === lineStringIndex && this.selectedEdge !== EDGE.NONE && selectedFeatureIndex === featureIndex) {
|
|
11913
|
-
/* Higlight selected edge of a LineString, previousely detected by mouseover event */
|
|
11914
|
-
ctx.beginPath();
|
|
11915
|
-
ctx.strokeStyle = '#FF0';
|
|
11916
|
-
ctx.lineWidth = 5;
|
|
11917
|
-
ctx.moveTo(XYCoords[this.selectedEdge].x, XYCoords[this.selectedEdge].y);
|
|
11918
|
-
ctx.lineTo(
|
|
11919
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11920
|
-
// @ts-ignore
|
|
11921
|
-
XYCoords[(this.selectedEdge + 1) % XYCoords.length].x,
|
|
11922
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11923
|
-
// @ts-ignore
|
|
11924
|
-
XYCoords[(this.selectedEdge + 1) % XYCoords.length].y);
|
|
11925
|
-
ctx.stroke();
|
|
11926
|
-
}
|
|
11927
|
-
middle.nr = XYCoords.length - 1;
|
|
11928
|
-
return middle;
|
|
11929
|
-
}
|
|
11930
|
-
}, {
|
|
11931
|
-
key: "drawPolygon",
|
|
11932
|
-
value: function drawPolygon(ctx, XYCoords, featureIndex, polygonIndex) {
|
|
11933
|
-
var _this$props11 = this.props,
|
|
11934
|
-
isInEditMode = _this$props11.isInEditMode,
|
|
11935
|
-
selectedFeatureIndex = _this$props11.selectedFeatureIndex;
|
|
11936
|
-
var feature = this.geojson.features[featureIndex];
|
|
11937
|
-
if (!(feature !== null && feature !== void 0 && feature.geometry) || XYCoords.length === 0) {
|
|
11938
|
-
return;
|
|
11939
|
-
}
|
|
11940
|
-
var polyProps = feature.properties;
|
|
11941
|
-
if (!polyProps) {
|
|
11942
|
-
polyProps = this.defaultPolyProps;
|
|
11943
|
-
}
|
|
11944
|
-
/* Draw polygons and calculate center of poly */
|
|
11945
|
-
var middle = {
|
|
11946
|
-
x: 0,
|
|
11947
|
-
y: 0,
|
|
11948
|
-
nr: 0
|
|
11949
|
-
};
|
|
11950
|
-
ctx.beginPath();
|
|
11951
|
-
ctx.strokeStyle = polyProps.stroke || this.defaultPolyProps.stroke;
|
|
11952
|
-
ctx.lineWidth = polyProps['stroke-width'] || this.defaultPolyProps['stroke-width'];
|
|
11953
|
-
ctx.fillStyle = polyProps.fill || this.defaultPolyProps.fill;
|
|
11954
|
-
var startCoord = XYCoords[0];
|
|
11955
|
-
ctx.moveTo(startCoord.x, startCoord.y);
|
|
11956
|
-
middle.x += startCoord.x;
|
|
11957
|
-
middle.y += startCoord.y;
|
|
11958
|
-
for (var j = 1; j < XYCoords.length; j += 1) {
|
|
11959
|
-
var coord = XYCoords[j];
|
|
11960
|
-
ctx.lineTo(coord.x, coord.y);
|
|
11961
|
-
if (j < XYCoords.length - 1) {
|
|
11962
|
-
middle.x += coord.x;
|
|
11963
|
-
middle.y += coord.y;
|
|
11964
|
-
}
|
|
11965
|
-
}
|
|
11966
|
-
ctx.closePath();
|
|
11967
|
-
ctx.globalAlpha = polyProps['fill-opacity'] || this.defaultPolyProps['fill-opacity'];
|
|
11968
|
-
if (polyProps['fill-opacity'] === 0) {
|
|
11969
|
-
ctx.globalAlpha = 0;
|
|
11970
|
-
}
|
|
11971
|
-
ctx.fill();
|
|
11972
|
-
ctx.globalAlpha = polyProps['stroke-opacity'] || this.defaultPolyProps['stroke-opacity'];
|
|
11973
|
-
ctx.stroke();
|
|
11974
|
-
var test = ctx.isPointInPath(this.mouseX, this.mouseY);
|
|
11975
|
-
if (test) {
|
|
11976
|
-
this.mouseOverPolygonCoordinates = XYCoords;
|
|
11977
|
-
this.mouseOverPolygonFeatureIndex = featureIndex;
|
|
11978
|
-
}
|
|
11979
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11980
|
-
// @ts-ignore
|
|
11981
|
-
middle.x = parseInt(middle.x / (XYCoords.length - 1), 10);
|
|
11982
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11983
|
-
// @ts-ignore
|
|
11984
|
-
middle.y = parseInt(middle.y / (XYCoords.length - 1), 10);
|
|
11985
|
-
if (isInEditMode === true && this.snappedPolygonIndex === polygonIndex && this.selectedEdge !== EDGE.NONE && selectedFeatureIndex === featureIndex) {
|
|
11986
|
-
/* Higlight selected edge of a polygon, previousely detected by mouseover event */
|
|
11987
|
-
ctx.strokeStyle = '#FF0';
|
|
11988
|
-
ctx.lineWidth = 5;
|
|
11989
|
-
ctx.beginPath();
|
|
11990
|
-
ctx.moveTo(XYCoords[this.selectedEdge].x, XYCoords[this.selectedEdge].y);
|
|
11991
|
-
ctx.lineTo(
|
|
11992
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11993
|
-
// @ts-ignore
|
|
11994
|
-
XYCoords[(this.selectedEdge + 1) % XYCoords.length].x,
|
|
11995
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11996
|
-
// @ts-ignore
|
|
11997
|
-
XYCoords[(this.selectedEdge + 1) % XYCoords.length].y);
|
|
11998
|
-
ctx.stroke();
|
|
11999
|
-
}
|
|
12000
|
-
middle.nr = XYCoords.length - 1;
|
|
12001
|
-
return middle;
|
|
12002
|
-
}
|
|
12003
|
-
}, {
|
|
12004
|
-
key: "initializeFeatureCoordinates",
|
|
12005
|
-
value: function initializeFeatureCoordinates(feature, type) {
|
|
12006
|
-
this.initializeFeature(feature);
|
|
12007
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
12008
|
-
if (feature.properties._type) {
|
|
12009
|
-
delete feature.properties._type;
|
|
12010
|
-
}
|
|
12011
|
-
// eslint-disable-next-line default-case
|
|
12012
|
-
switch (type) {
|
|
12013
|
-
case DRAWMODE.POINT:
|
|
12014
|
-
feature.geometry.type = 'Point';
|
|
12015
|
-
break;
|
|
12016
|
-
case DRAWMODE.MULTIPOINT:
|
|
12017
|
-
feature.geometry.type = 'MultiPoint';
|
|
12018
|
-
break;
|
|
12019
|
-
case DRAWMODE.BOX:
|
|
12020
|
-
feature.geometry.type = 'Polygon';
|
|
12021
|
-
feature.properties._type = 'box';
|
|
12022
|
-
break;
|
|
12023
|
-
case DRAWMODE.POLYGON:
|
|
12024
|
-
feature.geometry.type = 'Polygon';
|
|
12025
|
-
break;
|
|
12026
|
-
case DRAWMODE.LINESTRING:
|
|
12027
|
-
feature.geometry.type = 'LineString';
|
|
12028
|
-
break;
|
|
12029
|
-
}
|
|
12030
|
-
// eslint-disable-next-line default-case
|
|
12031
|
-
switch (feature.geometry.type) {
|
|
12032
|
-
case 'MultiPoint':
|
|
12033
|
-
if (feature.geometry.coordinates.length === 0) {
|
|
12034
|
-
feature.geometry.coordinates.push([]);
|
|
12035
|
-
}
|
|
12036
|
-
break;
|
|
12037
|
-
case 'Polygon':
|
|
12038
|
-
if (feature.properties._type !== 'box' && feature.geometry.coordinates.length === 0) {
|
|
12039
|
-
feature.geometry.coordinates.push([]);
|
|
12040
|
-
}
|
|
12041
|
-
break;
|
|
12042
|
-
case 'LineString':
|
|
12043
|
-
if (feature.geometry.coordinates.length === 0) {
|
|
12044
|
-
feature.geometry.coordinates.push([]);
|
|
12045
|
-
}
|
|
12046
|
-
break;
|
|
12047
|
-
}
|
|
12048
|
-
return feature;
|
|
12049
|
-
}
|
|
12050
|
-
// eslint-disable-next-line class-methods-use-this
|
|
12051
|
-
}, {
|
|
12052
|
-
key: "checkIfFeatureIsBox",
|
|
12053
|
-
value: function checkIfFeatureIsBox(feature) {
|
|
12054
|
-
var _feature$properties4;
|
|
12055
|
-
if (!(feature !== null && feature !== void 0 && (_feature$properties4 = feature.properties) !== null && _feature$properties4 !== void 0 && _feature$properties4._type)) {
|
|
12056
|
-
return false;
|
|
12057
|
-
}
|
|
12058
|
-
return feature.properties._type === 'box';
|
|
12059
|
-
}
|
|
12060
|
-
}, {
|
|
12061
|
-
key: "featureHasChanged",
|
|
12062
|
-
value: function featureHasChanged(text) {
|
|
12063
|
-
var updateGeojson = this.props.updateGeojson;
|
|
12064
|
-
if (text !== NEW_FEATURE_CREATED) {
|
|
12065
|
-
this.validatePolys(text === 'cancelEdit');
|
|
12066
|
-
}
|
|
12067
|
-
if (updateGeojson && this.geojson) {
|
|
12068
|
-
updateGeojson(cloneDeep(this.geojson), text);
|
|
12069
|
-
}
|
|
12070
|
-
}
|
|
12071
|
-
}, {
|
|
12072
|
-
key: "render",
|
|
12073
|
-
value: function render() {
|
|
12074
|
-
return jsx("div", {});
|
|
12075
|
-
}
|
|
12076
|
-
}]);
|
|
12077
|
-
}(React.PureComponent); // eslint-disable-next-line react/static-property-placement
|
|
12078
|
-
MapDraw.defaultProps = {
|
|
12079
|
-
isInEditMode: false,
|
|
12080
|
-
isInDeleteMode: false,
|
|
12081
|
-
webmapjs: undefined,
|
|
12082
|
-
selectedFeatureIndex: 0
|
|
12083
|
-
};
|
|
12084
|
-
|
|
12085
|
-
var MapDrawContainer = function MapDrawContainer(_ref) {
|
|
12086
|
-
var featureLayers = _ref.featureLayers,
|
|
12087
|
-
linkedFeatures = _ref.linkedFeatures,
|
|
12088
|
-
mapId = _ref.mapId;
|
|
12089
|
-
return jsx(Fragment, {
|
|
12090
|
-
children: featureLayers.map(function (layer) {
|
|
12091
|
-
return jsx("div", {
|
|
12092
|
-
"data-testid": "featureLayer-".concat(layer.id),
|
|
12093
|
-
style: {
|
|
12094
|
-
display: 'none'
|
|
12095
|
-
},
|
|
12096
|
-
children: jsx(MapDraw, {
|
|
12097
|
-
geojson: layer.geojson,
|
|
12098
|
-
linkedFeatures: linkedFeatures,
|
|
12099
|
-
isInEditMode: layer.isInEditMode,
|
|
12100
|
-
isInDeleteMode: layer.isInDeleteMode,
|
|
12101
|
-
drawMode: layer.drawMode,
|
|
12102
|
-
mapId: mapId,
|
|
12103
|
-
onHoverFeature: function onHoverFeature(hoverInfo) {
|
|
12104
|
-
if (layer.onHoverFeature) {
|
|
12105
|
-
layer.onHoverFeature(hoverInfo);
|
|
12106
|
-
}
|
|
12107
|
-
},
|
|
12108
|
-
onClickFeature: function onClickFeature(hoverInfo) {
|
|
12109
|
-
if (layer.onClickFeature) {
|
|
12110
|
-
layer.onClickFeature(hoverInfo);
|
|
12111
|
-
}
|
|
12112
|
-
},
|
|
12113
|
-
updateGeojson: function updateGeojson(geojson, reason) {
|
|
12114
|
-
if (layer.updateGeojson) {
|
|
12115
|
-
layer.updateGeojson(geojson, reason);
|
|
12116
|
-
}
|
|
12117
|
-
},
|
|
12118
|
-
exitDrawModeCallback: function exitDrawModeCallback(reason, newGeoJSON) {
|
|
12119
|
-
if (layer.exitDrawModeCallback) {
|
|
12120
|
-
layer.exitDrawModeCallback(reason, newGeoJSON);
|
|
12121
|
-
}
|
|
12122
|
-
},
|
|
12123
|
-
selectedFeatureIndex: parseInt(layer.selectedFeatureIndex || '0', 10)
|
|
12124
|
-
})
|
|
12125
|
-
}, layer.id);
|
|
12126
|
-
})
|
|
12127
|
-
});
|
|
12128
|
-
};
|
|
12129
|
-
|
|
12130
|
-
var GeoJSONTextField = function GeoJSONTextField(_ref) {
|
|
12131
|
-
var onChangeGeoJSON = _ref.onChangeGeoJSON,
|
|
12132
|
-
geoJSON = _ref.geoJSON,
|
|
12133
|
-
_ref$title = _ref.title,
|
|
12134
|
-
title = _ref$title === void 0 ? 'GeoJSON text' : _ref$title,
|
|
12135
|
-
sx = _ref.sx,
|
|
12136
|
-
_ref$maxRows = _ref.maxRows,
|
|
12137
|
-
maxRows = _ref$maxRows === void 0 ? 18 : _ref$maxRows;
|
|
12138
|
-
var _useState = useState(true),
|
|
12139
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
12140
|
-
isValid = _useState2[0],
|
|
12141
|
-
setValidity = _useState2[1];
|
|
12142
|
-
var onChange = function onChange(event) {
|
|
12143
|
-
try {
|
|
12144
|
-
onChangeGeoJSON(JSON.parse(event.target.value));
|
|
12145
|
-
setValidity(true);
|
|
12146
|
-
} catch (e) {
|
|
12147
|
-
onChangeGeoJSON(null);
|
|
12148
|
-
setValidity(false);
|
|
12149
|
-
}
|
|
12150
|
-
};
|
|
12151
|
-
return jsx(Grid, {
|
|
12152
|
-
size: {
|
|
12153
|
-
xs: 12
|
|
12154
|
-
},
|
|
12155
|
-
sx: sx,
|
|
12156
|
-
children: jsx(TextField, {
|
|
12157
|
-
sx: {
|
|
12158
|
-
padding: 0,
|
|
12159
|
-
border: 'none',
|
|
12160
|
-
width: '100%',
|
|
12161
|
-
height: '100%',
|
|
12162
|
-
fontSize: '10px',
|
|
12163
|
-
'.MuiInputBase-root': {
|
|
12164
|
-
height: '100%',
|
|
12165
|
-
alignItems: 'baseline'
|
|
12166
|
-
}
|
|
12167
|
-
},
|
|
12168
|
-
multiline: true,
|
|
12169
|
-
error: !isValid,
|
|
12170
|
-
maxRows: maxRows,
|
|
12171
|
-
label: !isValid ? 'GeoJSON not valid' : title,
|
|
12172
|
-
variant: "filled",
|
|
12173
|
-
onChange: onChange,
|
|
12174
|
-
value: JSON.stringify(geoJSON, null, 2),
|
|
12175
|
-
disabled: !onChangeGeoJSON
|
|
12176
|
-
})
|
|
12177
|
-
});
|
|
12178
|
-
};
|
|
12179
|
-
|
|
12180
|
-
var FeatureLayers = function FeatureLayers(_ref) {
|
|
12181
|
-
var geojson = _ref.geojson,
|
|
12182
|
-
onChangeLayerIndex = _ref.onChangeLayerIndex,
|
|
12183
|
-
activeFeatureLayerIndex = _ref.activeFeatureLayerIndex,
|
|
12184
|
-
getToolIcon = _ref.getToolIcon;
|
|
12185
|
-
var featureLayerList = geojson ? Array.from(Array(geojson.features.length).keys()).map(function (index) {
|
|
12186
|
-
var _geojson$features$ind;
|
|
12187
|
-
return {
|
|
12188
|
-
index: index,
|
|
12189
|
-
value: (_geojson$features$ind = geojson.features[index].properties) === null || _geojson$features$ind === void 0 ? void 0 : _geojson$features$ind.selectionType,
|
|
12190
|
-
label: "".concat(index + 1, ": ").concat(geojson.features[index].geometry.type)
|
|
12191
|
-
};
|
|
12192
|
-
}) : [];
|
|
12193
|
-
return jsx(Grid, {
|
|
12194
|
-
size: {
|
|
12195
|
-
sm: 12
|
|
12196
|
-
},
|
|
12197
|
-
children: jsxs(FormControl, {
|
|
12198
|
-
disabled: !featureLayerList.length,
|
|
12199
|
-
variant: "filled",
|
|
12200
|
-
sx: {
|
|
12201
|
-
width: '100%'
|
|
12202
|
-
},
|
|
12203
|
-
children: [jsx(InputLabel, {
|
|
12204
|
-
id: "demo-feature-number",
|
|
12205
|
-
children: "Features"
|
|
12206
|
-
}), jsx(Select, {
|
|
12207
|
-
labelId: "demo-feature-type",
|
|
12208
|
-
value: (featureLayerList.length ? activeFeatureLayerIndex : '').toString(),
|
|
12209
|
-
onChange: function onChange(event) {
|
|
12210
|
-
var featureNr = parseInt(event.target.value, 10);
|
|
12211
|
-
onChangeLayerIndex(featureNr, geojson.features[featureNr]);
|
|
12212
|
-
},
|
|
12213
|
-
sx: {
|
|
12214
|
-
'.MuiSelect-select': {
|
|
12215
|
-
display: 'flex'
|
|
9854
|
+
}) : [];
|
|
9855
|
+
return jsx(Grid, {
|
|
9856
|
+
size: {
|
|
9857
|
+
sm: 12
|
|
9858
|
+
},
|
|
9859
|
+
children: jsxs(FormControl, {
|
|
9860
|
+
disabled: !featureLayerList.length,
|
|
9861
|
+
variant: "filled",
|
|
9862
|
+
sx: {
|
|
9863
|
+
width: '100%'
|
|
9864
|
+
},
|
|
9865
|
+
children: [jsx(InputLabel, {
|
|
9866
|
+
id: "demo-feature-number",
|
|
9867
|
+
children: "Features"
|
|
9868
|
+
}), jsx(Select, {
|
|
9869
|
+
labelId: "demo-feature-type",
|
|
9870
|
+
value: (featureLayerList.length ? activeFeatureLayerIndex : '').toString(),
|
|
9871
|
+
onChange: function onChange(event) {
|
|
9872
|
+
var featureNr = parseInt(event.target.value, 10);
|
|
9873
|
+
onChangeLayerIndex(featureNr, geojson.features[featureNr]);
|
|
9874
|
+
},
|
|
9875
|
+
sx: {
|
|
9876
|
+
'.MuiSelect-select': {
|
|
9877
|
+
display: 'flex'
|
|
12216
9878
|
}
|
|
12217
9879
|
},
|
|
12218
9880
|
children: featureLayerList.map(function (listItem) {
|
|
@@ -13192,6 +10854,32 @@ var getFeatureExtent = function getFeatureExtent(geoJSON) {
|
|
|
13192
10854
|
};
|
|
13193
10855
|
};
|
|
13194
10856
|
|
|
10857
|
+
/* *
|
|
10858
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10859
|
+
* you may not use this file except in compliance with the License.
|
|
10860
|
+
* You may obtain a copy of the License at
|
|
10861
|
+
*
|
|
10862
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10863
|
+
*
|
|
10864
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10865
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10866
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10867
|
+
* See the License for the specific language governing permissions and
|
|
10868
|
+
* limitations under the License.
|
|
10869
|
+
*
|
|
10870
|
+
* Copyright 2025 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
10871
|
+
* Copyright 2025 - Finnish Meteorological Institute (FMI)
|
|
10872
|
+
* Copyright 2025 - The Norwegian Meteorological Institute (MET Norway)
|
|
10873
|
+
* */
|
|
10874
|
+
var DRAWMODE;
|
|
10875
|
+
(function (DRAWMODE) {
|
|
10876
|
+
DRAWMODE["POLYGON"] = "POLYGON";
|
|
10877
|
+
DRAWMODE["BOX"] = "BOX";
|
|
10878
|
+
DRAWMODE["MULTIPOINT"] = "MULTIPOINT";
|
|
10879
|
+
DRAWMODE["POINT"] = "POINT";
|
|
10880
|
+
DRAWMODE["LINESTRING"] = "LINESTRING";
|
|
10881
|
+
})(DRAWMODE || (DRAWMODE = {}));
|
|
10882
|
+
|
|
13195
10883
|
var defaultIntersectionStyleProperties = _objectSpread2(_objectSpread2({}, defaultGeoJSONStyleProperties), {}, {
|
|
13196
10884
|
'fill-opacity': 0.5
|
|
13197
10885
|
});
|
|
@@ -15148,26 +12836,6 @@ var radarGetCapabilities_spec = {
|
|
|
15148
12836
|
WMS_Capabilities: WMS_Capabilities
|
|
15149
12837
|
};
|
|
15150
12838
|
|
|
15151
|
-
var ReactMapViewLayer = function ReactMapViewLayer(props) {
|
|
15152
|
-
var id = props.id;
|
|
15153
|
-
return jsx("div", {
|
|
15154
|
-
style: {
|
|
15155
|
-
width: '100%',
|
|
15156
|
-
padding: '2px',
|
|
15157
|
-
margin: 0,
|
|
15158
|
-
wordWrap: 'break-word',
|
|
15159
|
-
border: '1px solid rgba(0, 0, 0, 0.5)',
|
|
15160
|
-
lineHeight: '14px',
|
|
15161
|
-
fontSize: '10px',
|
|
15162
|
-
background: 'rgba(255, 255, 255, 0.5)',
|
|
15163
|
-
display: 'none'
|
|
15164
|
-
},
|
|
15165
|
-
children: jsx("div", {
|
|
15166
|
-
children: id
|
|
15167
|
-
})
|
|
15168
|
-
});
|
|
15169
|
-
};
|
|
15170
|
-
|
|
15171
12839
|
/* *
|
|
15172
12840
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15173
12841
|
* you may not use this file except in compliance with the License.
|
|
@@ -15194,14 +12862,6 @@ var getCurrentDimensionValue = function getCurrentDimensionValue(name) {
|
|
|
15194
12862
|
};
|
|
15195
12863
|
var getLayerUpdateInfo = function getLayerUpdateInfo(wmLayer, mapId) {
|
|
15196
12864
|
var origin = 'ReactMapViewParseLayer';
|
|
15197
|
-
var map = webmapUtils.getWMJSMapById(mapId);
|
|
15198
|
-
var mapDimensions = map === null || map === void 0 ? void 0 : map.mapdimensions.map(function (mapdim) {
|
|
15199
|
-
return {
|
|
15200
|
-
units: mapdim.units,
|
|
15201
|
-
currentValue: mapdim.currentValue,
|
|
15202
|
-
name: mapdim.name
|
|
15203
|
-
};
|
|
15204
|
-
});
|
|
15205
12865
|
var layerDimensions = wmLayer.dimensions.map(function (dim) {
|
|
15206
12866
|
var name = dim.name,
|
|
15207
12867
|
units = dim.units,
|
|
@@ -15228,7 +12888,7 @@ var getLayerUpdateInfo = function getLayerUpdateInfo(wmLayer, mapId) {
|
|
|
15228
12888
|
mapDimensions: {
|
|
15229
12889
|
mapId: mapId,
|
|
15230
12890
|
origin: origin,
|
|
15231
|
-
dimensions:
|
|
12891
|
+
dimensions: []
|
|
15232
12892
|
},
|
|
15233
12893
|
layerDimensions: {
|
|
15234
12894
|
origin: origin,
|
|
@@ -15242,6 +12902,23 @@ var getLayerUpdateInfo = function getLayerUpdateInfo(wmLayer, mapId) {
|
|
|
15242
12902
|
return updateObject;
|
|
15243
12903
|
};
|
|
15244
12904
|
|
|
12905
|
+
/* *
|
|
12906
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12907
|
+
* you may not use this file except in compliance with the License.
|
|
12908
|
+
* You may obtain a copy of the License at
|
|
12909
|
+
*
|
|
12910
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12911
|
+
*
|
|
12912
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12913
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12914
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12915
|
+
* See the License for the specific language governing permissions and
|
|
12916
|
+
* limitations under the License.
|
|
12917
|
+
*
|
|
12918
|
+
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
12919
|
+
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
12920
|
+
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
12921
|
+
* */
|
|
15245
12922
|
/** Returns filtered list of props with geoJson
|
|
15246
12923
|
* @param children React.ReactNode, layers with geoJson
|
|
15247
12924
|
*/
|
|
@@ -15259,900 +12936,35 @@ var getFeatureLayers = function getFeatureLayers(children) {
|
|
|
15259
12936
|
};
|
|
15260
12937
|
/**
|
|
15261
12938
|
* Returns true if this is a maplayer and not a baselayer or overlayer
|
|
15262
|
-
* @param layer The LayerFoundation object, or the props from the ReactWMJSLayer
|
|
15263
|
-
*/
|
|
15264
|
-
var isAMapLayer = function isAMapLayer(layer) {
|
|
15265
|
-
return layer.layerType === LayerType.mapLayer;
|
|
15266
|
-
};
|
|
15267
|
-
/**
|
|
15268
|
-
* Returns true if this is a geojsonlayer (layer containing geojson field)
|
|
15269
|
-
* @param layer The LayerFoundation object, or the props from the ReactWMJSLayer
|
|
15270
|
-
*/
|
|
15271
|
-
var isAGeoJSONLayer = function isAGeoJSONLayer(layer) {
|
|
15272
|
-
return layer.geojson !== undefined;
|
|
15273
|
-
};
|
|
15274
|
-
function getIsInsideAcceptanceTime(acceptanceTimeInMinutes, mapDimensions, layerDimensions) {
|
|
15275
|
-
var _mapDimensions$find, _layerDimensions$find;
|
|
15276
|
-
var mapCurrentTime = mapDimensions === null || mapDimensions === void 0 || (_mapDimensions$find = mapDimensions.find(function (dimension) {
|
|
15277
|
-
return dimension.name === 'time';
|
|
15278
|
-
})) === null || _mapDimensions$find === void 0 ? void 0 : _mapDimensions$find.currentValue;
|
|
15279
|
-
var layerCurrentTime = layerDimensions === null || layerDimensions === void 0 || (_layerDimensions$find = layerDimensions.find(function (dimension) {
|
|
15280
|
-
return dimension.name === 'time';
|
|
15281
|
-
})) === null || _layerDimensions$find === void 0 ? void 0 : _layerDimensions$find.currentValue;
|
|
15282
|
-
if (acceptanceTimeInMinutes === undefined || !mapCurrentTime || !layerCurrentTime) {
|
|
15283
|
-
return true;
|
|
15284
|
-
}
|
|
15285
|
-
var minutesBetween = dateUtils.differenceInMinutes(new Date(mapCurrentTime), new Date(layerCurrentTime));
|
|
15286
|
-
if (Math.abs(minutesBetween) > acceptanceTimeInMinutes) {
|
|
15287
|
-
return false;
|
|
15288
|
-
}
|
|
15289
|
-
return true;
|
|
15290
|
-
}
|
|
15291
|
-
var makeLayerPropListFromChildren = function makeLayerPropListFromChildren(children, mapId) {
|
|
15292
|
-
var myChildren = [];
|
|
15293
|
-
var takenIds = new Set();
|
|
15294
|
-
var wmjsMap = getWMJSMapById(mapId);
|
|
15295
|
-
React__default.Children.forEach(children, function (child) {
|
|
15296
|
-
if (child) {
|
|
15297
|
-
var childProps = child.props;
|
|
15298
|
-
if (childProps && childProps.id) {
|
|
15299
|
-
if (!takenIds.has(childProps.id)) {
|
|
15300
|
-
myChildren.push(childProps);
|
|
15301
|
-
takenIds.add(childProps.id);
|
|
15302
|
-
} else {
|
|
15303
|
-
var _childProps$onLayerEr;
|
|
15304
|
-
(_childProps$onLayerEr = childProps.onLayerError) === null || _childProps$onLayerEr === void 0 || _childProps$onLayerEr.call(childProps, childProps, new Error("Duplicate layer id \"".concat(childProps.id, "\" encountered within this mapTypes.WebMap")), wmjsMap);
|
|
15305
|
-
console.warn('ReactWMJSLayer has a duplicate id', child);
|
|
15306
|
-
}
|
|
15307
|
-
} else {
|
|
15308
|
-
debugLogger(DebugType.Warning, 'ReactElement child ignored: has no props or id', child);
|
|
15309
|
-
}
|
|
15310
|
-
}
|
|
15311
|
-
});
|
|
15312
|
-
myChildren.reverse();
|
|
15313
|
-
return myChildren;
|
|
15314
|
-
};
|
|
15315
|
-
var parseWMJSLayer = function parseWMJSLayer(wmLayer, forceReload) {
|
|
15316
|
-
return wmLayer.parseLayer(forceReload);
|
|
15317
|
-
};
|
|
15318
|
-
var setWMLayerPropsBasedOnChildProps = function setWMLayerPropsBasedOnChildProps(child, wmLayer, mapViewProps) {
|
|
15319
|
-
var needsRedraw = false;
|
|
15320
|
-
/* Set the name of the ADAGUC WMJSLayer */
|
|
15321
|
-
/* Set the Opacity of the ADAGUC WMJSLayer */
|
|
15322
|
-
if (child.opacity !== undefined && wmLayer.opacity !== child.opacity) {
|
|
15323
|
-
wmLayer.setOpacity(child.opacity);
|
|
15324
|
-
needsRedraw = false;
|
|
15325
|
-
}
|
|
15326
|
-
/* Set the Style of the ADAGUC WMJSLayer */
|
|
15327
|
-
if (child.style !== undefined && wmLayer.currentStyle !== child.style) {
|
|
15328
|
-
wmLayer.setStyle(child.style);
|
|
15329
|
-
needsRedraw = true;
|
|
15330
|
-
}
|
|
15331
|
-
var enabled = child.enabled,
|
|
15332
|
-
acceptanceTimeInMinutes = child.acceptanceTimeInMinutes,
|
|
15333
|
-
layerDimensions = child.dimensions;
|
|
15334
|
-
var isInsideAcceptanceTime = getIsInsideAcceptanceTime(acceptanceTimeInMinutes, mapViewProps.dimensions, layerDimensions);
|
|
15335
|
-
if (enabled !== undefined) {
|
|
15336
|
-
var wmLayerShouldBeShown = isInsideAcceptanceTime && enabled;
|
|
15337
|
-
if (wmLayerShouldBeShown !== wmLayer.enabled) {
|
|
15338
|
-
wmLayer.display(wmLayerShouldBeShown);
|
|
15339
|
-
needsRedraw = true;
|
|
15340
|
-
}
|
|
15341
|
-
}
|
|
15342
|
-
/* Set the dimensions of the ADAGUC WMJSLayer */
|
|
15343
|
-
if (child.dimensions !== undefined) {
|
|
15344
|
-
var _iterator = _createForOfIteratorHelper(child.dimensions),
|
|
15345
|
-
_step;
|
|
15346
|
-
try {
|
|
15347
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
15348
|
-
var childDimension = _step.value;
|
|
15349
|
-
var dim = childDimension;
|
|
15350
|
-
var wmjsDim = wmLayer.getDimension(dim.name);
|
|
15351
|
-
if (wmjsDim) {
|
|
15352
|
-
if (wmjsDim.currentValue !== dim.currentValue) {
|
|
15353
|
-
wmLayer.setDimension(dim.name, dim.currentValue, false);
|
|
15354
|
-
needsRedraw = true;
|
|
15355
|
-
}
|
|
15356
|
-
if (wmjsDim.synced !== dim.synced) {
|
|
15357
|
-
wmjsDim.synced = dim.synced;
|
|
15358
|
-
needsRedraw = true;
|
|
15359
|
-
}
|
|
15360
|
-
} else {
|
|
15361
|
-
debugLogger(DebugType.Warning, "MapView: Dimension does not exist, skipping ".concat(child.name, " :: ").concat(dim.name, " = ").concat(dim.currentValue));
|
|
15362
|
-
}
|
|
15363
|
-
}
|
|
15364
|
-
} catch (err) {
|
|
15365
|
-
_iterator.e(err);
|
|
15366
|
-
} finally {
|
|
15367
|
-
_iterator.f();
|
|
15368
|
-
}
|
|
15369
|
-
}
|
|
15370
|
-
return needsRedraw;
|
|
15371
|
-
};
|
|
15372
|
-
var addWMLayerPropsBasedOnChildProps = function addWMLayerPropsBasedOnChildProps(child, mapId, props, onUpdateLayerInformation) {
|
|
15373
|
-
var wmjsMap = getWMJSMapById(mapId);
|
|
15374
|
-
if (!wmjsMap || wmjsMap.isDestroyed) {
|
|
15375
|
-
return;
|
|
15376
|
-
}
|
|
15377
|
-
var keepOnTop = child.layerType === LayerType.overLayer || false;
|
|
15378
|
-
var newWMLayer = new WMLayer(_objectSpread2(_objectSpread2({}, child), {}, {
|
|
15379
|
-
keepOnTop: keepOnTop
|
|
15380
|
-
}));
|
|
15381
|
-
registerWMLayer(newWMLayer, child.id);
|
|
15382
|
-
newWMLayer.ReactWMJSLayerId = child.id;
|
|
15383
|
-
var isBaselayer = !isAMapLayer(child) && !isAGeoJSONLayer(child);
|
|
15384
|
-
if (isBaselayer) {
|
|
15385
|
-
/* Add ADAGUC WebMapJS Baselayer */
|
|
15386
|
-
var baseLayers = wmjsMap.getBaseLayers();
|
|
15387
|
-
baseLayers.unshift(newWMLayer);
|
|
15388
|
-
wmjsMap.setBaseLayers(baseLayers);
|
|
15389
|
-
// If this layer has a tileserver configured, add it to the map.
|
|
15390
|
-
if (child.tileServer) {
|
|
15391
|
-
wmjsMap.addWMTileRendererTileSetting(child.tileServer);
|
|
15392
|
-
}
|
|
15393
|
-
} else {
|
|
15394
|
-
/* Add ADAGUC WebMapJS Layer */
|
|
15395
|
-
wmjsMap.addLayer(newWMLayer).then(function () {
|
|
15396
|
-
if (newWMLayer.hasError === true) {
|
|
15397
|
-
child.onLayerError && child.onLayerError(newWMLayer, new Error(newWMLayer.lastError));
|
|
15398
|
-
}
|
|
15399
|
-
// This ensures that MultiMapViewConnect works properly.
|
|
15400
|
-
setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
15401
|
-
var wmjsMap, layerInfo;
|
|
15402
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
15403
|
-
while (1) switch (_context.prev = _context.next) {
|
|
15404
|
-
case 0:
|
|
15405
|
-
wmjsMap = getWMJSMapById(mapId);
|
|
15406
|
-
if (!(!wmjsMap || wmjsMap.isDestroyed)) {
|
|
15407
|
-
_context.next = 3;
|
|
15408
|
-
break;
|
|
15409
|
-
}
|
|
15410
|
-
return _context.abrupt("return");
|
|
15411
|
-
case 3:
|
|
15412
|
-
setWMLayerPropsBasedOnChildProps(child, newWMLayer, props);
|
|
15413
|
-
_context.next = 6;
|
|
15414
|
-
return newWMLayer.parseLayer();
|
|
15415
|
-
case 6:
|
|
15416
|
-
layerInfo = getLayerUpdateInfo(newWMLayer, mapId);
|
|
15417
|
-
onUpdateLayerInformation && onUpdateLayerInformation(layerInfo);
|
|
15418
|
-
child.onLayerReady && child.onLayerReady(newWMLayer, wmjsMap);
|
|
15419
|
-
wmjsMap.draw();
|
|
15420
|
-
case 10:
|
|
15421
|
-
case "end":
|
|
15422
|
-
return _context.stop();
|
|
15423
|
-
}
|
|
15424
|
-
}, _callee);
|
|
15425
|
-
})), 1);
|
|
15426
|
-
})["catch"](function (e) {
|
|
15427
|
-
child.onLayerError && child.onLayerError(newWMLayer, e);
|
|
15428
|
-
});
|
|
15429
|
-
}
|
|
15430
|
-
};
|
|
15431
|
-
var ORIGIN_REACTMAPVIEW_UTILS_ONUPDATELAYERINFO = 'ORIGIN_REACTMAPVIEW_UTILS_ONUPDATELAYERINFO';
|
|
15432
|
-
var removeWMLayerFromMap = function removeWMLayerFromMap(wmLayer, mapId, onUpdateLayerInformation) {
|
|
15433
|
-
// This will call the remove property of the WMJSLayer, which will adjust the layers array of WebMapJS */
|
|
15434
|
-
wmLayer.remove();
|
|
15435
|
-
/// Trigger update of all map dimensions
|
|
15436
|
-
var wmjsMap = getWMJSMapById(mapId);
|
|
15437
|
-
if (!wmjsMap) {
|
|
15438
|
-
return;
|
|
15439
|
-
}
|
|
15440
|
-
onUpdateLayerInformation && onUpdateLayerInformation({
|
|
15441
|
-
origin: ORIGIN_REACTMAPVIEW_UTILS_ONUPDATELAYERINFO,
|
|
15442
|
-
layerStyle: null,
|
|
15443
|
-
layerDimensions: null,
|
|
15444
|
-
mapDimensions: {
|
|
15445
|
-
origin: origin,
|
|
15446
|
-
mapId: mapId,
|
|
15447
|
-
dimensions: wmjsMap.mapdimensions.map(function (_ref2) {
|
|
15448
|
-
var name = _ref2.name,
|
|
15449
|
-
units = _ref2.units,
|
|
15450
|
-
currentValue = _ref2.currentValue,
|
|
15451
|
-
synced = _ref2.synced;
|
|
15452
|
-
return {
|
|
15453
|
-
name: name,
|
|
15454
|
-
units: units,
|
|
15455
|
-
currentValue: currentValue,
|
|
15456
|
-
synced: synced
|
|
15457
|
-
};
|
|
15458
|
-
})
|
|
15459
|
-
}
|
|
15460
|
-
});
|
|
15461
|
-
};
|
|
15462
|
-
// TODO: Improve performance in https://gitlab.com/opengeoweb/opengeoweb/-/issues/4566
|
|
15463
|
-
var orderLayers = function orderLayers(wmjsMap, _reactMapViewLayers) {
|
|
15464
|
-
var mapLayers = wmjsMap.getLayers();
|
|
15465
|
-
var mapLayersIds = mapLayers.map(function (ml) {
|
|
15466
|
-
return ml.id;
|
|
15467
|
-
});
|
|
15468
|
-
var filtered = _reactMapViewLayers.filter(function (_l) {
|
|
15469
|
-
return mapLayersIds.includes(_l.id);
|
|
15470
|
-
}).reverse();
|
|
15471
|
-
var order = mapLayers.map(function (wmLayer) {
|
|
15472
|
-
return filtered.findIndex(function (reactMapViewLayer) {
|
|
15473
|
-
return reactMapViewLayer.id === wmLayer.id;
|
|
15474
|
-
});
|
|
15475
|
-
});
|
|
15476
|
-
var wasReordered = wmjsMap.reorderLayers(order);
|
|
15477
|
-
return wasReordered;
|
|
15478
|
-
};
|
|
15479
|
-
|
|
15480
|
-
var getDisplayText = function getDisplayText(currentAdagucTime) {
|
|
15481
|
-
var timeFormat = 'eee dd MMM yyyy HH:mm [UTC]';
|
|
15482
|
-
var adagucTime = dateUtils.utc(currentAdagucTime);
|
|
15483
|
-
var adagucTimeFormatted = dateUtils.dateToString(adagucTime, timeFormat) || '';
|
|
15484
|
-
return adagucTimeFormatted;
|
|
15485
|
-
};
|
|
15486
|
-
var ORIGIN_REACTMAPVIEW_ONMAPCHANGEDIMENSION = 'ORIGIN_REACTMAPVIEW_ONMAPCHANGEDIMENSION';
|
|
15487
|
-
var ORIGIN_REACTMAPVIEW_ONUPDATELAYERINFO = 'ORIGIN_REACTMAPVIEW_ONUPDATELAYERINFO';
|
|
15488
|
-
var MINUTE_TO_MILLISECOND = 60000;
|
|
15489
|
-
var ReactMapView = /*#__PURE__*/function (_React$Component) {
|
|
15490
|
-
function ReactMapView(props) {
|
|
15491
|
-
var _this;
|
|
15492
|
-
_classCallCheck(this, ReactMapView);
|
|
15493
|
-
_this = _callSuper(this, ReactMapView, [props]);
|
|
15494
|
-
_this.adaguc = {
|
|
15495
|
-
initialized: false,
|
|
15496
|
-
baseLayers: [],
|
|
15497
|
-
oldbbox: undefined,
|
|
15498
|
-
currentWidth: -1,
|
|
15499
|
-
currentHeight: -1,
|
|
15500
|
-
currentChildren: []
|
|
15501
|
-
};
|
|
15502
|
-
_this.refetchTimer = null;
|
|
15503
|
-
_this.lastRefetched = null;
|
|
15504
|
-
_this.handleVisibilityChange = function () {
|
|
15505
|
-
var shouldAutoFetch = _this.props.shouldAutoFetch;
|
|
15506
|
-
var autoFetchInterval = Number(shouldAutoFetch); // Default true -> 1 minute
|
|
15507
|
-
var autoFetchIntervalMilliSeconds = Math.abs(autoFetchInterval) * MINUTE_TO_MILLISECOND;
|
|
15508
|
-
if (document.visibilityState === 'visible') {
|
|
15509
|
-
// Check if the last refetch time is not set or if the time since the last refetch exceeds the interval
|
|
15510
|
-
if (!_this.lastRefetched || new Date().getTime() - _this.lastRefetched > autoFetchIntervalMilliSeconds) {
|
|
15511
|
-
// Refetch immediately and restart the timer
|
|
15512
|
-
_this.onStartRefetchTimer(true);
|
|
15513
|
-
}
|
|
15514
|
-
}
|
|
15515
|
-
};
|
|
15516
|
-
/**
|
|
15517
|
-
* Start the refetch timer
|
|
15518
|
-
* @param force - Force a fetch and wmLayer parse immediately
|
|
15519
|
-
*/
|
|
15520
|
-
_this.onStartRefetchTimer = function (force) {
|
|
15521
|
-
var shouldAutoFetch = _this.props.shouldAutoFetch;
|
|
15522
|
-
_this.clearRefetchTimer();
|
|
15523
|
-
var autoFetchInterval = Number(shouldAutoFetch); // Default true -> 1 minute
|
|
15524
|
-
var refetch = function refetch() {
|
|
15525
|
-
var isVisible = document.visibilityState === 'visible';
|
|
15526
|
-
if (isVisible) {
|
|
15527
|
-
_this.lastRefetched = new Date().getTime();
|
|
15528
|
-
var mapId = _this.props.mapId;
|
|
15529
|
-
var wmjsMap = webmapUtils.getWMJSMapById(mapId);
|
|
15530
|
-
var layers = wmjsMap === null || wmjsMap === void 0 ? void 0 : wmjsMap.getLayers();
|
|
15531
|
-
layers === null || layers === void 0 || layers.forEach( /*#__PURE__*/function () {
|
|
15532
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(layer) {
|
|
15533
|
-
var _this2, _props, _mapId, onUpdateLayerInformation, layerInfo;
|
|
15534
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
15535
|
-
while (1) switch (_context.prev = _context.next) {
|
|
15536
|
-
case 0:
|
|
15537
|
-
if (!(layer.enabled !== false)) {
|
|
15538
|
-
_context.next = 13;
|
|
15539
|
-
break;
|
|
15540
|
-
}
|
|
15541
|
-
_context.prev = 1;
|
|
15542
|
-
_context.next = 4;
|
|
15543
|
-
return layer.parseLayer();
|
|
15544
|
-
case 4:
|
|
15545
|
-
_this2 = _this, _props = _this2.props;
|
|
15546
|
-
_mapId = _props.mapId, onUpdateLayerInformation = _props.onUpdateLayerInformation;
|
|
15547
|
-
layerInfo = getLayerUpdateInfo(layer, _mapId);
|
|
15548
|
-
onUpdateLayerInformation && onUpdateLayerInformation(layerInfo);
|
|
15549
|
-
_context.next = 13;
|
|
15550
|
-
break;
|
|
15551
|
-
case 10:
|
|
15552
|
-
_context.prev = 10;
|
|
15553
|
-
_context.t0 = _context["catch"](1);
|
|
15554
|
-
console.error(_context.t0);
|
|
15555
|
-
case 13:
|
|
15556
|
-
case "end":
|
|
15557
|
-
return _context.stop();
|
|
15558
|
-
}
|
|
15559
|
-
}, _callee, null, [[1, 10]]);
|
|
15560
|
-
}));
|
|
15561
|
-
return function (_x) {
|
|
15562
|
-
return _ref.apply(this, arguments);
|
|
15563
|
-
};
|
|
15564
|
-
}());
|
|
15565
|
-
}
|
|
15566
|
-
};
|
|
15567
|
-
if (autoFetchInterval > 0) {
|
|
15568
|
-
_this.refetchTimer = setInterval(refetch, Math.abs(autoFetchInterval) * MINUTE_TO_MILLISECOND);
|
|
15569
|
-
}
|
|
15570
|
-
if (force) {
|
|
15571
|
-
refetch();
|
|
15572
|
-
}
|
|
15573
|
-
};
|
|
15574
|
-
_this.clearRefetchTimer = function () {
|
|
15575
|
-
if (_this.refetchTimer) {
|
|
15576
|
-
clearInterval(_this.refetchTimer);
|
|
15577
|
-
}
|
|
15578
|
-
};
|
|
15579
|
-
_this.state = {
|
|
15580
|
-
adagucInitialised: false
|
|
15581
|
-
};
|
|
15582
|
-
_this.tileServerSettings = props.tileServerSettings || ReactMapView.defaultProps.tileServerSettings;
|
|
15583
|
-
_this.resize = _this.resize.bind(_this);
|
|
15584
|
-
_this.handleWindowResize = _this.handleWindowResize.bind(_this);
|
|
15585
|
-
_this.drawDebounced = debounce(_this.drawDebounced, 600);
|
|
15586
|
-
_this.updateWMJSMapProps = _this.updateWMJSMapProps.bind(_this);
|
|
15587
|
-
_this.mountWMJSMap = _this.mountWMJSMap.bind(_this);
|
|
15588
|
-
_this.handleVisibilityChange = _this.handleVisibilityChange.bind(_this);
|
|
15589
|
-
_this.onAfterSetBBoxListener = _this.onAfterSetBBoxListener.bind(_this);
|
|
15590
|
-
_this.onUpdateBBoxListener = _this.onUpdateBBoxListener.bind(_this);
|
|
15591
|
-
_this.onDimChangeListener = _this.onDimChangeListener.bind(_this);
|
|
15592
|
-
_this.adagucContainerRef = /*#__PURE__*/React.createRef();
|
|
15593
|
-
_this.adagucWebMapJSRef = /*#__PURE__*/React.createRef();
|
|
15594
|
-
return _this;
|
|
12939
|
+
* @param layer The LayerFoundation object, or the props from the ReactWMJSLayer
|
|
12940
|
+
*/
|
|
12941
|
+
var isAMapLayer = function isAMapLayer(layer) {
|
|
12942
|
+
return layer.layerType === LayerType.mapLayer;
|
|
12943
|
+
};
|
|
12944
|
+
/**
|
|
12945
|
+
* Returns true if this is a geojsonlayer (layer containing geojson field)
|
|
12946
|
+
* @param layer The LayerFoundation object, or the props from the ReactWMJSLayer
|
|
12947
|
+
*/
|
|
12948
|
+
var isAGeoJSONLayer = function isAGeoJSONLayer(layer) {
|
|
12949
|
+
return layer.geojson !== undefined;
|
|
12950
|
+
};
|
|
12951
|
+
function getIsInsideAcceptanceTime(acceptanceTimeInMinutes, mapDimensions, layerDimensions) {
|
|
12952
|
+
var _mapDimensions$find, _layerDimensions$find;
|
|
12953
|
+
var mapCurrentTime = mapDimensions === null || mapDimensions === void 0 || (_mapDimensions$find = mapDimensions.find(function (dimension) {
|
|
12954
|
+
return dimension.name === 'time';
|
|
12955
|
+
})) === null || _mapDimensions$find === void 0 ? void 0 : _mapDimensions$find.currentValue;
|
|
12956
|
+
var layerCurrentTime = layerDimensions === null || layerDimensions === void 0 || (_layerDimensions$find = layerDimensions.find(function (dimension) {
|
|
12957
|
+
return dimension.name === 'time';
|
|
12958
|
+
})) === null || _layerDimensions$find === void 0 ? void 0 : _layerDimensions$find.currentValue;
|
|
12959
|
+
if (acceptanceTimeInMinutes === undefined || !mapCurrentTime || !layerCurrentTime) {
|
|
12960
|
+
return true;
|
|
15595
12961
|
}
|
|
15596
|
-
|
|
15597
|
-
|
|
15598
|
-
|
|
15599
|
-
value: function componentDidMount() {
|
|
15600
|
-
var _this$props = this.props,
|
|
15601
|
-
shouldAutoFetch = _this$props.shouldAutoFetch,
|
|
15602
|
-
onWMJSMount = _this$props.onWMJSMount,
|
|
15603
|
-
mapId = _this$props.mapId;
|
|
15604
|
-
/* If this components re-mounts, make sure that the initialized state is set back to false */
|
|
15605
|
-
this.setState({
|
|
15606
|
-
adagucInitialised: false
|
|
15607
|
-
});
|
|
15608
|
-
window.addEventListener('resize', this.handleWindowResize);
|
|
15609
|
-
this.mountWMJSMap();
|
|
15610
|
-
if (shouldAutoFetch) {
|
|
15611
|
-
this.onStartRefetchTimer();
|
|
15612
|
-
document.addEventListener('visibilitychange', this.handleVisibilityChange);
|
|
15613
|
-
}
|
|
15614
|
-
onWMJSMount(mapId);
|
|
15615
|
-
}
|
|
15616
|
-
}, {
|
|
15617
|
-
key: "componentDidUpdate",
|
|
15618
|
-
value: function componentDidUpdate(prevProps) {
|
|
15619
|
-
this.updateWMJSMapProps(prevProps, this.props);
|
|
15620
|
-
}
|
|
15621
|
-
}, {
|
|
15622
|
-
key: "componentWillUnmount",
|
|
15623
|
-
value: function componentWillUnmount() {
|
|
15624
|
-
var _this$props2 = this.props,
|
|
15625
|
-
mapId = _this$props2.mapId,
|
|
15626
|
-
onWMJSUnMount = _this$props2.onWMJSUnMount;
|
|
15627
|
-
window.removeEventListener('resize', this.handleWindowResize);
|
|
15628
|
-
this.clearRefetchTimer();
|
|
15629
|
-
document.removeEventListener('visibilitychange', this.handleVisibilityChange);
|
|
15630
|
-
webmapUtils.unRegisterWMJSMap(mapId);
|
|
15631
|
-
/* Reset adaguc properties */
|
|
15632
|
-
this.adaguc.initialized = false;
|
|
15633
|
-
this.adaguc.currentHeight = -1;
|
|
15634
|
-
this.adaguc.currentWidth = -1;
|
|
15635
|
-
this.adaguc.baseLayers = [];
|
|
15636
|
-
this.adaguc.oldbbox = new WMBBOX();
|
|
15637
|
-
this.adaguc.currentChildren = [];
|
|
15638
|
-
onWMJSUnMount && onWMJSUnMount(mapId);
|
|
15639
|
-
}
|
|
15640
|
-
}, {
|
|
15641
|
-
key: "handleWindowResize",
|
|
15642
|
-
value: function handleWindowResize() {
|
|
15643
|
-
this.resize();
|
|
15644
|
-
}
|
|
15645
|
-
}, {
|
|
15646
|
-
key: "onDimChangeListener",
|
|
15647
|
-
value: function onDimChangeListener() {
|
|
15648
|
-
var _this$props3 = this.props,
|
|
15649
|
-
mapId = _this$props3.mapId,
|
|
15650
|
-
onMapChangeDimension = _this$props3.onMapChangeDimension;
|
|
15651
|
-
var wmjsMap = webmapUtils.getWMJSMapById(mapId);
|
|
15652
|
-
if (wmjsMap) {
|
|
15653
|
-
var timeDimension = wmjsMap.getDimension('time');
|
|
15654
|
-
if (timeDimension) {
|
|
15655
|
-
onMapChangeDimension({
|
|
15656
|
-
mapId: mapId,
|
|
15657
|
-
origin: ORIGIN_REACTMAPVIEW_ONMAPCHANGEDIMENSION,
|
|
15658
|
-
dimension: {
|
|
15659
|
-
name: 'time',
|
|
15660
|
-
currentValue: timeDimension.currentValue
|
|
15661
|
-
}
|
|
15662
|
-
});
|
|
15663
|
-
}
|
|
15664
|
-
}
|
|
15665
|
-
}
|
|
15666
|
-
}, {
|
|
15667
|
-
key: "onAfterSetBBoxListener",
|
|
15668
|
-
value: function onAfterSetBBoxListener() {
|
|
15669
|
-
var _this3 = this;
|
|
15670
|
-
/* Update the map after 100 ms */
|
|
15671
|
-
window.setTimeout(function () {
|
|
15672
|
-
var _this3$props = _this3.props,
|
|
15673
|
-
MapViewBBOX = _this3$props.bbox,
|
|
15674
|
-
mapId = _this3$props.mapId,
|
|
15675
|
-
onMapZoomEnd = _this3$props.onMapZoomEnd;
|
|
15676
|
-
var wmjsMap = webmapUtils.getWMJSMapById(mapId);
|
|
15677
|
-
if (!wmjsMap) {
|
|
15678
|
-
return;
|
|
15679
|
-
}
|
|
15680
|
-
var projectionInfo = wmjsMap.getProjection();
|
|
15681
|
-
/* Trigger onMapZoomEnd callback */
|
|
15682
|
-
var mapBBOX = projectionInfo.bbox;
|
|
15683
|
-
if (MapViewBBOX.left !== mapBBOX.left || MapViewBBOX.right !== mapBBOX.right || MapViewBBOX.bottom !== mapBBOX.bottom || MapViewBBOX.top !== mapBBOX.top) {
|
|
15684
|
-
onMapZoomEnd({
|
|
15685
|
-
mapId: mapId,
|
|
15686
|
-
bbox: {
|
|
15687
|
-
left: projectionInfo.bbox.left,
|
|
15688
|
-
bottom: projectionInfo.bbox.bottom,
|
|
15689
|
-
right: projectionInfo.bbox.right,
|
|
15690
|
-
top: projectionInfo.bbox.top
|
|
15691
|
-
},
|
|
15692
|
-
srs: projectionInfo.srs
|
|
15693
|
-
});
|
|
15694
|
-
}
|
|
15695
|
-
}, 100);
|
|
15696
|
-
}
|
|
15697
|
-
}, {
|
|
15698
|
-
key: "onUpdateBBoxListener",
|
|
15699
|
-
value: function onUpdateBBoxListener(newBbox) {
|
|
15700
|
-
var oldbbox = this.adaguc.oldbbox || new WMBBOX(ReactMapView.defaultProps.bbox);
|
|
15701
|
-
if (oldbbox.left !== newBbox.left || oldbbox.right !== newBbox.right || oldbbox.top !== newBbox.top || oldbbox.bottom !== newBbox.bottom) {
|
|
15702
|
-
oldbbox.left = newBbox.left;
|
|
15703
|
-
oldbbox.right = newBbox.right;
|
|
15704
|
-
oldbbox.top = newBbox.top;
|
|
15705
|
-
oldbbox.bottom = newBbox.bottom;
|
|
15706
|
-
this.adaguc.oldbbox = new WMBBOX(oldbbox);
|
|
15707
|
-
}
|
|
15708
|
-
}
|
|
15709
|
-
}, {
|
|
15710
|
-
key: "updateWMJSMapProps",
|
|
15711
|
-
value: function updateWMJSMapProps(prevProps, props) {
|
|
15712
|
-
if (!props) {
|
|
15713
|
-
return;
|
|
15714
|
-
}
|
|
15715
|
-
var mapId = props.mapId,
|
|
15716
|
-
children = props.children,
|
|
15717
|
-
isTimeScrollingEnabled = props.isTimeScrollingEnabled;
|
|
15718
|
-
if (isTimeScrollingEnabled) {
|
|
15719
|
-
var _wmjsMap = webmapUtils.getWMJSMapById(mapId);
|
|
15720
|
-
_wmjsMap === null || _wmjsMap === void 0 || _wmjsMap.detachWheelEvent();
|
|
15721
|
-
} else {
|
|
15722
|
-
var _wmjsMap2 = webmapUtils.getWMJSMapById(mapId);
|
|
15723
|
-
_wmjsMap2 === null || _wmjsMap2 === void 0 || _wmjsMap2.attachWheelEvent();
|
|
15724
|
-
}
|
|
15725
|
-
if (prevProps && prevProps.mapId !== props.mapId) {
|
|
15726
|
-
console.warn('MapId has changed on an already mounted map!');
|
|
15727
|
-
var prevWMJSMap = webmapUtils.getWMJSMapById(prevProps.mapId);
|
|
15728
|
-
if (prevWMJSMap) {
|
|
15729
|
-
webmapUtils.registerWMJSMap(prevWMJSMap, mapId);
|
|
15730
|
-
}
|
|
15731
|
-
}
|
|
15732
|
-
var wmjsMap = webmapUtils.getWMJSMapById(mapId);
|
|
15733
|
-
if (!wmjsMap) {
|
|
15734
|
-
console.warn("No wmjsMap ".concat(mapId));
|
|
15735
|
-
return;
|
|
15736
|
-
}
|
|
15737
|
-
var needsRedraw = false;
|
|
15738
|
-
/* Check map props */
|
|
15739
|
-
if (!prevProps || prevProps.showLegend !== props.showLegend) {
|
|
15740
|
-
wmjsMap.displayLegendInMap(props.showLegend !== false);
|
|
15741
|
-
}
|
|
15742
|
-
if (!prevProps || prevProps.showScaleBar !== props.showScaleBar) {
|
|
15743
|
-
wmjsMap.displayScaleBarInMap(props.showScaleBar !== false);
|
|
15744
|
-
needsRedraw = true;
|
|
15745
|
-
}
|
|
15746
|
-
if (!prevProps || prevProps.timestep !== props.timestep) {
|
|
15747
|
-
wmjsMap.timestepInMinutes = props.timestep;
|
|
15748
|
-
}
|
|
15749
|
-
if (!prevProps || prevProps.holdShiftToScroll !== props.holdShiftToScroll) {
|
|
15750
|
-
wmjsMap.holdShiftToScroll = !!props.holdShiftToScroll;
|
|
15751
|
-
}
|
|
15752
|
-
/* Check map dimensions */
|
|
15753
|
-
if (!prevProps || prevProps.dimensions !== props.dimensions) {
|
|
15754
|
-
if (props.dimensions) {
|
|
15755
|
-
var _iterator = _createForOfIteratorHelper(props.dimensions),
|
|
15756
|
-
_step;
|
|
15757
|
-
try {
|
|
15758
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
15759
|
-
var propDimension = _step.value;
|
|
15760
|
-
var mapDim = wmjsMap.getDimension(propDimension.name);
|
|
15761
|
-
if (mapDim && mapDim.currentValue !== propDimension.currentValue || !mapDim) {
|
|
15762
|
-
wmjsMap.setDimension(propDimension.name, propDimension.currentValue, false, false);
|
|
15763
|
-
}
|
|
15764
|
-
if (props.displayTimeInMap && propDimension.name === 'time' && propDimension.currentValue !== undefined) {
|
|
15765
|
-
needsRedraw = true;
|
|
15766
|
-
var displayText = getDisplayText(propDimension.currentValue);
|
|
15767
|
-
wmjsMap.setTimeOffset(displayText);
|
|
15768
|
-
}
|
|
15769
|
-
}
|
|
15770
|
-
} catch (err) {
|
|
15771
|
-
_iterator.e(err);
|
|
15772
|
-
} finally {
|
|
15773
|
-
_iterator.f();
|
|
15774
|
-
}
|
|
15775
|
-
}
|
|
15776
|
-
}
|
|
15777
|
-
/* Check if srs and BBOX is updated */
|
|
15778
|
-
if (!prevProps || prevProps.bbox !== props.bbox) {
|
|
15779
|
-
if (props.bbox.left !== undefined) {
|
|
15780
|
-
var projectionInfo = wmjsMap.getProjection();
|
|
15781
|
-
var mapBBOX = projectionInfo.bbox;
|
|
15782
|
-
if (props.bbox.left !== mapBBOX.left || props.bbox.right !== mapBBOX.right || props.bbox.bottom !== mapBBOX.bottom || props.bbox.top !== mapBBOX.top) {
|
|
15783
|
-
wmjsMap.suspendEvent('onupdatebbox');
|
|
15784
|
-
wmjsMap.setProjection(props.srs, new WMBBOX(props.bbox));
|
|
15785
|
-
wmjsMap.resumeEvent('onupdatebbox');
|
|
15786
|
-
wmjsMap.draw();
|
|
15787
|
-
}
|
|
15788
|
-
}
|
|
15789
|
-
}
|
|
15790
|
-
/* Check if srs */
|
|
15791
|
-
if (!prevProps || prevProps.srs !== props.srs) {
|
|
15792
|
-
if (props.bbox.left !== undefined) {
|
|
15793
|
-
wmjsMap.suspendEvent('onupdatebbox');
|
|
15794
|
-
wmjsMap.setProjection(props.srs, new WMBBOX(props.bbox));
|
|
15795
|
-
wmjsMap.resumeEvent('onupdatebbox');
|
|
15796
|
-
wmjsMap.draw();
|
|
15797
|
-
}
|
|
15798
|
-
}
|
|
15799
|
-
/* Check display/hide map cursor */
|
|
15800
|
-
if (!prevProps || prevProps.displayMapPin !== props.displayMapPin) {
|
|
15801
|
-
if (props.displayMapPin === true) {
|
|
15802
|
-
wmjsMap.getMapPin().showMapPin();
|
|
15803
|
-
} else if (props.displayMapPin === false) {
|
|
15804
|
-
wmjsMap.getMapPin().hideMapPin();
|
|
15805
|
-
}
|
|
15806
|
-
}
|
|
15807
|
-
/* Set map cursor location */
|
|
15808
|
-
if (!prevProps || prevProps.mapPinLocation !== props.mapPinLocation) {
|
|
15809
|
-
if (props.mapPinLocation) {
|
|
15810
|
-
wmjsMap.getMapPin().positionMapPinByLatLon({
|
|
15811
|
-
x: props.mapPinLocation.lon,
|
|
15812
|
-
y: props.mapPinLocation.lat
|
|
15813
|
-
});
|
|
15814
|
-
wmjsMap.draw();
|
|
15815
|
-
}
|
|
15816
|
-
}
|
|
15817
|
-
/* Set disable map pin */
|
|
15818
|
-
if (!prevProps || prevProps.disableMapPin !== props.disableMapPin) {
|
|
15819
|
-
if (props.disableMapPin === true) {
|
|
15820
|
-
wmjsMap.getMapPin().setMapPinDisabled();
|
|
15821
|
-
} else if (props.disableMapPin === false) {
|
|
15822
|
-
wmjsMap.getMapPin().setMapPinEnabled();
|
|
15823
|
-
}
|
|
15824
|
-
wmjsMap.draw();
|
|
15825
|
-
}
|
|
15826
|
-
/* Change the animation delay */
|
|
15827
|
-
if (!prevProps || prevProps.animationDelay !== props.animationDelay) {
|
|
15828
|
-
if (props.animationDelay) {
|
|
15829
|
-
if (typeof wmjsMap.setAnimationDelay === 'function') {
|
|
15830
|
-
wmjsMap.setAnimationDelay(props.animationDelay);
|
|
15831
|
-
}
|
|
15832
|
-
}
|
|
15833
|
-
}
|
|
15834
|
-
/* Check if layer metadata should be shown */
|
|
15835
|
-
if (!prevProps || prevProps.showLayerInfo !== props.showLayerInfo) {
|
|
15836
|
-
if (props.showLayerInfo) {
|
|
15837
|
-
wmjsMap.showLayerInfo = props.showLayerInfo;
|
|
15838
|
-
}
|
|
15839
|
-
}
|
|
15840
|
-
var myChildren = makeLayerPropListFromChildren(children, mapId);
|
|
15841
|
-
// Only enter this loop if there are changes.
|
|
15842
|
-
if (!isEqual(myChildren, this.adaguc.currentChildren)) {
|
|
15843
|
-
this.adaguc.currentChildren = myChildren;
|
|
15844
|
-
// ReactWMJSLayer Layer Childs: Detect all ReactLayers connected to WMJSLayers, remove WMJSLayer if there is no ReactLayer
|
|
15845
|
-
var wmjsLayers = wmjsMap.getLayers();
|
|
15846
|
-
var onUpdateLayerInformation = props.onUpdateLayerInformation,
|
|
15847
|
-
_mapId2 = props.mapId;
|
|
15848
|
-
wmjsLayers.forEach(function (wmLayer) {
|
|
15849
|
-
var isWMLayerInReactMapViewChildren = myChildren.find(function (child) {
|
|
15850
|
-
return child.id === wmLayer.ReactWMJSLayerId;
|
|
15851
|
-
});
|
|
15852
|
-
if (!isWMLayerInReactMapViewChildren) {
|
|
15853
|
-
removeWMLayerFromMap(wmLayer, _mapId2, onUpdateLayerInformation);
|
|
15854
|
-
}
|
|
15855
|
-
});
|
|
15856
|
-
// ReactWMJSLayer BaseLayer Childs: For the baseLayers, detect all ReactLayers connected to WMJSLayers, remove WMJSLayer if there is no ReactLayer
|
|
15857
|
-
var webmapJSBaselayers = wmjsMap.getBaseLayers();
|
|
15858
|
-
var _loop = function _loop(l) {
|
|
15859
|
-
var wmjsBaseLayers = wmjsMap.getBaseLayers();
|
|
15860
|
-
if (myChildren.filter(function (child) {
|
|
15861
|
-
return child.id === wmjsBaseLayers[l].ReactWMJSLayerId && child.name;
|
|
15862
|
-
}).length === 0) {
|
|
15863
|
-
/* TODO (Maarten Plieger, 2020-03-19):The remove property for the baselayer is not working yet */
|
|
15864
|
-
wmjsBaseLayers.splice(l, 1);
|
|
15865
|
-
wmjsMap.setBaseLayers(wmjsBaseLayers);
|
|
15866
|
-
wmjsBaseLayers = wmjsMap.getBaseLayers();
|
|
15867
|
-
}
|
|
15868
|
-
};
|
|
15869
|
-
for (var l = 0; l < webmapJSBaselayers.length; l += 1) {
|
|
15870
|
-
_loop(l);
|
|
15871
|
-
}
|
|
15872
|
-
// Loop through all React layers and update WMJSLayer properties where needed
|
|
15873
|
-
myChildren.filter(function (child) {
|
|
15874
|
-
return child.name;
|
|
15875
|
-
}).forEach(function (child) {
|
|
15876
|
-
var wmLayer = getWMLayerById(child.id);
|
|
15877
|
-
var layerIsInThisMap = wmjsMap.hasLayer(wmLayer);
|
|
15878
|
-
if (!layerIsInThisMap) {
|
|
15879
|
-
// Add a new layer, it is not in the this map
|
|
15880
|
-
addWMLayerPropsBasedOnChildProps(child, _mapId2, props, onUpdateLayerInformation);
|
|
15881
|
-
needsRedraw = true;
|
|
15882
|
-
} else {
|
|
15883
|
-
// Handle existing layer
|
|
15884
|
-
if (child.name !== undefined && wmLayer.name !== child.name) {
|
|
15885
|
-
// Handle layer name change
|
|
15886
|
-
wmLayer.setName(child.name).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
15887
|
-
var layerInfo;
|
|
15888
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
15889
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
15890
|
-
case 0:
|
|
15891
|
-
_context2.next = 2;
|
|
15892
|
-
return wmLayer.parseLayer();
|
|
15893
|
-
case 2:
|
|
15894
|
-
layerInfo = getLayerUpdateInfo(wmLayer, _mapId2);
|
|
15895
|
-
setWMLayerPropsBasedOnChildProps(child, wmLayer, props);
|
|
15896
|
-
onUpdateLayerInformation && onUpdateLayerInformation(layerInfo);
|
|
15897
|
-
wmjsMap.draw();
|
|
15898
|
-
case 6:
|
|
15899
|
-
case "end":
|
|
15900
|
-
return _context2.stop();
|
|
15901
|
-
}
|
|
15902
|
-
}, _callee2);
|
|
15903
|
-
})))["catch"](function (e) {
|
|
15904
|
-
child.onLayerError && child.onLayerError(wmLayer, e);
|
|
15905
|
-
});
|
|
15906
|
-
needsRedraw = true;
|
|
15907
|
-
}
|
|
15908
|
-
if (setWMLayerPropsBasedOnChildProps(child, wmLayer, props) === true) {
|
|
15909
|
-
needsRedraw = true;
|
|
15910
|
-
}
|
|
15911
|
-
}
|
|
15912
|
-
});
|
|
15913
|
-
// Check if order of layers has changed
|
|
15914
|
-
if (orderLayers(wmjsMap, myChildren)) {
|
|
15915
|
-
needsRedraw = true;
|
|
15916
|
-
}
|
|
15917
|
-
if (needsRedraw) {
|
|
15918
|
-
wmjsMap.draw();
|
|
15919
|
-
}
|
|
15920
|
-
}
|
|
15921
|
-
}
|
|
15922
|
-
}, {
|
|
15923
|
-
key: "drawDebounced",
|
|
15924
|
-
value: function drawDebounced() {
|
|
15925
|
-
var mapId = this.props.mapId;
|
|
15926
|
-
var wmjsMap = webmapUtils.getWMJSMapById(mapId);
|
|
15927
|
-
if (!wmjsMap) {
|
|
15928
|
-
return;
|
|
15929
|
-
}
|
|
15930
|
-
wmjsMap.getListener().suspendEvents();
|
|
15931
|
-
wmjsMap.draw();
|
|
15932
|
-
wmjsMap.getListener().resumeEvents();
|
|
15933
|
-
}
|
|
15934
|
-
}, {
|
|
15935
|
-
key: "mountWMJSMap",
|
|
15936
|
-
value: function mountWMJSMap() {
|
|
15937
|
-
var _this4 = this;
|
|
15938
|
-
var _this$props4 = this.props,
|
|
15939
|
-
mapId = _this$props4.mapId,
|
|
15940
|
-
listeners = _this$props4.listeners,
|
|
15941
|
-
srs = _this$props4.srs,
|
|
15942
|
-
bbox = _this$props4.bbox,
|
|
15943
|
-
onMapPinChangeLocation = _this$props4.onMapPinChangeLocation,
|
|
15944
|
-
shouldDisablePrefetching = _this$props4.shouldDisablePrefetching;
|
|
15945
|
-
/* Check if we have something to mount IWMJSMap on */
|
|
15946
|
-
if (this.adagucWebMapJSRef.current === null) {
|
|
15947
|
-
console.warn('No this.adagucWebMapJSRef.current yet ');
|
|
15948
|
-
return null;
|
|
15949
|
-
}
|
|
15950
|
-
/* Check if webmapjs was not already initialized */
|
|
15951
|
-
var existingWMJSMap = webmapUtils.getWMJSMapById(mapId);
|
|
15952
|
-
if (existingWMJSMap) {
|
|
15953
|
-
console.warn("Somehow ".concat(mapId, " already exists"));
|
|
15954
|
-
webmapUtils.unRegisterWMJSMap(mapId);
|
|
15955
|
-
}
|
|
15956
|
-
var wmjsMap = new WMJSMap(this.adagucWebMapJSRef.current);
|
|
15957
|
-
wmjsMap.shouldPrefetch = !shouldDisablePrefetching;
|
|
15958
|
-
// pass translation function
|
|
15959
|
-
var t = this.props.t;
|
|
15960
|
-
wmjsMap.t = t;
|
|
15961
|
-
this.adaguc.currentChildren = [];
|
|
15962
|
-
this.adaguc.baseLayers = [];
|
|
15963
|
-
webmapUtils.registerWMJSMap(wmjsMap, mapId);
|
|
15964
|
-
this.adaguc.initialized = true;
|
|
15965
|
-
/* Enable to show actual layer properties in the map */
|
|
15966
|
-
wmjsMap.showLayerInfo = false;
|
|
15967
|
-
wmjsMap.removeAllLayers();
|
|
15968
|
-
if (srs) {
|
|
15969
|
-
wmjsMap.setProjection(srs, new WMBBOX(bbox));
|
|
15970
|
-
}
|
|
15971
|
-
wmjsMap.setWMTileRendererTileSettings(this.tileServerSettings || tilesettings);
|
|
15972
|
-
if (listeners) {
|
|
15973
|
-
listeners.forEach(function (listener) {
|
|
15974
|
-
wmjsMap.addListener(listener.name, function (data) {
|
|
15975
|
-
listener.callbackfunction(wmjsMap, data);
|
|
15976
|
-
}, listener.keep);
|
|
15977
|
-
});
|
|
15978
|
-
}
|
|
15979
|
-
wmjsMap.addListener('ondimchange', function () {
|
|
15980
|
-
_this4.onDimChangeListener();
|
|
15981
|
-
}, true);
|
|
15982
|
-
wmjsMap.addListener('onmapready', function () {
|
|
15983
|
-
_this4.setState({
|
|
15984
|
-
adagucInitialised: true
|
|
15985
|
-
});
|
|
15986
|
-
});
|
|
15987
|
-
wmjsMap.addListener('aftersetbbox', function () {
|
|
15988
|
-
_this4.onAfterSetBBoxListener();
|
|
15989
|
-
}, true);
|
|
15990
|
-
wmjsMap.addListener('onupdatebbox', function (newBbox) {
|
|
15991
|
-
_this4.onUpdateBBoxListener(newBbox);
|
|
15992
|
-
}, true);
|
|
15993
|
-
wmjsMap.addListener('onsetmappin', function (mapPinLatLonCoordinate) {
|
|
15994
|
-
// only change location when mapPin is visible and enabled
|
|
15995
|
-
if (onMapPinChangeLocation &&
|
|
15996
|
-
// eslint-disable-next-line react/destructuring-assignment
|
|
15997
|
-
_this4.props.displayMapPin &&
|
|
15998
|
-
// eslint-disable-next-line react/destructuring-assignment
|
|
15999
|
-
!_this4.props.disableMapPin) {
|
|
16000
|
-
onMapPinChangeLocation({
|
|
16001
|
-
mapPinLocation: {
|
|
16002
|
-
lat: mapPinLatLonCoordinate.lat,
|
|
16003
|
-
lon: mapPinLatLonCoordinate.lon,
|
|
16004
|
-
projectionX: mapPinLatLonCoordinate.projectionX,
|
|
16005
|
-
projectionY: mapPinLatLonCoordinate.projectionY,
|
|
16006
|
-
screenOffsetX: mapPinLatLonCoordinate.screenOffsetX,
|
|
16007
|
-
screenOffsetY: mapPinLatLonCoordinate.screenOffsetY,
|
|
16008
|
-
srs: mapPinLatLonCoordinate.srs
|
|
16009
|
-
},
|
|
16010
|
-
mapId: mapId
|
|
16011
|
-
});
|
|
16012
|
-
}
|
|
16013
|
-
}, true);
|
|
16014
|
-
this.resize();
|
|
16015
|
-
wmjsMap.draw();
|
|
16016
|
-
this.updateWMJSMapProps(null, this.props);
|
|
16017
|
-
return wmjsMap;
|
|
16018
|
-
}
|
|
16019
|
-
}, {
|
|
16020
|
-
key: "resize",
|
|
16021
|
-
value: function resize() {
|
|
16022
|
-
var element = this.adagucContainerRef.current;
|
|
16023
|
-
if (element) {
|
|
16024
|
-
var newWidth = element.clientWidth;
|
|
16025
|
-
var newHeight = element.clientHeight;
|
|
16026
|
-
if (this.adaguc.currentWidth !== newWidth || this.adaguc.currentHeight !== newHeight) {
|
|
16027
|
-
this.adaguc.currentWidth = newWidth;
|
|
16028
|
-
this.adaguc.currentHeight = newHeight;
|
|
16029
|
-
var mapId = this.props.mapId;
|
|
16030
|
-
var wmjsMap = webmapUtils.getWMJSMapById(mapId);
|
|
16031
|
-
if (!wmjsMap) {
|
|
16032
|
-
return;
|
|
16033
|
-
}
|
|
16034
|
-
wmjsMap.setSize(newWidth, newHeight);
|
|
16035
|
-
}
|
|
16036
|
-
}
|
|
16037
|
-
}
|
|
16038
|
-
}, {
|
|
16039
|
-
key: "render",
|
|
16040
|
-
value: function render() {
|
|
16041
|
-
var _this$props5 = this.props,
|
|
16042
|
-
passiveMap = _this$props5.passiveMap,
|
|
16043
|
-
children = _this$props5.children,
|
|
16044
|
-
onClick = _this$props5.onClick,
|
|
16045
|
-
mapId = _this$props5.mapId,
|
|
16046
|
-
linkedFeatures = _this$props5.linkedFeatures;
|
|
16047
|
-
var adagucInitialised = this.state.adagucInitialised;
|
|
16048
|
-
var featureLayers = getFeatureLayers(children);
|
|
16049
|
-
featureLayers.forEach(function (featureLayer) {
|
|
16050
|
-
var wmFeatureLayer = getWMLayerById(featureLayer.id);
|
|
16051
|
-
if (!wmFeatureLayer) {
|
|
16052
|
-
registerWMLayer(new WMLayer(_objectSpread2({
|
|
16053
|
-
layerType: LayerType.featureLayer,
|
|
16054
|
-
service: ''
|
|
16055
|
-
}, featureLayer)), featureLayer.id);
|
|
16056
|
-
} else if (featureLayer.geojson) {
|
|
16057
|
-
wmFeatureLayer.geojson = featureLayer.geojson;
|
|
16058
|
-
}
|
|
16059
|
-
});
|
|
16060
|
-
return jsx("div", {
|
|
16061
|
-
className: "MapView",
|
|
16062
|
-
style: {
|
|
16063
|
-
height: '100%',
|
|
16064
|
-
width: '100%',
|
|
16065
|
-
border: 'none',
|
|
16066
|
-
display: 'block',
|
|
16067
|
-
overflow: 'hidden'
|
|
16068
|
-
},
|
|
16069
|
-
children: jsxs("div", {
|
|
16070
|
-
ref: this.adagucContainerRef,
|
|
16071
|
-
style: {
|
|
16072
|
-
minWidth: 'inherit',
|
|
16073
|
-
minHeight: 'inherit',
|
|
16074
|
-
width: 'inherit',
|
|
16075
|
-
height: 'inherit',
|
|
16076
|
-
overflow: 'hidden',
|
|
16077
|
-
display: 'block',
|
|
16078
|
-
border: 'none'
|
|
16079
|
-
},
|
|
16080
|
-
children: [jsx("div", {
|
|
16081
|
-
className: "MapViewComponent",
|
|
16082
|
-
style: {
|
|
16083
|
-
position: 'absolute',
|
|
16084
|
-
overflow: 'hidden',
|
|
16085
|
-
display: 'block',
|
|
16086
|
-
padding: '0',
|
|
16087
|
-
margin: '0',
|
|
16088
|
-
zIndex: 10
|
|
16089
|
-
},
|
|
16090
|
-
children: jsx("div", {
|
|
16091
|
-
role: "application",
|
|
16092
|
-
"aria-label": "map",
|
|
16093
|
-
ref: this.adagucWebMapJSRef
|
|
16094
|
-
})
|
|
16095
|
-
}), jsxs("div", {
|
|
16096
|
-
style: {
|
|
16097
|
-
position: 'absolute',
|
|
16098
|
-
overflow: 'hidden',
|
|
16099
|
-
display: 'block',
|
|
16100
|
-
padding: '0',
|
|
16101
|
-
margin: '0',
|
|
16102
|
-
zIndex: 100
|
|
16103
|
-
},
|
|
16104
|
-
children: [jsx("div", {
|
|
16105
|
-
children: children
|
|
16106
|
-
}), adagucInitialised && featureLayers && featureLayers.length ? jsx(MapDrawContainer, {
|
|
16107
|
-
featureLayers: featureLayers,
|
|
16108
|
-
linkedFeatures: linkedFeatures,
|
|
16109
|
-
mapId: mapId
|
|
16110
|
-
}) : null]
|
|
16111
|
-
}), passiveMap &&
|
|
16112
|
-
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/control-has-associated-label, jsx-a11y/interactive-supports-focus
|
|
16113
|
-
jsx("div", {
|
|
16114
|
-
style: {
|
|
16115
|
-
position: 'absolute',
|
|
16116
|
-
overflow: 'hidden',
|
|
16117
|
-
display: 'block',
|
|
16118
|
-
padding: '0',
|
|
16119
|
-
margin: '0',
|
|
16120
|
-
zIndex: 100,
|
|
16121
|
-
width: '100%',
|
|
16122
|
-
height: '100%'
|
|
16123
|
-
},
|
|
16124
|
-
onClick: onClick,
|
|
16125
|
-
role: "button"
|
|
16126
|
-
})]
|
|
16127
|
-
})
|
|
16128
|
-
});
|
|
16129
|
-
}
|
|
16130
|
-
}]);
|
|
16131
|
-
}(React.Component);
|
|
16132
|
-
ReactMapView.defaultProps = {
|
|
16133
|
-
srs: PROJECTION.EPSG_3857.value,
|
|
16134
|
-
bbox: {
|
|
16135
|
-
left: -2324980.5498391856,
|
|
16136
|
-
bottom: 5890854.775012179,
|
|
16137
|
-
right: 6393377.702660825,
|
|
16138
|
-
top: 11652109.058827976
|
|
16139
|
-
},
|
|
16140
|
-
shouldAutoFetch: true,
|
|
16141
|
-
displayMapPin: false,
|
|
16142
|
-
disableMapPin: false,
|
|
16143
|
-
tileServerSettings: tilesettings,
|
|
16144
|
-
onWMJSMount: function onWMJSMount() {},
|
|
16145
|
-
onWMJSUnMount: function onWMJSUnMount() {},
|
|
16146
|
-
onMapChangeDimension: function onMapChangeDimension() {
|
|
16147
|
-
/* nothing */
|
|
16148
|
-
},
|
|
16149
|
-
onUpdateLayerInformation: function onUpdateLayerInformation() {
|
|
16150
|
-
/* nothing */
|
|
16151
|
-
},
|
|
16152
|
-
onMapZoomEnd: function onMapZoomEnd() {
|
|
16153
|
-
/* nothing */
|
|
12962
|
+
var minutesBetween = dateUtils.differenceInMinutes(new Date(mapCurrentTime), new Date(layerCurrentTime));
|
|
12963
|
+
if (Math.abs(minutesBetween) > acceptanceTimeInMinutes) {
|
|
12964
|
+
return false;
|
|
16154
12965
|
}
|
|
16155
|
-
|
|
12966
|
+
return true;
|
|
12967
|
+
}
|
|
16156
12968
|
|
|
16157
12969
|
var getTimeDimension = function getTimeDimension(dimensions) {
|
|
16158
12970
|
return dimensions.find(function (dimension) {
|
|
@@ -16192,339 +13004,6 @@ var MapTime = function MapTime(_ref) {
|
|
|
16192
13004
|
});
|
|
16193
13005
|
};
|
|
16194
13006
|
|
|
16195
|
-
/* *
|
|
16196
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
16197
|
-
* you may not use this file except in compliance with the License.
|
|
16198
|
-
* You may obtain a copy of the License at
|
|
16199
|
-
*
|
|
16200
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16201
|
-
*
|
|
16202
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
16203
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16204
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16205
|
-
* See the License for the specific language governing permissions and
|
|
16206
|
-
* limitations under the License.
|
|
16207
|
-
*
|
|
16208
|
-
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
16209
|
-
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
16210
|
-
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
16211
|
-
* */
|
|
16212
|
-
var MS_IN_HOUR = 3600 * 1000;
|
|
16213
|
-
// The following is necessary to allow to assign to the CanvasRenderingContext2D ctx property
|
|
16214
|
-
/* eslint-disable no-param-reassign */
|
|
16215
|
-
/**
|
|
16216
|
-
* This component registers to a webmap instance and draws axis for height and time in the map using the Map Canvas.
|
|
16217
|
-
*/
|
|
16218
|
-
var ProfileAxis = function ProfileAxis(_ref) {
|
|
16219
|
-
var mapId = _ref.mapId;
|
|
16220
|
-
var drawAxisOnMapDisplay = function drawAxisOnMapDisplay(ctx, webMap, axisStyle) {
|
|
16221
|
-
var bbox = webMap.getDrawBBOX();
|
|
16222
|
-
var _webMap$getSize = webMap.getSize(),
|
|
16223
|
-
width = _webMap$getSize.width,
|
|
16224
|
-
height = _webMap$getSize.height;
|
|
16225
|
-
var offY = height - 50;
|
|
16226
|
-
var offX = 20;
|
|
16227
|
-
try {
|
|
16228
|
-
var startDate = new Date(bbox.left);
|
|
16229
|
-
var endDate = new Date(bbox.right);
|
|
16230
|
-
webMap.setMessage("".concat(startDate.toDateString(), ", ").concat(startDate.getUTCHours(), " to ").concat(endDate.getUTCHours(), " hours UTC"));
|
|
16231
|
-
} catch (e) {
|
|
16232
|
-
webMap.setMessage('');
|
|
16233
|
-
}
|
|
16234
|
-
// Draw the horizontal time axis
|
|
16235
|
-
drawTimeAxis(ctx, bbox, offX, offY, width, height, axisStyle);
|
|
16236
|
-
// Draw the vertical elevation axis
|
|
16237
|
-
drawHeightAxis(ctx, bbox, offX, offY, width, height, axisStyle);
|
|
16238
|
-
// Draw the mouse cursor
|
|
16239
|
-
drawCursor(ctx, bbox, offX, offY, width, height, webMap, axisStyle);
|
|
16240
|
-
// Draw the layer name
|
|
16241
|
-
drawLayerName(ctx, bbox, offX, offY, width, height, webMap, axisStyle);
|
|
16242
|
-
};
|
|
16243
|
-
React__default.useEffect(function () {
|
|
16244
|
-
var axisStyle = {
|
|
16245
|
-
backgroundColor: 'white',
|
|
16246
|
-
color: 'black',
|
|
16247
|
-
fontStyleSmall: '10px Roboto, Helvetica, Arial',
|
|
16248
|
-
fontStyleBig: '14px Roboto, Helvetica, Arial'
|
|
16249
|
-
};
|
|
16250
|
-
// Draw on map canvas callback function
|
|
16251
|
-
var beforeCanvasDisplay = function beforeCanvasDisplay(ctx) {
|
|
16252
|
-
var webmapjs = getWMJSMapById(mapId);
|
|
16253
|
-
webmapjs && drawAxisOnMapDisplay(ctx, webmapjs, axisStyle);
|
|
16254
|
-
};
|
|
16255
|
-
// unMount logic
|
|
16256
|
-
var unMount = function unMount() {
|
|
16257
|
-
var webMap = getWMJSMapById(mapId);
|
|
16258
|
-
if (webMap) {
|
|
16259
|
-
webMap.removeListener('beforecanvasdisplay', beforeCanvasDisplay);
|
|
16260
|
-
}
|
|
16261
|
-
};
|
|
16262
|
-
// Mount logic
|
|
16263
|
-
var webMap = getWMJSMapById(mapId);
|
|
16264
|
-
if (webMap && webMap.getProjection().srs === 'GFI:TIME_ELEVATION') {
|
|
16265
|
-
webMap.displayScaleBarInMap(false);
|
|
16266
|
-
webMap.hideMouseCursorProperties();
|
|
16267
|
-
webMap.setTimeOffset('');
|
|
16268
|
-
webMap.addListener('beforecanvasdisplay', beforeCanvasDisplay, true);
|
|
16269
|
-
webMap.draw();
|
|
16270
|
-
}
|
|
16271
|
-
return unMount;
|
|
16272
|
-
}, [mapId]);
|
|
16273
|
-
return null;
|
|
16274
|
-
};
|
|
16275
|
-
/**
|
|
16276
|
-
* Calculates a time spacing. This is used to place labels on the X axis (time axis).
|
|
16277
|
-
* To make readable time labels, the time spacing is discretized to rounded times,
|
|
16278
|
-
* The time spacing changes according to zoom level.
|
|
16279
|
-
* @param bbox
|
|
16280
|
-
* @param width
|
|
16281
|
-
* @returns
|
|
16282
|
-
*/
|
|
16283
|
-
var getTimeSpacingInMs = function getTimeSpacingInMs(bbox, width) {
|
|
16284
|
-
var hoursInView = Math.abs(bbox.right - bbox.left) / (MS_IN_HOUR * width / 500);
|
|
16285
|
-
return Math.pow(2, Math.round((Math.log10(hoursInView / 10) + 0.5) / Math.log10(2)) - 1) * MS_IN_HOUR;
|
|
16286
|
-
};
|
|
16287
|
-
var drawTimeAxis = function drawTimeAxis(ctx, bbox, offsetX, offsetY, width, height, axisStyle) {
|
|
16288
|
-
var backgroundColor = axisStyle.backgroundColor,
|
|
16289
|
-
color = axisStyle.color,
|
|
16290
|
-
fontStyleSmall = axisStyle.fontStyleSmall,
|
|
16291
|
-
fontStyleBig = axisStyle.fontStyleBig;
|
|
16292
|
-
// Draw rectangle with backgroundColor for axis
|
|
16293
|
-
ctx.textBaseline = 'middle';
|
|
16294
|
-
ctx.fillStyle = backgroundColor;
|
|
16295
|
-
ctx.fillRect(0, offsetY, width, 50);
|
|
16296
|
-
ctx.font = fontStyleSmall;
|
|
16297
|
-
ctx.textAlign = 'left';
|
|
16298
|
-
ctx.fillStyle = color;
|
|
16299
|
-
ctx.strokeStyle = color;
|
|
16300
|
-
var ticksMs = getTimeSpacingInMs(bbox, width);
|
|
16301
|
-
var roundedTimeLeftMs = Math.round(bbox.left / ticksMs) * ticksMs;
|
|
16302
|
-
var roundedTimeRightMs = Math.round(bbox.right / ticksMs) * ticksMs;
|
|
16303
|
-
var numHoursInView = Math.min((roundedTimeRightMs - roundedTimeLeftMs) / ticksMs + 1, 100);
|
|
16304
|
-
for (var hoursToPlot = 0; hoursToPlot < numHoursInView; hoursToPlot += 1) {
|
|
16305
|
-
var timeMs = roundedTimeLeftMs + hoursToPlot * ticksMs;
|
|
16306
|
-
var posX = Math.round((timeMs - bbox.left) / (bbox.right - bbox.left) * width) + 0.5;
|
|
16307
|
-
ctx.beginPath();
|
|
16308
|
-
ctx.moveTo(posX, offsetY + 0);
|
|
16309
|
-
ctx.lineTo(posX, offsetY + 10);
|
|
16310
|
-
var date = new Date(timeMs);
|
|
16311
|
-
var hourString = "0".concat(date.getUTCHours()).slice(-2);
|
|
16312
|
-
var minuteString = ":".concat("0".concat(date.getUTCMinutes()).slice(-2));
|
|
16313
|
-
var txt = "".concat(hourString).concat(minuteString);
|
|
16314
|
-
ctx.stroke();
|
|
16315
|
-
ctx.fillText("".concat(txt), posX - 13, offsetY + 16);
|
|
16316
|
-
}
|
|
16317
|
-
// Draw units in map
|
|
16318
|
-
ctx.font = fontStyleBig;
|
|
16319
|
-
ctx.fillText('time UTC (h)', width / 2 - 10, offsetY + 38);
|
|
16320
|
-
};
|
|
16321
|
-
/**
|
|
16322
|
-
* Calculates a spacing for the height axis. This is used to place labels on the Y axis (height axis).
|
|
16323
|
-
* To make readable height labels, the height spacing is discretized to rounded elevations,
|
|
16324
|
-
* The spacing changes according to zoom level.
|
|
16325
|
-
* @param bbox
|
|
16326
|
-
* @param height
|
|
16327
|
-
* @returns
|
|
16328
|
-
*/
|
|
16329
|
-
var getHeightSpacingInMs = function getHeightSpacingInMs(bbox, height) {
|
|
16330
|
-
var numMeterInView = Math.abs(bbox.bottom - bbox.top) / height;
|
|
16331
|
-
return Math.pow(10, Math.round(Math.log10(numMeterInView * 100) + 0.5) - 1);
|
|
16332
|
-
};
|
|
16333
|
-
var drawHeightAxis = function drawHeightAxis(ctx, bbox, offsetX, offsetY, width, height, axisStyle) {
|
|
16334
|
-
var backgroundColor = axisStyle.backgroundColor,
|
|
16335
|
-
color = axisStyle.color,
|
|
16336
|
-
fontStyleSmall = axisStyle.fontStyleSmall,
|
|
16337
|
-
fontStyleBig = axisStyle.fontStyleBig;
|
|
16338
|
-
// Draw rectangle in backgroundColor for axis
|
|
16339
|
-
ctx.fillStyle = backgroundColor;
|
|
16340
|
-
ctx.fillRect(0, 0, 60 + offsetX, height);
|
|
16341
|
-
ctx.font = fontStyleSmall;
|
|
16342
|
-
ctx.textAlign = 'right';
|
|
16343
|
-
ctx.fillStyle = color;
|
|
16344
|
-
var ticksM = getHeightSpacingInMs(bbox, height);
|
|
16345
|
-
var roundedElevBottomMeter = Math.round(bbox.bottom / ticksM) * ticksM;
|
|
16346
|
-
var roundedElevTopMeter = Math.round(bbox.top / ticksM) * ticksM;
|
|
16347
|
-
var numKmInView = Math.min((roundedElevTopMeter - roundedElevBottomMeter) / ticksM + 1, 100);
|
|
16348
|
-
for (var kmToPlot = 0; kmToPlot < numKmInView; kmToPlot += 1) {
|
|
16349
|
-
var valueInKm = roundedElevBottomMeter + kmToPlot * ticksM;
|
|
16350
|
-
var posY = Math.round((bbox.top - valueInKm) / (bbox.top - bbox.bottom) * height) + 0.5;
|
|
16351
|
-
ctx.beginPath();
|
|
16352
|
-
ctx.moveTo(offsetX + 50, posY);
|
|
16353
|
-
ctx.lineTo(offsetX + 60, posY);
|
|
16354
|
-
ctx.stroke();
|
|
16355
|
-
var txt = valueInKm;
|
|
16356
|
-
ctx.fillText("".concat(txt), offsetX + 48, posY + 2);
|
|
16357
|
-
}
|
|
16358
|
-
// Draw height unit in axis
|
|
16359
|
-
ctx.font = axisStyle.fontStyleBig;
|
|
16360
|
-
ctx.save();
|
|
16361
|
-
ctx.translate(5, height / 2 - 50);
|
|
16362
|
-
ctx.rotate(-Math.PI / 2);
|
|
16363
|
-
ctx.font = fontStyleBig;
|
|
16364
|
-
ctx.fillText('height (m)', 5, 5);
|
|
16365
|
-
ctx.restore();
|
|
16366
|
-
ctx.fillStyle = backgroundColor;
|
|
16367
|
-
ctx.fillRect(0, height - 60, offsetX + 60, 60);
|
|
16368
|
-
// Draw line border for map
|
|
16369
|
-
ctx.moveTo(offsetX + 60, offsetY + 0.5);
|
|
16370
|
-
ctx.lineTo(width, offsetY + 0.5);
|
|
16371
|
-
ctx.moveTo(offsetX + 60.5, 0);
|
|
16372
|
-
ctx.lineTo(offsetX + 60.5, height - 50);
|
|
16373
|
-
ctx.stroke();
|
|
16374
|
-
};
|
|
16375
|
-
var drawCursor = function drawCursor(ctx, bbox, offsetX, offsetY, width, height, webMapJS, axisStyle) {
|
|
16376
|
-
var _webMapJS$getMapMouse = webMapJS.getMapMouseCoordinates(),
|
|
16377
|
-
mapMouseX = _webMapJS$getMapMouse.mouseX,
|
|
16378
|
-
mapMouseY = _webMapJS$getMapMouse.mouseY;
|
|
16379
|
-
// Do not draw if mouse is not in the map
|
|
16380
|
-
if (mapMouseX < 5 && mapMouseY < 5) {
|
|
16381
|
-
return;
|
|
16382
|
-
}
|
|
16383
|
-
/* Draw cursor line */
|
|
16384
|
-
var mouseX = Math.round(mapMouseX) + 0.5;
|
|
16385
|
-
var mouseY = Math.round(mapMouseY) + 0.5;
|
|
16386
|
-
ctx.strokeStyle = '#303030';
|
|
16387
|
-
ctx.setLineDash([15, 5]);
|
|
16388
|
-
ctx.beginPath();
|
|
16389
|
-
ctx.moveTo(0, mouseY);
|
|
16390
|
-
ctx.lineTo(width, mouseY);
|
|
16391
|
-
ctx.moveTo(mouseX, 0);
|
|
16392
|
-
ctx.lineTo(mouseX, height);
|
|
16393
|
-
ctx.stroke();
|
|
16394
|
-
ctx.strokeStyle = axisStyle.color;
|
|
16395
|
-
ctx.lineWidth = 1;
|
|
16396
|
-
ctx.setLineDash([]);
|
|
16397
|
-
};
|
|
16398
|
-
var drawLayerName = function drawLayerName(ctx, bbox, offsetX, offsetY, width, height, webMapJS, axisStyle) {
|
|
16399
|
-
// Draw layername
|
|
16400
|
-
var layers = webMapJS.getLayers();
|
|
16401
|
-
if (layers.length > 0) {
|
|
16402
|
-
ctx.textBaseline = 'middle';
|
|
16403
|
-
ctx.fillStyle = axisStyle.backgroundColor;
|
|
16404
|
-
ctx.font = axisStyle.fontStyleBig;
|
|
16405
|
-
ctx.textAlign = 'left';
|
|
16406
|
-
ctx.fillStyle = axisStyle.color;
|
|
16407
|
-
ctx.strokeStyle = axisStyle.color;
|
|
16408
|
-
ctx.fillText("Layer: ".concat(layers[0].name), 10, offsetY + 38);
|
|
16409
|
-
}
|
|
16410
|
-
};
|
|
16411
|
-
// Re-enable the previousely disabled eslint rule
|
|
16412
|
-
/* eslint-enable no-param-reassign */
|
|
16413
|
-
|
|
16414
|
-
var _excluded$1 = ["children", "controls", "displayTimeInMap", "onWMJSMount", "isTimeScrollingEnabled"];
|
|
16415
|
-
var MapView = function MapView(_ref) {
|
|
16416
|
-
var children = _ref.children,
|
|
16417
|
-
_ref$controls = _ref.controls,
|
|
16418
|
-
controls = _ref$controls === void 0 ? {
|
|
16419
|
-
zoomControls: true
|
|
16420
|
-
} : _ref$controls,
|
|
16421
|
-
_ref$displayTimeInMap = _ref.displayTimeInMap,
|
|
16422
|
-
displayTimeInMap = _ref$displayTimeInMap === void 0 ? true : _ref$displayTimeInMap,
|
|
16423
|
-
_onWMJSMount = _ref.onWMJSMount,
|
|
16424
|
-
isTimeScrollingEnabled = _ref.isTimeScrollingEnabled,
|
|
16425
|
-
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
16426
|
-
var dimensions = props.dimensions,
|
|
16427
|
-
mapIdProp = props.mapId;
|
|
16428
|
-
var _useTranslation = useTranslation(),
|
|
16429
|
-
t = _useTranslation.t;
|
|
16430
|
-
var wmjsMapRef = React.useRef(null);
|
|
16431
|
-
var mapId = React.useRef(mapIdProp).current;
|
|
16432
|
-
if (mapIdProp !== mapId) {
|
|
16433
|
-
console.warn("Warning, MapId ".concat(mapId, " has been updated to ").concat(mapIdProp, " on an already mounted component. Keeping ").concat(mapId));
|
|
16434
|
-
}
|
|
16435
|
-
var _useResizeDetector = useResizeDetector(),
|
|
16436
|
-
ref = _useResizeDetector.ref,
|
|
16437
|
-
height = _useResizeDetector.height,
|
|
16438
|
-
width = _useResizeDetector.width;
|
|
16439
|
-
React.useEffect(function () {
|
|
16440
|
-
if (wmjsMapRef.current && !!width && !!height) {
|
|
16441
|
-
var _wmjsMapRef$current$g = wmjsMapRef.current.getSize(),
|
|
16442
|
-
mapHeight = _wmjsMapRef$current$g.height,
|
|
16443
|
-
mapWidth = _wmjsMapRef$current$g.width;
|
|
16444
|
-
if (width !== mapWidth || height !== mapHeight) {
|
|
16445
|
-
wmjsMapRef.current.setSize(Math.ceil(width), Math.ceil(height));
|
|
16446
|
-
}
|
|
16447
|
-
}
|
|
16448
|
-
}, [width, height]);
|
|
16449
|
-
var reactMapViewProps = _objectSpread2(_objectSpread2({}, props), {}, {
|
|
16450
|
-
mapId: mapId,
|
|
16451
|
-
isTimeScrollingEnabled: isTimeScrollingEnabled
|
|
16452
|
-
});
|
|
16453
|
-
return jsxs(Box, {
|
|
16454
|
-
ref: ref,
|
|
16455
|
-
sx: {
|
|
16456
|
-
display: 'grid',
|
|
16457
|
-
width: '100%',
|
|
16458
|
-
height: '100%',
|
|
16459
|
-
position: 'relative',
|
|
16460
|
-
overflow: 'hidden'
|
|
16461
|
-
},
|
|
16462
|
-
children: [controls && controls.zoomControls && jsxs(MapControls, {
|
|
16463
|
-
style: {
|
|
16464
|
-
top: 0,
|
|
16465
|
-
position: 'absolute'
|
|
16466
|
-
},
|
|
16467
|
-
children: [jsx(ProfileAxis, {
|
|
16468
|
-
mapId: mapId
|
|
16469
|
-
}), jsx(ZoomControls, {
|
|
16470
|
-
onZoomIn: function onZoomIn() {
|
|
16471
|
-
var _webmapUtils$getWMJSM;
|
|
16472
|
-
(_webmapUtils$getWMJSM = webmapUtils.getWMJSMapById(mapId)) === null || _webmapUtils$getWMJSM === void 0 || _webmapUtils$getWMJSM.zoomIn(undefined);
|
|
16473
|
-
},
|
|
16474
|
-
onZoomOut: function onZoomOut() {
|
|
16475
|
-
var _webmapUtils$getWMJSM2;
|
|
16476
|
-
(_webmapUtils$getWMJSM2 = webmapUtils.getWMJSMapById(mapId)) === null || _webmapUtils$getWMJSM2 === void 0 || _webmapUtils$getWMJSM2.zoomOut();
|
|
16477
|
-
},
|
|
16478
|
-
onZoomReset: function onZoomReset() {
|
|
16479
|
-
var wmjsMap = webmapUtils.getWMJSMapById(mapId);
|
|
16480
|
-
if (!wmjsMap) {
|
|
16481
|
-
return;
|
|
16482
|
-
}
|
|
16483
|
-
wmjsMap.zoomToLayer(wmjsMap.getActiveLayer());
|
|
16484
|
-
}
|
|
16485
|
-
})]
|
|
16486
|
-
}), jsx(Box, {
|
|
16487
|
-
sx: {
|
|
16488
|
-
gridColumnStart: 1,
|
|
16489
|
-
gridRowStart: 1
|
|
16490
|
-
},
|
|
16491
|
-
children: jsx(ReactMapView, _objectSpread2(_objectSpread2({}, reactMapViewProps), {}, {
|
|
16492
|
-
showLegend: false,
|
|
16493
|
-
displayTimeInMap: false,
|
|
16494
|
-
shouldDisablePrefetching: props.shouldDisablePrefetching,
|
|
16495
|
-
onWMJSMount: function onWMJSMount(id) {
|
|
16496
|
-
var webMapJS = webmapUtils.getWMJSMapById(id);
|
|
16497
|
-
if (!webMapJS) {
|
|
16498
|
-
return;
|
|
16499
|
-
}
|
|
16500
|
-
wmjsMapRef.current = webMapJS;
|
|
16501
|
-
if (_onWMJSMount) {
|
|
16502
|
-
_onWMJSMount(id);
|
|
16503
|
-
}
|
|
16504
|
-
},
|
|
16505
|
-
t: t,
|
|
16506
|
-
children: children
|
|
16507
|
-
}))
|
|
16508
|
-
}), displayTimeInMap && dimensions && jsx(MapTime, {
|
|
16509
|
-
dimensions: dimensions
|
|
16510
|
-
})]
|
|
16511
|
-
});
|
|
16512
|
-
};
|
|
16513
|
-
|
|
16514
|
-
var MapViewLayer = function MapViewLayer(props) {
|
|
16515
|
-
// TODO: This component should not do anything, but just return null: https://gitlab.com/opengeoweb/opengeoweb/-/issues/4579
|
|
16516
|
-
var id = props.id;
|
|
16517
|
-
return React.useMemo(function () {
|
|
16518
|
-
return jsx("div", {
|
|
16519
|
-
"data-testid": "mapViewLayer",
|
|
16520
|
-
style: {
|
|
16521
|
-
display: 'none'
|
|
16522
|
-
},
|
|
16523
|
-
children: id
|
|
16524
|
-
});
|
|
16525
|
-
}, [id]);
|
|
16526
|
-
};
|
|
16527
|
-
|
|
16528
13007
|
var MapWarningProperties = function MapWarningProperties(_ref) {
|
|
16529
13008
|
var selectedFeatureProperties = _ref.selectedFeatureProperties,
|
|
16530
13009
|
languageIndex = _ref.languageIndex,
|
|
@@ -17529,6 +14008,7 @@ var useIconStyle = function useIconStyle(_ref) {
|
|
|
17529
14008
|
|
|
17530
14009
|
var OpenLayersGetFeatureInfo = function OpenLayersGetFeatureInfo(_ref) {
|
|
17531
14010
|
var displayMapPin = _ref.displayMapPin,
|
|
14011
|
+
disableMapPin = _ref.disableMapPin,
|
|
17532
14012
|
mapPinLocation = _ref.mapPinLocation,
|
|
17533
14013
|
selectLocation = _ref.selectLocation;
|
|
17534
14014
|
var _useContext = useContext(MapContext),
|
|
@@ -17538,6 +14018,9 @@ var OpenLayersGetFeatureInfo = function OpenLayersGetFeatureInfo(_ref) {
|
|
|
17538
14018
|
options: {
|
|
17539
14019
|
icon: {
|
|
17540
14020
|
anchor: [0.5, 1]
|
|
14021
|
+
},
|
|
14022
|
+
render: {
|
|
14023
|
+
fillStyle: disableMapPin ? '#808080' : '#000000'
|
|
17541
14024
|
}
|
|
17542
14025
|
}
|
|
17543
14026
|
}),
|
|
@@ -18375,32 +14858,4 @@ var ClickOnMapTool = function ClickOnMapTool(_ref) {
|
|
|
18375
14858
|
});
|
|
18376
14859
|
};
|
|
18377
14860
|
|
|
18378
|
-
|
|
18379
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
18380
|
-
* you may not use this file except in compliance with the License.
|
|
18381
|
-
* You may obtain a copy of the License at
|
|
18382
|
-
*
|
|
18383
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18384
|
-
*
|
|
18385
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
18386
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18387
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18388
|
-
* See the License for the specific language governing permissions and
|
|
18389
|
-
* limitations under the License.
|
|
18390
|
-
*
|
|
18391
|
-
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
18392
|
-
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
18393
|
-
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
18394
|
-
* */
|
|
18395
|
-
// wrap around webmap i18n exports so geoweb app
|
|
18396
|
-
// doesn't have to depend on webmap directly
|
|
18397
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
18398
|
-
var _useOpenLayers = true;
|
|
18399
|
-
var setOpenLayersEnabled = function setOpenLayersEnabled(openLayersOnOrOff) {
|
|
18400
|
-
_useOpenLayers = openLayersOnOrOff;
|
|
18401
|
-
};
|
|
18402
|
-
var isOpenLayersEnabled = function isOpenLayersEnabled() {
|
|
18403
|
-
return _useOpenLayers;
|
|
18404
|
-
};
|
|
18405
|
-
|
|
18406
|
-
export { ClickOnMapTool, DRAWMODE, DefaultBaseLayers, DimensionSelectButton, DimensionSelectDialog, DimensionSelectSlider, EDITMODE, EditModeButton as EditModeButtonField, FEATURE_FILL, FEATURE_STROKE, FEATURE_STROKE_EDIT, FEATURE_VERTICES_EDIT_HANDLES, FEATURE_VERTICE_HANDLE_IMAGE, FEATURE_VERTICE_IMAGE, FeatureLayers, GeoJSONTextField, ICON_LOCATIONMARKER, ICON_LOCATIONMARKER_MODIFY, IntersectionSelect, LayerInfoButton, LayerInfoDialog, LayerInfoLegend, LayerInfoList, LayerInfoText, Legend, LegendButton, LegendDialog, LegendLayout, MINUTE_TO_MILLISECOND, MapContext, MapControlButton, MapControls, MapDimensionSelect, MapDrawContainer, MapFeatureClass, MapTime, MapView, MapViewLayer, MapWarningProperties, NEW_FEATURE_CREATED, NEW_LINESTRING_CREATED, NEW_POINT_CREATED, ORIGIN_REACTMAPVIEW_ONMAPCHANGEDIMENSION, ORIGIN_REACTMAPVIEW_ONUPDATELAYERINFO, OpenLayersFeatureLayer, OpenLayersGetFeatureInfo, OpenLayersLayer, OpenLayersMapDraw, OpenLayersMapView, OpenLayersZoomControl, Proj4js, radarGetCapabilities_spec as RadarGetCapabilities, ReactMapView, ReactMapViewLayer, SelectField, StoryLayoutGrid, TimeAwareEDRLocationLayer, TimeContext, TimeawareImageSource, WEBMAP_REACT_NAMESPACE, WMSLayer, ZoomControls, addFeatureProperties, addGeoJSONProperties, addSelectionTypeToGeoJSON, addWMLayerPropsBasedOnChildProps, basicExampleDrawOptions, basicExampleMultipleShapeDrawOptions, basicExampleMultipleShapeWithValuesDrawOptions, checkHoverFeatures, colorMaps, convertGeoCoordsToScreenCoords, createIconStyle, createInterSections, currentlySupportedDrawModes, defaultBox, defaultDelete, defaultGeoJSONStyleProperties, defaultIntersectionStyleProperties, defaultLayers, defaultModes, defaultPoint, defaultPolygon, defaultTimeFormat, dimensionConfig, distance, drawPolyStoryStyles, drawStyles, emptyGeoJSON, endToolExampleConfig, exampleIntersectionOptions, exampleIntersectionWithShapeOptions, exampleIntersections, exampleIntersectionsMultiDrawTool, fakeEdrLayerApiHandlers, featureBox, featureMultiPoint, featurePoint, featurePolygon, fillOptions, findClosestCoords, firSelectionType, formatTime, genericOpenLayersFeatureStyle, geowebColorToOpenLayersColor, getCurrentDimensionValue, getDimensionIcon, getDimensionLabel, getDimensionValue, getDimensionsList, getDoubleControlToolIcon, getDrawFunctionFromStore, getFeatureCollection, getFeatureExtent, getFeatureLayers, getFirTitle, getGeoJSONPropertyValue, getGeoJson, getIcon, getIntersectionToolIcon, getIsInsideAcceptanceTime, getLastEmptyFeatureIndex, getLayerBbox, getLayerStyles, getLayerUpdateInfo, getLegendClass, getPixelCoordFromGeoCoord, getProj4, getTimeDimension, getToolIcon, initializeOpenLayersProjections, inlineFeatureStyle, intersectPointGeoJSONS, intersectPolygonGeoJSONS, intersectionFeatureBE, intersectionFeatureNL, isAGeoJSONLayer, isAMapLayer, isBetween, isGeoJSONFeatureCreatedByTool, isGeoJSONGeometryEmpty, isOpenLayersEnabled, isPointFeatureCollection, lineString, lineStringCollection, makeFeatureStyleDisc, makeFeatureStyleLoading, makeLayerPropListFromChildren, makeLegendFromColorMap, makeView, marksByDimension, modifyStyles, moveFeature, multiLineStringLabelStyle, multiPolygonLabelStyle, opacityOptions, openLayersGetMapImageStore, orderLayers, parseWMJSLayer, projectorCache, publicLayers, publicServices, registerDrawFunction, removeWMLayerFromMap, rewindGeometry, selectPreferredWMSProjection, setMapCenter, setOpenLayersEnabled, setViewFromExtent, setViewFromFeature, setWMLayerPropsBasedOnChildProps, simpleBoxGeoJSON, simpleBoxGeoJSONWrongOrder, simpleFlightRouteLineStringGeoJSON, simpleFlightRoutePointsGeoJSON, simpleGeometryCollectionGeoJSON, simpleLineStringGeoJSON, simpleMultiPolygon, simplePointsGeojson, simplePolygonGeoJSON, simpleSmallLineStringGeoJSON, startToolExampleConfig, strokeWidthOptions, textLabelStyle, textStyle, textStyleWithMargin, updateEditModeButtonsWithFir, useAnimationForLayer, useEDRCollection, useEDRCollectionCube, useEDRCollectionLocation, useGeoJSON, useGetWMLayerInstance, useGetWMSLayerStyleList, useIconStyle, useMapDrawTool, useProjection, useQueryGetWMSGetCapabilities, useQueryGetWMSLayer, useQueryGetWMSLayers, useQueryGetWMSLayersTree, useQueryGetWMSServiceInfo, useQueryWMTSGetCapabilities, useSetIntervalWhenVisible, useViewFromLayer, viewUtils, webmapReactTranslations, wowTemperatureLegendColors };
|
|
14861
|
+
export { ClickOnMapTool, DRAWMODE, DefaultBaseLayers, DimensionSelectButton, DimensionSelectDialog, DimensionSelectSlider, EditModeButton as EditModeButtonField, FEATURE_FILL, FEATURE_STROKE, FEATURE_STROKE_EDIT, FEATURE_VERTICES_EDIT_HANDLES, FEATURE_VERTICE_HANDLE_IMAGE, FEATURE_VERTICE_IMAGE, FeatureLayers, GeoJSONTextField, ICON_LOCATIONMARKER, ICON_LOCATIONMARKER_MODIFY, IntersectionSelect, LayerInfoButton, LayerInfoDialog, LayerInfoLegend, LayerInfoList, LayerInfoText, Legend, LegendButton, LegendDialog, LegendLayout, MapContext, MapControlButton, MapControls, MapDimensionSelect, MapFeatureClass, MapTime, MapWarningProperties, NEW_FEATURE_CREATED, NEW_LINESTRING_CREATED, NEW_POINT_CREATED, OpenLayersFeatureLayer, OpenLayersGetFeatureInfo, OpenLayersLayer, OpenLayersMapDraw, OpenLayersMapView, OpenLayersZoomControl, Proj4js, radarGetCapabilities_spec as RadarGetCapabilities, SelectField, StoryLayoutGrid, TimeAwareEDRLocationLayer, TimeContext, TimeawareImageSource, WEBMAP_REACT_NAMESPACE, WMSLayer, ZoomControls, addFeatureProperties, addGeoJSONProperties, addSelectionTypeToGeoJSON, basicExampleDrawOptions, basicExampleMultipleShapeDrawOptions, basicExampleMultipleShapeWithValuesDrawOptions, clearImageCacheForAllMaps, colorMaps, createIconStyle, createInterSections, currentlySupportedDrawModes, defaultBox, defaultDelete, defaultGeoJSONStyleProperties, defaultIntersectionStyleProperties, defaultLayers, defaultModes, defaultPoint, defaultPolygon, defaultTimeFormat, dimensionConfig, drawPolyStoryStyles, drawStyles, emptyGeoJSON, endToolExampleConfig, exampleIntersectionOptions, exampleIntersectionWithShapeOptions, exampleIntersections, exampleIntersectionsMultiDrawTool, fakeEdrLayerApiHandlers, featureBox, featureMultiPoint, featurePoint, featurePolygon, fillOptions, firSelectionType, formatTime, genericOpenLayersFeatureStyle, geowebColorToOpenLayersColor, getCurrentDimensionValue, getDimensionIcon, getDimensionLabel, getDimensionValue, getDimensionsList, getDoubleControlToolIcon, getFeatureCollection, getFeatureExtent, getFeatureLayers, getFirTitle, getGeoJSONPropertyValue, getGeoJson, getIcon, getIntersectionToolIcon, getIsInsideAcceptanceTime, getLastEmptyFeatureIndex, getLayerBbox, getLayerStyles, getLayerUpdateInfo, getLegendClass, getProj4, getTimeDimension, getToolIcon, initializeOpenLayersProjections, inlineFeatureStyle, intersectPointGeoJSONS, intersectPolygonGeoJSONS, intersectionFeatureBE, intersectionFeatureNL, isAGeoJSONLayer, isAMapLayer, isGeoJSONFeatureCreatedByTool, isGeoJSONGeometryEmpty, isPointFeatureCollection, lineString, lineStringCollection, makeFeatureStyleDisc, makeFeatureStyleLoading, makeLegendFromColorMap, makeView, marksByDimension, modifyStyles, moveFeature, multiLineStringLabelStyle, multiPolygonLabelStyle, opacityOptions, openLayersGetMapImageStore, projectorCache, publicLayers, publicServices, rewindGeometry, selectPreferredWMSProjection, setMapCenter, setViewFromExtent, setViewFromFeature, simpleBoxGeoJSON, simpleBoxGeoJSONWrongOrder, simpleFlightRouteLineStringGeoJSON, simpleFlightRoutePointsGeoJSON, simpleGeometryCollectionGeoJSON, simpleLineStringGeoJSON, simpleMultiPolygon, simplePointsGeojson, simplePolygonGeoJSON, simpleSmallLineStringGeoJSON, startToolExampleConfig, strokeWidthOptions, textLabelStyle, textStyle, textStyleWithMargin, updateEditModeButtonsWithFir, useAnimationForLayer, useEDRCollection, useEDRCollectionCube, useEDRCollectionLocation, useGeoJSON, useGetWMLayerInstance, useGetWMSLayerStyleList, useIconStyle, useMapDrawTool, useProjection, useQueryGetWMSGetCapabilities, useQueryGetWMSLayer, useQueryGetWMSLayers, useQueryGetWMSLayersTree, useQueryGetWMSServiceInfo, useQueryWMTSGetCapabilities, useSetIntervalWhenVisible, useViewFromLayer, viewUtils, webmapReactTranslations, wowTemperatureLegendColors };
|