feat(osm-equity): selectable heat-map metric + grey N/A shading#30
Conversation
render_maplibre_map gains metric/metric_label params (default attr_completeness), so a map can colour units by any per-unit metric — e.g. footprint_completeness to show the OSM-vs-authoritative building gap. Negative sentinels (N/A, e.g. no footprint reference) now render grey via a MapLibre `case` rather than as the worst colour. Default behaviour unchanged. Used to render a full-detail tiled Tucson map (real OSM 282k buildings vs 252k Microsoft footprints): 21/167 2-sq-mi tiles fall below 50% OSM building completeness — intra-city under-mapping the national aggregate hides. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request updates render_maplibre_map to support dynamic metrics and labels, and introduces a grey fallback color for negative metric values. The review feedback points out a potential runtime rendering error in MapLibre GL JS if the metric property is missing or null, and suggests providing a fallback value of -1 to the to-number expression to ensure robust rendering.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| 'fill-color':['case',['<',['to-number',['get','{metric}']],0],'#999999', | ||
| ['interpolate',['linear'],['to-number',['get','{metric}']], | ||
| 0.0,'#d73027',0.25,'#fc8d59',0.5,'#fee08b',0.75,'#91cf60',1.0,'#1a9850']], |
There was a problem hiding this comment.
In MapLibre GL JS, the interpolate expression strictly requires a numeric input. If the property specified by {metric} is missing or null on any feature, ['to-number', ['get', '{metric}']] will return null. Comparing null < 0 will evaluate to false, causing the expression to fall through to the interpolate block with a null input, which triggers a runtime rendering error in MapLibre.
To prevent this and ensure robust rendering, provide a fallback value (such as -1) to the to-number expression. This way, any missing or invalid values will safely default to -1, match the < 0 condition, and render as grey (#999999).
| 'fill-color':['case',['<',['to-number',['get','{metric}']],0],'#999999', | |
| ['interpolate',['linear'],['to-number',['get','{metric}']], | |
| 0.0,'#d73027',0.25,'#fc8d59',0.5,'#fee08b',0.75,'#91cf60',1.0,'#1a9850']], | |
| 'fill-color':['case',['<',['to-number',['get','{metric}'],-1],0],'#999999', | |
| ['interpolate',['linear'],['to-number',['get','{metric}'],-1], | |
| 0.0,'#d73027',0.25,'#fc8d59',0.5,'#fee08b',0.75,'#91cf60',1.0,'#1a9850']], |
render_maplibre_mapgainsmetric/metric_labelparams (defaultattr_completeness) so maps can colour by any per-unit metric — e.g.footprint_completenessfor the OSM-vs-authoritative building gap. Negative N/A sentinels render grey (MapLibrecase) instead of worst-colour. Default behaviour unchanged; 16 offline tests pass; ruff clean.Used for a full-detail tiled Tucson map (real OSM 282k buildings vs 252k MS footprints): 21/167 tiles below 50% OSM building completeness.
🤖 Generated with Claude Code