Skip to content

Commit

Permalink
added errors
Browse files Browse the repository at this point in the history
  • Loading branch information
romer8 committed Nov 21, 2024
1 parent 843f4a9 commit 5b802e0
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 38 deletions.
29 changes: 25 additions & 4 deletions reactapp/features/Map/components/mapgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { useHydroFabricContext } from 'features/hydroFabric/hooks/useHydroFabric
});
});
// Ensure 'unclustered-point' and 'clusters' layers are rendered on top of others

if (map.getLayer('unclustered-point')) {
map.moveLayer('unclustered-point');
}
Expand All @@ -37,9 +38,29 @@ import { useHydroFabricContext } from 'features/hydroFabric/hooks/useHydroFabric
if(map.getLayer('flowpaths')){
map.setFilter('flowpaths', ['any', ['in', 'id', ""]]);
}
if (map.getLayer('cluster-count')) {
map.moveLayer('cluster-count');
}
};


// Define the Cluster Count Layer
const clusterCountLayer = {
id: 'cluster-count',
type: 'symbol',
source: 'nexus-points',
filter: ['has', 'point_count'],
layout: {
'text-field': '{point_count_abbreviated}',
'text-font': ['Noto Sans Regular'],
'text-size': 12,
'text-anchor': 'center',
'text-justify': 'center',
'symbol-placement': 'point',
},
paint: {
'text-color': '#ffffff',
},
};
// Define the style for the Nexus Layer
const clusterLayer = {
id: 'clusters',
Expand Down Expand Up @@ -259,19 +280,19 @@ const MapComponent = () => {
clusterMaxZoom={14}
>
<Layer {...clusterLayer} />
<Layer {...clusterCountLayer} />
<Layer {...unclusteredPointLayer} />
</Source>
)}



{/* Add the PMTiles source */}

<Source id="conus" type="vector" url={pmtilesUrl}>
{/* Add the layer that uses the source */}
<Layer {...catchmentConfig} />
<Layer {...flowPathsConfig} />

</Source>

</Map>
);
};
Expand Down
23 changes: 18 additions & 5 deletions reactapp/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
html, body {
height: 100%;
margin: 0;
padding: 0;
}
:root {
/* Enabling light mode and dark mode*/
color-scheme: light dark;

/* Assigning light/dark color tokens into variable*/
--text-heading: light-dark(#333333, #f0f0f0);
--text-body: light-dark(#555555, #e0e0e0);
--background-primary: light-dark(#ff7d7d, #6f0000);
--background-secondary: light-dark(#fffef3, #1a1913);
}
body {
/* Consuming the color tokens */
background-color: var(--bg-primary);
color: var(--text-body);
height: 100%;
margin: 0;
padding: 0;
}
70 changes: 41 additions & 29 deletions tethysapp/ngiab/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import xarray as xr


import os


def append_ngen_usgs_column(gdf, app_workspace):
# Load ngen_usgs_crosswalk.parquet into DuckDB
base_output_teehr_path = get_base_teehr_path(app_workspace)
Expand All @@ -15,23 +18,28 @@ def append_ngen_usgs_column(gdf, app_workspace):
base_output_teehr_path, "ngen_usgs_crosswalk.parquet"
)

# Query the data from DuckDB
query = f"""
SELECT secondary_location_id, primary_location_id
FROM '{ngen_usgs_crosswalk_path}'
"""
ngen_usgs_df = duckdb.query(query).to_df()
if not os.path.exists(ngen_usgs_crosswalk_path):
# File not found, set 'ngen_usgs' column to 'none' for all entries
gdf["ngen_usgs"] = "none"
else:
# Query the data from DuckDB
query = f"""
SELECT secondary_location_id, primary_location_id
FROM '{ngen_usgs_crosswalk_path}'
"""
ngen_usgs_df = duckdb.query(query).to_df()

# Create a dictionary for fast lookup, replacing 'ngen' with 'nex' in the keys
ngen_usgs_map = {
sec_id.replace("ngen", "nex"): prim_id
for sec_id, prim_id in zip(
ngen_usgs_df["secondary_location_id"], ngen_usgs_df["primary_location_id"]
)
}
# Create a dictionary for fast lookup, replacing 'ngen' with 'nex' in the keys
ngen_usgs_map = {
sec_id.replace("ngen", "nex"): prim_id
for sec_id, prim_id in zip(
ngen_usgs_df["secondary_location_id"],
ngen_usgs_df["primary_location_id"],
)
}

# Append ngen_usgs column to the GeoDataFrame
gdf["ngen_usgs"] = gdf["id"].apply(lambda x: ngen_usgs_map.get(x, "none"))
# Append ngen_usgs column to the GeoDataFrame
gdf["ngen_usgs"] = gdf["id"].apply(lambda x: ngen_usgs_map.get(x, "none"))

return gdf

Expand All @@ -44,22 +52,26 @@ def append_nwm_usgs_column(gdf, app_workspace):
base_output_teehr_path, "nwm_usgs_crosswalk.parquet"
)

query = f"""
SELECT primary_location_id, secondary_location_id
FROM '{nwm_usgs_crosswalk_path}'
"""
nwm_usgs_df = duckdb.query(query).to_df()

# Create a dictionary for fast lookup
nwm_usgs_map = dict(
zip(
nwm_usgs_df["primary_location_id"],
nwm_usgs_df["secondary_location_id"],
if not os.path.exists(nwm_usgs_crosswalk_path):
# File not found, set 'ngen_usgs' column to 'none' for all entries
gdf["ngen_usgs"] = "none"
else:
query = f"""
SELECT primary_location_id, secondary_location_id
FROM '{nwm_usgs_crosswalk_path}'
"""
nwm_usgs_df = duckdb.query(query).to_df()

# Create a dictionary for fast lookup
nwm_usgs_map = dict(
zip(
nwm_usgs_df["primary_location_id"],
nwm_usgs_df["secondary_location_id"],
)
)
)

# Append nwm_usgs column to the GeoDataFrame
gdf["nwm_usgs"] = gdf["ngen_usgs"].apply(lambda x: nwm_usgs_map.get(x, "none"))
# Append nwm_usgs column to the GeoDataFrame
gdf["nwm_usgs"] = gdf["ngen_usgs"].apply(lambda x: nwm_usgs_map.get(x, "none"))
return gdf


Expand Down

0 comments on commit 5b802e0

Please sign in to comment.