KSvend Claude Happy commited on
Commit
1ee8d52
·
1 Parent(s): 2dc7d77

feat: register NDVI indicator and add raster map support to worker

Browse files

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>

Files changed (2) hide show
  1. app/indicators/__init__.py +2 -0
  2. app/worker.py +21 -1
app/indicators/__init__.py CHANGED
@@ -8,8 +8,10 @@ from app.indicators.no2 import NO2Indicator
8
  from app.indicators.lst import LSTIndicator
9
  from app.indicators.nightlights import NightlightsIndicator
10
  from app.indicators.food_security import FoodSecurityIndicator
 
11
 
12
  registry = IndicatorRegistry()
 
13
  registry.register(FiresIndicator())
14
  registry.register(CroplandIndicator())
15
  registry.register(VegetationIndicator())
 
8
  from app.indicators.lst import LSTIndicator
9
  from app.indicators.nightlights import NightlightsIndicator
10
  from app.indicators.food_security import FoodSecurityIndicator
11
+ from app.indicators.ndvi import NdviIndicator
12
 
13
  registry = IndicatorRegistry()
14
+ registry.register(NdviIndicator())
15
  registry.register(FiresIndicator())
16
  registry.register(CroplandIndicator())
17
  registry.register(VegetationIndicator())
app/worker.py CHANGED
@@ -91,7 +91,27 @@ async def process_job(job_id: str, db: Database, registry: IndicatorRegistry) ->
91
  # Generate map PNG for every indicator
92
  spatial = spatial_cache.get(result.indicator_id)
93
  map_path = os.path.join(results_dir, f"{result.indicator_id}_map.png")
94
- if spatial is not None:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  render_indicator_map(
96
  spatial=spatial,
97
  aoi=job.request.aoi,
 
91
  # Generate map PNG for every indicator
92
  spatial = spatial_cache.get(result.indicator_id)
93
  map_path = os.path.join(results_dir, f"{result.indicator_id}_map.png")
94
+
95
+ if spatial is not None and spatial.map_type == "raster":
96
+ # New: raster-on-true-color rendering for openEO indicators
97
+ indicator_obj = registry.get(result.indicator_id)
98
+ raster_path = getattr(indicator_obj, '_indicator_raster_path', None)
99
+ true_color_path = getattr(indicator_obj, '_true_color_path', None)
100
+ peak_band = getattr(indicator_obj, '_ndvi_peak_band', 1)
101
+ from app.outputs.maps import render_raster_map
102
+ render_raster_map(
103
+ true_color_path=true_color_path,
104
+ indicator_path=raster_path,
105
+ indicator_band=peak_band,
106
+ aoi=job.request.aoi,
107
+ status=result.status,
108
+ output_path=map_path,
109
+ cmap=spatial.colormap,
110
+ vmin=-0.2 if "ndvi" in result.indicator_id else None,
111
+ vmax=0.9 if "ndvi" in result.indicator_id else None,
112
+ label=spatial.label,
113
+ )
114
+ elif spatial is not None:
115
  render_indicator_map(
116
  spatial=spatial,
117
  aoi=job.request.aoi,