From 0abde72b1355907203b9cd2ce9017d4c3709f390 Mon Sep 17 00:00:00 2001 From: Simon Seyock Date: Tue, 14 May 2024 11:10:59 +0200 Subject: [PATCH] feat: use `WmsLayer` from `ol-util` instead of `react-util` --- .../AddWmsPanel/AddWmsLayerEntry/AddWmsLayerEntry.tsx | 2 +- src/Container/AddWmsPanel/AddWmsPanel.tsx | 3 +-- src/Legend/Legend.tsx | 11 +++-------- .../TimeLayerSliderPanel/TimeLayerSliderPanel.tsx | 10 ++++------ 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/Container/AddWmsPanel/AddWmsLayerEntry/AddWmsLayerEntry.tsx b/src/Container/AddWmsPanel/AddWmsLayerEntry/AddWmsLayerEntry.tsx index 8044e06ec9..e538be6c14 100644 --- a/src/Container/AddWmsPanel/AddWmsLayerEntry/AddWmsLayerEntry.tsx +++ b/src/Container/AddWmsPanel/AddWmsLayerEntry/AddWmsLayerEntry.tsx @@ -2,7 +2,7 @@ import './AddWmsLayerEntry.less'; import { faCopyright, faInfo } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { WmsLayer } from '@terrestris/react-util/dist/Util/typeUtils'; +import { WmsLayer } from '@terrestris/ol-util'; import { Checkbox, Tooltip } from 'antd'; import OlMap from 'ol/Map'; import React, { useEffect, useState } from 'react'; diff --git a/src/Container/AddWmsPanel/AddWmsPanel.tsx b/src/Container/AddWmsPanel/AddWmsPanel.tsx index 9aa1158803..dfa4353674 100644 --- a/src/Container/AddWmsPanel/AddWmsPanel.tsx +++ b/src/Container/AddWmsPanel/AddWmsPanel.tsx @@ -1,11 +1,10 @@ import './AddWmsPanel.less'; import Logger from '@terrestris/base-util/dist/Logger'; +import { WmsLayer } from '@terrestris/ol-util'; import useMap from '@terrestris/react-util/dist/Hooks/useMap/useMap'; -import { WmsLayer } from '@terrestris/react-util/dist/Util/typeUtils'; import { Checkbox } from 'antd'; import { CheckboxValueType } from 'antd/lib/checkbox/Group'; -import _isFunction from 'lodash/isFunction'; import React, { useState } from 'react'; import SimpleButton from '../../Button/SimpleButton/SimpleButton'; diff --git a/src/Legend/Legend.tsx b/src/Legend/Legend.tsx index f84c12c0ae..4279566839 100644 --- a/src/Legend/Legend.tsx +++ b/src/Legend/Legend.tsx @@ -1,13 +1,8 @@ import { faCircleNotch } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import Logger from '@terrestris/base-util/dist/Logger'; -import MapUtil from '@terrestris/ol-util/dist/MapUtil/MapUtil'; +import { MapUtil, WmsLayer } from '@terrestris/ol-util'; import { Spin } from 'antd'; -import _isEqual from 'lodash/isEqual'; -import OlLayerImage from 'ol/layer/Image'; -import OlLayerTile from 'ol/layer/Tile'; -import OlSourceImageWMS from 'ol/source/ImageWMS'; -import OlSourceTileWMS from 'ol/source/TileWMS'; import * as React from 'react'; import { useCallback, useEffect, useState } from 'react'; @@ -22,7 +17,7 @@ import { CSS_PREFIX } from '../constants'; * @param params The extra params. */ const getLegendUrl = ( - legendLayer: OlLayerTile | OlLayerImage, + legendLayer: WmsLayer, params: any ) => { let url; @@ -44,7 +39,7 @@ export interface BaseProps { /** * The layer you want to display the legend of. */ - layer: OlLayerTile | OlLayerImage; + layer: WmsLayer; /** * An object containing additional request params like "{HEIGHT: 400}" will * be transformed to "&HEIGHT=400" an added to the GetLegendGraphic request. diff --git a/src/Panel/TimeLayerSliderPanel/TimeLayerSliderPanel.tsx b/src/Panel/TimeLayerSliderPanel/TimeLayerSliderPanel.tsx index e9d3cfdf59..a6f8f8cc55 100644 --- a/src/Panel/TimeLayerSliderPanel/TimeLayerSliderPanel.tsx +++ b/src/Panel/TimeLayerSliderPanel/TimeLayerSliderPanel.tsx @@ -1,12 +1,10 @@ +import { WmsLayer } from '@terrestris/ol-util'; import { DatePicker, Popover, Select } from 'antd'; import dayjs from 'dayjs'; import _isEqual from 'lodash/isEqual'; import _isFinite from 'lodash/isFinite'; import moment, { Moment } from 'moment'; import { getUid } from 'ol'; -import OlLayer from 'ol/layer/Layer'; -import OlImageWMS from 'ol/source/ImageWMS'; -import OlTileWMS from 'ol/source/TileWMS'; import React, { memo, useCallback, useEffect, useRef, useState } from 'react'; const RangePicker = DatePicker.RangePicker; const Option = Select.Option; @@ -41,7 +39,7 @@ export type PlaybackSpeedType = 'hours' | 'days' | 'weeks' | 'months' | 'years'; export interface TimeLayerSliderPanelProps { className?: string; onChange?: (arg: moment.Moment) => void; - timeAwareLayers: OlLayer[]; + timeAwareLayers: WmsLayer[]; value?: moment.Moment; dateFormat?: string; tooltips?: Tooltips; @@ -95,7 +93,7 @@ export const TimeLayerSliderPanel: React.FC = memo( const wrapTimeSlider = useCallback(() => { const wmsTimeLayers: TimeLayerAwareConfig[] = []; - timeAwareLayers.forEach((l: OlLayer) => { + timeAwareLayers.forEach(l => { if (l.get('type') === 'WMSTime') { wmsTimeLayers.push({ layer: l }); } @@ -188,7 +186,7 @@ export const TimeLayerSliderPanel: React.FC = memo( const startDatesFromLayers: moment.Moment[] = []; const endDatesFromLayers: moment.Moment[] = []; - timeAwareLayers.forEach((l: OlLayer) => { + timeAwareLayers.forEach(l => { const layerType = l.get('type'); if (layerType === 'WMSTime') { const layerStartDate = l.get('startDate');