From 580a9a38afc8829f6ce22d1cd22070de0e3dbcc8 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Tue, 18 May 2021 17:52:24 +0200 Subject: [PATCH 1/9] Draw canvas when cloning overlay A suggestion from https://github.com/openlayers/ol-cesium/issues/947 --- src/olcs/SynchronizedOverlay.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/olcs/SynchronizedOverlay.js b/src/olcs/SynchronizedOverlay.js index aef216eb4..e8d9607ee 100644 --- a/src/olcs/SynchronizedOverlay.js +++ b/src/olcs/SynchronizedOverlay.js @@ -184,6 +184,10 @@ class SynchronizedOverlay extends olOverlay { handleElementChanged() { function cloneNode(node, parent) { const clone = node.cloneNode(); + if (node.nodeName === 'CANVAS') { + const ctx = clone.getContext('2d'); + ctx.drawImage(node, 0, 0); + } if (parent) { parent.appendChild(clone); } From 69528970c71a859816566c9d1a891cc8cd9d61bd Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 19 May 2021 14:40:54 +0200 Subject: [PATCH 2/9] Improve linting --- webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index 9c7edbf85..c2bb2db2a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,6 @@ // eslint-disable-next-line import/no-unresolved const {merge} = require('webpack-merge'); -const commons = require('./buildtools/webpack.commons'); +const commons = require('./buildtools/webpack.commons.js'); let config = commons.config; From 13e1e3a78a342bfa2baf78ce06c7ae55fec7c2c4 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 19 May 2021 14:59:10 +0200 Subject: [PATCH 3/9] Update dependencies (except webpack) --- package.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 3af4153d4..ee0f8aae0 100644 --- a/package.json +++ b/package.json @@ -26,28 +26,28 @@ "cesium": ">= 1.62.0" }, "devDependencies": { - "@babel/core": "7.12.10", - "@babel/preset-env": "7.12.11", - "@mapbox/geojsonhint": "3.0.0", + "@babel/core": "^7.14.3", + "@babel/preset-env": "^7.14.2", + "@mapbox/geojsonhint": "^3.0.1", "babel-loader": "8.2.2", - "cesium": "1.77.0", - "copy-webpack-plugin": "6.2.1", + "cesium": "^1.81.0", + "copy-webpack-plugin": "^6.2.1", "cross-env": "7.0.3", - "eslint": "7.18.0", + "eslint": "^7.26.0", "eslint-config-openlayers": "12.0.0", - "eslint-import-resolver-webpack": "0.13.0", + "eslint-import-resolver-webpack": "^0.13.1", "fast-glob": "3.2.5", - "fs-extra": "9.0.1", + "fs-extra": "^10.0.0", "html-loader": "1.3.2", "html-webpack-plugin": "4.5.1", - "htmlparser2": "6.0.0", - "jsdoc": "3.6.6", + "htmlparser2": "^6.1.0", + "jsdoc": "^3.6.7", "nomnom": "1.8.1", "ol": "6.5.0", - "proj4": "2.7.0", + "proj4": "^2.7.2", "temp": "0.9.4", - "typedoc": "0.20.16", - "typescript": "4.1.3", + "typedoc": "^0.20.36", + "typescript": "^4.2.4", "webpack": "4.44.2", "webpack-cli": "3.3.12", "webpack-dev-server": "3.11.2", From 55062869a2a49af13e8fb2ec1106a9ca1dd46fbc Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 19 May 2021 14:59:24 +0200 Subject: [PATCH 4/9] Update old-fashioned example --- examples/lazy.html | 1 - examples/oldfashioned.html | 11 ++++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/lazy.html b/examples/lazy.html index 911f7ada3..dd13a902e 100644 --- a/examples/lazy.html +++ b/examples/lazy.html @@ -9,7 +9,6 @@
Delay downloading the Cesium script and initializing the 3D globe.
-
This is an experimental feature.
diff --git a/examples/oldfashioned.html b/examples/oldfashioned.html index 8fbdd36d7..a267829ef 100644 --- a/examples/oldfashioned.html +++ b/examples/oldfashioned.html @@ -1,14 +1,15 @@ - + - + - + +

Old-fashioned example

