Skip to content

Commit

Permalink
Set up name overrides for future if we hit critical mass of suggestio…
Browse files Browse the repository at this point in the history
…ns or spot some on our own to slot in
  • Loading branch information
sdl60660 committed Dec 22, 2021
1 parent 3cd84d5 commit fb62658
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions public/data/name_overrides.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"542939": {
"nameid": "542939",
"feature_name": "Sunkoshi"
}
}
5 changes: 4 additions & 1 deletion src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
d3.json("data/us_states.json"),
d3.json("data/global_stopping_features.json"),
d3.json("data/active_nwis_sites.json"),
d3.json("data/name_overrides.json"),
];
const dataLoad = Promise.all(dataFilePromises).then(async (data) => {
Expand All @@ -19,8 +20,9 @@
).features;
const activeNWISSites = data[2].sites;
const nameOverrides = data[3];
return [states, stoppingFeatures, activeNWISSites];
return [states, stoppingFeatures, activeNWISSites, nameOverrides];
});
</script>

Expand All @@ -35,6 +37,7 @@
stateBoundaries={data[0]}
stoppingFeatures={data[1]}
activeNWISSites={data[2]}
nameOverrides={data[3]}
visibleIndex={1}
addTopo={true}
mapStyle={"mapbox://styles/mapbox-map-design/ckhqrf2tz0dt119ny6azh975y"}
Expand Down
6 changes: 5 additions & 1 deletion src/components/Map.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
export let mapStyle;
export let addTopo;
export let advancedFeaturesOn;
export let nameOverrides;
const urlParams = new URLSearchParams(window.location.search);
let startingSearch = urlParams.has("lat")
Expand Down Expand Up @@ -619,11 +620,14 @@
flowlinesData.features = flowlinesData.features.sort(
(a, b) => b.properties.hydroseq - a.properties.hydroseq
);
flowlinesData.features.forEach((feature) => {
feature.properties.feature_name =
feature.properties.nameid === "unknown"
? `Unidentified River ${feature.properties.levelpathi}`
? nameOverrides[feature.properties.levelpathi]?.feature_name ||
`Unidentified River ${feature.properties.levelpathi}`
: feature.properties.nameid;
feature.properties.feature_id =
feature.properties.nameid === "unknown"
? feature.properties.levelpathi
Expand Down

1 comment on commit fb62658

@vercel
Copy link

@vercel vercel bot commented on fb62658 Dec 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.