@opengeoweb/core 9.0.0 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import * as React from 'react';
2
- import React__default, { useState, forwardRef, useContext, useEffect, useLayoutEffect, useRef } from 'react';
2
+ import React__default, { useState, forwardRef, useContext, useRef, useEffect, useLayoutEffect } from 'react';
3
3
  import { Grid, Box as Box$2, MenuItem, Typography, useTheme as useTheme$2, Button, Popper, ListItemText, ListItemIcon, FormControl, InputLabel, Paper, List, ListItemButton, CircularProgress, ListSubheader, Dialog, DialogTitle, DialogContent, DialogContentText, TextField, InputAdornment, DialogActions, LinearProgress, styled as styled$1, Slider, Checkbox, Card, IconButton, Select, CardContent, RadioGroup, FormControlLabel, Radio, ToggleButtonGroup, ToggleButton, Divider, Tooltip, ButtonGroup } from '@mui/material';
4
4
  import { CustomIconButton, TooltipSelect, AlertIcon, useControlledTooltip, CustomTooltip, tooltipContainerStyles, sliderHeaderStyle, CustomSlider, ToggleMenu, AlertBanner, CustomAccordion, calculateStartSize, ToolContainerDraggable, dateUtils, withEggs } from '@opengeoweb/shared';
5
5
  import { LayerSelectButtonConnect, LayerInfoButton, LayerInfoButtonConnect, getUserAddedServices, layerSelectConfig } from '@opengeoweb/layer-select';
6
- import { CollapseSmall, CollapseMedium, CollapseLarge, CollapseWindow, ExpandWindow, Copy, None, FastForward, AutoUpdateActive, Both, Visibility, VisibilityOff, Delete, DragHandle as DragHandle$1, Cached, Add, MapAdd, WorldMapProjection, Layers, Equalizer, DimensionsElevation, Link, LinkOff, List as List$1, ExitDomain, Info, Search, Close, ChevronDown, ChevronUp, StepForward, StepBackward, Pause, Play, Options, ThemeWrapper, lightTheme } from '@opengeoweb/theme';
6
+ import { CollapseSmall, CollapseMedium, CollapseLarge, CollapseWindow, ExpandWindow, Copy, None, FastForward, AutoUpdateActive, Both, Visibility, VisibilityOff, Delete, DragHandle as DragHandle$1, Cached, Add, MapAdd, WorldMapProjection, Layers, Equalizer, DimensionsElevation, Link, LinkOff, List as List$1, ExitDomain, Info, Search, MyLocation, Close, ChevronDown, ChevronUp, StepForward, StepBackward, Pause, Play, Options, ThemeWrapper, lightTheme } from '@opengeoweb/theme';
7
7
  import { useDispatch, useSelector, connect, Provider } from 'react-redux';
8
8
  import { ReactSortable } from 'react-sortablejs';
9
9
  import { layerTypes, layerUtils, layerActions, layerSelectors, serviceSelectors, serviceActions, mapSelectors, mapActions, mapEnums, mapConstants, filterLayers, uiSelectors, uiTypes, useSetupDialog, uiActions, drawtoolSelectors, genericActions, syncConstants, defaultLayers, mapStoreActions, getSingularDrawtoolDrawLayerId, syncGroupsSelectors, syncGroupsSelector, coreModuleConfig, routerUtils, routerModuleConfig, appModuleConfig, appActions } from '@opengeoweb/store';
10
10
  import { WMGetServiceFromStore, getCapabilities, webmapUtils, LayerType, handleMomentISOString, WMLayer } from '@opengeoweb/webmap';
11
11
  import { jsx } from 'react/jsx-runtime';
12
12
  import _, { isEqual, range } from 'lodash';
