From 0182b777cd99132c015965b0e1896c955a089ed8 Mon Sep 17 00:00:00 2001 From: Ebubeker Rexha <60944813+Ebubeker@users.noreply.github.com> Date: Tue, 4 Jul 2023 17:24:34 +0200 Subject: [PATCH 1/2] fix: fixed the isochrone network --- .../src/components/isochrones/Isochrones.vue | 82 ++++++++++++++++--- 1 file changed, 69 insertions(+), 13 deletions(-) diff --git a/app/client/src/components/isochrones/Isochrones.vue b/app/client/src/components/isochrones/Isochrones.vue index e939d81a7..477e763cf 100644 --- a/app/client/src/components/isochrones/Isochrones.vue +++ b/app/client/src/components/isochrones/Isochrones.vue @@ -1202,22 +1202,16 @@ export default { }) }) .then(response => { - let olFeatures = geojsonToFeature(response.data, { - dataProjection: "EPSG:3857", - featureProjection: "EPSG:3857" - }); - olFeatures.forEach(feature => { - feature.set("calculationNumber", selectedCalculation.id); - }); - selectedCalculation.additionalData[type].data = olFeatures; - this.isochroneLayer.getSource().addFeatures(olFeatures); + this.getIsochroneNetwork( + response.data.task_id, + 1, + payload, + selectedCalculation, + type + ); }) .catch(error => { console.log(error); - }) - .finally(() => { - this.isMapBusy = false; - this.isIsochroneBusy = false; }); } else { this.isochroneLayer @@ -1469,6 +1463,68 @@ export default { } }, + /** + * + * Get Isochrone Network + * + */ + + getIsochroneNetwork( + taskId, + currentTry, + payload, + selectedCalculation, + type + ) { + const returnType = "network"; + const axiosInstance = axios.create(); + const CancelToken = axios.CancelToken; + if (this.maxTries > currentTry) { + let promise = axiosInstance.get( + `./indicators/result/${taskId}?return_type=${returnType}`, + { + // responseType: "arraybuffer", + cancelToken: new CancelToken(c => { + // An executor function receives a cancel function as a parameter + this.isochroneCancelToken = c; + }) + } + ); + promise + .then(response => { + if (response.status === 202) { + setTimeout(() => { + if (this.isochroneCancelToken != null) { + this.getIsochroneNetwork( + taskId, + currentTry + 1, + payload, + selectedCalculation, + type + ); + } else { + this.isIsochroneBusy = false; + this.isMapBusy = false; + } + }, 1000); + } else { + this.isIsochroneBusy = false; + this.isMapBusy = false; + let olFeatures = geojsonToFeature(response.data, { + dataProjection: "EPSG:3857", + featureProjection: "EPSG:3857" + }); + olFeatures.forEach(feature => { + feature.set("calculationNumber", selectedCalculation.id); + }); + selectedCalculation.additionalData[type].data = olFeatures; + this.isochroneLayer.getSource().addFeatures(olFeatures); + } + }) + .catch(err => console.log(err)); + } + }, + /** * Update isochrone change * From 603dee2655d6f1c03914e79252458b6132ce0cd1 Mon Sep 17 00:00:00 2001 From: Ebubeker Date: Fri, 14 Jul 2023 14:20:23 +0200 Subject: [PATCH 2/2] fix: fixed the buffer legend in the print --- app/client/package.json | 2 +- .../components/viewer/print/PrintLegend.vue | 26 +++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/client/package.json b/app/client/package.json index 6cbedffc6..5cfb389f0 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -3,7 +3,7 @@ "version": "1.0.1", "private": true, "scripts": { - "serve": "vue-cli-service serve --watch", + "serve": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --watch", "build": "vue-cli-service build", "lint": "vue-cli-service lint", "i18n:report": "vue-cli-service i18n:report --src './src/**/*.?(js|vue)' --locales './src/locales/**/*.json'" diff --git a/app/client/src/components/viewer/print/PrintLegend.vue b/app/client/src/components/viewer/print/PrintLegend.vue index 83e7f6049..168a945ed 100644 --- a/app/client/src/components/viewer/print/PrintLegend.vue +++ b/app/client/src/components/viewer/print/PrintLegend.vue @@ -105,8 +105,19 @@ {{ calculation.position }}

-->

- {{ calculationTravelTime[calculation.id - 1] }} - {{ $t("isochrones.traveltimes.minutes") }} + {{ + traveltimeLabel( + calculationTravelTime[calculation.id - 1], + calculation.routing + ) + }} + {{ + $t( + `isochrones.traveltimes.${ + calculation.routing === "buffer" ? "meters" : "minutes" + }` + ) + }}

@@ -346,6 +357,17 @@ export default { return styling; }, + // get the right time for isochrones and meters for buffer isochrone + traveltimeLabel(time, mode) { + if (mode === "buffer") { + time = time * 50; // converts to meters + } + if (time < 10) { + return "0" + time; + } else { + return time.toString(); + } + }, secondsToHoursAndMins },