Skip to content

Commit

Permalink
Merge pull request #3 from Aquaveo/adding-maplibre
Browse files Browse the repository at this point in the history
filtered flowpaths
  • Loading branch information
romer8 authored Nov 15, 2024
2 parents 7240372 + 9482b6a commit 66d8719
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
25 changes: 22 additions & 3 deletions reactapp/features/Map/components/mapgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ import { useHydroFabricContext } from 'features/hydroFabric/hooks/useHydroFabric
if (map.getLayer('catchments')) {
map.setFilter('catchments', ['any', ['in', 'divide_id', ""]]);
console.log("Base 'catchments' layer has been filtered out.");
} else {
console.log("Base 'catchments' layer not found.");
}
if(map.getLayer('flowpaths')){
map.setFilter('flowpaths', ['any', ['in', 'id', ""]]);
console.log("Base 'flowpaths' layer has been filtered out.");
}
};

Expand Down Expand Up @@ -81,7 +83,7 @@ const MapComponent = () => {
const { actions: hydroFabricActions } = useHydroFabricContext();
const [nexusPoints, setNexusPoints] = useState(null);
const [catchmentConfig, setCatchmentConfig] = useState(null);

const [flowPathsConfig, setFlowPathsConfig] = useState(null);
const mapRef = useRef(null);

useEffect(() => {
Expand Down Expand Up @@ -113,6 +115,22 @@ const MapComponent = () => {
};
setCatchmentConfig(catchmentLayerConfig);

const flowPathsLayerConfig = {
"id": "flowpaths-layer",
"type": "line",
"source": "conus",
"source-layer": "flowpaths",
"layout": {},
"paint": {
"line-color": ["rgba", 0, 119, 187, 1],
"line-width": { "stops": [[7, 1], [10, 2]] },
"line-opacity": { "stops": [[7, 0], [11, 1]] }
},
"filter": ["any",["in", "id", ...response.flow_paths_ids]] // Replace with actual
}

setFlowPathsConfig(flowPathsLayerConfig);


}).catch(error => {
console.log(error);
Expand Down Expand Up @@ -206,6 +224,7 @@ const MapComponent = () => {
<Source id="conus" type="vector" url={pmtilesUrl}>
{/* Add the layer that uses the source */}
<Layer {...catchmentConfig} />
<Layer {...flowPathsConfig} />

</Source>
</Map>
Expand Down
4 changes: 3 additions & 1 deletion tethysapp/ngiab/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ def getGeoSpatialData(request, app_workspace):
# Convert the DataFrame to the "EPSG:3857" coordinate system
# gdf = gdf.to_crs("EPSG:3857")
gdf = gdf.to_crs("EPSG:4326")

flow_paths_ids = gdf["toid"].tolist()
bounds = gdf.total_bounds.tolist()
# filtered_gdf = gdf[gdf["ngen_usgs"] != "none"]
# data = json.loads(filtered_gdf.to_json())
Expand All @@ -105,7 +107,7 @@ def getGeoSpatialData(request, app_workspace):
response_object["nexus"] = data
response_object["bounds"] = bounds
response_object["catchments"] = getCatchmentsList(app_workspace)

response_object["flow_paths_ids"] = flow_paths_ids
return JsonResponse(response_object)


Expand Down

0 comments on commit 66d8719

Please sign in to comment.