()
| 94 | setGeeData(cached); |
| 95 | return; |
| 96 | } |
| 97 | const fetchGee = async () => { |
| 98 | setGeeLoading(true); |
| 99 | try { |
| 100 | const polygon = field.coordinates[0]; |
| 101 | const { data, error } = await callBackend("gee-analytics", { polygon, analyses: ["land_use", "vegetation", "suitability"] }); |
| 102 | if (error) throw error; |
| 103 | if (hasGeeAnalyticsPayload(data)) { |
| 104 | setGeeData(data); |
| 105 | setLocalCache(GEE_ANALYTICS_CACHE_KEY, field.id, data); |
| 106 | } else if (isFallbackPayload(data)) { |
| 107 | setGeeData(cached ?? null); |
| 108 | } else { |
| 109 | setGeeData(null); |
| 110 | } |
| 111 | } catch (e) { |
| 112 | console.error("GEE analytics error:", e); |
| 113 | setGeeData(cached ?? null); |
| 114 | } finally { setGeeLoading(false); } |
| 115 | }; |
| 116 | fetchGee(); |
| 117 | }, [field.id]); |
| 118 | |
| 119 | // Fetch NDVI time-series |
no test coverage detected