Skip to contents

V1's zoneBoundsFromMap() (the Atlas app) reads querySourceFeatures(), which only sees vector-tile features already IN VIEW – a zone far outside the current camera has no bounds to zoom to and the search falls back to an announce-only path. Publishing each zone's bbox here (R3-C3, round 3 plan) makes that search independent of tile state: read the bounds from boot.zones[].bbox, never a queried source.

Usage

app_zone_bbox(path, type)

Arguments

path

a GeoPackage (or any sf::st_read()-able file) carrying a {type}_key column, e.g. data/zone_sets.csv's source (the same file app_zone_names() reads)

type

the zone type ("programarea", "planarea", "ecoregion", "subregion"), i.e. the {type}_key column prefix

Value

data.frame(fld, key, w, s, e, n), one row per distinct key with at least one finite vertex. w/e are WGS84 longitude degrees; w > e marks a zone that crosses the antimeridian (read it as wrapping, not as an empty box). A key with only non-finite/empty geometry is dropped, not published with NA bounds.

Details

Computed from the SAME zone-set GeoPackage app_zone_names() reads (one vertex extent per distinct {type}_key), never from a release's zone/zone_cell tables – a Program Area's geometry does not change release to release (see ../CLAUDE.md's "zone_cell is shared, not per-release"), so one extraction serves every version on that zone-set.

Dateline-aware. A naive min/max of longitude is the wrong extent for a zone that crosses the antimeridian (the Aleutian Arc has vertices near both +180 and -180; the naive box is ~358 degrees wide, essentially the whole globe). lon_span() picks the narrower of the -180..180 and 0..360 frames per zone; when that narrower frame's xmax exceeds 180 (a real wraparound, e.g. 170..190) it is folded back into -180..180 (190 - 360 = -170) so the PUBLISHED box reads w = 170 > e = -170 – the west/east reversal IS the wraparound signal a consumer checks for, the same convention msens:::.app_bbox()'s callers already expect from lon_span_agg(), just folded back rather than left > 180 (a zone bbox is drawn by a search zoom, not handed straight to fitBounds(), so it is published in the frame a human-readable w/e pair should be in).