From 177b9a3431d008305ea626f5081905c9ffae511c Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 13 Mar 2024 12:13:45 +0100 Subject: [PATCH 1/4] Adapt code to ol 9.0.0 --- jest.config.cjs | 2 +- package-lock.json | 70 +++++++++++++++++++++++++++++++++++++++----- package.json | 4 +-- src/MVTEncoder.ts | 25 +++++++--------- src/demo/demo-app.ts | 2 +- 5 files changed, 77 insertions(+), 26 deletions(-) diff --git a/jest.config.cjs b/jest.config.cjs index dc960a1..4709149 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -192,6 +192,6 @@ module.exports = { // Whether to use watchman for file crawling // watchman: true, transformIgnorePatterns: [ - "node_modules/(?!(ol|pbf|@open-wc|chai-a11y-axe|lit-html|lit-element|node-fetch|fetch-blob|data-uri-to-buffer|formdata-polyfill)/)", // <- exclude the OL lib + "node_modules/(?!(ol|pbf|@open-wc|chai-a11y-axe|lit-html|lit-element|node-fetch|fetch-blob|data-uri-to-buffer|formdata-polyfill|color-space|color-rgba|color-parse)/)", // <- exclude the OL lib ] }; diff --git a/package-lock.json b/package-lock.json index f4b7360..ebff152 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,7 @@ "jest-environment-jsdom": "29.7.0", "lit": "3.1.2", "node-fetch": "3.3.2", - "ol": "8.0.0", + "ol": "9.0.0", "ol-mapbox-style": "12.2.1", "pixelmatch": "^5.3.0", "pngjs": "^7.0.0", @@ -34,7 +34,7 @@ "vite": "5.1.4" }, "peerDependencies": { - "ol": "7 || 8" + "ol": "9" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -4615,6 +4615,31 @@ "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", "dev": true }, + "node_modules/color-parse": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/color-parse/-/color-parse-2.0.0.tgz", + "integrity": "sha512-g2Z+QnWsdHLppAbrpcFWo629kLOnOPtpxYV69GCqm92gqSgyXbzlfyN3MXs0412fPBkFmiuS+rXposgBgBa6Kg==", + "dev": true, + "dependencies": { + "color-name": "^1.0.0" + } + }, + "node_modules/color-rgba": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/color-rgba/-/color-rgba-3.0.0.tgz", + "integrity": "sha512-PPwZYkEY3M2THEHHV6Y95sGUie77S7X8v+h1r6LSAPF3/LL2xJ8duUXSrkic31Nzc4odPwHgUbiX/XuTYzQHQg==", + "dev": true, + "dependencies": { + "color-parse": "^2.0.0", + "color-space": "^2.0.0" + } + }, + "node_modules/color-space": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-space/-/color-space-2.0.1.tgz", + "integrity": "sha512-nKqUYlo0vZATVOFHY810BSYjmCARrG7e5R3UE3CQlyjJTvv5kSSmPG1kzm/oDyyqjehM+lW1RnEt9It9GNa5JA==", + "dev": true + }, "node_modules/combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", @@ -9087,11 +9112,13 @@ } }, "node_modules/ol": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/ol/-/ol-8.0.0.tgz", - "integrity": "sha512-tWDVFlt4ylZJeByD/Q5vSWPxEMoHy1tyyWT+LFDlGmGl6p9kmxtCfGAIupwUGrc5ifWsy+gDbg6QGd1Qw0y3HA==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/ol/-/ol-9.0.0.tgz", + "integrity": "sha512-+nYHZYbHrRUTDJ8ryxXPdDoAiaT6Zea02cocmGqsJXs4Oac1fYC9EbTIU2Y7803QcmG3u2MR88RxbksBvK+ZfQ==", "dev": true, "dependencies": { + "color-rgba": "^3.0.0", + "color-space": "^2.0.1", "earcut": "^2.2.3", "geotiff": "^2.0.7", "pbf": "3.2.1", @@ -14245,6 +14272,31 @@ "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", "dev": true }, + "color-parse": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/color-parse/-/color-parse-2.0.0.tgz", + "integrity": "sha512-g2Z+QnWsdHLppAbrpcFWo629kLOnOPtpxYV69GCqm92gqSgyXbzlfyN3MXs0412fPBkFmiuS+rXposgBgBa6Kg==", + "dev": true, + "requires": { + "color-name": "^1.0.0" + } + }, + "color-rgba": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/color-rgba/-/color-rgba-3.0.0.tgz", + "integrity": "sha512-PPwZYkEY3M2THEHHV6Y95sGUie77S7X8v+h1r6LSAPF3/LL2xJ8duUXSrkic31Nzc4odPwHgUbiX/XuTYzQHQg==", + "dev": true, + "requires": { + "color-parse": "^2.0.0", + "color-space": "^2.0.0" + } + }, + "color-space": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-space/-/color-space-2.0.1.tgz", + "integrity": "sha512-nKqUYlo0vZATVOFHY810BSYjmCARrG7e5R3UE3CQlyjJTvv5kSSmPG1kzm/oDyyqjehM+lW1RnEt9It9GNa5JA==", + "dev": true + }, "combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", @@ -17533,11 +17585,13 @@ } }, "ol": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/ol/-/ol-8.0.0.tgz", - "integrity": "sha512-tWDVFlt4ylZJeByD/Q5vSWPxEMoHy1tyyWT+LFDlGmGl6p9kmxtCfGAIupwUGrc5ifWsy+gDbg6QGd1Qw0y3HA==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/ol/-/ol-9.0.0.tgz", + "integrity": "sha512-+nYHZYbHrRUTDJ8ryxXPdDoAiaT6Zea02cocmGqsJXs4Oac1fYC9EbTIU2Y7803QcmG3u2MR88RxbksBvK+ZfQ==", "dev": true, "requires": { + "color-rgba": "^3.0.0", + "color-space": "^2.0.1", "earcut": "^2.2.3", "geotiff": "^2.0.7", "pbf": "3.2.1", diff --git a/package.json b/package.json index 6ddb6f4..5b301f2 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "test": "jest" }, "peerDependencies": { - "ol": "7 || 8" + "ol": "9" }, "devDependencies": { "@babel/preset-env": "7.24.0", @@ -45,7 +45,7 @@ "jest-environment-jsdom": "29.7.0", "lit": "3.1.2", "node-fetch": "3.3.2", - "ol": "8.0.0", + "ol": "9.0.0", "ol-mapbox-style": "12.2.1", "pixelmatch": "^5.3.0", "pngjs": "^7.0.0", diff --git a/src/MVTEncoder.ts b/src/MVTEncoder.ts index ea40995..85a2b32 100644 --- a/src/MVTEncoder.ts +++ b/src/MVTEncoder.ts @@ -24,7 +24,6 @@ import {transform2D} from 'ol/geom/flat/transform.js'; import CanvasBuilderGroup from 'ol/render/canvas/BuilderGroup.js'; import CanvasExecutorGroup from 'ol/render/canvas/ExecutorGroup.js'; -import RBush from 'rbush'; import TileGrid from 'ol/tilegrid/TileGrid'; /** @@ -109,7 +108,7 @@ export default class MVTEncoder { * @param coordinateToPixelTransform World to CSS coordinates transform (top-left is 0) * @param context * @param renderBuffer - * @param declutterTree + * @param declutter */ private drawFeaturesToContextUsingRenderAPI_( featuresExtent: _FeatureExtent, @@ -118,7 +117,7 @@ export default class MVTEncoder { coordinateToPixelTransform: Transform, context: CanvasRenderingContext2D, renderBuffer: number, - declutterTree?: RBush + declutter: boolean ) { const pixelRatio = 1; const builderGroup = new CanvasBuilderGroup( @@ -129,7 +128,7 @@ export default class MVTEncoder { ); let declutterBuilderGroup: CanvasBuilderGroup | undefined; - if (declutterTree) { + if (declutter) { declutterBuilderGroup = new CanvasBuilderGroup( 0, featuresExtent.extent, @@ -169,7 +168,7 @@ export default class MVTEncoder { tolerance, resourceLoadedListener, undefined, - declutterBuilderGroup + declutter ) || loading; } } @@ -195,14 +194,13 @@ export default class MVTEncoder { executorGroupInstructions, renderBuffer ); - const scale = 1; const transform = coordinateToPixelTransform; const viewRotation = 0; const snapToPixel = true; renderingExecutorGroup.execute( context, - scale, + [context.canvas.width, context.canvas.height], transform, viewRotation, snapToPixel, @@ -220,12 +218,12 @@ export default class MVTEncoder { ); declutterExecutorGroup.execute( context, - scale, + [context.canvas.width, context.canvas.height], transform, viewRotation, snapToPixel, undefined, - declutterTree + declutter ); } } @@ -433,8 +431,7 @@ export default class MVTEncoder { const styleResolution = options.styleResolution || tileResolution; const layerStyleFunction = layer.getStyleFunction()!; // there is always a default one const layerOpacity = layer.get('opacity'); - - const decluterTree = layer.getDeclutter() ? new RBush(9) : undefined; + const declutter = !!layer.getDeclutter(); // render to these tiles; const encodedLayers = renderTiles.map((rt) => @@ -446,7 +443,7 @@ export default class MVTEncoder { layerStyleFunction, layerOpacity, renderBuffer, - decluterTree, + declutter, outputFormat ) ); @@ -461,7 +458,7 @@ export default class MVTEncoder { layerStyleFunction: StyleFunction, layerOpacity: number, renderBuffer: number, - decluterTree?: RBush, + declutter: boolean, outputFormat?: string ): PrintResult { const canvas = document.createElement('canvas'); @@ -497,7 +494,7 @@ export default class MVTEncoder { transform, ctx!, renderBuffer, - decluterTree + declutter ); } }); diff --git a/src/demo/demo-app.ts b/src/demo/demo-app.ts index 49fdd60..6a86ea1 100644 --- a/src/demo/demo-app.ts +++ b/src/demo/demo-app.ts @@ -66,7 +66,7 @@ export class DemoApp extends LitElement { private map?: OLMap; private mvtLayer?: VectorTileLayer; - private printExtentLayer?: VectorLayer>; + private printExtentLayer?: VectorLayer>>; private targetSizeInPdfPoints: [number, number] = [255, 355]; // 72pts / inch => ~[9cm, 12.5cm] private printScale = 1 / 5000; private dpi = 96; // let's take a value adapted for a screen. For a printer 254 would be better. From d7c79d4b569e8b6b70adb479a28bc021b5dbd4b4 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 15 Mar 2024 14:27:39 +0100 Subject: [PATCH 2/4] Support OpenLayers 7, 8, 9 --- package-lock.json | 68 ++++++++++++++++++++++++++++------------------- package.json | 2 +- src/MVTEncoder.ts | 25 +++++++++++++---- 3 files changed, 62 insertions(+), 33 deletions(-) diff --git a/package-lock.json b/package-lock.json index ebff152..4b3647f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,7 +34,7 @@ "vite": "5.1.4" }, "peerDependencies": { - "ol": "9" + "ol": "7 || 8 || 9" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -3263,9 +3263,9 @@ } }, "node_modules/@petamoriken/float16": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/@petamoriken/float16/-/float16-3.8.3.tgz", - "integrity": "sha512-an2OZ7/6er9Jja8EDUvU/tmtGIutdlb6LwXOwgjzoCjDRAsUd8sRZMBjoPEy78Xa9iOp+Kglk2CHgVwZuZbWbw==", + "version": "3.8.6", + "resolved": "https://registry.npmjs.org/@petamoriken/float16/-/float16-3.8.6.tgz", + "integrity": "sha512-GNJhABTtcmt9al/nqdJPycwFD46ww2+q2zwZzTjY0dFFwUAFRw9zszvEr9osyJRd9krRGy6hUDopWUg9fX7VVw==", "dev": true }, "node_modules/@rollup/rollup-android-arm-eabi": { @@ -4616,9 +4616,9 @@ "dev": true }, "node_modules/color-parse": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/color-parse/-/color-parse-2.0.0.tgz", - "integrity": "sha512-g2Z+QnWsdHLppAbrpcFWo629kLOnOPtpxYV69GCqm92gqSgyXbzlfyN3MXs0412fPBkFmiuS+rXposgBgBa6Kg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-parse/-/color-parse-2.0.1.tgz", + "integrity": "sha512-lJJCDBXlTHDI+iO1VIbrMPR8OqxR3kZoyiLDqPh+FOtXfzjL45q8QNHjf98KaZ5Ki+WPPcdWmbUibMD15spbUg==", "dev": true, "dependencies": { "color-name": "^1.0.0" @@ -6109,9 +6109,9 @@ } }, "node_modules/geotiff": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/geotiff/-/geotiff-2.0.7.tgz", - "integrity": "sha512-FKvFTNowMU5K6lHYY2f83d4lS2rsCNdpUC28AX61x9ZzzqPNaWFElWv93xj0eJFaNyOYA63ic5OzJ88dHpoA5Q==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/geotiff/-/geotiff-2.1.3.tgz", + "integrity": "sha512-PT6uoF5a1+kbC3tHmZSUsLHBp2QJlHasxxxxPW47QIY1VBKpFB+FcDvX+MxER6UzgLQZ0xDzJ9s48B9JbOCTqA==", "dev": true, "dependencies": { "@petamoriken/float16": "^3.4.7", @@ -6120,7 +6120,8 @@ "parse-headers": "^2.0.2", "quick-lru": "^6.1.1", "web-worker": "^1.2.0", - "xml-utils": "^1.0.2" + "xml-utils": "^1.0.2", + "zstddec": "^0.1.0" }, "engines": { "node": ">=10.19" @@ -10744,9 +10745,9 @@ } }, "node_modules/web-worker": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/web-worker/-/web-worker-1.2.0.tgz", - "integrity": "sha512-PgF341avzqyx60neE9DD+XS26MMNMoUQRz9NOZwW32nPQrF6p77f1htcnjBSEV8BGMKZ16choqUG4hyI0Hx7mA==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/web-worker/-/web-worker-1.3.0.tgz", + "integrity": "sha512-BSR9wyRsy/KOValMgd5kMyr3JzpdeoR9KVId8u5GVlTTAtNChlsE4yTxeY7zMdNSyOmoKBv8NH2qeRY9Tg+IaA==", "dev": true }, "node_modules/webidl-conversions": { @@ -11075,6 +11076,12 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/zstddec": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/zstddec/-/zstddec-0.1.0.tgz", + "integrity": "sha512-w2NTI8+3l3eeltKAdK8QpiLo/flRAr2p8AGeakfMZOXBxOg9HIu4LVDxBi81sYgVhFhdJjv1OrB5ssI8uFPoLg==", + "dev": true } }, "dependencies": { @@ -13289,9 +13296,9 @@ } }, "@petamoriken/float16": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/@petamoriken/float16/-/float16-3.8.3.tgz", - "integrity": "sha512-an2OZ7/6er9Jja8EDUvU/tmtGIutdlb6LwXOwgjzoCjDRAsUd8sRZMBjoPEy78Xa9iOp+Kglk2CHgVwZuZbWbw==", + "version": "3.8.6", + "resolved": "https://registry.npmjs.org/@petamoriken/float16/-/float16-3.8.6.tgz", + "integrity": "sha512-GNJhABTtcmt9al/nqdJPycwFD46ww2+q2zwZzTjY0dFFwUAFRw9zszvEr9osyJRd9krRGy6hUDopWUg9fX7VVw==", "dev": true }, "@rollup/rollup-android-arm-eabi": { @@ -14273,9 +14280,9 @@ "dev": true }, "color-parse": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/color-parse/-/color-parse-2.0.0.tgz", - "integrity": "sha512-g2Z+QnWsdHLppAbrpcFWo629kLOnOPtpxYV69GCqm92gqSgyXbzlfyN3MXs0412fPBkFmiuS+rXposgBgBa6Kg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-parse/-/color-parse-2.0.1.tgz", + "integrity": "sha512-lJJCDBXlTHDI+iO1VIbrMPR8OqxR3kZoyiLDqPh+FOtXfzjL45q8QNHjf98KaZ5Ki+WPPcdWmbUibMD15spbUg==", "dev": true, "requires": { "color-name": "^1.0.0" @@ -15389,9 +15396,9 @@ "dev": true }, "geotiff": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/geotiff/-/geotiff-2.0.7.tgz", - "integrity": "sha512-FKvFTNowMU5K6lHYY2f83d4lS2rsCNdpUC28AX61x9ZzzqPNaWFElWv93xj0eJFaNyOYA63ic5OzJ88dHpoA5Q==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/geotiff/-/geotiff-2.1.3.tgz", + "integrity": "sha512-PT6uoF5a1+kbC3tHmZSUsLHBp2QJlHasxxxxPW47QIY1VBKpFB+FcDvX+MxER6UzgLQZ0xDzJ9s48B9JbOCTqA==", "dev": true, "requires": { "@petamoriken/float16": "^3.4.7", @@ -15400,7 +15407,8 @@ "parse-headers": "^2.0.2", "quick-lru": "^6.1.1", "web-worker": "^1.2.0", - "xml-utils": "^1.0.2" + "xml-utils": "^1.0.2", + "zstddec": "^0.1.0" } }, "get-caller-file": { @@ -18740,9 +18748,9 @@ "dev": true }, "web-worker": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/web-worker/-/web-worker-1.2.0.tgz", - "integrity": "sha512-PgF341avzqyx60neE9DD+XS26MMNMoUQRz9NOZwW32nPQrF6p77f1htcnjBSEV8BGMKZ16choqUG4hyI0Hx7mA==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/web-worker/-/web-worker-1.3.0.tgz", + "integrity": "sha512-BSR9wyRsy/KOValMgd5kMyr3JzpdeoR9KVId8u5GVlTTAtNChlsE4yTxeY7zMdNSyOmoKBv8NH2qeRY9Tg+IaA==", "dev": true }, "webidl-conversions": { @@ -18983,6 +18991,12 @@ "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "dev": true + }, + "zstddec": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/zstddec/-/zstddec-0.1.0.tgz", + "integrity": "sha512-w2NTI8+3l3eeltKAdK8QpiLo/flRAr2p8AGeakfMZOXBxOg9HIu4LVDxBi81sYgVhFhdJjv1OrB5ssI8uFPoLg==", + "dev": true } } } diff --git a/package.json b/package.json index 5b301f2..fce144c 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "test": "jest" }, "peerDependencies": { - "ol": "9" + "ol": "7 || 8 || 9" }, "devDependencies": { "@babel/preset-env": "7.24.0", diff --git a/src/MVTEncoder.ts b/src/MVTEncoder.ts index 85a2b32..3c1245e 100644 --- a/src/MVTEncoder.ts +++ b/src/MVTEncoder.ts @@ -24,7 +24,12 @@ import {transform2D} from 'ol/geom/flat/transform.js'; import CanvasBuilderGroup from 'ol/render/canvas/BuilderGroup.js'; import CanvasExecutorGroup from 'ol/render/canvas/ExecutorGroup.js'; -import TileGrid from 'ol/tilegrid/TileGrid'; +import RBush from 'rbush'; +import TileGrid from 'ol/tilegrid/TileGrid.js'; +import {VERSION} from 'ol'; +import type {Size} from 'ol/size.js'; + +const olMajorVersion = Number.parseInt(VERSION.split('.')[0]); /** * Simple proxy to the fetch function for now. @@ -168,7 +173,7 @@ export default class MVTEncoder { tolerance, resourceLoadedListener, undefined, - declutter + declutterBuilderGroup ) || loading; } } @@ -197,10 +202,14 @@ export default class MVTEncoder { const transform = coordinateToPixelTransform; const viewRotation = 0; const snapToPixel = true; + const scaledSize = + olMajorVersion < 9 + ? (1 as unknown as Size) + : [context.canvas.width, context.canvas.height]; renderingExecutorGroup.execute( context, - [context.canvas.width, context.canvas.height], + scaledSize, transform, viewRotation, snapToPixel, @@ -218,7 +227,7 @@ export default class MVTEncoder { ); declutterExecutorGroup.execute( context, - [context.canvas.width, context.canvas.height], + scaledSize, transform, viewRotation, snapToPixel, @@ -431,7 +440,13 @@ export default class MVTEncoder { const styleResolution = options.styleResolution || tileResolution; const layerStyleFunction = layer.getStyleFunction()!; // there is always a default one const layerOpacity = layer.get('opacity'); - const declutter = !!layer.getDeclutter(); + // declutter is a boolean in OpenLayers 9 but anq RBush in earlier versions + const declutter: boolean = + olMajorVersion < 9 + ? ((layer.getDeclutter() + ? new RBush(7) + : undefined) as unknown as boolean) + : !!layer.getDeclutter(); // render to these tiles; const encodedLayers = renderTiles.map((rt) => From e1480d7ca991912b43e8edfb1e5f36a6780d161f Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 15 Mar 2024 14:43:40 +0100 Subject: [PATCH 3/4] Update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbc1ac0..a092b39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# v0.7.5 - 2024/03/15 + +- port to OpenLayers 9 +- support for OpenLayers versions 7 and 8 is deprecated and will be removed in the future + # v0.7.4 - 2023/09/04 - port to OpenLayers 8 From ec8657ebe8dd35130d8afb99ac4e4da76a5d4ee4 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 15 Mar 2024 14:58:50 +0100 Subject: [PATCH 4/4] Onldy create declutter builder group when using it --- src/MVTEncoder.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/MVTEncoder.ts b/src/MVTEncoder.ts index 3c1245e..a28e17a 100644 --- a/src/MVTEncoder.ts +++ b/src/MVTEncoder.ts @@ -133,7 +133,7 @@ export default class MVTEncoder { ); let declutterBuilderGroup: CanvasBuilderGroup | undefined; - if (declutter) { + if (declutter && olMajorVersion <= 9) { declutterBuilderGroup = new CanvasBuilderGroup( 0, featuresExtent.extent, @@ -173,7 +173,9 @@ export default class MVTEncoder { tolerance, resourceLoadedListener, undefined, - declutterBuilderGroup + olMajorVersion <= 9 + ? (declutterBuilderGroup as unknown as boolean) + : declutter ) || loading; } }