13
- import { MapControlButton, ZoomControls, MapView, MapViewLayer, LegendDialog, SearchDialog, emptyGeoJSON, MapControls, publicLayers } from '@opengeoweb/webmap-react';
13
+ import { MapControlButton, ZoomControls, MapView, MapViewLayer, LegendDialog, registerDrawFunction, emptyGeoJSON, MapControls, publicLayers } from '@opengeoweb/webmap-react';
14
14
  import { TIME_SLIDER_LEGEND_HEIGHT, TimeSliderConnect, TimeSliderClockConnect, speedFactors } from '@opengeoweb/timeslider';
15
15
  import axios from 'axios';
16
16
  import { useDebounce } from '@opengeoweb/api';
@@ -11365,19 +11365,31 @@ var filterServices = function filterServices(presetArray) {
11365
11365
  var services = hasValidServices ? validServices : undefined;
11366
11366
  return services;
11367
11367
  };
11368
+ var filterTimeSeriesServices = function filterTimeSeriesServices(presetArray) {
11369
+ var hasServices = presetArray && Array.isArray(presetArray) && presetArray.length > 0;
11370
+ var validServices = hasServices ? presetArray.filter(function (preset) {
11371
+ return isValidService(preset);
11372
+ }) : null;
11373
+ var hasValidServices = validServices && validServices.length > 0;
11374
+ var services = hasValidServices ? validServices : undefined;
11375
+ return services;
11376
+ };
11368
11377
  var filterMapPresets = function filterMapPresets(initialAppPreset) {
11369
11378
  var preset = initialAppPreset && initialAppPreset.preset || {};
11370
11379
  var layers = preset.layers,
11371
11380
  services = preset.services,
11372
- baseServices = preset.baseServices;
11381
+ baseServices = preset.baseServices,
11382
+ timeSeriesServices = preset.timeSeriesServices;
11373
11383
  var _ref = layers ? filterLayers.filterLayers(layers, filterLayers.parseLayer) : filterLayers.createEmtpyFilteredList(undefined),
11374
11384
  baseLayers = _ref.baseLayers,
11375
11385
  mapLayers = _ref.mapLayers;
11376
11386
  var filterredServices = services ? filterServices(services) : undefined;
11377
11387
  var filteredBaseServices = baseServices ? filterServices(baseServices) : undefined;
11388
+ var filteredTimeSeriesServices = timeSeriesServices ? filterTimeSeriesServices(timeSeriesServices) : undefined;
11378
11389
  var filteredPreset = {
11379
11390
  services: filterredServices,
11380
11391
  baseServices: filteredBaseServices,
11392
+ timeSeriesServices: filteredTimeSeriesServices,
11381
11393
  baseLayers: baseLayers,
11382
11394
  mapLayers: mapLayers
11383
11395
  };
@@ -11388,6 +11400,32 @@ var preset = {
11388
11400
  presetType: "mapPreset",
11389
11401
  presetId: "mapPreset-1",
11390
11402
  presetName: "Layer manager preset",
11403
+ timeSeriesServices: [
11404
+ {
11405
+ name: "KNMI",
11406
+ url: "https://gw-edr-dev-add-cfn-t3.pub.dev.knmi.cloud/edr",
11407
+ id: "knmi",
11408
+ description: "KNMI EDR",
11409
+ type: "EDR",
11410
+ scope: "system"
11411
+ },
11412
+ {
11413
+ name: "FMI",
11414
+ url: "https://opendata.fmi.fi/edr",
11415
+ id: "fmi",
11416
+ description: "FMI EDR",
11417
+ type: "EDR",
11418
+ scope: "system"
11419
+ },
11420
+ {
11421
+ name: "MET Norway",
11422
+ url: "https://interpol-b.met.no",
11423
+ id: "METNorway",
11424
+ description: "MET Norway EDR",
11425
+ type: "EDR",
11426
+ scope: "system"
11427
+ }
11428
+ ],
11391
11429
  services: [
11392
11430
  {
11393
11431
  name: "KNMIgeoservicesRadar",
@@ -15707,10 +15745,178 @@ var SearchControlButtonConnect = function SearchControlButtonConnect(_ref) {
15707
15745
  return /*#__PURE__*/React__default.createElement(MapControlButton, {
15708
15746
  onClick: openSearchDialog,
15709
15747
  title: "Search",
15710
- "aria-label": "Map search"
15748
+ "aria-label": "Map search",
15749
+ isActive: isOpenInStore
15711
15750
  }, /*#__PURE__*/React__default.createElement(Search, null));
15712
15751
  };
15713
15752
 
15753
+ /* *
15754
+ * Licensed under the Apache License, Version 2.0 (the "License");
15755
+ * you may not use this file except in compliance with the License.
15756
+ * You may obtain a copy of the License at
15757
+ *
15758
+ * http://www.apache.org/licenses/LICENSE-2.0
15759
+ *
15760
+ * Unless required by applicable law or agreed to in writing, software
15761
+ * distributed under the License is distributed on an "AS IS" BASIS,
15762
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15763
+ * See the License for the specific language governing permissions and
15764
+ * limitations under the License.
15765
+ *
15766
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
15767
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
15768
+ * */
15769
+ var MY_LOCATION = 'MyLocation';
15770
+ var locationOptions = {
15771
+ enableHighAccuracy: true,
15772
+ timeout: 5000,
15773
+ maximumAge: 0
15774
+ };
15775
+ var circleDrawFunction = function circleDrawFunction(args) {
15776
+ var fillColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '#88F';
15777
+ var radius = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 12;
15778
+ var ctx = args.context,
15779
+ coord = args.coord;
15780
+ ctx.strokeStyle = '#000';
15781
+ ctx.fillStyle = fillColor || '#88F';
15782
+ ctx.lineWidth = 1;
15783
+ ctx.beginPath();
15784
+ ctx.arc(coord.x, coord.y, radius || 10, 0, 2 * Math.PI);
15785
+ ctx.fill();
15786
+ ctx.stroke();
15787
+ ctx.fillStyle = '#000';
15788
+ ctx.beginPath();
15789
+ ctx.arc(coord.x, coord.y, 2, 0, 2 * Math.PI);
15790
+ ctx.fill();
15791
+ };
15792
+ var MyMapLocation = function MyMapLocation(_ref) {
15793
+ var mapId = _ref.mapId;
15794
+ var dispatch = useDispatch();
15795
+ var layers = useSelector(function (store) {
15796
+ return layerSelectors.getLayers(store);
15797
+ });
15798
+ var layerLocation = layers.find(function (layer) {
15799
+ var _a;
15800
+ if (layer.geojson && layer.geojson.features[0] && layer.geojson.features[0].properties && ((_a = layer.geojson.features[0].properties) === null || _a === void 0 ? void 0 : _a.name)) {
15801
+ if (layer.geojson.features[0].properties.name === MY_LOCATION) {
15802
+ return layer;
15803
+ }
15804
+ }
15805
+ return undefined;
15806
+ });
15807
+ var layerLocationId = (layerLocation === null || layerLocation === void 0 ? void 0 : layerLocation.id) || '';
15808
+ var circleDrawFunctionId = useRef(registerDrawFunction(circleDrawFunction));
15809
+ var handleLocationClick = function handleLocationClick() {
15810
+ if (mapId && layerLocationId !== '') {
15811
+ dispatch(layerActions.layerDelete({
15812
+ mapId: mapId,
15813
+ layerIndex: 0,
15814
+ layerId: layerLocationId
15815
+ }));
15816
+ } else if (navigator.geolocation && mapId && layerLocationId === '' && circleDrawFunctionId) {
15817
+ navigator.geolocation.getCurrentPosition(function (success) {
15818
+ var _success$coords = success.coords,
15819
+ latitude = _success$coords.latitude,
15820
+ longitude = _success$coords.longitude;
15821
+ var geojson = {
15822
+ type: 'FeatureCollection',
15823
+ features: [{
15824
+ type: 'Feature',
15825
+ properties: {
15826
+ name: MY_LOCATION,
15827
+ drawFunctionId: circleDrawFunctionId.current
15828
+ },
15829
+ geometry: {
15830
+ type: 'Point',
15831
+ coordinates: [longitude, latitude]
15832
+ }
15833
+ }]
15834
+ };
15835
+ var layerId = webmapUtils.generateLayerId();
15836
+ dispatch(layerActions.addLayer({
15837
+ mapId: mapId,
15838
+ layer: {
15839
+ geojson: geojson,
15840
+ layerType: LayerType.featureLayer
15841
+ },
15842
+ layerId: layerId,
15843
+ origin: MY_LOCATION
15844
+ }));
15845
+ var wmjsMap = webmapUtils.getWMJSMapById(mapId);
15846
+ if (!wmjsMap) {
15847
+ return;
15848
+ }
15849
+ wmjsMap.zoomToLayer(wmjsMap.getActiveLayer());
15850
+ }, function (error) {
15851
+ console.warn("Geolocation error: ".concat(error.message));
15852
+ }, locationOptions);
15853
+ }
15854
+ };
15855
+ return /*#__PURE__*/React__default.createElement(CustomIconButton, {
15856
+ title: "Find my location",
15857
+ "aria-label": MY_LOCATION,
15858
+ onClick: handleLocationClick,
15859
+ isSelected: layerLocationId !== '',
15860
+ size: "large"
15861
+ }, /*#__PURE__*/React__default.createElement(MyLocation, null));
15862
+ };
15863
+
15864
+ /* *
15865
+ * Licensed under the Apache License, Version 2.0 (the "License");
15866
+ * you may not use this file except in compliance with the License.
15867
+ * You may obtain a copy of the License at
15868
+ *
15869
+ * http://www.apache.org/licenses/LICENSE-2.0
15870
+ *
15871
+ * Unless required by applicable law or agreed to in writing, software
15872
+ * distributed under the License is distributed on an "AS IS" BASIS,
15873
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15874
+ * See the License for the specific language governing permissions and
15875
+ * limitations under the License.
15876
+ *
15877
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
15878
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
15879
+ * */
15880
+ var SearchDialog = function SearchDialog(_ref) {
15881
+ var isOpen = _ref.isOpen,
15882
+ onClose = _ref.onClose,
15883
+ _ref$mapId = _ref.mapId,
15884
+ mapId = _ref$mapId === void 0 ? '' : _ref$mapId;
15885
+ return isOpen && mapId ? /*#__PURE__*/React__default.createElement(Box$1, {
15886
+ sx: {
15887
+ display: 'flex',
15888
+ flexDirection: 'row',
15889
+ alignItems: 'center',
15890
+ position: 'absolute',
15891
+ pointerEvents: 'all',
15892
+ zIndex: 999,
15893
+ left: 50,
15894
+ top: 15,
15895
+ borderBottom: '1px solid grey',
15896
+ backgroundColor: function backgroundColor(theme) {
15897
+ return theme.palette.background.paper;
15898
+ }
15899
+ }
15900
+ }, /*#__PURE__*/React__default.createElement(MyMapLocation, {
15901
+ mapId: mapId
15902
+ }), /*#__PURE__*/React__default.createElement(TextField, {
15903
+ id: "dummy-search-field",
15904
+ label: "Search",
15905
+ variant: "filled",
15906
+ InputProps: {
15907
+ disableUnderline: true,
15908
+ endAdornment: /*#__PURE__*/React__default.createElement(InputAdornment, {
15909
+ position: "end"
15910
+ }, /*#__PURE__*/React__default.createElement(CustomIconButton, {
15911
+ tooltipTitle: "Close",
15912
+ edge: "end",
15913
+ onClick: onClose,
15914
+ size: "large"
15915
+ }, /*#__PURE__*/React__default.createElement(Close, null)))
15916
+ }
15917
+ })) : null;
15918
+ };
15919
+
15714
15920
  /* *
15715
15921
  * Licensed under the Apache License, Version 2.0 (the "License");
15716
15922
  * you may not use this file except in compliance with the License.
@@ -15735,7 +15941,8 @@ var SearchControlConnect = function SearchControlConnect(_ref) {
15735
15941
  onCloseDialog = _useSetupDialog.onCloseDialog;
15736
15942
  return /*#__PURE__*/React__default.createElement(SearchDialog, {
15737
15943
  isOpen: isDialogOpen,
15738
- onClose: onCloseDialog
15944
+ onClose: onCloseDialog,
15945
+ mapId: mapId
15739
15946
  });
15740
15947
  };
15741
15948
 
@@ -16727,13 +16934,22 @@ var reformatFinnishDateString = function reformatFinnishDateString(dateString) {
16727
16934
  };
16728
16935
  /**
16729
16936
  * Marks UTC time with Z after hh:mm or hh.mm or appends UTC to the end of the date string
16937
+ * If two matches of time are found, the second one is marked
16730
16938
  */
16731
16939
  var shortUTCTime = function shortUTCTime(dateString) {
16732
- var result = dateString.replace(/(\d[:.]\d{2})/, '$1Z');
16733
- if (result === dateString) {
16940
+ var timeRegex = /(\d[:.]\d{2})/g;
16941
+ var match = dateString.match(timeRegex);
16942
+ if (!match) {
16734
16943
  return "".concat(dateString, " UTC");
16735
16944
  }
16736
- return result;
16945
+ var _match = _slicedToArray(match, 2),
16946
+ first = _match[0],
16947
+ second = _match[1];
16948
+ if (second) {
16949
+ var secondIndex = dateString.lastIndexOf(second);
16950
+ return "".concat(dateString.substring(0, secondIndex)).concat(second, "Z").concat(dateString.substring(secondIndex + second.length));
16951
+ }
16952
+ return dateString.replace(first, "".concat(first, "Z"));
16737
16953
  };
16738
16954
  var getMonthChanges = function getMonthChanges(startDate, endDate) {
16739
16955
  var result = [];
@@ -19519,4 +19735,4 @@ var AppWrapperConnect = withEggs([appModuleConfig])(function (_ref) {
19519
19735
  return children;
19520
19736
  });
19521
19737
 
19522
- export { AppWrapperConnect, ConfigurableMapConnect, CoreThemeProvider, CoreThemeStoreProvider, HarmonieTempAndPrecipPreset, LayerManager, BaseLayerRow as LayerManagerBaseLayerRow, LayerManagerConnect, DescriptionRow as LayerManagerDescriptionRow, HeaderOptions as LayerManagerHeaderOptions, LayerContainerRow as LayerManagerLayerContainerRow, LayerManagerMapButtonConnect, LegendConnect, LegendMapButtonConnect, MapViewConnect, MultiDimensionSelectMapButtonsConnect, MultiMapMultiDimensionSelectConnect as MultiMapDimensionSelectConnect, MultiMapViewConnect, RouterWrapperConnect, SyncGroupViewerConnect, TimeSliderLite, TimeSliderLiteConnect, TimeSliderLiteOptionsMenu, timeSliderLiteUtils as TimeSliderLiteUtils, ZoomControlConnect, componentsLookUp, defaultBbox, defaultConfigurations, filterMapPresets, filterServices, testLayers, useFetchServices };
19738
+ export { AppWrapperConnect, ConfigurableMapConnect, CoreThemeProvider, CoreThemeStoreProvider, HarmonieTempAndPrecipPreset, LayerManager, BaseLayerRow as LayerManagerBaseLayerRow, LayerManagerConnect, DescriptionRow as LayerManagerDescriptionRow, HeaderOptions as LayerManagerHeaderOptions, LayerContainerRow as LayerManagerLayerContainerRow, LayerManagerMapButtonConnect, LegendConnect, LegendMapButtonConnect, MapViewConnect, MultiDimensionSelectMapButtonsConnect, MultiMapMultiDimensionSelectConnect as MultiMapDimensionSelectConnect, MultiMapViewConnect, MyMapLocation, RouterWrapperConnect, SearchControlButtonConnect, SearchControlConnect, SearchDialog, SyncGroupViewerConnect, TimeSliderLite, TimeSliderLiteConnect, TimeSliderLiteOptionsMenu, timeSliderLiteUtils as TimeSliderLiteUtils, ZoomControlConnect, componentsLookUp, defaultBbox, defaultConfigurations, filterMapPresets, filterServices, filterTimeSeriesServices, testLayers, useFetchServices };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/core",
3
- "version": "9.0.0",
3
+ "version": "9.1.0",
4
4
  "description": "GeoWeb Core library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ declare const _default: {
3
+ title: string;
4
+ };
5
+ export default _default;
6
+ export declare const MultipleDrawToolsDemo: () => React.ReactElement;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export interface MyMapLocationProps {
3
+ mapId: string | undefined;
4
+ }
5
+ export declare const MY_LOCATION = "MyLocation";
6
+ export declare const MyMapLocation: React.FC<MyMapLocationProps>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ export interface SearchDialogProps {
3
+ isOpen: boolean;
4
+ onClose: () => void;
5
+ mapId?: string;
6
+ }
7
+ export declare const SearchDialog: React.FC<SearchDialogProps>;
@@ -1,2 +1,4 @@
1
1
  export { SearchControlButtonConnect } from './SearchControlButtonConnect';
2
2
  export { SearchControlConnect } from './SearchControlConnect';
3
+ export { SearchDialog } from './SearchDialog';
4
+ export { MyMapLocation } from './MyMapLocation';
@@ -21,6 +21,7 @@ export declare const SEVEN_DAYS_IN_SECONDS: number;
21
21
  export declare const reformatFinnishDateString: (dateString: string) => string;
22
22
  /**
23
23
  * Marks UTC time with Z after hh:mm or hh.mm or appends UTC to the end of the date string
24
+ * If two matches of time are found, the second one is marked
24
25
  */
25
26
  export declare const shortUTCTime: (dateString: string) => string;
26
27
  export declare const getMonthChanges: (startDate: Date, endDate: Date) => number[];
@@ -16,4 +16,5 @@ export * from './utils/jsonPresetFilter';
16
16
  export * as defaultConfigurations from './utils/defaultConfigurations';
17
17
  export * from './components/Providers/Providers';
18
18
  export * from './components/RouterWrapper';
19
+ export * from './components/Search';
19
20
  export * from './components/AppWrapper';
@@ -1,14 +1,17 @@
1
1
  import { layerSelectTypes } from '@opengeoweb/layer-select';
2
+ import { TimeSeriesService } from '@opengeoweb/shared';
2
3
  import { filterLayers, layerTypes } from '@opengeoweb/store';
3
4
  interface FilteredMapPresets extends filterLayers.FilteredLayerList {
4
5
  services?: layerSelectTypes.LayerSelectService[];
5
6
  baseServices?: layerSelectTypes.LayerSelectService[];
7
+ timeSeriesServices?: TimeSeriesService[];
6
8
  }
7
9
  export interface InitialAppPresetProps {
8
10
  presetType?: string;
9
11
  presetId?: string;
10
12
  presetName?: string;
11
13
  services?: layerSelectTypes.LayerSelectService[];
14
+ timeSeriesServices?: TimeSeriesService[];
12
15
  baseServices?: layerSelectTypes.LayerSelectService[];
13
16
  layers?: layerTypes.Layer[];
14
17
  baseLayers?: layerTypes.Layer[];
@@ -17,5 +20,6 @@ export interface InitialAppPreset {
17
20
  preset: InitialAppPresetProps;
18
21
  }
19
22
  export declare const filterServices: (presetArray: layerSelectTypes.LayerSelectService[]) => layerSelectTypes.LayerSelectService[];
23
+ export declare const filterTimeSeriesServices: (presetArray: TimeSeriesService[]) => TimeSeriesService[];
20
24
  export declare const filterMapPresets: (initialAppPreset: InitialAppPreset) => FilteredMapPresets;
21
25
  export {};