diff --git a/reactapp/features/Map/components/mapgl.js b/reactapp/features/Map/components/mapgl.js index 5df392d..1fa0f17 100644 --- a/reactapp/features/Map/components/mapgl.js +++ b/reactapp/features/Map/components/mapgl.js @@ -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'); } @@ -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', @@ -259,19 +280,19 @@ const MapComponent = () => { clusterMaxZoom={14} > + )} - {/* Add the PMTiles source */} + - {/* Add the layer that uses the source */} - + ); }; diff --git a/reactapp/index.css b/reactapp/index.css index 53ec905..0b14fb1 100644 --- a/reactapp/index.css +++ b/reactapp/index.css @@ -1,5 +1,18 @@ -html, body { - height: 100%; - margin: 0; - padding: 0; - } \ No newline at end of file +: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; +} \ No newline at end of file diff --git a/tethysapp/ngiab/utils.py b/tethysapp/ngiab/utils.py index 8e3a362..bec1318 100644 --- a/tethysapp/ngiab/utils.py +++ b/tethysapp/ngiab/utils.py @@ -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) @@ -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 @@ -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