From 42404fdbc25a1dd2766e9f0588eecca449ee99e6 Mon Sep 17 00:00:00 2001 From: Jonas Date: Thu, 12 Jan 2023 09:26:28 +0100 Subject: [PATCH] New version of OpenLayers (#1648) New version of OpenLayers and removed monkey patch in print component since OL now have native support for transform: scale --- package-lock.json | 67 ++++++++++++++++----------- package.json | 4 +- src/controls/print/print-component.js | 37 --------------- 3 files changed, 43 insertions(+), 65 deletions(-) diff --git a/package-lock.json b/package-lock.json index e0fec5b69..2912b4949 100644 --- a/package-lock.json +++ b/package-lock.json @@ -285,16 +285,16 @@ "integrity": "sha512-rY0o9A5ECsTQRVhv7tL/OyDpGAoUB4tTvLiW1DSzQGq4bvTPhNw1VpSNjDJc5GFZ2XuyOtSWSVN05qOtcD71qQ==" }, "@mapbox/mapbox-gl-style-spec": { - "version": "13.25.0", - "resolved": "https://registry.npmjs.org/@mapbox/mapbox-gl-style-spec/-/mapbox-gl-style-spec-13.25.0.tgz", - "integrity": "sha512-ukBk13MyI/X4tjRfPaNCo4rJLrRJ7ZbANxjeQyGeLYJTF1DZxqkX9C8qlxnQlxYllBBDBWiYYX5lU1fIsm2jwg==", + "version": "13.28.0", + "resolved": "https://registry.npmjs.org/@mapbox/mapbox-gl-style-spec/-/mapbox-gl-style-spec-13.28.0.tgz", + "integrity": "sha512-B8xM7Fp1nh5kejfIl4SWeY0gtIeewbuRencqO3cJDrCHZpaPg7uY+V8abuR+esMeuOjRl5cLhVTP40v+1ywxbg==", "requires": { "@mapbox/jsonlint-lines-primitives": "~2.0.2", "@mapbox/point-geometry": "^0.1.0", "@mapbox/unitbezier": "^0.0.0", "csscolorparser": "~1.0.2", "json-stringify-pretty-compact": "^2.0.0", - "minimist": "^1.2.5", + "minimist": "^1.2.6", "rw": "^1.3.3", "sort-object": "^0.3.2" } @@ -367,9 +367,9 @@ } }, "@petamoriken/float16": { - "version": "3.6.6", - "resolved": "https://registry.npmjs.org/@petamoriken/float16/-/float16-3.6.6.tgz", - "integrity": "sha512-3MUulwMtsdCA9lw8a/Kc0XDBJJVCkYTQ5aGd+///TbfkOMXoOGAzzoiYKwPEsLYZv7He7fKJ/mCacqKOO7REyg==" + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/@petamoriken/float16/-/float16-3.7.1.tgz", + "integrity": "sha512-oXZOc+aePd0FnhTWk15pyqK+Do87n0TyLV1nxdEougE95X/WXWDqmQobfhgnSY7QsWn5euZUWuDVeTQvoQ5VNw==" }, "@polka/url": { "version": "1.0.0-next.21", @@ -1789,6 +1789,11 @@ "integrity": "sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==", "dev": true }, + "earcut": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/earcut/-/earcut-2.2.4.tgz", + "integrity": "sha512-/pjZsA1b4RPHbeWZQn66SWS8nZZWLQQ23oE3Eam7aroEFGEvwKAsJfZ9ytiEMycfzXWpca4FA9QIOehf7PocBQ==" + }, "ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -2790,17 +2795,24 @@ } }, "geotiff": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/geotiff/-/geotiff-2.0.4.tgz", - "integrity": "sha512-aG8h9bJccGusioPsEWsEqx8qdXpZN71A20WCvRKGxcnHSOWLKmC5ZmsAmodfxb9TRQvs+89KikGuPzxchhA+Uw==", + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/geotiff/-/geotiff-2.0.7.tgz", + "integrity": "sha512-FKvFTNowMU5K6lHYY2f83d4lS2rsCNdpUC28AX61x9ZzzqPNaWFElWv93xj0eJFaNyOYA63ic5OzJ88dHpoA5Q==", "requires": { "@petamoriken/float16": "^3.4.7", "lerc": "^3.0.0", - "lru-cache": "^6.0.0", "pako": "^2.0.4", "parse-headers": "^2.0.2", + "quick-lru": "^6.1.1", "web-worker": "^1.2.0", "xml-utils": "^1.0.2" + }, + "dependencies": { + "quick-lru": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-6.1.1.tgz", + "integrity": "sha512-S27GBT+F0NTRiehtbrgaSE1idUAJ5bX8dPAQTdylEyNlrdcH5X4Lz7Edz3DYzecbsCluD5zO8ZNEe04z3D3u6Q==" + } } }, "get-caller-file": { @@ -3778,6 +3790,7 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, "requires": { "yallist": "^4.0.0" } @@ -4531,20 +4544,21 @@ "dev": true }, "ol": { - "version": "6.15.1", - "resolved": "https://registry.npmjs.org/ol/-/ol-6.15.1.tgz", - "integrity": "sha512-ZG2CKTpJ8Q+tPywYysVwPk+yevwJzlbwjRKhoCvd7kLVWMbfBl1O/+Kg/yrZZrhG9FNXbFH4GeOZ5yVRqo3P4w==", + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/ol/-/ol-7.2.2.tgz", + "integrity": "sha512-eqJ1hhVQQ3Ap4OhYq9DRu5pz9RMpLhmoTauDoIqpn7logVi1AJE+lXjEHrPrTSuZYjtFbMgqr07sxoLNR65nrw==", "requires": { - "geotiff": "2.0.4", - "ol-mapbox-style": "^8.0.5", + "earcut": "^2.2.3", + "geotiff": "^2.0.7", + "ol-mapbox-style": "^9.2.0", "pbf": "3.2.1", "rbush": "^3.0.1" } }, "ol-mapbox-style": { - "version": "8.2.1", - "resolved": "https://registry.npmjs.org/ol-mapbox-style/-/ol-mapbox-style-8.2.1.tgz", - "integrity": "sha512-3kBBuZC627vDL8vnUdfVbCbfkhkcZj2kXPHQcuLhC4JJEA+XkEVEtEde8x8+AZctRbHwBkSiubTPaRukgLxIRw==", + "version": "9.4.0", + "resolved": "https://registry.npmjs.org/ol-mapbox-style/-/ol-mapbox-style-9.4.0.tgz", + "integrity": "sha512-I9dK1K41P8DjozFeQ4x1pfou86q/WedRzjCMpNhtHW9APJ/l3UT6aGsp2HcbG7cLfx3EpzK4Q7HxKwcQYR5Chw==", "requires": { "@mapbox/mapbox-gl-style-spec": "^13.23.1", "mapbox-to-css-font": "^2.4.1" @@ -4649,9 +4663,9 @@ "dev": true }, "pako": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pako/-/pako-2.0.4.tgz", - "integrity": "sha512-v8tweI900AUkZN6heMU/4Uy4cXRc2AYNRggVmTR+dEncawDJgCdLMximOVA2p4qO57WMynangsfGRb5WD6L1Bg==" + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", + "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==" }, "parent-module": { "version": "1.0.1", @@ -6789,9 +6803,9 @@ "dev": true }, "xml-utils": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/xml-utils/-/xml-utils-1.2.0.tgz", - "integrity": "sha512-z4unVPZruEDC3tfyd7wvWfjclnMz34iwQpv8H28H+qREpjKkR083MBvcrWXfJrIcrSmHR5ghguOcgQqWdnBpVA==" + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/xml-utils/-/xml-utils-1.3.0.tgz", + "integrity": "sha512-i4PIrX33Wd66dvwo4syicwlwmnr6wuvvn4f2ku9hA67C2Uk62Xubczuhct+Evnd12/DV71qKNeDdJwES8HX1RA==" }, "xtend": { "version": "4.0.2", @@ -6808,7 +6822,8 @@ "yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true }, "yargs": { "version": "16.2.0", diff --git a/package.json b/package.json index 6cb9b1d43..f41aa5966 100644 --- a/package.json +++ b/package.json @@ -39,9 +39,9 @@ "downloadjs": "^1.4.7", "elm-pep": "^1.0.6", "html2canvas": "^1.4.0", - "ol-mapbox-style": "8.2.1", + "ol-mapbox-style": "9.4.0", "jspdf": "^2.5.0", - "ol": "^6.15.1", + "ol": "^7.2.2", "pepjs": "^0.5.3", "proj4": "^2.7.5" }, diff --git a/src/controls/print/print-component.js b/src/controls/print/print-component.js index b9067cc75..625b33a51 100644 --- a/src/controls/print/print-component.js +++ b/src/controls/print/print-component.js @@ -5,7 +5,6 @@ import TileImage from 'ol/source/TileImage'; import TileWMSSource from 'ol/source/TileWMS'; import TileGrid from 'ol/tilegrid/TileGrid'; import { Group } from 'ol/layer'; -import PluggableMap from 'ol/PluggableMap'; import { Button, Component, cuid, dom } from '../../ui'; @@ -19,34 +18,6 @@ import { afterRender, beforeRender } from './download-callback'; import maputils from '../../maputils'; import PrintResize from './print-resize'; import { withLoading } from '../../loading'; -/** Backup of original OL function */ -const original = PluggableMap.prototype.getEventPixel; - -/** - * Recalculates the event position to account for transform: scale in the container as OL does not do that. - * Used to monkey patch OL. - * @param {any} event - */ -const getEventPixelScale = function monkeyPatch(event) { - // This is internal in OL, nust allow - // eslint-disable-next-line no-underscore-dangle - const viewportPosition = this.viewport_.getBoundingClientRect(); - let size = [viewportPosition.width, viewportPosition.height]; - const view = this.getView(); - if (view) { - // This is internal in OL, nust allow - // eslint-disable-next-line no-underscore-dangle - size = view.getViewportSize_(); - } - const eventPosition = 'changedTouches' in event ? event.changedTouches[0] : event; - - return [ - ((eventPosition.clientX - viewportPosition.left) * size[0]) - / viewportPosition.width, - ((eventPosition.clientY - viewportPosition.top) * size[1]) - / viewportPosition.height - ]; -}; const PrintComponent = function PrintComponent(options = {}) { const { @@ -463,10 +434,6 @@ const PrintComponent = function PrintComponent(options = {}) { printResize.resetLayers(); printResize.setResolution(150); } - // Restore monkey patch - // WORKAROUND: Remove when OL supports transform: scale - // See https://github.com/openlayers/openlayers/issues/13283 - PluggableMap.prototype.getEventPixel = original; // Restore scales if (!supressResolutionsRecalculation) { const viewerResolutions = viewer.getResolutions(); @@ -553,10 +520,6 @@ const PrintComponent = function PrintComponent(options = {}) { })); }, async onRender() { - // Monkey patch OL - // WORKAROUND: Remove when OL supports transform: scale - // See https://github.com/openlayers/openlayers/issues/13283 - PluggableMap.prototype.getEventPixel = getEventPixelScale; printScale = 0; today = new Date(Date.now()); viewerMapTarget = map.getTarget();