Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filtered flowpaths #3

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading