@opengeoweb/webmap-react 13.1.0 → 13.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js CHANGED
@@ -17,8 +17,8 @@ import { useTranslation } from 'react-i18next';
17
17
  import { Paper, Box, Typography, useTheme, Grid, TextField, FormControl, InputLabel, Select, MenuItem, Icon as Icon$2, FormLabel, Switch, styled, Slider } from '@mui/material';
18
18
  import { useQuery } from '@tanstack/react-query';
19
19
  import { Style, Icon as Icon$1, Circle, Stroke, Fill, Text } from 'ol/style';
20
- import { Point, MultiPoint, Polygon } from 'ol/geom';
21
- import { arrowUpPath, Home, Add, Minus, List, Delete, Edit, DrawRegion, DrawPolygon, Location, DrawFIRLand, ArrowUp, Equalizer, DimensionsElevation, Link, LinkOff, Info, DimensionsOther, DimensionsRefTime, DimensionsTime, locationPath } from '@opengeoweb/theme';
20
+ import { Point, MultiPoint, LineString, Polygon } from 'ol/geom';
21
+ import { arrowUpPath, Home, Add, Minus, List, Delete, Edit, DrawRegion, DrawPolygon, Location, DrawFIRLand, ArrowUp, SandStorm, Equalizer, DimensionsElevation, Link, LinkOff, Info, DimensionsOther, DimensionsRefTime, DimensionsTime, locationPath } from '@opengeoweb/theme';
22
22
  import { http, HttpResponse } from 'msw';
23
23
  import proj4 from 'proj4';
24
24
  import * as turf from '@turf/turf';
@@ -11668,6 +11668,7 @@ var DRAWMODE;
11668
11668
  DRAWMODE["MULTIPOINT"] = "MULTIPOINT";
11669
11669
  DRAWMODE["POINT"] = "POINT";
11670
11670
  DRAWMODE["LINESTRING"] = "LINESTRING";
11671
+ DRAWMODE["SMOOTHLINE"] = "SMOOTHLINE";
11671
11672
  })(DRAWMODE || (DRAWMODE = {}));
11672
11673
 
11673
11674
  var defaultIntersectionStyleProperties = _objectSpread2(_objectSpread2({}, defaultGeoJSONStyleProperties), {}, {
@@ -11961,6 +11962,9 @@ var getToolIcon = function getToolIcon(selectionType) {
11961
11962
  if (selectionType === customLineButton.selectionType) {
11962
11963
  return jsx(ArrowUp, {});
11963
11964
  }
11965
+ if (selectionType === smoothLineButton.selectionType) {
11966
+ return jsx(SandStorm, {});
11967
+ }
11964
11968
  return jsx("div", {});
11965
11969
  };
11966
11970
  // custom buttons
@@ -12164,6 +12168,18 @@ var basicExampleMultipleShapeWithValuesDrawOptions = _objectSpread2(_objectSprea
12164
12168
  }]
12165
12169
  }
12166
12170
  });
12171
+ var smoothLineButton = {
12172
+ drawModeId: 'tool-smooth-line',
12173
+ value: DRAWMODE.SMOOTHLINE,
12174
+ title: 'Smooth LineString',
12175
+ shape: emptyLineString,
12176
+ isSelectable: true,
12177
+ selectionType: 'smooth-line'
12178
+ };
12179
+ var basicExampleSmoothLineOptions = {
12180
+ shouldAllowMultipleShapes: true,
12181
+ defaultDrawModes: [].concat(_toConsumableArray(defaultModes), [smoothLineButton])
12182
+ };
12167
12183
 
