MCPcopy Create free account
hub / github.com/Thanas-R/Virdis / fetchGee

Function fetchGee

src/components/FieldComparisonColumn.tsx:96–116  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

FieldComparisonColumnFunction · 0.70

Calls 3

hasGeeAnalyticsPayloadFunction · 0.90
setLocalCacheFunction · 0.90
isFallbackPayloadFunction · 0.90

Tested by

no test coverage detected