Skip to content

Commit

Permalink
Made some minor changes to incorporate Chesapeake Bay as a stopping f…
Browse files Browse the repository at this point in the history
…eature and correctly size bottom of the map for mobile. Reverted the changes to the stopping point calculation for now and will restore after pushing this to keep working on fixing the locator map issue.
  • Loading branch information
sdl60660 committed May 27, 2021
1 parent 52bdc3b commit 168783a
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/components/Map.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
// Construct full coordinate path by taking the first coordinate in each flowline (each coordinate in the flowline is an unnecessary level of detail)
const coordinatePath = flowlinesData.features.length > 3 ? [flowlinesData.features[0].geometry.coordinates[0], ...flowlinesData.features.map( feature => feature.geometry.coordinates.slice(-1)[0] ) ]
: flowlinesData.features.map( feature => feature.geometry.coordinates).flat();
: flowlinesData.features.map( feature => feature.geometry.coordinates).flat().filter((d,i) => i % 2 === 0);
// Update props used by child components
riverPath = [{ geometry: { coordinates: coordinatePath }}];
Expand Down Expand Up @@ -209,7 +209,6 @@
routeDistance * 0.00005
).geometry.coordinates;
// (Add error handling here)
const cameraStart = findArtificialCameraPoint({ distanceGap, originPoint: smoothedPath[0], targetPoint: firstBearingPoint})
// console.log('Distances:', routeDistance, cameraRouteDistance, trueRouteDistance);
Expand Down Expand Up @@ -350,9 +349,6 @@
let uniqueFeatureNames = featureNames.filter((item, i, ar) => ar.indexOf(item) === i);
const fullDistance = flowlinesData.features[0].properties.pathlength;
const fullPath = flowlinesData.features.map( feature => feature.geometry.coordinates ).flat();
const fullPathDistance = length(lineString(fullPath));
// This fixes a rare, but frustrating bug, where because I don't sample each flowline for VAA data, and because...
// I assume once a feature starts that it continues until the next unique feature, this function gets confused by...
// Long rivers sandwiching small unnames features, like the snake river in Idaho, and thinks that the small feature interruption
Expand Down Expand Up @@ -380,13 +376,11 @@
let riverFeatures = uniqueFeatureNames.map((feature, index) => {
const featureData = flowlinesData.features.find(item => item.properties.feature_id === feature);
const featureIndex = flowlinesData.features.findIndex(item => item.properties.feature_id === feature);
const progress = fullDistance === -999 ? (featureIndex / flowlinesData.features.length) :
getPartialDistance(fullPath, featureData.geometry.coordinates[0]) / fullPathDistance;
const featureIndex = flowlinesData.features.findIndex(item => item.properties.feature_id === feature);
return ({
feature_data_index: featureIndex,
progress,
progress: fullDistance === -999 ? (featureIndex / flowlinesData.features.length) : ((fullDistance - featureData.properties.pathlength) / fullDistance),
name: featureData.properties.feature_name,
distance_from_destination: featureData.properties.pathlength === -9999 ? 0 : featureData.properties.pathlength,
index,
Expand All @@ -395,8 +389,6 @@
})
});
console.log(riverFeatures.map(d => d.progress));
// Because I'm not sampling every flowline, sometimes I get weird results at the end of the flowpath where, for example, there's a flowline
// that's part of the Mississippi Delta, but isn't technically isn't grouped under the Mississippi river, and it considers it the last step
// Here, I'm going to treat anyting with streamlevel 1 (which means it's a terminal feature) as the last feature in the sequence, but add an
Expand Down Expand Up @@ -592,8 +584,7 @@
const startPoints = riverFeatures.map(d => d.progress);
let startPoint = startPoints[0];
const stopPoints = riverFeatures.map(d => d.stop_point);
console.log('stop points', stopPoints);
const stopPoints = riverFeatures.map(d => d.stop_point)
let stopPoint = stopPoints[0];
activeFeatureIndex = 0;
Expand Down

0 comments on commit 168783a

Please sign in to comment.