Skip to content

Commit

Permalink
Merge pull request #1080 from terrestris/olandreactgeoupdate
Browse files Browse the repository at this point in the history
Breaking: Updating ol to v7, react-geo to v22
  • Loading branch information
weskamm authored Dec 14, 2022
2 parents b1bec27 + 594a901 commit 1bc7296
Show file tree
Hide file tree
Showing 18 changed files with 903 additions and 761 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 4.0.0 - 2022-12-14

Breaking:
- Updating OpenLayers to v7 and react-geo to v22 ([#1080](/~https://github.com/terrestris/react-geo-baseclient/pull/1080))

## 3.0.0 - 2022-12-13

- Enable download of multiple `FeatureInfoGrids`
Expand Down
3 changes: 1 addition & 2 deletions config/webpack.common.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ const commonWebpackConfig = {
'react-redux': path.join(__dirname + '/../', 'node_modules', 'react-redux'),
'react-i18next': path.join(__dirname + '/../', 'node_modules', 'react-i18next'),
'@ant-design/icons': path.join(__dirname + '/../', 'node_modules', '@ant-design/icons'),
'moment': path.join(__dirname + '/../', 'node_modules', 'moment'),
'ol': path.join(__dirname + '/../', 'node_modules', 'ol')
'moment': path.join(__dirname + '/../', 'node_modules', 'moment')
}
}
};
Expand Down
1,573 changes: 846 additions & 727 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
"@fortawesome/react-fontawesome": "^0.2.0",
"@reduxjs/toolkit": "^1.9.0",
"@terrestris/base-util": "1.0.1",
"@terrestris/mapfish-print-manager": "^6.5.1",
"@terrestris/ol-util": "^7.4.1",
"@terrestris/react-geo": "^19.8.2",
"@terrestris/mapfish-print-manager": "^7.0.2",
"@terrestris/ol-util": "^10.1.2",
"@terrestris/react-geo": "^22.0.0",
"@terrestris/vectortiles": "0.4.0",
"antd": "4.18.9",
"copy-to-clipboard": "3.3.2",
Expand All @@ -74,7 +74,7 @@
"node-fetch": "^2.6.7",
"normalize.css": "^8.0.1",
"object-fit-polyfill": "0.1.0",
"ol": "6.14.0",
"ol": "7.1.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-i18next": "11.18.6",
Expand Down
2 changes: 1 addition & 1 deletion src/component/AddLayerPanel/AddLayerPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class AddLayerPanel extends React.Component<AddLayerPanelProps, AddLayerPanelSta
*/
getCapabilities = (url: string) => {
this.setState({fetching: true});
CapabilitiesUtil.parseWmsCapabilities(url)
CapabilitiesUtil.getWmsCapabilities(url)
.then((capabilities: any) => CapabilitiesUtil.getLayersFromWmsCapabilities(capabilities, 'Title'))
.then((layers: WmsLayer[]) => {this.setState({layers});})
.finally(() => {this.setState({fetching: false});});
Expand Down
2 changes: 1 addition & 1 deletion src/component/Multisearch/Multisearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export default class Multisearch extends
featureTypes={Object.keys(searchConfig)}
onFetchSuccess={this.wfsSearchSuccess.bind(this)}
onFetchError={this.onFetchError.bind(this)}
searchAttributes={searchAttributes}
attributeDetails={searchAttributes}
visible={false}
searchTerm={searchTerm}
additionalFetchOptions={{
Expand Down
9 changes: 5 additions & 4 deletions src/component/Popup/FeatureInfo/FeatureInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,12 @@ export const FeatureInfo: React.FC<ComponentProps> = ({
positioning,
stopEvent,
insertFirst,
autoPan,
autoPanAnimation: {
duration: autoPanAnimationDuration
autoPan: {
animation: {
duration: autoPanAnimationDuration
},
margin: autoPanMargin
},
autoPanMargin
});

// If the pointer is over the popup, no pointermove should be fired.
Expand Down
1 change: 1 addition & 0 deletions src/component/PrintPanel/PrintPanelV2.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import * as React from 'react';
import {
Row,
Expand Down
1 change: 1 addition & 0 deletions src/component/PrintPanel/PrintPanelV3.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import * as React from 'react';
import {
Row,
Expand Down
2 changes: 1 addition & 1 deletion src/component/SiderMenu/SiderMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ToggleGroup from '@terrestris/react-geo/dist/Button/ToggleGroup/ToggleGro
import LayerTree from '@terrestris/react-geo/dist/LayerTree/LayerTree';

import LegendContainer from '../container/Legend/LegendContainer';
import MapUtil from '@terrestris/ol-util/src/MapUtil/MapUtil';
import MapUtil from '@terrestris/ol-util/dist/MapUtil/MapUtil';
const { Sider } = Layout;
const SubMenu = Menu.SubMenu;

Expand Down
21 changes: 13 additions & 8 deletions src/component/button/HsiButton/HsiButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import ToggleButton, { ToggleButtonProps } from '@terrestris/react-geo/dist/Butt
import OlMap from 'ol/Map';
import OlView from 'ol/View';
import OlProjection from 'ol/proj/Projection';
import OlSourceImageWMS from 'ol/source/ImageWMS';
import OlSourceTileWMS from 'ol/source/TileWMS';
import OlSourceVector from 'ol/source/Vector';
import OlFeature from 'ol/Feature';
import OlMapBrowserEvent from 'ol/MapBrowserEvent';
import OlGeometry from 'ol/geom/Geometry';
Expand All @@ -22,6 +19,8 @@ import {
fetchFeatures
} from '../../../state/remoteFeatures/actions';

import { WmsLayer } from '@terrestris/react-geo/dist/Util/typeUtils';

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faInfo } from '@fortawesome/free-solid-svg-icons';

Expand Down Expand Up @@ -142,11 +141,17 @@ export const HsiButton: React.FC<ComponentProps> = ({
// dispatch that any running HOVER process should be canceled
dispatch(abortFetchingFeatures('HOVER'));

map.forEachLayerAtPixel(pixel, (layer: LayerType) => {
const layerSource = layer.getSource();
const mapLayers =
map.getAllLayers()
.filter(layerFilter);
mapLayers.forEach(layer => {
const layerSource = (layer as WmsLayer).getSource();
if (!layerSource) {
return;
}
const coordinate: number[] = map.getCoordinateFromPixel(pixel);

if (layer.getSource() instanceof OlSourceVector) {
if (layer.getSource().constructor.name === 'VectorSource') {
internalVectorFeatures[layer.get('name')] = [];
const internalFeatures = olEvt.map.getFeaturesAtPixel(pixel, {
layerFilter: (layerCandidate: LayerType) => {
Expand Down Expand Up @@ -224,8 +229,8 @@ export const HsiButton: React.FC<ComponentProps> = ({
const layerFilter = (layerCandidate: LayerType) => {
const source = layerCandidate.getSource();
const isHoverable: boolean = layerCandidate.get('hoverable');
const isSupportedHoverSource: boolean = source instanceof OlSourceImageWMS ||
source instanceof OlSourceTileWMS || source instanceof OlSourceVector;
const isSupportedHoverSource: boolean = source.constructor.name === 'ImageWMS' ||
source.constructor.name === 'TileWMS' || source.constructor.name === 'VectorSource';
return isHoverable && isSupportedHoverSource;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import OlLayer from 'ol/layer/Layer';
import OlImageLayer from 'ol/layer/Image';
import OlMap from 'ol/Map';
import ImageWMS from 'ol/source/ImageWMS';
import TileWMS from 'ol/source/TileWMS';
import { getUid } from 'ol/util';

import isEqual from 'lodash/isEqual';
Expand Down Expand Up @@ -215,7 +216,10 @@ export class LayerLegendAccordion extends React.Component<LayerLegendAccordionPr
const scale = MapUtil.getScaleForResolution(map.getView().getResolution(), unit);

// clone the array, reverse will work in place
const reversed = mapLayers.slice(0).reverse().filter((l) => l && l.getVisible());
const reversed = mapLayers.slice(0).reverse().filter(
(l) => l && l.getVisible() && (
l.getSource() instanceof TileWMS) ||
l.getSource() instanceof ImageWMS);
if (baseLayer) {
reversed.push(baseLayer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import _isEmpty from 'lodash/isEmpty';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faTimes } from '@fortawesome/free-solid-svg-icons';
import ImageWMS from 'ol/source/ImageWMS';
import TileWMS from 'ol/source/TileWMS';
import { isWmsLayer } from '@terrestris/react-geo/dist/Util/typeUtils';

interface DefaultLayerTreeClassicProps {
Expand Down Expand Up @@ -131,7 +132,9 @@ export const LayerTreeClassic: React.FC<ComponentProps> = ({
}
</div>
</div>
{(layer.get('visible') && isInResolutionRange) &&
{(layer.get('visible') && isInResolutionRange) && (
layer.getSource() instanceof TileWMS ||
layer.getSource() instanceof ImageWMS) &&
<>
<div className='layer-transparency'>
{t('LayerTreeClassic.transparency')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import React, { useState } from 'react';
import { MenuInfo } from 'rc-menu/lib/interface';

import OlLayerBase from 'ol/layer/Base';
import OlLayerLayer from 'ol/layer/Layer';
import OlLayerTile from 'ol/layer/Tile';
import OlMap from 'ol/Map';
import { transformExtent } from 'ol/proj';
import {Extent as OlExtent} from 'ol/extent';
import TileWMS from 'ol/source/TileWMS';
import ImageWMS from 'ol/source/ImageWMS';
import LayerRenderer from 'ol/renderer/Layer';
import OlSourceImageWMS from 'ol/source/ImageWMS';
import OlLayerImage from 'ol/layer/Image';
import OlSourceTileWMS from 'ol/source/TileWMS';

import {
Menu,
Expand Down Expand Up @@ -121,8 +121,8 @@ export const LayerTreeDropdownContextMenu: React.FC<ComponentProps> = ({
setExtentLoading(true);

try {
let extent: OlExtent = await LayerUtil.getExtentForLayer(layer as OlLayerLayer<TileWMS | ImageWMS,
LayerRenderer<any>>);
let extent: OlExtent = await LayerUtil.getExtentForLayer(
layer as OlLayerTile<OlSourceTileWMS> | OlLayerImage<OlSourceImageWMS>);
extent = transformExtent(extent, 'EPSG:4326', map.getView().getProjection());
map.getView().fit(extent);
} catch (error) {
Expand Down
5 changes: 4 additions & 1 deletion src/component/container/Legend/LegendContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import OlLayerGroup from 'ol/layer/Group';
import OlLayerBase from 'ol/layer/Base';
import OlImageLayer from 'ol/layer/Image';
import ImageWMS from 'ol/source/ImageWMS';
import TileWMS from 'ol/source/TileWMS';
import { getUid } from 'ol/util';

import { MapUtil } from '@terrestris/ol-util/dist/MapUtil/MapUtil';
Expand Down Expand Up @@ -69,7 +70,9 @@ export default class LegendContainer extends React.Component<LegendContainerProp
let layers: OlImageLayer<ImageWMS>[] = MapUtil.getAllLayers(layerGroup) as OlImageLayer<ImageWMS>[];

layers = layers
.filter((layer: OlImageLayer<ImageWMS>) => !(layer instanceof OlLayerGroup))
.filter((layer: OlImageLayer<ImageWMS>) =>
(layer.getSource && layer.getSource() instanceof TileWMS) ||
layer.getSource && layer.getSource() instanceof ImageWMS)
.filter(filterFn);

// clone the array, reverse will work in place
Expand Down
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { get as OlGetProjection } from 'ol/proj';
import OlView from 'ol/View';
import OlScaleLine from 'ol/control/ScaleLine';

import ProjectionUtil from '@terrestris/ol-util/src/ProjectionUtil/ProjectionUtil';
import ProjectionUtil from '@terrestris/ol-util/dist/ProjectionUtil/ProjectionUtil';

import MapProvider from '@terrestris/react-geo/dist/Provider/MapProvider/MapProvider';
import { mappify } from '@terrestris/react-geo/dist/HigherOrderComponent/MappifiedComponent/MappifiedComponent';
Expand All @@ -42,7 +42,7 @@ const MappifiedMain = mappify(Main);
*/
const setupMap = (state: BaseClientState) => {
ProjectionUtil.initProj4Definitions();
ProjectionUtil.initProj4DefinitionMappings();
ProjectionUtil.initProj4DefinitionMappings([]);
const mapViewConfig = state.mapView;
const mapLayers = state.mapLayers;
const {
Expand Down
2 changes: 1 addition & 1 deletion src/state/mapView/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {

import { Coordinate } from 'ol/coordinate';

import { MapUtil } from '@terrestris/ol-util/src/MapUtil/MapUtil';
import { MapUtil } from '@terrestris/ol-util/dist/MapUtil/MapUtil';

export interface MapView {
center: Coordinate;
Expand Down
3 changes: 2 additions & 1 deletion src/util/AppContextUtil/BaseAppContextUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ProjectionLike } from 'ol/proj';
import { MapUtil } from '@terrestris/ol-util/dist/MapUtil/MapUtil';

import { BaseClientState } from '../../state/reducer';
import { Units } from 'ol/proj/Units';

export interface AppContextUtil {
canReadCurrentAppContext: () => boolean;
Expand Down Expand Up @@ -32,7 +33,7 @@ class BaseAppContextUtil {
* @param {string} projUnit Projection unit. Default to 'm'
* @return {Array} Array of computed map scales.
*/
getMapScales(resolutions: number[], projUnit: string = 'm'): number[] {
getMapScales(resolutions: number[], projUnit: Units = 'm'): number[] {
if (!resolutions) {
return;
}
Expand Down

0 comments on commit 1bc7296

Please sign in to comment.