@opengeoweb/webmap-react 9.25.3 → 9.26.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 +170 -99
- package/package.json +1 -1
- package/src/lib/components/MapDraw/MapDraw.d.ts +10 -10
- package/src/lib/components/MapDraw/MapDraw.stories.d.ts +4 -0
- package/src/lib/components/MapDraw/geojsonShapes.d.ts +0 -2
- package/src/lib/components/MapDraw/mapDrawUtils.d.ts +3 -3
- package/src/lib/components/MapDraw/storyComponents/geojsonExamples.d.ts +12 -11
- package/src/lib/components/ReactMapView/ReactMapView.d.ts +1 -1
- package/src/lib/layers/defaultStorybookSettings.d.ts +1 -1
package/index.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { useRef, useState, useEffect } from 'react';
|
|
4
4
|
import { legendImageStore, WMImageEventType, webmapUtils, getLegendGraphicURLForLayer, getPixelCoordFromLatLong, WMJSMAP_LONLAT_EPSGCODE, getLatLongFromPixelCoord, LayerType, getWMJSMapById, debugLogger, DebugType, WMLayer, registerWMLayer, WMBBOX, getWMLayerById, WMJSMap, tilesettings } from '@opengeoweb/webmap';
|
|
5
|
-
import { CustomTooltip, CanvasComponent, ToolContainerDraggable, CustomIconButton, dateUtils } from '@opengeoweb/shared';
|
|
5
|
+
import { CustomTooltip, CanvasComponent, ToolContainerDraggable, CustomIconButton, dateUtils, PROJECTION } from '@opengeoweb/shared';
|
|
6
6
|
import i18n from 'i18next';
|
|
7
7
|
import { initReactI18next, useTranslation } from 'react-i18next';
|
|
8
8
|
import { Paper, Box, Typography, Grid, TextField, FormControl, InputLabel, Select, MenuItem, Icon as Icon$1, FormLabel, Switch, styled, Slider } from '@mui/material';
|
|
@@ -2826,10 +2826,18 @@ const findClosestCoords = (positions, mouseX, mouseY) => {
|
|
|
2826
2826
|
});
|
|
2827
2827
|
return closestIndexes;
|
|
2828
2828
|
};
|
|
2829
|
-
const checkHoverVertice = (feature, mouseX, mouseY, convertGeoCoordsToScreenCoords, ignoreCoordinateIndexInFeature) => {
|
|
2829
|
+
const checkHoverVertice = (feature, mouseX, mouseY, convertGeoCoordsToScreenCoords, ignoreCoordinateIndexInFeature, geometry = feature.geometry) => {
|
|
2830
2830
|
const maxDistance = 20;
|
|
2831
|
-
if (
|
|
2832
|
-
const
|
|
2831
|
+
if (geometry.type === 'GeometryCollection') {
|
|
2832
|
+
for (const geom of geometry.geometries) {
|
|
2833
|
+
const result = checkHoverVertice(feature, mouseX, mouseY, convertGeoCoordsToScreenCoords, ignoreCoordinateIndexInFeature, geom);
|
|
2834
|
+
if (result) {
|
|
2835
|
+
return result;
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
if (geometry.type === 'Point') {
|
|
2840
|
+
const featureCoords = geometry.coordinates;
|
|
2833
2841
|
/* Get all vertexes */
|
|
2834
2842
|
const XYCoords = convertGeoCoordsToScreenCoords([featureCoords]);
|
|
2835
2843
|
const calculatedDistance = XYCoords.length > 0 ? distance(XYCoords[0], {
|
|
@@ -2844,9 +2852,9 @@ const checkHoverVertice = (feature, mouseX, mouseY, convertGeoCoordsToScreenCoor
|
|
|
2844
2852
|
};
|
|
2845
2853
|
}
|
|
2846
2854
|
}
|
|
2847
|
-
if (
|
|
2848
|
-
for (let polygonIndex =
|
|
2849
|
-
const featureCoords =
|
|
2855
|
+
if (geometry.type === 'MultiPoint') {
|
|
2856
|
+
for (let polygonIndex = geometry.coordinates.length - 1; polygonIndex >= 0; polygonIndex -= 1) {
|
|
2857
|
+
const featureCoords = geometry.coordinates[polygonIndex];
|
|
2850
2858
|
if (featureCoords === undefined) {
|
|
2851
2859
|
// eslint-disable-next-line no-continue
|
|
2852
2860
|
continue;
|
|
@@ -2866,10 +2874,10 @@ const checkHoverVertice = (feature, mouseX, mouseY, convertGeoCoordsToScreenCoor
|
|
|
2866
2874
|
}
|
|
2867
2875
|
}
|
|
2868
2876
|
}
|
|
2869
|
-
if (
|
|
2877
|
+
if (geometry.type === 'Polygon') {
|
|
2870
2878
|
const point = [mouseX, mouseY];
|
|
2871
|
-
for (let polygonIndex =
|
|
2872
|
-
const featureCoords =
|
|
2879
|
+
for (let polygonIndex = geometry.coordinates.length - 1; polygonIndex >= 0; polygonIndex -= 1) {
|
|
2880
|
+
const featureCoords = geometry.coordinates[polygonIndex];
|
|
2873
2881
|
if (featureCoords === undefined) {
|
|
2874
2882
|
// eslint-disable-next-line no-continue
|
|
2875
2883
|
continue;
|
|
@@ -2905,10 +2913,10 @@ const checkHoverVertice = (feature, mouseX, mouseY, convertGeoCoordsToScreenCoor
|
|
|
2905
2913
|
}
|
|
2906
2914
|
}
|
|
2907
2915
|
}
|
|
2908
|
-
if (
|
|
2916
|
+
if (geometry.type === 'MultiPolygon') {
|
|
2909
2917
|
const point = [mouseX, mouseY];
|
|
2910
|
-
for (let polygonIndex =
|
|
2911
|
-
const featureCoords =
|
|
2918
|
+
for (let polygonIndex = geometry.coordinates.length - 1; polygonIndex >= 0; polygonIndex -= 1) {
|
|
2919
|
+
const featureCoords = geometry.coordinates[polygonIndex][0];
|
|
2912
2920
|
if (featureCoords === undefined) {
|
|
2913
2921
|
// eslint-disable-next-line no-continue
|
|
2914
2922
|
continue;
|
|
@@ -2933,10 +2941,9 @@ const checkHoverVertice = (feature, mouseX, mouseY, convertGeoCoordsToScreenCoor
|
|
|
2933
2941
|
}
|
|
2934
2942
|
}
|
|
2935
2943
|
}
|
|
2936
|
-
if (
|
|
2937
|
-
const featureCoords = feature.geometry.coordinates;
|
|
2944
|
+
if (geometry.type === 'LineString') {
|
|
2938
2945
|
/* Get all vertexes */
|
|
2939
|
-
const XYCoords = convertGeoCoordsToScreenCoords(
|
|
2946
|
+
const XYCoords = convertGeoCoordsToScreenCoords(geometry.coordinates);
|
|
2940
2947
|
/* Snap to the vertex closer than specified pixels */
|
|
2941
2948
|
for (let j = 0; j < XYCoords.length; j += 1) {
|
|
2942
2949
|
const coord = XYCoords[j];
|
|
@@ -3146,7 +3153,7 @@ class MapDraw extends React.PureComponent {
|
|
|
3146
3153
|
constructor(props) {
|
|
3147
3154
|
super(props);
|
|
3148
3155
|
this.handleGeoJSONUpdate = newGeoJSON => {
|
|
3149
|
-
var _a;
|
|
3156
|
+
var _a, _b;
|
|
3150
3157
|
const {
|
|
3151
3158
|
selectedFeatureIndex,
|
|
3152
3159
|
mapId
|
|
@@ -3155,13 +3162,15 @@ class MapDraw extends React.PureComponent {
|
|
|
3155
3162
|
/* Ensure that this.snappedPolygonIndex is still within the coordinates array */
|
|
3156
3163
|
if (((_a = this.geojson) === null || _a === void 0 ? void 0 : _a.features) && selectedFeatureIndex < this.geojson.features.length) {
|
|
3157
3164
|
const feature = this.getSelectedFeature();
|
|
3158
|
-
if (feature.geometry) {
|
|
3165
|
+
if (((_b = feature.geometry) === null || _b === void 0 ? void 0 : _b.type) === 'Polygon') {
|
|
3159
3166
|
const {
|
|
3160
3167
|
coordinates
|
|
3161
3168
|
} = feature.geometry;
|
|
3162
3169
|
if (Number(this.snappedPolygonIndex) > coordinates.length - 1) {
|
|
3163
3170
|
this.snappedPolygonIndex = coordinates.length - 1;
|
|
3164
3171
|
}
|
|
3172
|
+
} else {
|
|
3173
|
+
this.snappedPolygonIndex = SNAPPEDFEATURE.NONE;
|
|
3165
3174
|
}
|
|
3166
3175
|
}
|
|
3167
3176
|
const webmapjs = webmapUtils.getWMJSMapById(mapId);
|
|
@@ -3175,8 +3184,8 @@ class MapDraw extends React.PureComponent {
|
|
|
3175
3184
|
if (this.myDrawMode === DRAWMODE.POLYGON && this.myEditMode === EDITMODE.ADD_FEATURE) {
|
|
3176
3185
|
const currentFeature = this.getSelectedFeature();
|
|
3177
3186
|
const currentGeometry = currentFeature.geometry;
|
|
3178
|
-
const coordinates = currentGeometry.coordinates[0];
|
|
3179
3187
|
if (currentGeometry.type === 'Polygon') {
|
|
3188
|
+
const coordinates = currentGeometry.coordinates[0];
|
|
3180
3189
|
const firstElement = coordinates[0];
|
|
3181
3190
|
coordinates[this.mouseIsOverVertexNr] = cloneDeep(firstElement);
|
|
3182
3191
|
}
|
|
@@ -3357,7 +3366,7 @@ class MapDraw extends React.PureComponent {
|
|
|
3357
3366
|
mapId
|
|
3358
3367
|
} = this.props;
|
|
3359
3368
|
const feature = this.getSelectedFeature();
|
|
3360
|
-
if (feature) {
|
|
3369
|
+
if (feature && feature.geometry.type !== 'GeometryCollection') {
|
|
3361
3370
|
const featureCoords = feature.geometry.coordinates;
|
|
3362
3371
|
this.mouseIsOverVertexNr = featureCoords.length - 1;
|
|
3363
3372
|
}
|
|
@@ -3945,11 +3954,13 @@ class MapDraw extends React.PureComponent {
|
|
|
3945
3954
|
deletePolygonCallback
|
|
3946
3955
|
} = this.props;
|
|
3947
3956
|
const feature = this.getSelectedFeature();
|
|
3948
|
-
feature.geometry.
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3957
|
+
if (feature.geometry.type !== 'GeometryCollection') {
|
|
3958
|
+
feature.geometry.coordinates.splice(index, 1);
|
|
3959
|
+
if (deletePolygonCallback) {
|
|
3960
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3961
|
+
// @ts-ignore
|
|
3962
|
+
deletePolygonCallback();
|
|
3963
|
+
}
|
|
3953
3964
|
}
|
|
3954
3965
|
}
|
|
3955
3966
|
deleteFeature() {
|
|
@@ -4100,9 +4111,12 @@ class MapDraw extends React.PureComponent {
|
|
|
4100
4111
|
}
|
|
4101
4112
|
}
|
|
4102
4113
|
moveVertex(feature, mouseDown) {
|
|
4103
|
-
const
|
|
4114
|
+
const geometryType = feature.geometry.type;
|
|
4115
|
+
if (geometryType === 'GeometryCollection') {
|
|
4116
|
+
return undefined;
|
|
4117
|
+
}
|
|
4104
4118
|
let featureCoords = feature.geometry.coordinates[this.snappedPolygonIndex];
|
|
4105
|
-
if (
|
|
4119
|
+
if (geometryType === 'Point' || geometryType === 'MultiPoint' || geometryType === 'LineString') {
|
|
4106
4120
|
featureCoords = feature.geometry.coordinates;
|
|
4107
4121
|
}
|
|
4108
4122
|
if (!featureCoords) {
|
|
@@ -4110,7 +4124,7 @@ class MapDraw extends React.PureComponent {
|
|
|
4110
4124
|
}
|
|
4111
4125
|
const vertexSelected = mouseDown === true && this.mouseIsOverVertexNr !== VERTEX.NONE;
|
|
4112
4126
|
if (vertexSelected || this.myEditMode === EDITMODE.ADD_FEATURE) {
|
|
4113
|
-
if (
|
|
4127
|
+
if (geometryType === 'LineString') {
|
|
4114
4128
|
this.transposeVertex(featureCoords);
|
|
4115
4129
|
// eslint-disable-next-line consistent-return
|
|
4116
4130
|
return false;
|
|
@@ -4238,7 +4252,7 @@ class MapDraw extends React.PureComponent {
|
|
|
4238
4252
|
}
|
|
4239
4253
|
}
|
|
4240
4254
|
// eslint-disable-next-line class-methods-use-this
|
|
4241
|
-
|
|
4255
|
+
initializeFeature(feature) {
|
|
4242
4256
|
if (!feature.properties) {
|
|
4243
4257
|
feature.properties = {};
|
|
4244
4258
|
}
|
|
@@ -4248,7 +4262,7 @@ class MapDraw extends React.PureComponent {
|
|
|
4248
4262
|
if (!feature.type) {
|
|
4249
4263
|
feature.type = 'Feature';
|
|
4250
4264
|
}
|
|
4251
|
-
if (!feature.geometry.coordinates) {
|
|
4265
|
+
if (feature.geometry.type !== 'GeometryCollection' && !feature.geometry.coordinates) {
|
|
4252
4266
|
feature.geometry.coordinates = [];
|
|
4253
4267
|
}
|
|
4254
4268
|
}
|
|
@@ -4259,7 +4273,7 @@ class MapDraw extends React.PureComponent {
|
|
|
4259
4273
|
}
|
|
4260
4274
|
for (const geoJsonFeature of this.geojson.features) {
|
|
4261
4275
|
const feature = geoJsonFeature;
|
|
4262
|
-
this.
|
|
4276
|
+
this.initializeFeature(feature);
|
|
4263
4277
|
const featureType = feature.geometry.type;
|
|
4264
4278
|
if (featureType === 'Polygon') {
|
|
4265
4279
|
/* Loop through all polygons of the same feature */
|
|
@@ -4328,28 +4342,16 @@ class MapDraw extends React.PureComponent {
|
|
|
4328
4342
|
this.textPositions = [];
|
|
4329
4343
|
this.mouseOverPolygonCoordinates = [];
|
|
4330
4344
|
this.mouseOverPolygonFeatureIndex = -1;
|
|
4331
|
-
const
|
|
4345
|
+
const drawFeatureGeometry = (feature, featureIndex, geometry = feature.geometry) => {
|
|
4332
4346
|
var _a, _b, _c;
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
y: 0,
|
|
4337
|
-
nr: 0
|
|
4338
|
-
};
|
|
4339
|
-
if (featureType === 'Point') {
|
|
4340
|
-
const featureCoords = feature.geometry.coordinates;
|
|
4341
|
-
const XYCoords = getPixelCoordFromGeoCoord([featureCoords], mapId);
|
|
4342
|
-
if (XYCoords.length === 0) {
|
|
4343
|
-
// eslint-disable-next-line no-continue
|
|
4344
|
-
return;
|
|
4345
|
-
}
|
|
4346
|
-
for (let j = 0; j < XYCoords.length; j += 1) {
|
|
4347
|
-
this.drawPoint(ctx, XYCoords[j], this.mouseIsOverVertexNr === j && selectedFeatureIndex === featureIndex, false, isInEditMode && selectedFeatureIndex === featureIndex, feature, featureIndex);
|
|
4347
|
+
if (geometry.type === 'GeometryCollection') {
|
|
4348
|
+
for (const geom of geometry.geometries) {
|
|
4349
|
+
drawFeatureGeometry(feature, featureIndex, geom);
|
|
4348
4350
|
}
|
|
4349
4351
|
}
|
|
4350
|
-
if (
|
|
4351
|
-
const
|
|
4352
|
-
const XYCoords = getPixelCoordFromGeoCoord(
|
|
4352
|
+
if (geometry.type === 'Point' || geometry.type === 'MultiPoint') {
|
|
4353
|
+
const coordinates = geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates;
|
|
4354
|
+
const XYCoords = getPixelCoordFromGeoCoord(coordinates, mapId);
|
|
4353
4355
|
if (XYCoords.length === 0) {
|
|
4354
4356
|
return;
|
|
4355
4357
|
}
|
|
@@ -4357,12 +4359,16 @@ class MapDraw extends React.PureComponent {
|
|
|
4357
4359
|
this.drawPoint(ctx, XYCoords[j], this.mouseIsOverVertexNr === j && selectedFeatureIndex === featureIndex, false, isInEditMode && selectedFeatureIndex === featureIndex, feature, featureIndex);
|
|
4358
4360
|
}
|
|
4359
4361
|
}
|
|
4360
|
-
if (
|
|
4361
|
-
const
|
|
4362
|
-
|
|
4362
|
+
if (geometry.type === 'MultiPolygon') {
|
|
4363
|
+
const totalMiddle = {
|
|
4364
|
+
x: 0,
|
|
4365
|
+
y: 0,
|
|
4366
|
+
nr: 0
|
|
4367
|
+
};
|
|
4368
|
+
for (const multiPoly of geometry.coordinates) {
|
|
4363
4369
|
for (let polygonIndex = 0; polygonIndex < multiPoly.length; polygonIndex += 1) {
|
|
4364
|
-
const
|
|
4365
|
-
const XYCoords = getPixelCoordFromGeoCoord(
|
|
4370
|
+
const ringCoordinates = multiPoly[polygonIndex];
|
|
4371
|
+
const XYCoords = getPixelCoordFromGeoCoord(ringCoordinates, mapId);
|
|
4366
4372
|
/* Only draw if there is stuff to show */
|
|
4367
4373
|
if (XYCoords.length === 0) {
|
|
4368
4374
|
// eslint-disable-next-line no-continue
|
|
@@ -4370,9 +4376,9 @@ class MapDraw extends React.PureComponent {
|
|
|
4370
4376
|
}
|
|
4371
4377
|
const middle = this.drawPolygon(ctx, XYCoords, featureIndex, polygonIndex);
|
|
4372
4378
|
if (middle) {
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4379
|
+
totalMiddle.x += middle.x * middle.nr;
|
|
4380
|
+
totalMiddle.y += middle.y * middle.nr;
|
|
4381
|
+
totalMiddle.nr += middle.nr;
|
|
4376
4382
|
}
|
|
4377
4383
|
if (isInEditMode) {
|
|
4378
4384
|
/* Draw all vertices on the edges of the polygons */
|
|
@@ -4386,9 +4392,9 @@ class MapDraw extends React.PureComponent {
|
|
|
4386
4392
|
}
|
|
4387
4393
|
}
|
|
4388
4394
|
}
|
|
4389
|
-
if (
|
|
4390
|
-
const mx =
|
|
4391
|
-
const my =
|
|
4395
|
+
if (totalMiddle.nr > 0) {
|
|
4396
|
+
const mx = totalMiddle.x / totalMiddle.nr;
|
|
4397
|
+
const my = totalMiddle.y / totalMiddle.nr;
|
|
4392
4398
|
if ((_a = feature.properties) === null || _a === void 0 ? void 0 : _a.text) {
|
|
4393
4399
|
this.textPositions.push({
|
|
4394
4400
|
x: mx,
|
|
@@ -4398,11 +4404,10 @@ class MapDraw extends React.PureComponent {
|
|
|
4398
4404
|
}
|
|
4399
4405
|
}
|
|
4400
4406
|
}
|
|
4401
|
-
if (
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
const featureCoords = polygonGeometry.coordinates[polygonIndex];
|
|
4407
|
+
if (geometry.type === 'Polygon') {
|
|
4408
|
+
/* Loop through all rings of the same polygon */
|
|
4409
|
+
for (let polygonIndex = 0; polygonIndex < geometry.coordinates.length; polygonIndex += 1) {
|
|
4410
|
+
const featureCoords = geometry.coordinates[polygonIndex];
|
|
4406
4411
|
const XYCoords = getPixelCoordFromGeoCoord(featureCoords, mapId);
|
|
4407
4412
|
/* Only draw if there is stuff to show */
|
|
4408
4413
|
if (XYCoords.length === 0) {
|
|
@@ -4432,9 +4437,9 @@ class MapDraw extends React.PureComponent {
|
|
|
4432
4437
|
}
|
|
4433
4438
|
}
|
|
4434
4439
|
}
|
|
4435
|
-
if (
|
|
4440
|
+
if (geometry.type === 'LineString') {
|
|
4436
4441
|
/* Loop through all line pints of the same feature */
|
|
4437
|
-
const featureCoords =
|
|
4442
|
+
const featureCoords = geometry.coordinates;
|
|
4438
4443
|
if (!featureCoords || !featureCoords.length) {
|
|
4439
4444
|
return;
|
|
4440
4445
|
}
|
|
@@ -4464,11 +4469,11 @@ class MapDraw extends React.PureComponent {
|
|
|
4464
4469
|
const feature = this.geojson.features[featureIndex];
|
|
4465
4470
|
/* Do not draw selected feature here, should be done last */
|
|
4466
4471
|
if (featureIndex !== selectedFeatureIndex) {
|
|
4467
|
-
|
|
4472
|
+
drawFeatureGeometry(feature, featureIndex);
|
|
4468
4473
|
}
|
|
4469
4474
|
}
|
|
4470
4475
|
/* Draw selected feature to display it on top */
|
|
4471
|
-
|
|
4476
|
+
drawFeatureGeometry(this.getSelectedFeature(), selectedFeatureIndex);
|
|
4472
4477
|
/* Higlight polygon with mousehover */
|
|
4473
4478
|
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) {
|
|
4474
4479
|
const feature = this.getSelectedFeature();
|
|
@@ -4544,12 +4549,17 @@ class MapDraw extends React.PureComponent {
|
|
|
4544
4549
|
mapId
|
|
4545
4550
|
} = this.props;
|
|
4546
4551
|
const {
|
|
4547
|
-
|
|
4548
|
-
type
|
|
4552
|
+
type: geometryType
|
|
4549
4553
|
} = geometry;
|
|
4550
|
-
if (
|
|
4551
|
-
|
|
4552
|
-
|
|
4554
|
+
if (geometryType === 'GeometryCollection') {
|
|
4555
|
+
return {
|
|
4556
|
+
selectedEdge: EDGE.NONE,
|
|
4557
|
+
snappedPolygonIndex: SNAPPEDFEATURE.NONE
|
|
4558
|
+
};
|
|
4559
|
+
}
|
|
4560
|
+
if (geometryType === 'Polygon') {
|
|
4561
|
+
for (let polygonIndex = geometry.coordinates.length - 1; polygonIndex >= 0; polygonIndex -= 1) {
|
|
4562
|
+
const featureCoords = geometry.coordinates[polygonIndex];
|
|
4553
4563
|
if (featureCoords === undefined) {
|
|
4554
4564
|
// eslint-disable-next-line no-continue
|
|
4555
4565
|
continue;
|
|
@@ -4575,8 +4585,8 @@ class MapDraw extends React.PureComponent {
|
|
|
4575
4585
|
snappedPolygonIndex: SNAPPEDFEATURE.NONE
|
|
4576
4586
|
};
|
|
4577
4587
|
}
|
|
4578
|
-
if (
|
|
4579
|
-
const featureCoords = coordinates;
|
|
4588
|
+
if (geometryType === 'LineString') {
|
|
4589
|
+
const featureCoords = geometry.coordinates;
|
|
4580
4590
|
if (featureCoords === undefined) {
|
|
4581
4591
|
return {
|
|
4582
4592
|
selectedEdge: EDGE.NONE,
|
|
@@ -4823,10 +4833,7 @@ class MapDraw extends React.PureComponent {
|
|
|
4823
4833
|
selectedFeatureIndex
|
|
4824
4834
|
} = this.props;
|
|
4825
4835
|
const feature = this.geojson.features[featureIndex];
|
|
4826
|
-
if (!(feature === null || feature === void 0 ? void 0 : feature.geometry)) {
|
|
4827
|
-
return;
|
|
4828
|
-
}
|
|
4829
|
-
if (feature.geometry.type !== 'Polygon' && feature.geometry.type !== 'MultiPolygon') {
|
|
4836
|
+
if (!(feature === null || feature === void 0 ? void 0 : feature.geometry) || XYCoords.length === 0) {
|
|
4830
4837
|
return;
|
|
4831
4838
|
}
|
|
4832
4839
|
let polyProps = feature.properties;
|
|
@@ -4893,7 +4900,7 @@ class MapDraw extends React.PureComponent {
|
|
|
4893
4900
|
return middle;
|
|
4894
4901
|
}
|
|
4895
4902
|
initializeFeatureCoordinates(feature, type) {
|
|
4896
|
-
this.
|
|
4903
|
+
this.initializeFeature(feature);
|
|
4897
4904
|
// eslint-disable-next-line no-underscore-dangle
|
|
4898
4905
|
if (feature.properties._type) {
|
|
4899
4906
|
delete feature.properties._type;
|
|
@@ -4905,27 +4912,32 @@ class MapDraw extends React.PureComponent {
|
|
|
4905
4912
|
break;
|
|
4906
4913
|
case DRAWMODE.MULTIPOINT:
|
|
4907
4914
|
feature.geometry.type = 'MultiPoint';
|
|
4908
|
-
if (feature.geometry.coordinates.length === 0) {
|
|
4909
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4910
|
-
feature.geometry.coordinates.push([]);
|
|
4911
|
-
}
|
|
4912
4915
|
break;
|
|
4913
4916
|
case DRAWMODE.BOX:
|
|
4914
4917
|
feature.geometry.type = 'Polygon';
|
|
4915
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
4916
4918
|
feature.properties._type = 'box';
|
|
4917
4919
|
break;
|
|
4918
4920
|
case DRAWMODE.POLYGON:
|
|
4919
4921
|
feature.geometry.type = 'Polygon';
|
|
4922
|
+
break;
|
|
4923
|
+
case DRAWMODE.LINESTRING:
|
|
4924
|
+
feature.geometry.type = 'LineString';
|
|
4925
|
+
break;
|
|
4926
|
+
}
|
|
4927
|
+
// eslint-disable-next-line default-case
|
|
4928
|
+
switch (feature.geometry.type) {
|
|
4929
|
+
case 'MultiPoint':
|
|
4920
4930
|
if (feature.geometry.coordinates.length === 0) {
|
|
4921
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4922
4931
|
feature.geometry.coordinates.push([]);
|
|
4923
4932
|
}
|
|
4924
4933
|
break;
|
|
4925
|
-
case
|
|
4926
|
-
feature.
|
|
4934
|
+
case 'Polygon':
|
|
4935
|
+
if (feature.properties._type !== 'box' && feature.geometry.coordinates.length === 0) {
|
|
4936
|
+
feature.geometry.coordinates.push([]);
|
|
4937
|
+
}
|
|
4938
|
+
break;
|
|
4939
|
+
case 'LineString':
|
|
4927
4940
|
if (feature.geometry.coordinates.length === 0) {
|
|
4928
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4929
4941
|
feature.geometry.coordinates.push([]);
|
|
4930
4942
|
}
|
|
4931
4943
|
break;
|
|
@@ -5592,6 +5604,65 @@ const intersectionFeatureBE = {
|
|
|
5592
5604
|
},
|
|
5593
5605
|
properties: defaultGeoJSONStyleProperties
|
|
5594
5606
|
};
|
|
5607
|
+
const simpleGeometryCollectionGeoJSON = {
|
|
5608
|
+
type: 'FeatureCollection',
|
|
5609
|
+
features: [{
|
|
5610
|
+
type: 'Feature',
|
|
5611
|
+
properties: {
|
|
5612
|
+
stroke: '#8F8',
|
|
5613
|
+
'stroke-width': 4,
|
|
5614
|
+
'stroke-opacity': 1,
|
|
5615
|
+
fill: '#33ccFF',
|
|
5616
|
+
'fill-opacity': 0.5,
|
|
5617
|
+
country: 'Finland',
|
|
5618
|
+
details: {
|
|
5619
|
+
identifier: '2.49.0.0.246.0.FI.240410113246.jma418B852H2nBY1ntp3',
|
|
5620
|
+
severity: 'Moderate',
|
|
5621
|
+
certainty: 'Possible',
|
|
5622
|
+
onset: '2024-04-11T12:00:00+03:00',
|
|
5623
|
+
expires: '2024-04-11T18:00:00+03:00',
|
|
5624
|
+
languages: [{
|
|
5625
|
+
language: 'fi-FI',
|
|
5626
|
+
event: 'Tuulivaroitus maa-alueille',
|
|
5627
|
+
senderName: 'Ilmatieteen laitos',
|
|
5628
|
+
headline: '',
|
|
5629
|
+
description: 'Tuulivaroitus maa-alueille: Länsituuli on voimakasta iltapäivällä, tuulen nopeus puuskissa 20 m/s.',
|
|
5630
|
+
areaDesc: 'Kainuu, Pudasjärvi, Taivalkoski, Kuusamo'
|
|
5631
|
+
}, {
|
|
5632
|
+
language: 'sv-SE',
|
|
5633
|
+
event: 'Vindvarning för landområden',
|
|
5634
|
+
senderName: 'Meteorologiska institutet',
|
|
5635
|
+
headline: '',
|
|
5636
|
+
description: 'Vindvarning för landområden: På eftermiddagen är den västliga vinden kraftigt, i vindbyarna 20 m/s.',
|
|
5637
|
+
areaDesc: 'Kainuu, Pudasjärvi, Taivalkoski, Kuusamo'
|
|
5638
|
+
}, {
|
|
5639
|
+
language: 'en-GB',
|
|
5640
|
+
event: 'Wind warning for land areas',
|
|
5641
|
+
senderName: 'Finnish Meteorological Institute',
|
|
5642
|
+
headline: '',
|
|
5643
|
+
description: 'Wind warning for land areas: In the afternoon, strong winds from west may bring strong gusts of 20 m/s.',
|
|
5644
|
+
areaDesc: 'Kainuu, Pudasjärvi, Taivalkoski, Kuusamo'
|
|
5645
|
+
}]
|
|
5646
|
+
}
|
|
5647
|
+
},
|
|
5648
|
+
geometry: {
|
|
5649
|
+
type: 'GeometryCollection',
|
|
5650
|
+
geometries: [{
|
|
5651
|
+
type: 'MultiPolygon',
|
|
5652
|
+
coordinates: [[[[29.758392564346536, 65.49273540846954], [29.71941427879389, 65.49638044528335], [29.21459755302349, 65.51209391081191], [29.170693731268035, 65.5197800533191], [29.147217916080326, 65.50275296777002], [28.633374093002843, 65.3721705402633], [28.18723681698394, 65.25672404742585], [28.14911332514444, 65.24984205608105], [28.111118852458272, 65.24063653209379], [27.693819807358636, 65.16109646665383], [27.33039713116483, 65.09068209391778], [27.332840574130387, 65.0387703089369], [27.326646217967365, 64.97976270671202], [27.157653690059732, 64.83986451042715], [27.126612443366312, 64.82736609485796], [26.916420458938006, 64.76188902343115], [26.886428080039778, 64.75000916898261], [26.467815769740625, 64.56827471246525], [26.334511209056984, 64.50150678855421], [26.305590843292137, 64.47468873954321], [26.339316861749918, 64.44776636198924], [26.504854495183764, 64.3399621504545], [26.526789567510534, 64.3210451684454], [26.64680093131525, 64.20565204411693], [26.805502956254468, 64.05176843450018], [26.822846233907782, 64.02833008717302], [26.866302819035326, 64.02149244583438], [27.25090982244751, 63.95456911474786], [27.63394361227682, 63.88676185094127], [28.01539289698782, 63.81807690948368], [28.336001020870327, 63.75944634860591], [28.36953495057645, 63.75291483074939], [28.38146960707695, 63.780308294502746], [28.453212390927888, 63.86320698957978], [28.488122426266656, 63.87072168747777], [29.061327279544, 63.87578318437369], [29.67289940508833, 63.87894724382795], [29.701281337390554, 63.87096916155944], [29.95452767634896, 63.762659061713634], [29.991551532456302, 63.74790651378042], [30.022558687101863, 63.76119168003561], [30.214883314310555, 63.81188283894816], [30.24646259407193, 63.8240131577964], [30.45743761263076, 63.98659320159419], [30.485808880817984, 64.00962934474863], [30.528497757656666, 64.05664110171924], [30.54104187728157, 64.08719012709481], [30.548808176296486, 64.12087568595071], [30.519336467341862, 64.20177024842253], [30.501794237261407, 64.23261663433796], [30.4770997493347, 64.25733643782799], [30.278855247194695, 64.32813156135076], [30.249923179452413, 64.34139133102182], [30.034923434023412, 64.50055888989162], [30.006675740312176, 64.52232084337746], [29.843095805108717, 64.6732364080745], [29.698703502979736, 64.8052603050698], [29.677920179868693, 64.82640388377037], [29.638540921311844, 64.88072887102366], [29.62541734471698, 64.90735364979494], [29.60157369391645, 64.9718516701184], [29.597607059999827, 64.9972352266183], [29.669945543777658, 65.23518451106732], [29.73413551222892, 65.44365355519507], [29.743985637492894, 65.469616744196], [29.758392564346536, 65.49273540846954]]]]
|
|
5653
|
+
}, {
|
|
5654
|
+
type: 'MultiPolygon',
|
|
5655
|
+
coordinates: [[[[27.766520457815957, 65.8195160088791], [27.73085604057836, 65.83947485866196], [27.45820033758423, 65.9493211039968], [27.430865666979813, 65.9554713265499], [27.407432994387463, 65.93839022633652], [27.17343408151436, 65.79130783497929], [27.13700155265117, 65.7748045054381], [27.043143659347365, 65.74146868282556], [26.93212618070619, 65.72018457880594], [26.770113943520442, 65.70598902727579], [26.723301465692543, 65.70590768662042], [26.387054877123173, 65.71366432114496], [26.158116226051387, 65.7257708265435], [26.154050492787476, 65.48723563080719], [26.158292174759623, 65.41018287503542], [26.226082500593677, 65.28786857013642], [26.24918073602433, 65.26064963421615], [26.311435369016323, 65.20611737168086], [26.34746159341583, 65.19097379678617], [26.47064990531538, 65.14852904702708], [26.617354013993747, 65.10039082072402], [26.658172378514152, 65.09683493161036], [26.7850977917127, 65.09445840537802], [27.33039713116483, 65.09068209391778], [27.693819807358636, 65.16109646665383], [28.111118852458272, 65.24063653209379], [28.14911332514444, 65.24984205608105], [28.141796473873793, 65.28201842856463], [28.04237271730372, 65.42610665418935], [27.942039909829926, 65.57026895303783], [27.766520457815957, 65.8195160088791]]]]
|
|
5656
|
+
}, {
|
|
5657
|
+
type: 'MultiPolygon',
|
|
5658
|
+
coordinates: [[[[29.170693731268035, 65.5197800533191], [29.130087050229307, 65.54237017185336], [28.793692264131735, 65.71359634271593], [28.549640756625106, 65.83637062837917], [28.52068592987659, 65.85585413976165], [28.48883706877227, 65.85421373746401], [28.124779448491477, 65.84111872142014], [27.79622169654993, 65.82862408942168], [27.766520457815957, 65.8195160088791], [27.942039909829926, 65.57026895303783], [28.04237271730372, 65.42610665418935], [28.141796473873793, 65.28201842856463], [28.14911332514444, 65.24984205608105], [28.18723681698394, 65.25672404742585], [28.633374093002843, 65.3721705402633], [29.147217916080326, 65.50275296777002], [29.170693731268035, 65.5197800533191]]]]
|
|
5659
|
+
}, {
|
|
5660
|
+
type: 'MultiPolygon',
|
|
5661
|
+
coordinates: [[[[29.568191250285462, 66.43045265195359], [29.527651742524338, 66.42954425078428], [29.167149655693773, 66.45472209596944], [28.72266047369712, 66.48468310371933], [28.68788794031491, 66.4858456386077], [28.686129727583417, 66.45685684583327], [28.616947548792908, 66.21978395191063], [28.57140958210226, 66.06194633146768], [28.526330219060455, 65.90427238999632], [28.52068592987659, 65.85585413976165], [28.549640756625106, 65.83637062837917], [28.793692264131735, 65.71359634271593], [29.130087050229307, 65.54237017185336], [29.170693731268035, 65.5197800533191], [29.21459755302349, 65.51209391081191], [29.71941427879389, 65.49638044528335], [29.758392564346536, 65.49273540846954], [29.803357612639658, 65.51348157207968], [30.11053968124635, 65.65921283899507], [30.124309492013527, 65.69970034115639], [30.121904515243088, 65.75312552789165], [30.108659610722114, 65.8017236758968], [30.093512380951722, 65.84734580681476], [30.05919479177051, 65.92010170197672], [29.930537319625472, 66.1076962309863], [29.91149731454561, 66.13245763550866], [29.74544846833132, 66.28135761175152], [29.5988415801629, 66.41164508252187], [29.568191250285462, 66.43045265195359]]]]
|
|
5662
|
+
}]
|
|
5663
|
+
}
|
|
5664
|
+
}]
|
|
5665
|
+
};
|
|
5595
5666
|
|
|
5596
5667
|
const drawPolyStoryStyles = {
|
|
5597
5668
|
MapDrawGeoJSONContainer: {
|
|
@@ -6003,13 +6074,13 @@ const getGeoJson = (geojson, shouldAllowMultipleShapes) => {
|
|
|
6003
6074
|
const {
|
|
6004
6075
|
geometry
|
|
6005
6076
|
} = geojson.features[0];
|
|
6006
|
-
if (geometry.type === '
|
|
6007
|
-
return geojson
|
|
6077
|
+
if (geometry.type === 'Polygon' && geometry.coordinates.length > 1) {
|
|
6078
|
+
return produce(geojson, draft => {
|
|
6079
|
+
const draftFeature = draft.features[0];
|
|
6080
|
+
draftFeature.geometry.coordinates = [draftFeature.geometry.coordinates[1]];
|
|
6081
|
+
});
|
|
6008
6082
|
}
|
|
6009
|
-
return
|
|
6010
|
-
const draftFeature = draft.features[0];
|
|
6011
|
-
draftFeature.geometry.coordinates = [draftFeature.geometry.coordinates[1]];
|
|
6012
|
-
}) : geojson;
|
|
6083
|
+
return geojson;
|
|
6013
6084
|
};
|
|
6014
6085
|
const hasFeatures = geometry => {
|
|
6015
6086
|
if (geometry.type === 'Point') {
|
|
@@ -10392,7 +10463,7 @@ class ReactMapView extends React.Component {
|
|
|
10392
10463
|
}
|
|
10393
10464
|
}
|
|
10394
10465
|
ReactMapView.defaultProps = {
|
|
10395
|
-
srs:
|
|
10466
|
+
srs: PROJECTION.EPSG_3857.value,
|
|
10396
10467
|
bbox: {
|
|
10397
10468
|
left: -2324980.5498391856,
|
|
10398
10469
|
bottom: 5890854.775012179,
|
|
@@ -12399,4 +12470,4 @@ var publicLayers = /*#__PURE__*/Object.freeze({
|
|
|
12399
12470
|
veiligheidsRegiosGebiedsIndelingenLabels: veiligheidsRegiosGebiedsIndelingenLabels
|
|
12400
12471
|
});
|
|
12401
12472
|
|
|
12402
|
-
export { DRAWMODE, DimensionSelectButton, DimensionSelectDialog, DimensionSelectSlider, EDITMODE, EditModeButton as EditModeButtonField, FeatureLayers, GeoJSONTextField, IntersectionSelect, LayerInfoButton, LayerInfoDialog, LayerInfoLegend, LayerInfoList, LayerInfoText, Legend, LegendButton, LegendDialog, LegendLayout, MINUTE_TO_MILLISECOND, MapControlButton, MapControls, MapDimensionSelect, MapDrawContainer, MapTime, MapView, MapViewLayer, MapWarningProperties, NEW_FEATURE_CREATED, NEW_LINESTRING_CREATED, NEW_POINT_CREATED, ORIGIN_REACTMAPVIEW_ONMAPCHANGEDIMENSION, ORIGIN_REACTMAPVIEW_ONUPDATELAYERINFO, Proj4js, radarGetCapabilities_spec as RadarGetCapabilities, ReactMapView, ReactMapViewLayer, SelectField, StoryLayoutGrid, WEBMAP_REACT_NAMESPACE, ZoomControls, addFeatureProperties, addGeoJSONProperties, addSelectionTypeToGeoJSON, addWMLayerPropsBasedOnChildProps, basicExampleDrawOptions, basicExampleMultipleShapeDrawOptions, basicExampleMultipleShapeWithValuesDrawOptions, checkHoverFeatures, convertGeoCoordsToScreenCoords, createInterSections, currentlySupportedDrawModes, defaultBox, defaultDelete, defaultGeoJSONStyleProperties, defaultIntersectionStyleProperties, defaultLayers, defaultModes, defaultPoint, defaultPolygon, defaultTimeFormat, dimensionConfig, distance, drawPolyStoryStyles, emptyGeoJSON, endToolExampleConfig, exampleIntersectionOptions, exampleIntersectionWithShapeOptions, exampleIntersections, exampleIntersectionsMultiDrawTool, featureBox, featureMultiPoint, featurePoint, featurePolygon, fillOptions, findClosestCoords, firSelectionType, formatTime, getCurrentDimensionValue, getDimensionIcon, getDimensionLabel, getDimensionValue, getDimensionsList, getDoubleControlToolIcon, getDrawFunctionFromStore, getFeatureCollection, getFeatureExtent, getFeatureLayers, getFirTitle, getGeoJSONPropertyValue, getGeoJson, getIcon, getIntersectionToolIcon, getIsInsideAcceptanceTime, getLastEmptyFeatureIndex, getLayerBbox, getLayerStyles, getLayerUpdateInfo, getPixelCoordFromGeoCoord, getProj4, getTimeDimension, getToolIcon, intersectPointGeoJSONS, intersectPolygonGeoJSONS, intersectionFeatureBE, intersectionFeatureNL, isAGeoJSONLayer, isAMapLayer, isBetween, isGeoJSONFeatureCreatedByTool, isPointFeatureCollection, lineString, lineStringCollection, makeLayerPropListFromChildren, marksByDimension, moveFeature, opacityOptions, orderLayers, parseWMJSLayer, projectorCache, publicLayers, publicServices, registerDrawFunction, removeWMLayerFromMap, rewindGeometry, setWMLayerPropsBasedOnChildProps, simpleBoxGeoJSON, simpleBoxGeoJSONWrongOrder, simpleFlightRouteLineStringGeoJSON, simpleFlightRoutePointsGeoJSON, simpleLineStringGeoJSON, simpleMultiPolygon, simplePointsGeojson, simplePolygonGeoJSON, simpleSmallLineStringGeoJSON, startToolExampleConfig, strokeWidthOptions, textStyle, textStyleWithMargin, updateEditModeButtonsWithFir, useGeoJSON, useMapDrawTool, webmapReactTranslations };
|
|
12473
|
+
export { DRAWMODE, DimensionSelectButton, DimensionSelectDialog, DimensionSelectSlider, EDITMODE, EditModeButton as EditModeButtonField, FeatureLayers, GeoJSONTextField, IntersectionSelect, LayerInfoButton, LayerInfoDialog, LayerInfoLegend, LayerInfoList, LayerInfoText, Legend, LegendButton, LegendDialog, LegendLayout, MINUTE_TO_MILLISECOND, MapControlButton, MapControls, MapDimensionSelect, MapDrawContainer, MapTime, MapView, MapViewLayer, MapWarningProperties, NEW_FEATURE_CREATED, NEW_LINESTRING_CREATED, NEW_POINT_CREATED, ORIGIN_REACTMAPVIEW_ONMAPCHANGEDIMENSION, ORIGIN_REACTMAPVIEW_ONUPDATELAYERINFO, Proj4js, radarGetCapabilities_spec as RadarGetCapabilities, ReactMapView, ReactMapViewLayer, SelectField, StoryLayoutGrid, WEBMAP_REACT_NAMESPACE, ZoomControls, addFeatureProperties, addGeoJSONProperties, addSelectionTypeToGeoJSON, addWMLayerPropsBasedOnChildProps, basicExampleDrawOptions, basicExampleMultipleShapeDrawOptions, basicExampleMultipleShapeWithValuesDrawOptions, checkHoverFeatures, convertGeoCoordsToScreenCoords, createInterSections, currentlySupportedDrawModes, defaultBox, defaultDelete, defaultGeoJSONStyleProperties, defaultIntersectionStyleProperties, defaultLayers, defaultModes, defaultPoint, defaultPolygon, defaultTimeFormat, dimensionConfig, distance, drawPolyStoryStyles, emptyGeoJSON, endToolExampleConfig, exampleIntersectionOptions, exampleIntersectionWithShapeOptions, exampleIntersections, exampleIntersectionsMultiDrawTool, featureBox, featureMultiPoint, featurePoint, featurePolygon, fillOptions, findClosestCoords, firSelectionType, formatTime, getCurrentDimensionValue, getDimensionIcon, getDimensionLabel, getDimensionValue, getDimensionsList, getDoubleControlToolIcon, getDrawFunctionFromStore, getFeatureCollection, getFeatureExtent, getFeatureLayers, getFirTitle, getGeoJSONPropertyValue, getGeoJson, getIcon, getIntersectionToolIcon, getIsInsideAcceptanceTime, getLastEmptyFeatureIndex, getLayerBbox, getLayerStyles, getLayerUpdateInfo, getPixelCoordFromGeoCoord, getProj4, getTimeDimension, getToolIcon, intersectPointGeoJSONS, intersectPolygonGeoJSONS, intersectionFeatureBE, intersectionFeatureNL, isAGeoJSONLayer, isAMapLayer, isBetween, isGeoJSONFeatureCreatedByTool, isPointFeatureCollection, lineString, lineStringCollection, makeLayerPropListFromChildren, marksByDimension, moveFeature, opacityOptions, orderLayers, parseWMJSLayer, projectorCache, publicLayers, publicServices, registerDrawFunction, removeWMLayerFromMap, rewindGeometry, setWMLayerPropsBasedOnChildProps, simpleBoxGeoJSON, simpleBoxGeoJSONWrongOrder, simpleFlightRouteLineStringGeoJSON, simpleFlightRoutePointsGeoJSON, simpleGeometryCollectionGeoJSON, simpleLineStringGeoJSON, simpleMultiPolygon, simplePointsGeojson, simplePolygonGeoJSON, simpleSmallLineStringGeoJSON, startToolExampleConfig, strokeWidthOptions, textStyle, textStyleWithMargin, updateEditModeButtonsWithFir, useGeoJSON, useMapDrawTool, webmapReactTranslations };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { FeatureCollection, GeoJsonProperties, GeometryObject, Position } from 'geojson';
|
|
3
|
-
import {
|
|
3
|
+
import { GeoFeatureStyle, Coordinate } from './geojsonShapes';
|
|
4
4
|
interface DrawStyle {
|
|
5
5
|
x: number;
|
|
6
6
|
y: number;
|
|
@@ -23,7 +23,7 @@ export interface FeatureEvent {
|
|
|
23
23
|
mouseX: number;
|
|
24
24
|
mouseY: number;
|
|
25
25
|
isInEditMode: boolean;
|
|
26
|
-
feature:
|
|
26
|
+
feature: GeoJSON.Feature;
|
|
27
27
|
}
|
|
28
28
|
export interface MapDrawProps {
|
|
29
29
|
mapId: string;
|
|
@@ -112,8 +112,8 @@ export default class MapDraw extends React.PureComponent<MapDrawProps> {
|
|
|
112
112
|
handleDrawMode(_drawMode: string): void;
|
|
113
113
|
handleGeoJSONUpdate: (newGeoJSON: GeoJSON.FeatureCollection) => void;
|
|
114
114
|
handleExitDrawMode: (reason?: DrawModeExitCallback) => void;
|
|
115
|
-
getSelectedFeature: () =>
|
|
116
|
-
hoverVertex(feature:
|
|
115
|
+
getSelectedFeature: () => GeoJSON.Feature;
|
|
116
|
+
hoverVertex(feature: GeoJSON.Feature, mouseX: number, mouseY: number): void;
|
|
117
117
|
mouseMove(event: InputEvent): boolean;
|
|
118
118
|
triggerMouseDownTimer(event: InputEvent): void | boolean;
|
|
119
119
|
mouseDoubleClick(): void;
|
|
@@ -132,26 +132,26 @@ export default class MapDraw extends React.PureComponent<MapDrawProps> {
|
|
|
132
132
|
deleteFeature(): void;
|
|
133
133
|
mouseUp(event: InputEvent): void | boolean;
|
|
134
134
|
cancelEdit(cancelLastPoint: boolean): void;
|
|
135
|
-
moveVertex(feature:
|
|
135
|
+
moveVertex(feature: GeoJSON.Feature, mouseDown: boolean): boolean;
|
|
136
136
|
transposePolygon(featureCoords: Position[]): void;
|
|
137
137
|
transposeVertex(featureCoords: Position[]): void;
|
|
138
138
|
componentCleanup(): void;
|
|
139
|
-
|
|
139
|
+
initializeFeature(feature: GeoJSON.Feature): void;
|
|
140
140
|
validatePolys(fixPolys: boolean): void;
|
|
141
141
|
beforeDraw(ctx: CanvasRenderingContext2D): void;
|
|
142
142
|
checkDist(coord: Coordinate, polygonIndex: SNAPPEDFEATURE | number, mouseX: number, mouseY: number): boolean;
|
|
143
|
-
hoverEdge(geometry:
|
|
143
|
+
hoverEdge(geometry: GeoJSON.Geometry, mouseX: number, mouseY: number): {
|
|
144
144
|
selectedEdge: EDGE | number;
|
|
145
145
|
snappedPolygonIndex: SNAPPEDFEATURE | number;
|
|
146
146
|
};
|
|
147
147
|
drawVertice(ctx: CanvasRenderingContext2D, _coord: Coordinate, selected: boolean, middle: boolean, isInEditMode: boolean): void;
|
|
148
|
-
drawPoint(ctx: CanvasRenderingContext2D, _coord: Coordinate, selected: boolean, middle: boolean, isInEditMode: boolean, feature:
|
|
148
|
+
drawPoint(ctx: CanvasRenderingContext2D, _coord: Coordinate, selected: boolean, middle: boolean, isInEditMode: boolean, feature: GeoJSON.Feature, featureIndex: number): void;
|
|
149
149
|
drawIcon(ctx: CanvasRenderingContext2D, _coord: Coordinate, featureProperties: GeoJsonProperties): DrawStyle;
|
|
150
150
|
drawMarker(ctx: CanvasRenderingContext2D, _coord: Coordinate, selected: boolean, middle: boolean, isInEditMode: boolean, featureProperties: GeoFeatureStyle): void | DrawStyle;
|
|
151
151
|
drawLine(ctx: CanvasRenderingContext2D, XYCoords: Coordinate[], featureIndex: number, lineStringIndex: number): void | DrawStyle;
|
|
152
152
|
drawPolygon(ctx: CanvasRenderingContext2D, XYCoords: Coordinate[], featureIndex: number, polygonIndex: number): void | DrawStyle;
|
|
153
|
-
initializeFeatureCoordinates(feature:
|
|
154
|
-
checkIfFeatureIsBox(feature:
|
|
153
|
+
initializeFeatureCoordinates(feature: GeoJSON.Feature, type: string): GeoJSON.Feature;
|
|
154
|
+
checkIfFeatureIsBox(feature: GeoJSON.Feature): boolean;
|
|
155
155
|
featureHasChanged(text: string): void;
|
|
156
156
|
render(): React.ReactElement;
|
|
157
157
|
}
|
|
@@ -6,8 +6,6 @@ export declare const featurePolygon: GeoJSON.Feature<GeoJSON.Polygon>;
|
|
|
6
6
|
export declare const featureBox: GeoJSON.Feature<GeoJSON.Polygon>;
|
|
7
7
|
export declare const lineString: GeoJSON.Feature<GeoJSON.LineString>;
|
|
8
8
|
export declare const lineStringCollection: GeoJSON.FeatureCollection;
|
|
9
|
-
export type GeoJsonFeatureType = GeoJSON.Polygon | GeoJSON.MultiPoint | GeoJSON.Point | GeoJSON.LineString | GeoJSON.MultiPolygon;
|
|
10
|
-
export type GeoJsonFeature = GeoJSON.Feature<GeoJsonFeatureType>;
|
|
11
9
|
export interface GeoFeatureStyle {
|
|
12
10
|
stroke?: string;
|
|
13
11
|
fill?: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import proj4, { InterfaceProjection } from 'proj4';
|
|
2
2
|
import { Position } from 'geojson';
|
|
3
|
-
import { Coordinate
|
|
3
|
+
import { Coordinate } from './geojsonShapes';
|
|
4
4
|
export type CheckHoverFeaturesResult = {
|
|
5
5
|
coordinateIndexInFeature: number;
|
|
6
6
|
featureIndex: number;
|
|
7
|
-
feature:
|
|
7
|
+
feature: GeoJSON.Feature;
|
|
8
8
|
distance: number;
|
|
9
9
|
screenCoords: {
|
|
10
10
|
x: number;
|
|
@@ -27,7 +27,7 @@ export interface MapDrawDrawFunctionArgs {
|
|
|
27
27
|
coord: Coordinate;
|
|
28
28
|
selected: boolean;
|
|
29
29
|
isInEditMode: boolean;
|
|
30
|
-
feature:
|
|
30
|
+
feature: GeoJSON.Feature;
|
|
31
31
|
mouseX: number;
|
|
32
32
|
mouseY: number;
|
|
33
33
|
isHovered: boolean;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
export declare const simplePolygonGeoJSON: GeoJSON.FeatureCollection
|
|
2
|
-
export declare const simplePointsGeojson: GeoJSON.FeatureCollection
|
|
3
|
-
export declare const simpleSmallLineStringGeoJSON: GeoJSON.FeatureCollection
|
|
4
|
-
export declare const simpleFlightRoutePointsGeoJSON: GeoJSON.FeatureCollection
|
|
5
|
-
export declare const simpleLineStringGeoJSON: GeoJSON.FeatureCollection
|
|
6
|
-
export declare const simpleBoxGeoJSON: GeoJSON.FeatureCollection
|
|
7
|
-
export declare const simpleBoxGeoJSONWrongOrder: GeoJSON.FeatureCollection
|
|
8
|
-
export declare const simpleFlightRouteLineStringGeoJSON: GeoJSON.FeatureCollection
|
|
9
|
-
export declare const simpleMultiPolygon: GeoJSON.FeatureCollection
|
|
10
|
-
export declare const intersectionFeatureNL: GeoJSON.Feature
|
|
11
|
-
export declare const intersectionFeatureBE: GeoJSON.Feature
|
|
1
|
+
export declare const simplePolygonGeoJSON: GeoJSON.FeatureCollection<GeoJSON.Polygon>;
|
|
2
|
+
export declare const simplePointsGeojson: GeoJSON.FeatureCollection<GeoJSON.Point>;
|
|
3
|
+
export declare const simpleSmallLineStringGeoJSON: GeoJSON.FeatureCollection<GeoJSON.LineString>;
|
|
4
|
+
export declare const simpleFlightRoutePointsGeoJSON: GeoJSON.FeatureCollection<GeoJSON.Point>;
|
|
5
|
+
export declare const simpleLineStringGeoJSON: GeoJSON.FeatureCollection<GeoJSON.LineString>;
|
|
6
|
+
export declare const simpleBoxGeoJSON: GeoJSON.FeatureCollection<GeoJSON.Polygon>;
|
|
7
|
+
export declare const simpleBoxGeoJSONWrongOrder: GeoJSON.FeatureCollection<GeoJSON.Polygon>;
|
|
8
|
+
export declare const simpleFlightRouteLineStringGeoJSON: GeoJSON.FeatureCollection<GeoJSON.LineString>;
|
|
9
|
+
export declare const simpleMultiPolygon: GeoJSON.FeatureCollection<GeoJSON.MultiPolygon>;
|
|
10
|
+
export declare const intersectionFeatureNL: GeoJSON.Feature<GeoJSON.Polygon>;
|
|
11
|
+
export declare const intersectionFeatureBE: GeoJSON.Feature<GeoJSON.Polygon>;
|
|
12
|
+
export declare const simpleGeometryCollectionGeoJSON: GeoJSON.FeatureCollection<GeoJSON.GeometryCollection<GeoJSON.MultiPolygon>>;
|