From b01af566b3fc903a44a8fc896b9fa1f11943fdc9 Mon Sep 17 00:00:00 2001 From: sdl60660 Date: Mon, 17 Jan 2022 13:39:54 -0500 Subject: [PATCH] Fixed the issue with path lengths displaying as 0km, which was due to an off-by-one error with the flowline lengths --- src/components/Map.svelte | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/Map.svelte b/src/components/Map.svelte index a1315ae..db6843f 100644 --- a/src/components/Map.svelte +++ b/src/components/Map.svelte @@ -284,12 +284,13 @@ // currentFlowrateIndex = 0; } - // Find the parent features of flowlines along the path + totalLength = - flowlinesData.features[0].properties.pathlength > 0 - ? flowlinesData.features[0].properties.pathlength + flowlinesData.features[0].properties.pathlength >= 0 + ? flowlinesData.features[0].properties.pathlength + flowlinesData.features[0].properties.lengthkm : undefined; + // Find the parent features of flowlines along the path const riverFeatures = getFeatureGroups(flowlinesData); featureGroups = riverFeatures; @@ -527,7 +528,7 @@ try { const roundedLng = e.lngLat.lng.toFixed(roundingDigits); const roundedLat = e.lngLat.lat.toFixed(roundingDigits); - const iowURL = `https://merit.internetofwater.app/processes/river-runner/execution?lng=${roundedLng}&lat=${roundedLat}&properties=comid,nameid,pathlength,levelpathi,streamlev,riverid,hydroseq`; + const iowURL = `https://merit.internetofwater.app/processes/river-runner/execution?lng=${roundedLng}&lat=${roundedLat}&properties=comid,nameid,pathlength,levelpathi,streamlev,riverid,hydroseq,lengthkm`; const flowlinesResponse = await fetch(iowURL, { method: "GET", @@ -700,7 +701,7 @@ distance_from_destination: featureData.properties.pathlength === -9999 ? 0 - : featureData.properties.pathlength, + : featureData.properties.pathlength + featureData.properties.lengthkm, index, stream_level: featureData.properties.streamlev, active: false,