Skip to content

Commit 5293ef6

Browse files
authored
Merge pull request #25 from CIAT-DAPA/develop
Develop
2 parents 5794d4c + 2e8864c commit 5293ef6

File tree

8 files changed

+54
-8
lines changed

8 files changed

+54
-8
lines changed

src/src/assets/icons/cowpea.png

35.1 KB
Loading

src/src/assets/icons/eleusine.png

124 KB
Loading

src/src/assets/icons/peach.png

131 KB
Loading

src/src/assets/icons/sechium.png

139 KB
Loading

src/src/components/LayersMarkers/config.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
"UG": [[-1.482, 29.573], [4.231, 35.000]],
44
"TZ": [[-11.761, 29.338], [-0.95, 40.636]],
55
"BJ": [[6.225, 0.775], [12.409, 3.851]],
6-
"GH": [[4.738, -3.244], [11.174, 1.191]]
6+
"GH": [[4.738, -3.244], [11.174, 1.191]],
7+
"CO": [[-4.231, -79.02], [12.44, -66.87]],
8+
"KE": [[-4.68, 33.91], [5.03, 41.90]],
9+
"ZM": [[-18.08, 21.99], [-8.22, 33.68]],
10+
"PK": [[23.69, 60.88], [37.09, 77.83]],
11+
"MA": [[27.67, -13.17], [35.92, -0.99]],
12+
"EC": [[-5.02, -81.08], [1.47, -75.19]]
713
}
814
}

src/src/components/filterLeft/FilterLeft.jsx

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,29 @@ function FilterLeft({
155155
const file = event.target.files?.[0];
156156
if (!file) return;
157157

158+
const GAP_COLOR = "#e31a1c";
159+
158160
// Read TIFF/GeoTIFF
159161
const reader = new FileReader();
160162
reader.onload = () => {
161163
const tiffData = reader.result;
162164
parseGeoraster(tiffData).then((georaster) => {
165+
const nodata =georaster.noDataValue ?? georaster.nodataValue ?? georaster.nodata ?? null;
166+
const EPS = 1e-6;
167+
168+
const pixelValuesToColorFn = (values) => {
169+
const v = values?.[0];
170+
if (v == null || Number.isNaN(v)) return null; // transparent
171+
if (nodata != null && v === nodata) return null; // transparent
172+
if (Math.abs(v - 1) <= EPS) return GAP_COLOR; // color only class 1
173+
return null; // everything else hidden
174+
};
163175
const layer = new GeoRasterLayer({
164176
georaster,
165177
opacity: 0.7,
166178
resolution: 256,
179+
resampleMethod: "nearest",
180+
pixelValuesToColorFn,
167181
});
168182
setImage(layer);
169183
});
@@ -229,7 +243,6 @@ function FilterLeft({
229243
}
230244

231245
const requiredHeaders = [
232-
"id",
233246
"species_name",
234247
"ext_id",
235248
"crop",
@@ -252,7 +265,27 @@ function FilterLeft({
252265
return;
253266
}
254267

255-
setAccesionsInput(results.data);
268+
const cleaned = results.data
269+
.map((r) => {
270+
const lat = parseFloat(String(r.latitude).trim());
271+
const lon = parseFloat(String(r.longitude).trim());
272+
return { ...r, latitude: lat, longitude: lon };
273+
})
274+
.filter((r) =>
275+
Number.isFinite(r.latitude) &&
276+
Number.isFinite(r.longitude) &&
277+
r.latitude >= -90 && r.latitude <= 90 &&
278+
r.longitude >= -180 && r.longitude <= 180
279+
);
280+
281+
if (cleaned.length === 0) {
282+
setTitlemodal("No valid rows");
283+
setTextModal("No rows with valid latitude/longitude were found.");
284+
setShowF(true);
285+
return;
286+
}
287+
288+
setAccesionsInput(cleaned);
256289
},
257290
error: function () {
258291
setTitlemodal("CSV parsing error");

src/src/components/filterLeft/config.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"PROJECT_COUNTRIES": {
1717
"bolder": ["Benin","Ghana","Tanzania, United Republic of","Uganda"],
1818
"lga": [],
19-
"pdff": ["Colombia","India","Kenya","Nigeria","Zambia"],
19+
"pdff": ["Colombia","Kenya","Zambia"],
2020
"boldwp1": ["Ecuador","Morocco","Pakistan"]
2121
},
2222

@@ -83,7 +83,8 @@
8383
"Yam (Old World)",
8484
"Yam (New World)"
8585
],
86-
"boldwp1":["Brassica juncea","Brassica napus","Brassica rapa","Chickpea","Cucurbita ficifolia","Barley","Medicago truncatula","Rice","Passiflora tripartita","Physalis preuviana","Solanum betaceum","Wheat (Bread)","Wheat (Durum)"]
86+
"boldwp1":["Brassica juncea","Brassica napus","Brassica rapa","Chickpea","Cucurbita ficifolia","Barley","Medicago truncatula","Rice","Passiflora tripartita","Physalis preuviana","Solanum betaceum","Wheat (Bread)","Wheat (Durum)"],
87+
"pdff":["Cowpea","Eleusine coracana","Peach palm","Sechium edule","Sorghum"]
8788

8889
},
8990

@@ -98,6 +99,12 @@
9899
"Ecuador": ["Cucurbita ficifolia","Passiflora tripartita","Physalis preuviana","Solanum betaceum"],
99100
"Morocco": ["Chickpea","Barley","Medicago truncatula","Wheat (Durum)"],
100101
"Pakistan": ["Brassica juncea","Brassica napus","Brassica rapa","Chickpea","Rice","Wheat (Bread)"]
102+
},
103+
"pdff": {
104+
105+
"Colombia": ["Peach palm","Sechium edule"],
106+
"Kenya": ["Eleusine coracana"],
107+
"Zambia": ["Cowpea","Sorghum"]
101108
}
102109
}
103110
}

src/src/components/mapLegend/MapLegend.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const MapLegend = ({ colors, carouselLandraceItems, carouselMajorItems, option2C
2828
})}
2929
{image && (
3030
<li>
31-
<span style={{ background: "black", opacity: "0.7" }}></span>
31+
<span style={{ background: "#e31a1c", opacity: "0.7" }}></span>
3232
Custom Gap
3333
</li>
3434
)}
@@ -59,7 +59,7 @@ const MapLegend = ({ colors, carouselLandraceItems, carouselMajorItems, option2C
5959
})}
6060
{image && (
6161
<li>
62-
<span style={{ background: "black", opacity: "0.7" }}></span>
62+
<span style={{ background: "#e31a1c", opacity: "0.7" }}></span>
6363
Custom Gap
6464
</li>
6565
)}
@@ -80,7 +80,7 @@ const MapLegend = ({ colors, carouselLandraceItems, carouselMajorItems, option2C
8080

8181
{image && (
8282
<li>
83-
<span style={{ background: "black", opacity: "0.7" }}></span>
83+
<span style={{ background: "#e31a1c", opacity: "0.7" }}></span>
8484
Custom Gap
8585
</li>
8686
)}

0 commit comments

Comments
 (0)