12168
12184
  var getIntersectionToolIcon = function getIntersectionToolIcon(selectionType) {
12169
12185
  var defaultIcon = getIcon(selectionType);
@@ -16055,12 +16071,30 @@ var genericOpenLayersFeatureStyle = function genericOpenLayersFeatureStyle(featu
16055
16071
  var props = feature.getProperties();
16056
16072
  var fill = props.fill,
16057
16073
  stroke = props.stroke,
16074
+ strokeOpacity = props['stroke-opacity'],
16075
+ strokeWidth = props['stroke-width'],
16058
16076
  hover = props.hover,
16059
16077
  mapFeatureClass = props.mapFeatureClass,
16060
16078
  showNameOnHover = props.showNameOnHover,
16061
16079
  name = props.name,
16062
16080
  geometry = props.geometry,
16063
16081
  selectionType = props.selectionType;
16082
+ if (selectionType === 'smooth-line') {
16083
+ var geom = feature.getGeometry();
16084
+ if (geom instanceof LineString) {
16085
+ var coords = geom.getCoordinates();
16086
+ var smoothed = catmullRomSpline(coords, 16);
16087
+ // Smoothed line
16088
+ return new Style$1({
16089
+ geometry: new LineString(smoothed),
16090
+ stroke: new Stroke({
16091
+ width: strokeWidth || 3,
16092
+ color: geowebColorToOpenLayersColor(stroke, strokeOpacity || 1)
16093
+ })
16094
+ });
16095
+ }
16096
+ return undefined;
16097
+ }
16064
16098
  var shouldHighlight = mapFeatureClass !== MapFeatureClass.ObservationStation && !showNameOnHover && selectionType !== 'fir';
16065
16099
  // Highlight map polygons on hover
16066
16100
  if (hover && shouldHighlight) {
@@ -16119,6 +16153,57 @@ var drawPolygonLikeFeatureStyle = function drawPolygonLikeFeatureStyle(feature)
16119
16153
  }
16120
16154
  })];
16121
16155
  };
16156
+ // Simple Catmull-Rom spline smoothing
16157
+ var catmullRomSpline = function catmullRomSpline(points) {
16158
+ var numPoints = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 16;
16159
+ var result = [];
16160
+ if (points.length < 2) {
16161
+ return points;
16162
+ }
16163
+ for (var i = 0; i < points.length - 1; i += 1) {
16164
+ var _points, _points2;
16165
+ var p0 = (_points = points[i - 1]) !== null && _points !== void 0 ? _points : points[i];
16166
+ var p1 = points[i];
16167
+ var p2 = points[i + 1];
16168
+ var p3 = (_points2 = points[i + 2]) !== null && _points2 !== void 0 ? _points2 : p2;
16169
+ // always include the control point
16170
+ result.push(p1);
16171
+ for (var pointIndex = 1; pointIndex < numPoints; pointIndex += 1) {
16172
+ var t = pointIndex / numPoints;
16173
+ var t2 = t * t;
16174
+ var t3 = t2 * t;
16175
+ var x = 0.5 * (2 * p1[0] + (-p0[0] + p2[0]) * t + (2 * p0[0] - 5 * p1[0] + 4 * p2[0] - p3[0]) * t2 + (-p0[0] + 3 * p1[0] - 3 * p2[0] + p3[0]) * t3);
16176
+ var y = 0.5 * (2 * p1[1] + (-p0[1] + p2[1]) * t + (2 * p0[1] - 5 * p1[1] + 4 * p2[1] - p3[1]) * t2 + (-p0[1] + 3 * p1[1] - 3 * p2[1] + p3[1]) * t3);
16177
+ result.push([x, y]);
16178
+ }
16179
+ }
16180
+ // include the very last control point
16181
+ result.push(points[points.length - 1]);
16182
+ return result;
16183
+ };
16184
+ var smoothLineLikeFeatureStyle = function smoothLineLikeFeatureStyle(feature) {
16185
+ var props = feature.getProperties();
16186
+ var stroke = props.stroke,
16187
+ strokeOpacity = props['stroke-opacity'],
16188
+ strokeWidth = props['stroke-width'];
16189
+ var geom = feature.getGeometry();
16190
+ if (geom instanceof LineString) {
16191
+ var coords = geom.getCoordinates();
16192
+ var smoothed = catmullRomSpline(coords, 16);
16193
+ return [
16194
+ // Smoothed line
16195
+ new Style$1({
16196
+ geometry: new LineString(smoothed),
16197
+ stroke: new Stroke({
16198
+ width: strokeWidth || 3,
16199
+ color: geowebColorToOpenLayersColor(stroke || '#ff7800', strokeOpacity || 1)
16200
+ })
16201
+ }),
16202
+ // Vertices
16203
+ FEATURE_VERTICES_EDIT_HANDLES];
16204
+ }
16205
+ return undefined;
16206
+ };
16122
16207
  var drawPointLikeFeatureStyle = ICON_LOCATIONMARKER_MODIFY;
