Hello !
I'm currently trying to implement a new Model extending the GeoJsonCatalogItem Model.
My use case is that i have $\approx$ 2000 polygons (always the same geometries) but with fluctuating attributes values.
I wanted to make it so when the layer is first added it's loading the geometry, and when the timeframe is playing, the values of the polygons' attributes are updated. (First request is GeoJSON, subsequent ones are CSV)
So far i'm pretty close, the request are handled correctly, but my layer is not updating.
I'm using this :
exportdefaultclassDynamicGeoJsonCatalogItemextendsGeoJsonCatalogItem{privateclockDisposer?: ()=>void;privatelastFetchedDate?: string;// ISO date like "2025-05-22"constructor(id: string,terria: Terria){super(id,terria);// Attach clock tick listener after data is loadedif(!this.clockDisposer){this.clockDisposer=this.terria.timelineClock.onTick.addEventListener(clock=>{constcurrentIso=JulianDate.toDate(clock.currentTime).toISOString();constcurrentDate=currentIso.slice(0,10);// 'YYYY-MM-DD'if(currentDate!==this.lastFetchedDate){this.lastFetchedDate=currentDate;this.updateFromTime(currentIso);}});}}asyncupdateFromTime(currentTime: string){try{consttimeKey=currentTime.slice(0,10);// e.g. '2025-05-22'constcsvUrl=this.baseCsvUrl+`${timeKey}`;constcsvData=awaitloadCsv(csvUrl);runInAction(()=>{this.applyCsvDataToGeoJson(csvData);});}catch(e){console.error("Error loading or parsing CSV:",e);}}applyCsvDataToGeoJson(csvRows: any[]){if(!this.geoJsonData||!this.geoJsonData.features)return;for(constfeatureofthis.geoJsonData.features){constlakeId=feature.properties.id;constrow=csvRows.find((r: any)=>r.id===lakeId);if(row){feature.properties.level=row.level;}}// Force refresh of featuresthis.setTrait(CommonStrata.user,"geoJsonData",this.geoJsonData);}Not sure if
this.setTrait(CommonStrata.user, "geoJsonData", this.geoJsonData);
is the right method to use, or if my data formatting is wrong (i think it's the former)
just in case, here is what my data looks like
{"type" : "FeatureCollection", "features" : [{"type": "Feature", "geometry": {"type":"Polygon","coordinates": []}, "properties": {"id": 4460, "datetime": "2023-01-01T00:00:00+00:00", "etc": [] }}]}and
[{"id":1,"datetime":"2020-02-26T00:00:00+00:00","etc": []},{"id":3,"datetime":"2020-02-26T00:00:00+00:00","etc": []},
Hello !$\approx$ 2000 polygons (always the same geometries) but with fluctuating attributes values.
I'm currently trying to implement a new Model extending the GeoJsonCatalogItem Model.
My use case is that i have
I wanted to make it so when the layer is first added it's loading the geometry, and when the timeframe is playing, the values of the polygons' attributes are updated. (First request is GeoJSON, subsequent ones are CSV)
So far i'm pretty close, the request are handled correctly, but my layer is not updating.
I'm using this :
Not sure if
this.setTrait(CommonStrata.user, "geoJsonData", this.geoJsonData);is the right method to use, or if my data formatting is wrong (i think it's the former)
just in case, here is what my data looks like
{"type" : "FeatureCollection", "features" : [{"type": "Feature", "geometry": {"type":"Polygon","coordinates": []}, "properties": {"id": 4460, "datetime": "2023-01-01T00:00:00+00:00", "etc": [] }}]}and