diff --git a/src/actions/getWaterbodyData.jsx b/src/actions/getWaterbodyData.jsx
index cb42d6c5..c42b355a 100644
--- a/src/actions/getWaterbodyData.jsx
+++ b/src/actions/getWaterbodyData.jsx
@@ -1,231 +1,180 @@
import getVectorLayers from "./getVectorLayers";
import GeoJSON from "ol/format/GeoJSON";
-import { Style, Fill, Stroke } from "ol/style";
+import { Style, Stroke } from "ol/style";
export const getWaterbodyData = async ({
- district,
- block,
- map,
- waterbodyUID = null,
- }) => {
- console.log(district,block,waterbodyUID,map)
- if (
- !district?.label ||
- !block?.label ||
- !map
- ) {
- console.warn("Missing district/block label in getWaterbodyData", {
- district,
- block,
- });
- return null;
- }
+ district,
+ block,
+ map,
+ waterbodyUID = null,
+}) => {
+
+ if (!district?.label || !block?.label || !map) {
+ console.warn("Missing district/block label in getWaterbodyData");
+ return null;
+ }
+
+ const dist = district.label.toLowerCase().replace(/\s+/g, "_");
+ const blk = block.label.toLowerCase().replace(/\s+/g, "_");
+
+ const yellowWaterbodyStyle = new Style({
+ stroke: new Stroke({
+ color: "yellow",
+ width: 1.5,
+ }),
+ });
- const transformName = (name) => {
- if (!name) return "";
-
- // Extract base + alias from parentheses
- const match = name.match(/^(.+?)\s*\((.+?)\)$/);
-
- let parts = [];
-
- if (match) {
- const main = match[1];
- const alias = match[2];
-
- parts = [main, alias];
- } else {
- // no parentheses → repeat twice
- parts = [name];
+ const extractMwsUidList = (mwsUidString) => {
+ if (!mwsUidString) return [];
+ return mwsUidString.split("_").reduce((acc, val, idx, arr) => {
+ if (idx % 2 === 0 && arr[idx + 1]) {
+ acc.push(`${val}_${arr[idx + 1]}`);
}
-
- return parts
- .map((p) =>
- p
- .replace(/[^\w\s-]/g, "") // remove special chars
- .replace(/\s+/g, "_") // Space
- .replace(/_+/g, "_") // collapse _
- .replace(/^_|_$/g, "") // trim _
- .toLowerCase()
- )
- .join("_");
- };
-
- const dist = transformName(district.label);
-
- const blk = transformName(block.label);
-
- const yellowWaterbodyStyle = new Style({
- stroke: new Stroke({
- color: "yellow",
- width: 1.5,
- }),
+ return acc;
+ }, []);
+ };
+
+ // ===================== WATERBODY ======================
+
+ const wbLayerName = `surface_waterbodies_${dist}_${blk}`;
+ const wbLayer = await getVectorLayers("swb", wbLayerName, false, true);
+ map.addLayer(wbLayer);
+
+ wbLayer.setStyle(yellowWaterbodyStyle);
+
+ const wbSource = wbLayer.getSource();
+ const view = map.getView();
+ const extent = view.calculateExtent(map.getSize());
+
+ wbSource.loadFeatures(extent, view.getResolution(), view.getProjection());
+ const wbFeatures = await waitForFeatures(wbSource);
+
+ let matchedWaterbody = null;
+
+ if (waterbodyUID) {
+ matchedWaterbody = wbFeatures.find((f) => {
+ const uid = f.get("UID") || f.get("uid");
+ return uid?.toString() === waterbodyUID.toString();
});
+ }
+
+ // ===================== MWS ======================
+
+ const mwsLayerName = `deltaG_well_depth_${dist}_${blk}`;
+ const mwsLayer = await getVectorLayers("mws_layers", mwsLayerName, false, true);
+ map.addLayer(mwsLayer);
+
+ const mwsSource = mwsLayer.getSource();
+ mwsSource.loadFeatures(extent, view.getResolution(), view.getProjection());
+ const mwsFeatures = await waitForFeatures(mwsSource);
+
+ let matchedMWS = [];
+
+ if (matchedWaterbody) {
+ const wbMwsUID =
+ matchedWaterbody.get("MWS_UID") ||
+ matchedWaterbody.get("mws_uid");
+
+ if (wbMwsUID) {
+ const mwsUidList = extractMwsUidList(wbMwsUID.toString());
- const extractMwsUidList = (mwsUidString) => {
- if (!mwsUidString) return [];
-
- return mwsUidString
- .split("_")
- .reduce((acc, val, idx, arr) => {
- // join pairs: 12 + 33823 → 12_33823
- if (idx % 2 === 0 && arr[idx + 1]) {
- acc.push(`${val}_${arr[idx + 1]}`);
- }
- return acc;
- }, []);
- };
-
- const wbLayerName = `surface_waterbodies_${dist}_${blk}`;
- const wbLayer = await getVectorLayers("swb", wbLayerName, false, true);
- map.addLayer(wbLayer);
-
- wbLayer.setStyle(yellowWaterbodyStyle);
-
- const wbSource = wbLayer.getSource();
- const view = map.getView();
- const extent = view.calculateExtent(map.getSize());
-
- wbSource.loadFeatures(extent, view.getResolution(), view.getProjection());
- const wbFeatures = await waitForFeatures(wbSource);
-
- let matchedWaterbody = null;
-
- if (waterbodyUID) {
- matchedWaterbody = wbFeatures.find((f) => {
- const uid = f.get("UID") || f.get("uid");
- return uid?.toString() === waterbodyUID.toString();
+ matchedMWS = mwsFeatures.filter((f) => {
+ const uid = (f.get("uid") || f.get("UID"))?.toString();
+ return uid && mwsUidList.includes(uid.trim());
});
-
- if (!matchedWaterbody) {
- console.warn(" No waterbody matched UID:", waterbodyUID);
- }
- }
-
- const mwsLayerName = `deltaG_well_depth_${dist}_${blk}`;
- const mwsLayer = await getVectorLayers(
- "mws_layers",
- mwsLayerName,
- false,
- true
- );
- map.addLayer(mwsLayer);
-
- const mwsSource = mwsLayer.getSource();
- mwsSource.loadFeatures(extent, view.getResolution(), view.getProjection());
- const mwsFeatures = await waitForFeatures(mwsSource);
-
-
- let matchedMWS = [];
-
- if (matchedWaterbody) {
- const wbMwsUID =
- matchedWaterbody.get("MWS_UID") ||
- matchedWaterbody.get("mws_uid");
-
- if (wbMwsUID) {
- // extract list like ["12_308838","12_311076","12_316294"]
- const mwsUidList = extractMwsUidList(wbMwsUID.toString());
-
-
- matchedMWS = mwsFeatures.filter((f) => {
- const uid = (f.get("uid") || f.get("UID"))?.toString();
- return uid && mwsUidList.includes(uid.trim());
- });
- }
}
+ }
-// ===================== ZOI FETCH ======================
-const zoiLayerName = `waterbodies_zoi_${dist}_${blk}`;
+ // ===================== ZOI ======================
-// Try multiple namespaces — some servers store ZOI differently
-const zoiLayer =
- (await getVectorLayers("swb", zoiLayerName, false, true)) ||
- (await getVectorLayers("zoi_layers", zoiLayerName, false, true)) ||
- null;
+ const zoiLayerName = `waterbodies_zoi_${dist}_${blk}`;
- console.log("Zoi layer check:", {
- dist,
- blk,
- try1: `swb:waterbodies_zoi_${dist}_${blk}`,
- try2: `zoi_layers:waterbodies_zoi_${dist}_${blk}`
- });
-
+ const zoiLayer =
+ (await getVectorLayers("swb", zoiLayerName, false, true)) ||
+ (await getVectorLayers("zoi_layers", zoiLayerName, false, true)) ||
+ null;
-let rawZoiFeatures = [];
-let matchedZOI = [];
+ let rawZoiFeatures = [];
+ let matchedZOI = [];
-if (zoiLayer) {
- map.addLayer(zoiLayer);
+ if (zoiLayer) {
+ map.addLayer(zoiLayer);
- const zoiSource = zoiLayer.getSource();
- zoiSource.loadFeatures(extent, view.getResolution(), view.getProjection());
+ const zoiSource = zoiLayer.getSource();
+ zoiSource.loadFeatures(extent, view.getResolution(), view.getProjection());
- rawZoiFeatures = await waitForFeatures(zoiSource);
+ rawZoiFeatures = await waitForFeatures(zoiSource);
- // Match only for selected WB
- if (matchedWaterbody) {
- const wbUid =
- matchedWaterbody.get("UID")?.toString()?.trim() ||
- matchedWaterbody.get("uid")?.toString()?.trim();
-
- matchedZOI = rawZoiFeatures.filter(f => {
- const zUid =
- f.get("UID")?.toString()?.trim() ||
- f.get("uid")?.toString()?.trim();
- return zUid === wbUid;
- });
+ if (matchedWaterbody) {
+ const wbUid =
+ matchedWaterbody.get("UID")?.toString()?.trim() ||
+ matchedWaterbody.get("uid")?.toString()?.trim();
+
+ matchedZOI = rawZoiFeatures.filter((f) => {
+ const zUid =
+ f.get("UID")?.toString()?.trim() ||
+ f.get("uid")?.toString()?.trim();
+ return zUid === wbUid;
+ });
+ }
}
-}
-console.log("ZOI Layer fetched:", rawZoiFeatures.length);
-console.log("ZOI matched:", matchedZOI.length);
-
-
-
- return {
- wbLayer,
- wbFeatures,
-
- waterbody: matchedWaterbody
- ? {
+
+ // ===================== FINAL RETURN ======================
+
+ return {
+ wbLayer,
+ wbFeatures,
+
+ waterbody: matchedWaterbody
+ ? (() => {
+ const geo = new GeoJSON().writeFeatureObject(matchedWaterbody, {
+ dataProjection: "EPSG:4326",
+ featureProjection: "EPSG:4326",
+ });
+ delete geo.properties;
+ return {
olFeature: matchedWaterbody,
- geojson: new GeoJSON().writeFeatureObject(matchedWaterbody, {
- dataProjection: "EPSG:4326",
- featureProjection: "EPSG:4326",
- }),
- }
- : null,
-
-
- mws: matchedMWS.length
- ? matchedMWS.map(f => ({
+ geojson: geo,
+ };
+ })()
+ : null,
+
+ mws: matchedMWS.length
+ ? matchedMWS.map((f) => {
+ const geo = new GeoJSON().writeFeatureObject(f, {
+ dataProjection: "EPSG:4326",
+ featureProjection: "EPSG:4326",
+ });
+ delete geo.properties;
+ return {
olFeature: f,
- geojson: new GeoJSON().writeFeatureObject(f, {
- dataProjection: "EPSG:4326",
- featureProjection: "EPSG:4326",
- })
- }))
- : [],
-
- zoi: matchedZOI.length
- ? matchedZOI.map(f =>
- new GeoJSON().writeFeatureObject(f, {
- dataProjection: "EPSG:4326",
- featureProjection: "EPSG:4326",
+ geojson: geo,
+ };
+ })
+ : [],
+
+ zoi: matchedZOI.length
+ ? matchedZOI.map((f) => {
+ const geo = new GeoJSON().writeFeatureObject(f, {
+ dataProjection: "EPSG:4326",
+ featureProjection: "EPSG:4326",
+ });
+ delete geo.properties;
+ return geo;
})
- )
- : [],
-
- };
+ : [],
};
-
- const waitForFeatures = (source) =>
- new Promise((resolve) => {
- const interval = setInterval(() => {
- const feats = source.getFeatures();
- if (feats.length > 0) {
- clearInterval(interval);
- resolve(feats);
- }
- }, 200);
- });
+};
+
+// ===================== WAIT FUNCTION ======================
+
+const waitForFeatures = (source) =>
+ new Promise((resolve) => {
+ const interval = setInterval(() => {
+ const feats = source.getFeatures();
+ if (feats.length > 0) {
+ clearInterval(interval);
+ resolve(feats);
+ }
+ }, 200);
+ });
diff --git a/src/components/buttons/download_button.jsx b/src/components/buttons/download_button.jsx
index 0067e490..1a5cb5ca 100755
--- a/src/components/buttons/download_button.jsx
+++ b/src/components/buttons/download_button.jsx
@@ -1,11 +1,20 @@
-import './download_button.css'
+import "./download_button.css";
-const DownloadButton = ({name, onClickEvent, href, download, isDisabled}) => {
- return(
-
- )
-}
+const DownloadButton = ({
+ name,
+ onClick = () => {},
+ disabled = false
+}) => {
+ return (
+
+ );
+};
export default DownloadButton;
\ No newline at end of file
diff --git a/src/components/buttons/toggleButton.jsx b/src/components/buttons/toggleButton.jsx
index 97b0be3a..53b6b45f 100755
--- a/src/components/buttons/toggleButton.jsx
+++ b/src/components/buttons/toggleButton.jsx
@@ -1,17 +1,31 @@
-import '../css/toggleButton.css'
+import '../css/toggleButton.css';
-const ToggleButton = ({currentLayers, handleCheckboxChange, checkboxId}) => {
+const ToggleButton = ({
+ currentLayers,
+ handleCheckboxChange,
+ checkboxId
+}) => {
- const handleCheckBoxToggle = (e) => {
- handleCheckboxChange()
- }
+ const isChecked = currentLayers.includes(checkboxId);
- return (
-
-
-
-
- )
-}
+ return (
+
+
+
+
+
+ );
+};
export default ToggleButton;
\ No newline at end of file
diff --git a/src/components/kyl_leftSidebar.jsx b/src/components/kyl_leftSidebar.jsx
index 65cfb170..10eff3d3 100644
--- a/src/components/kyl_leftSidebar.jsx
+++ b/src/components/kyl_leftSidebar.jsx
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, { useState, useEffect } from 'react';
import KYLIndicatorFilter from './kyl_indicatorFilter';
import KYLPatternDisplay from './kyl_patternDisplay';
@@ -33,6 +33,11 @@ const KYLLeftSidebar = ({
// State to track selected pattern subcategory
const [selectedSubcategory, setSelectedSubcategory] = useState(null);
+ useEffect(() => {
+ setActiveTab('Filters');
+ setSelectedSubcategory(null);
+ setIndicatorType(null); // IMPORTANT
+}, []);
const combinedSelectedValues = {
...filterSelections.selectedMWSValues,
...filterSelections.selectedVillageValues
diff --git a/src/components/landscape-explorer/map/Map.jsx b/src/components/landscape-explorer/map/Map.jsx
index 928e802e..576c28c1 100644
--- a/src/components/landscape-explorer/map/Map.jsx
+++ b/src/components/landscape-explorer/map/Map.jsx
@@ -1505,6 +1505,41 @@ const Map = forwardRef(({
LayersArray[3].LayerRef.current = MicroWaterShedLayer;
}
+ // === Hydrological Boundaries Layer ===
+let HydrologicalBoundariesLayer = await getVectorLayers(
+ "hydrological_boundaries",
+ district.label.toLowerCase().replace(/\s*\(\s*/g, '_')
+ .replace(/\s*\)\s*/g, '')
+ .replace(/\s+/g, '_') +
+ "_" +
+ block.label.toLowerCase().replace(/\s*\(\s*/g, '_')
+ .replace(/\s*\)\s*/g, '')
+ .replace(/\s+/g, '_'),
+ true,
+ true
+);
+
+if (HydrologicalBoundariesLayer) {
+ HydrologicalBoundariesLayer.setStyle(function (feature) {
+ return new Style({
+ stroke: new Stroke({
+ color: "#000000",
+ width: 1.5,
+ }),
+ fill: new Fill({
+ color: "rgba(0, 0, 255, 0.2)",
+ }),
+ });
+ });
+
+ if (LayersArray[3].LayerRef.current != null) {
+ safeRemoveLayer(LayersArray[3].LayerRef.current);
+ }
+
+ LayersArray[3].LayerRef.current = HydrologicalBoundariesLayer;
+}
+
+
// === CLART Layer ===
let clartLayer = await getImageLayers(
"clart",
diff --git a/src/components/landscape-explorer/sidebar/RightSidebar.jsx b/src/components/landscape-explorer/sidebar/RightSidebar.jsx
index c14656da..6c860882 100644
--- a/src/components/landscape-explorer/sidebar/RightSidebar.jsx
+++ b/src/components/landscape-explorer/sidebar/RightSidebar.jsx
@@ -1,4 +1,5 @@
import { useState, useEffect } from 'react';
+import DownloadButton from '../../buttons/download_button';
import SelectButton from '../../buttons/select_button';
import {
downloadGeoJson,
@@ -7,12 +8,6 @@ import {
downloadExcel
} from '../utils/downloadHelper';
-// SVG Icons
-const ChevronLeftIcon = () => (
-
-);
const ChevronRightIcon = () => (