fix(hex): render GeoJSON hex tilesets instead of 404ing on .pbf (#252) - #253
Merged
Conversation
add_hex_tile_layer only ever built a {type:'vector'} source pointed at the
.pbf tile endpoint. When register_hex_tiles auto-selects GeoJSON, that
endpoint 404s and the layer renders blank.
Branch addHexTileLayer on format:
- geojson -> {type:'geojson', data: geojson_url}, fill layer with no
source-layer, and a *flat* fill-color ramp over the finest-res stats.
GeoJSON features carry only value columns (no `res`), so the per-res
`match` expression would render everything transparent — add
buildFlatFillColorExpression for the single-resolution case.
- vector -> existing path, unchanged.
The hash still derives from tile_url_template (returned for both formats);
geojson_url's shape isn't parseable by extractHashFromUrl. Extend the tool
schema with format + geojson_url and update the prompt to pass them through.
No conflict with the other GeoJSON pipelines (curated catalog layers,
h3geo overlay, animation tracks): the hex path keeps its own hex-<hash>
ids and shares no styling code.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #252.
Problem
add_hex_tile_layeronly ever built a{type:'vector'}source pointed at the.pbftile endpoint. Since mcp-data-server#181,register_hex_tilesauto-selects GeoJSON for small/single-resolution tilesets, whose.pbfendpoint deliberately 404s — so every GeoJSON hex render came up blank.A subtlety beyond "just add a geojson source"
Branching the source type alone isn't enough. Hex fill is painted by
buildFillColorExpression, which does['match', ['get','res'], …]because the vector pyramid packs multiple H3 resolutions per tile. The GeoJSON export carries only the value columns as feature properties — nores— so reusing that paint would send every feature to thematchfallback (rgba(0,0,0,0)), still blank.So the GeoJSON branch needs a flat ramp over the finest-res stats.
Changes
addHexTileLayerbranches onformat:geojson→addSource({type:'geojson', data: geojson_url})+ fill layer with nosource-layerand a flat ramp from newbuildFlatFillColorExpression(built overvalue_stats.by_res[finest_res]+ the chosen palette, so existing palette/opacity/legend wiring still applies).vector→ existing path, unchanged.tile_url_template(returned for both formats);geojson_url's shape (…/hex/<hash>/data.geojson) isn't parseable byextractHashFromUrl.format+geojson_url; description/prompt updated to pass them through and stop steering towardtile_url-only.No conflict with existing GeoJSON rendering
The three other GeoJSON pipelines are isolated from the hex path and unchanged: curated catalog layers (
dataset-catalog.js→ genericaddLayer, ids<ds>/<asset>), theh3geo.jscell overlay (fixed source id, interactive cell drawing), andanimation-manager.jstracks. The hex path keeps its ownhex-<hash>ids and shares no styling code, so there's no id collision or shared-state confusion.Tests
npm test→ 303 passing. Added coverage intest/hex-layer-helpers.test.js(flat ramp: structure, min==max collapse, validation) andtest/map-manager.hex.test.js(geojson source shape, nosource-layer, flat non-respaint, hash fromtile_url, finest-res selection, missing-geojson_urlerror).Browser render verification (MapLibre) is manual per the coverage policy — recommend a quick check on the padus dev app against the Yolo County hash from the issue.
🤖 Generated with Claude Code