16123
16208
  var modifyPolygonLikeFeatureStyle = [
16124
16209
  // Area
@@ -16133,6 +16218,7 @@ var drawStyles = {
16133
16218
  POLYGON: drawPolygonLikeFeatureStyle,
16134
16219
  BOX: drawPolygonLikeFeatureStyle,
16135
16220
  LINESTRING: drawPolygonLikeFeatureStyle,
16221
+ SMOOTHLINE: smoothLineLikeFeatureStyle,
16136
16222
  POINT: drawPointLikeFeatureStyle,
16137
16223
  MULTIPOINT: drawPointLikeFeatureStyle,
16138
16224
  DELETE: [],
@@ -16142,6 +16228,7 @@ var modifyStyles = {
16142
16228
  POLYGON: modifyPolygonLikeFeatureStyle,
16143
16229
  BOX: modifyPolygonLikeFeatureStyle,
16144
16230
  LINESTRING: modifyPolygonLikeFeatureStyle,
16231
+ SMOOTHLINE: smoothLineLikeFeatureStyle,
16145
16232
  POINT: [modifyPointLikeFeatureStyle],
16146
16233
  MULTIPOINT: [modifyPointLikeFeatureStyle],
16147
16234
  DELETE: [],
@@ -16163,6 +16250,10 @@ var createDrawOperation = function createDrawOperation(type) {
16163
16250
  return {
16164
16251
  type: 'LineString'
16165
16252
  };
16253
+ case 'SMOOTHLINE':
16254
+ return {
16255
+ type: 'LineString'
16256
+ };
16166
16257
  case 'POLYGON':
16167
16258
  default:
16168
16259
  return {
@@ -16229,6 +16320,8 @@ var selectionTypeToDrawModeValue = function selectionTypeToDrawModeValue(selecti
16229
16320
  case 'linestring':
16230
16321
  case 'custom-line':
16231
16322
  return DRAWMODE.LINESTRING;
16323
+ case 'smooth-line':
16324
+ return DRAWMODE.SMOOTHLINE;
16232
16325
  case 'delete':
16233
16326
  return 'DELETE';
16234
16327
  case 'fir':
@@ -16561,4 +16654,4 @@ var getLayerUpdateInfo = function getLayerUpdateInfo(wmLayer, mapId) {
16561
16654
  return updateObject;
16562
16655
  };
16563
16656
 
16564
- export { BaseLayerType, 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, FeatureLayer, 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, SelectField, StoryLayoutGrid, TimeAwareEDRLocationLayer, TimeContext, TimeawareImageSource, TimeawareImageSourceWMSLayer, WEBMAP_REACT_NAMESPACE, WMSLayer, WMTSLayer, XYZLayer, 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, generateImageFromLegend, genericOpenLayersFeatureStyle, geowebColorToOpenLayersColor, getDimensionIcon, getDimensionLabel, getDimensionValue, getDimensionsList, getDoubleControlToolIcon, getFeatureCollection, getFeatureExtent, getFirTitle, getGeoJSONPropertyValue, getGeoJson, getIcon, getIntersectionToolIcon, getIsInsideAcceptanceTime, getLastEmptyFeatureIndex, getLayerBbox, getLayerStyles, getLayerUpdateInfo, getLegendClass, getProj4, getTimeDimension, getToolIcon, initializeOpenLayersProjections, inlineFeatureStyle, intersectPointGeoJSONS, intersectPolygonGeoJSONS, intersectionFeatureBE, intersectionFeatureNL, isGeoJSONFeatureCreatedByTool, isGeoJSONGeometryEmpty, isPointFeatureCollection, lineString, lineStringCollection, makeFeatureStyleDisc, makeFeatureStyleLoading, makeFeatureStyleMultiParam, makeFeatureStyleMultiParamLoading, makeFeatureStyleWind, makeLegendFromColorMap, makeLegendFromStyleName, makeTimeList, makeView, marksByDimension, modifyStyles, moveFeature, multiLineStringLabelStyle, multiPolygonLabelStyle, opacityOptions, openLayersGetMapImageStore, precipitationMMLegendColorsWoW, projectorCache, publicLayers, publicServices, rewindGeometry, selectPreferredWMSProjection, setMapCenter, setViewFromExtent, setViewFromFeature, simpleBoxGeoJSON, simpleBoxGeoJSONWrongOrder, simpleFlightRouteLineStringGeoJSON, simpleFlightRoutePointsGeoJSON, simpleGeometryCollectionGeoJSON, simpleLineStringGeoJSON, simpleMultiPolygon, simplePointsGeojson, simplePolygonGeoJSON, simpleSmallLineStringGeoJSON, startToolExampleConfig, strokeWidthOptions, styleNameToStyleLike, temperatureLegendColorsCWK, temperatureLegendColorsWoW, textLabelStyle, textStyle, textStyleWithMargin, updateEditModeButtonsWithFir, useAnimationForLayer, useEDRLayerCollection, useEDRLayerCollectionCube, useGeoJSON, useGetEDRLayerInstance, useGetWMLayerInstance, useGetWMSLayerStyleList, useIconStyle, useMapDrawTool, useProjection, useQueryGetWMSGetCapabilities, useQueryGetWMSLayer, useQueryGetWMSLayers, useQueryGetWMSLayersTree, useQueryGetWMSServiceInfo, useQueryWMTSGetCapabilities, useSetIntervalWhenVisible, useViewFromLayer, viewUtils, webmapReactTranslations };
16657
+ export { BaseLayerType, 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, FeatureLayer, 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, SelectField, StoryLayoutGrid, TimeAwareEDRLocationLayer, TimeContext, TimeawareImageSource, TimeawareImageSourceWMSLayer, WEBMAP_REACT_NAMESPACE, WMSLayer, WMTSLayer, XYZLayer, ZoomControls, addFeatureProperties, addGeoJSONProperties, addSelectionTypeToGeoJSON, basicExampleDrawOptions, basicExampleMultipleShapeDrawOptions, basicExampleMultipleShapeWithValuesDrawOptions, basicExampleSmoothLineOptions, catmullRomSpline, 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, generateImageFromLegend, genericOpenLayersFeatureStyle, geowebColorToOpenLayersColor, getDimensionIcon, getDimensionLabel, getDimensionValue, getDimensionsList, getDoubleControlToolIcon, getFeatureCollection, getFeatureExtent, getFirTitle, getGeoJSONPropertyValue, getGeoJson, getIcon, getIntersectionToolIcon, getIsInsideAcceptanceTime, getLastEmptyFeatureIndex, getLayerBbox, getLayerStyles, getLayerUpdateInfo, getLegendClass, getProj4, getTimeDimension, getToolIcon, initializeOpenLayersProjections, inlineFeatureStyle, intersectPointGeoJSONS, intersectPolygonGeoJSONS, intersectionFeatureBE, intersectionFeatureNL, isGeoJSONFeatureCreatedByTool, isGeoJSONGeometryEmpty, isPointFeatureCollection, lineString, lineStringCollection, makeFeatureStyleDisc, makeFeatureStyleLoading, makeFeatureStyleMultiParam, makeFeatureStyleMultiParamLoading, makeFeatureStyleWind, makeLegendFromColorMap, makeLegendFromStyleName, makeTimeList, makeView, marksByDimension, modifyStyles, moveFeature, multiLineStringLabelStyle, multiPolygonLabelStyle, opacityOptions, openLayersGetMapImageStore, precipitationMMLegendColorsWoW, projectorCache, publicLayers, publicServices, rewindGeometry, selectPreferredWMSProjection, setMapCenter, setViewFromExtent, setViewFromFeature, simpleBoxGeoJSON, simpleBoxGeoJSONWrongOrder, simpleFlightRouteLineStringGeoJSON, simpleFlightRoutePointsGeoJSON, simpleGeometryCollectionGeoJSON, simpleLineStringGeoJSON, simpleMultiPolygon, simplePointsGeojson, simplePolygonGeoJSON, simpleSmallLineStringGeoJSON, startToolExampleConfig, strokeWidthOptions, styleNameToStyleLike, temperatureLegendColorsCWK, temperatureLegendColorsWoW, textLabelStyle, textStyle, textStyleWithMargin, updateEditModeButtonsWithFir, useAnimationForLayer, useEDRLayerCollection, useEDRLayerCollectionCube, useGeoJSON, useGetEDRLayerInstance, useGetWMLayerInstance, useGetWMSLayerStyleList, useIconStyle, useMapDrawTool, useProjection, useQueryGetWMSGetCapabilities, useQueryGetWMSLayer, useQueryGetWMSLayers, useQueryGetWMSLayersTree, useQueryGetWMSServiceInfo, useQueryWMTSGetCapabilities, useSetIntervalWhenVisible, useViewFromLayer, viewUtils, webmapReactTranslations };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/webmap-react",
3
- "version": "13.1.0",
3
+ "version": "13.2.1",
4
4
  "description": "GeoWeb react wrapper for webmap",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,9 +8,9 @@
8
8
  "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
9
  },
10
10
  "dependencies": {
11
- "@opengeoweb/webmap": "13.1.0",
12
- "@opengeoweb/theme": "13.1.0",
13
- "@opengeoweb/shared": "13.1.0",
11
+ "@opengeoweb/webmap": "13.2.1",
12
+ "@opengeoweb/theme": "13.2.1",
13
+ "@opengeoweb/shared": "13.2.1",
14
14
  "lodash": "^4.17.21",
15
15
  "ol": "^10.4.0",
16
16
  "proj4": "^2.9.2",
@@ -8,3 +8,4 @@ export declare const getToolIcon: (selectionType: SelectionType) => React.ReactE
8
8
  export declare const basicExampleDrawOptions: MapDrawToolOptions;
9
9
  export declare const basicExampleMultipleShapeDrawOptions: MapDrawToolOptions;
10
10
  export declare const basicExampleMultipleShapeWithValuesDrawOptions: MapDrawToolOptions;
11
+ export declare const basicExampleSmoothLineOptions: MapDrawToolOptions;
@@ -2,6 +2,8 @@ import { ColorLike } from 'ol/colorlike';
2
2
  import { FeatureLike } from 'ol/Feature';
3
3
  import { Circle, Fill, Stroke } from 'ol/style';
4
4
  import Style, { StyleFunction, StyleLike } from 'ol/style/Style';
5
+ import { Coordinate } from 'ol/coordinate';
6
+ import { LineCoordType } from 'ol/interaction/Draw';
5
7
  import { DrawModeValue } from '../MapDrawTool';
6
8
  export declare enum MapFeatureClass {
7
9
  MyLocation = "MyLocation",
@@ -25,5 +27,6 @@ export declare const multiLineStringLabelStyle: (text: string) => Style;
25
27
  export declare const geowebColorToOpenLayersColor: (color: string, opacity?: string | number) => ColorLike;
26
28
  export declare const inlineFeatureStyle: (feature: FeatureLike) => Style[];
27
29
  export declare const genericOpenLayersFeatureStyle: StyleFunction;
30
+ export declare const catmullRomSpline: (points: LineCoordType, numPoints?: number) => Coordinate[];
28
31
  export declare const drawStyles: Record<DrawModeValue, StyleLike>;
29
- export declare const modifyStyles: Record<DrawModeValue, Style[]>;
32
+ export declare const modifyStyles: Record<DrawModeValue, Style[] | StyleLike>;
@@ -7,3 +7,4 @@ export declare const OlBasicMapDrawTool: Story;
7
7
  export declare const OlBasicMapDrawToolShape: Story;
8
8
  export declare const OlBasicMapDrawToolWithMultipleShapes: Story;
9
9
  export declare const OlBasicMapDrawToolWithMultipleShapesValues: Story;
10
+ export declare const OlBasicMapDrawToolWithSmoothLines: Story;
@@ -3,7 +3,8 @@ export declare enum DRAWMODE {
3
3
  BOX = "BOX",
4
4
  MULTIPOINT = "MULTIPOINT",
5
5
  POINT = "POINT",
6
- LINESTRING = "LINESTRING"
6
+ LINESTRING = "LINESTRING",
7
+ SMOOTHLINE = "SMOOTHLINE"
7
8
  }
8
9
  export interface FeatureEvent {
9
10
  coordinateIndexInFeature: number;