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
- {{ 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 },