@@ -28,12 +29,12 @@ zoom: 3 }) }); - + var ol3d = new olcs.OLCesium({ map: ol2d, }); ol3d.setEnabled(true); - + var setEnabled = function() {ol3d.setEnabled(!ol3d.getEnabled())}; document.getElementById('enable').addEventListener('click', setEnabled); From 1828bc68e46941bfc0e4cad9913b5bc9697f1907 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 19 May 2021 16:03:33 +0200 Subject: [PATCH 5/9] Update webpack --- buildtools/webpack.commons.js | 12 ------------ buildtools/webpack.examples.js | 1 - buildtools/webpack.prod.js | 11 ++++------- package.json | 13 +++++++------ 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/buildtools/webpack.commons.js b/buildtools/webpack.commons.js index b37b01fdc..462da8d0d 100644 --- a/buildtools/webpack.commons.js +++ b/buildtools/webpack.commons.js @@ -1,6 +1,5 @@ const path = require('path'); - const babelPresets = [['@babel/preset-env', { 'targets': { 'browsers': ['ie 11'], @@ -31,16 +30,6 @@ const olcsRule = { } }; -const htmlRule = { - test: /\.html$/, - use: [{ - loader: 'html-loader', - options: { - minimize: false, - attributes: false - } - }] -}; const iconRule = { test: /\.(png|svg)$/, @@ -59,7 +48,6 @@ const config = { rules: [ olRule, olcsRule, - htmlRule, iconRule ] }, diff --git a/buildtools/webpack.examples.js b/buildtools/webpack.examples.js index f3be1211f..50b2284f2 100644 --- a/buildtools/webpack.examples.js +++ b/buildtools/webpack.examples.js @@ -24,7 +24,6 @@ for (const filename of glob.sync('examples/*.html', {onlyFiles: true})) { plugins.push( new HtmlWebpackPlugin({ template: `examples/${name}.html`, - chunksSortMode: 'manual', filename: `${exampleFilenamePrefix + name}.html`, chunks: ['commons', name], }) diff --git a/buildtools/webpack.prod.js b/buildtools/webpack.prod.js index f69c12e7e..66d3d9173 100644 --- a/buildtools/webpack.prod.js +++ b/buildtools/webpack.prod.js @@ -1,4 +1,3 @@ -const webpack = require('webpack'); const TerserPlugin = require('terser-webpack-plugin'); module.exports = { @@ -6,20 +5,18 @@ module.exports = { output: { filename: '[name].[chunkhash:20].js' }, - plugins: [ - new webpack.optimize.ModuleConcatenationPlugin(), - ], optimization: { minimizer: [ new TerserPlugin({ terserOptions: { + sourceMap: true, + ecma: 5, compress: { - drop_console: true + drop_console: true, + drop_debugger: true, } }, - cache: true, parallel: true, - sourceMap: true, }) ] } diff --git a/package.json b/package.json index ee0f8aae0..13f05bdf7 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "build-library": "cross-env NODE_ENV=production TARGET=library webpack --progress --bail", "build-library-debug": "cross-env NODE_ENV=development TARGET=library webpack --progress --bail", "build-umd": "cross-env NODE_ENV=production TARGET=umd webpack --progress --bail", - "start": "cross-env DEV_SERVER=1 NODE_ENV=development TARGET=examples webpack-dev-server --port 3000 --progress --watch --bail --debug", + "start": "cross-env DEV_SERVER=1 NODE_ENV=development TARGET=examples webpack serve --port 3000 --progress --bail", "typecheck": "tsc --pretty", "doc": "typedoc --name ol-cesium --excludeExternals --out dist/apidoc --entryPoints src/index.library.js --tsconfig ./tsconfig.json" }, @@ -29,17 +29,18 @@ "@babel/core": "^7.14.3", "@babel/preset-env": "^7.14.2", "@mapbox/geojsonhint": "^3.0.1", + "@types/webpack": "^5.28.0", "babel-loader": "8.2.2", "cesium": "^1.81.0", - "copy-webpack-plugin": "^6.2.1", + "copy-webpack-plugin": "^8.1.1", "cross-env": "7.0.3", "eslint": "^7.26.0", "eslint-config-openlayers": "12.0.0", "eslint-import-resolver-webpack": "^0.13.1", "fast-glob": "3.2.5", "fs-extra": "^10.0.0", - "html-loader": "1.3.2", - "html-webpack-plugin": "4.5.1", + "html-loader": "^2.1.2", + "html-webpack-plugin": "^5.3.1", "htmlparser2": "^6.1.0", "jsdoc": "^3.6.7", "nomnom": "1.8.1", @@ -48,8 +49,8 @@ "temp": "0.9.4", "typedoc": "^0.20.36", "typescript": "^4.2.4", - "webpack": "4.44.2", - "webpack-cli": "3.3.12", + "webpack": "^5.37.1", + "webpack-cli": "^4.7.0", "webpack-dev-server": "3.11.2", "webpack-merge": "5.7.3" } From 91e0f0c3b5b87481a8a683584150fd387a62e7db Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 19 May 2021 16:03:39 +0200 Subject: [PATCH 6/9] Add jsconfig --- jsconfig.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 jsconfig.json diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 000000000..cc4504850 --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "module": "esnext", + "baseUrl": ".", + "paths": { + "cesium/*": ["./node_modules/@camptocamp/cesium/Source/*"] + }, + "target": "es6" + }, + "include": [ + "src/**/*", + "./node_modules/@camptocamp/cesium/Source/**/*" + "./node_modules/ol/**/*" + ] + } From eaaaa6d8ad380905e5e1e34b31b7acc7929cc1c6 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 19 May 2021 17:13:53 +0200 Subject: [PATCH 7/9] Update changelog --- CHANGES.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index e555185b9..41fb0af0d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,12 @@ # Changelog +# v 2.13 - 2021-05-20 + +* Changes + * Port to CesiumJS 1.81 + * Port dev environment to webpack5 + * Copy canvas image when cloning overlay + # v 2.12 - 2021-01-18 * Changes diff --git a/package.json b/package.json index 13f05bdf7..da5a8d9e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ol-cesium", - "version": "2.12.1", + "version": "2.13.0", "description": "OpenLayers Cesium integration library", "scripts": { "build-examples": "cross-env NODE_ENV=production TARGET=examples webpack --progress --bail", From 5ece4b7a178eb8f303ea41c082f5784edd9e8d15 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 11 Mar 2021 14:25:41 +0100 Subject: [PATCH 8/9] Support -y in MVT template URL --- src/olcs/MVTImageryProvider.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/olcs/MVTImageryProvider.js b/src/olcs/MVTImageryProvider.js index 82aaaf91e..fd8cba0d8 100644 --- a/src/olcs/MVTImageryProvider.js +++ b/src/olcs/MVTImageryProvider.js @@ -5,6 +5,8 @@ import {toContext} from 'ol/render.js'; import {get as getProjection} from 'ol/proj.js'; import {VERSION as OL_VERSION} from 'ol/util.js'; import LRUCache from 'ol/structs/LRUCache.js'; +import {getForProjection as getTilegridForProjection} from 'ol/tilegrid.js'; +import {createFromTemplates as createTileUrlFunctions} from 'ol/tileurlfunction.js'; const format = new MVT(); @@ -40,6 +42,9 @@ export default class MVTImageryProvider { this.tileCache = new LRUCache(cacheSize); this.featureCache = options.featureCache || new LRUCache(cacheSize); // to avoid too frequent cache grooming we allow x2 capacity + + const tileGrid = getTilegridForProjection(this.projection_); + this.tileFunction_ = createTileUrlFunctions(this.urls, tileGrid); } getTileCredits() { @@ -103,7 +108,7 @@ export default class MVTImageryProvider { } getUrl_(z, x, y) { - const url = this.urls[0].replace('{x}', x).replace('{y}', y).replace('{z}', z); + const url = this.tileFunction_([z, x, y]); return url; } From c9eebe337eca0e243780c94216c1366822206f91 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Wed, 19 May 2021 17:21:10 +0200 Subject: [PATCH 9/9] Update changelog --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 41fb0af0d..62d8e4a06 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ * Port to CesiumJS 1.81 * Port dev environment to webpack5 * Copy canvas image when cloning overlay + * Use tile fonction in MVT imagery provider (handle minus, ...) # v 2.12 - 2021-01-18