Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed the isochrone network #2385

Merged
merged 2 commits into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
82 changes: 69 additions & 13 deletions app/client/src/components/isochrones/Isochrones.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
*
Expand Down
26 changes: 24 additions & 2 deletions app/client/src/components/viewer/print/PrintLegend.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,19 @@
{{ calculation.position }}
</p> -->
<p class="ma-0" style="font-size: 10.5px; font-weight: bold;">
{{ calculationTravelTime[calculation.id - 1] }}
{{ $t("isochrones.traveltimes.minutes") }}
{{
traveltimeLabel(
calculationTravelTime[calculation.id - 1],
calculation.routing
)
}}
{{
$t(
`isochrones.traveltimes.${
calculation.routing === "buffer" ? "meters" : "minutes"
}`
)
}}
</p>
</div>
</section>
Expand Down Expand Up @@ -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
},

Expand Down
Loading