Skip to content

Commit

Permalink
chore: update to latest ol
Browse files Browse the repository at this point in the history
BREAKING CHANGE: required peer dependency for ol is now >= 10
  • Loading branch information
dnlkoch committed Sep 20, 2024
1 parent f31fb02 commit 3d60731
Show file tree
Hide file tree
Showing 9 changed files with 4,789 additions and 1,301 deletions.
3 changes: 2 additions & 1 deletion jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ module.exports = {
],
transformIgnorePatterns: [
'node_modules/(?!(ol|@camptocamp/inkmap|@terrestris/*[a-z]*-util|d3-selection|color-*[a-z]*)|(rc-*[a-z]*)|' +
'filter-obj|query-string|decode-uri-component|split-on-first|shpjs/)'
'filter-obj|query-string|decode-uri-component|split-on-first|shpjs/|rbush|quickselect|geostyler-openlayers-parser|' +
'geostyler-style)'
],
setupFiles: [
'<rootDir>/jest/__mocks__/matchMediaMock.js'
Expand Down
6,041 changes: 4,764 additions & 1,277 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@
"@fortawesome/free-solid-svg-icons": "^6.5.2",
"@fortawesome/react-fontawesome": "^0.2.2",
"@terrestris/base-util": "^2.0.0",
"@terrestris/ol-util": ">=18",
"@terrestris/react-util": "^8.0.5",
"@terrestris/react-util": "^9.0.0",
"@types/lodash": "^4.17.4",
"ag-grid-community": "^32.0.2",
"ag-grid-react": "^32.0.2",
Expand All @@ -101,7 +100,7 @@
"@semantic-release/git": "^10.0.1",
"@terrestris/eslint-config-typescript": "^5.0.0",
"@terrestris/eslint-config-typescript-react": "^2.0.0",
"@terrestris/ol-util": "^19.0.0",
"@terrestris/ol-util": "^20.0.0",
"@testing-library/dom": "^10.1.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^16.0.1",
Expand Down Expand Up @@ -139,7 +138,7 @@
"jest-environment-jsdom": "^29.7.0",
"jest-fetch-mock": "^3.0.3",
"less-loader": "^12.2.0",
"ol": "^9.2.3",
"ol": "^10.1.0",
"ol-mapbox-style": "^12.3.2",
"react": "^18.3.1",
"react-docgen-typescript": "^2.2.2",
Expand All @@ -155,10 +154,10 @@
"whatwg-fetch": "^3.6.20"
},
"peerDependencies": {
"@terrestris/ol-util": ">=18",
"@terrestris/ol-util": ">=20",
"@types/react": ">=18",
"antd": "^5",
"ol": ">=9",
"ol": ">=10",
"ol-mapbox-style": ">=12",
"react": ">=18",
"react-dom": ">=18"
Expand Down
8 changes: 3 additions & 5 deletions src/Button/CopyButton/CopyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import {
UseSelectFeaturesProps
} from '@terrestris/react-util/dist/Hooks/useSelectFeatures/useSelectFeatures';
import { DigitizeUtil } from '@terrestris/react-util/dist/Util/DigitizeUtil';
import OlFeature, {
FeatureLike as OlFeatureLike
} from 'ol/Feature';
import { SelectEvent as OlSelectEvent } from 'ol/interaction/Select';
import OlLayerVector from 'ol/layer/Vector';
import OlSourceVector from 'ol/source/Vector';
import OlStyle from 'ol/style/Style';
import React, {
useCallback,
Expand All @@ -25,7 +23,7 @@ interface OwnProps {
* The vector layer which will be used for digitize features.
* The standard digitizeLayer can be retrieved via `DigitizeUtil.getDigitizeLayer(map)`.
*/
digitizeLayer?: OlLayerVector<OlFeature>;
digitizeLayer?: OlLayerVector<OlSourceVector>;
/**
* Listener function for the 'select' event of the ol.interaction.Select
* if in `Copy` mode.
Expand Down Expand Up @@ -77,7 +75,7 @@ const CopyButton: React.FC<CopyButtonProps> = ({

AnimateUtil.moveFeature(
map,
layer as OlLayerVector<OlFeatureLike>,
layer as OlLayerVector<OlSourceVector>,
copy,
500,
50,
Expand Down
4 changes: 2 additions & 2 deletions src/Button/DeleteButton/DeleteButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
UseSelectFeaturesProps
} from '@terrestris/react-util/dist/Hooks/useSelectFeatures/useSelectFeatures';
import { DigitizeUtil } from '@terrestris/react-util/dist/Util/DigitizeUtil';
import OlFeature from 'ol/Feature';
import { SelectEvent as OlSelectEvent } from 'ol/interaction/Select';
import OlVectorLayer from 'ol/layer/Vector';
import OlSourceVector from 'ol/source/Vector';
import * as React from 'react';
import {useCallback, useMemo} from 'react';

Expand All @@ -19,7 +19,7 @@ interface OwnProps {
* The vector layer which will be used for digitize features.
* The standard digitizeLayer can be retrieved via `DigitizeUtil.getDigitizeLayer(map)`.
*/
digitizeLayer?: OlVectorLayer<OlFeature>;
digitizeLayer?: OlVectorLayer<OlSourceVector>;
/**
* Listener function for the 'select' event of the ol.interaction.Select
* if in `Delete` mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import OlPoint from 'ol/geom/Point';
import { SelectEvent as OlSelectEvent } from 'ol/interaction/Select';
import OlVectorLayer from 'ol/layer/Vector';
import OlMap from 'ol/Map';
import OlSourceVector from 'ol/source/Vector';
import OlVectorSource from 'ol/source/Vector';
import OlView from 'ol/View';
import * as React from 'react';
Expand All @@ -17,7 +18,7 @@ describe('<SelectFeaturesButton />', () => {

const coord = [829729, 6708850];
let map: OlMap;
let layer: OlVectorLayer<OlFeature>;
let layer: OlVectorLayer<OlSourceVector>;
let feature: OlFeature;

beforeEach(() => {
Expand Down
9 changes: 5 additions & 4 deletions src/Grid/AgFeatureGrid/AgFeatureGrid.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import OlGeometry from 'ol/geom/Geometry';
import OlGeomGeometryCollection from 'ol/geom/GeometryCollection';
import OlLayerVector from 'ol/layer/Vector';
import OlMap from 'ol/Map';
import OlSourceVector from 'ol/source/Vector';
import OlStyle from 'ol/style/Style';
import React from 'react';

Expand Down Expand Up @@ -77,7 +78,7 @@ describe('<AgFeatureGrid />', () => {

const layerCand = map.getLayers().getArray().find(layer => layer.get('name') === defaultFeatureGridLayerName);

expect((layerCand as OlLayerVector<OlFeature>)?.getStyle()).toBe(featureStyle);
expect((layerCand as OlLayerVector<OlSourceVector>)?.getStyle()).toBe(featureStyle);
});

it('removes the vector layer from the map on unmount', () => {
Expand All @@ -103,7 +104,7 @@ describe('<AgFeatureGrid />', () => {

const layerCand = map.getLayers().getArray().find(layer => layer.get('name') === defaultFeatureGridLayerName);

expect((layerCand as OlLayerVector<OlFeature>)?.getSource()?.getFeatures()).toHaveLength(3);
expect((layerCand as OlLayerVector<OlSourceVector>)?.getSource()?.getFeatures()).toHaveLength(3);

data.forEach( ({ name }) => {
expect(screen.getByText(name)).toBeVisible();
Expand Down Expand Up @@ -152,7 +153,7 @@ describe('<AgFeatureGrid />', () => {

const layerCand = map.getLayers().getArray().find(layer => layer.get('name') === defaultFeatureGridLayerName);

const feats = (layerCand as OlLayerVector<OlFeature>)?.getSource()?.getFeatures() || [];
const feats = (layerCand as OlLayerVector<OlSourceVector>)?.getSource()?.getFeatures() || [];

for (const feat of feats) {
expect(feat.getStyle()).toBeDefined(); // TODO
Expand Down Expand Up @@ -186,7 +187,7 @@ describe('<AgFeatureGrid />', () => {
await userEvent.hover(row);

const layerCand = map.getLayers().getArray().find(layer => layer.get('name') === defaultFeatureGridLayerName);
const featCand = (layerCand as OlLayerVector<OlFeature>)?.getSource()?.getFeatures()
const featCand = (layerCand as OlLayerVector<OlSourceVector>)?.getSource()?.getFeatures()
.find(feat => feat.get('name') === 'Shinji Kagawa');

expect(featCand?.getStyle()).toBe(hoverStyle);
Expand Down
9 changes: 5 additions & 4 deletions src/Grid/FeatureGrid/FeatureGrid.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import userEvent from '@testing-library/user-event';
import OlFeature from 'ol/Feature';
import OlLayerVector from 'ol/layer/Vector';
import OlMap from 'ol/Map';
import OlSourceVector from 'ol/source/Vector';
import OlStyle from 'ol/style/Style';
import React from 'react';

Expand Down Expand Up @@ -77,7 +78,7 @@ describe('<FeatureGrid />', () => {

const layerCand = map.getLayers().getArray().find(layer => layer.get('name') === defaultFeatureGridLayerName);

expect((layerCand as OlLayerVector<OlFeature>)?.getStyle()).toBe(featureStyle);
expect((layerCand as OlLayerVector<OlSourceVector>)?.getStyle()).toBe(featureStyle);
});

it('removes the vector layer from the map on unmount', () => {
Expand All @@ -103,7 +104,7 @@ describe('<FeatureGrid />', () => {

const layerCand = map.getLayers().getArray().find(layer => layer.get('name') === defaultFeatureGridLayerName);

expect((layerCand as OlLayerVector<OlFeature>)?.getSource()?.getFeatures()).toHaveLength(3);
expect((layerCand as OlLayerVector<OlSourceVector>)?.getSource()?.getFeatures()).toHaveLength(3);

expect(screen.getByText('Shinji Kagawa')).toBeVisible();
expect(screen.getByText('Marco Reus')).toBeVisible();
Expand Down Expand Up @@ -138,7 +139,7 @@ describe('<FeatureGrid />', () => {
await userEvent.hover(row);

const layerCand = map.getLayers().getArray().find(layer => layer.get('name') === defaultFeatureGridLayerName);
const featCand = (layerCand as OlLayerVector<OlFeature>)?.getSource()?.getFeatures()
const featCand = (layerCand as OlLayerVector<OlSourceVector>)?.getSource()?.getFeatures()
.find(feat => feat.get('name') === 'Shinji Kagawa');

expect(featCand?.getStyle()).toBe(hoverStyle);
Expand All @@ -165,7 +166,7 @@ describe('<FeatureGrid />', () => {

const layerCand = map.getLayers().getArray().find(layer => layer.get('name') === defaultFeatureGridLayerName);

const feats = (layerCand as OlLayerVector<OlFeature>)?.getSource()?.getFeatures() || [];
const feats = (layerCand as OlLayerVector<OlSourceVector>)?.getSource()?.getFeatures() || [];

for (const feat of feats) {
expect(feat.getStyle()).toBe(selectStyle);
Expand Down
2 changes: 1 addition & 1 deletion src/Panel/SearchResultsPanel/SearchResultsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface SearchResultsPanelProps extends Partial<CollapseProps> {
}

const SearchResultsPanel = (props: SearchResultsPanelProps) => {
const [highlightLayer, setHighlightLayer] = useState<OlLayerVector<OlFeature> | null>(null);
const [highlightLayer, setHighlightLayer] = useState<OlLayerVector<OlSourceVector> | null>(null);
const map = useMap();

const {
Expand Down

0 comments on commit 3d60731

Please sign in to comment.