Documentation
¶
Overview ¶
Package mapscatalog fetches the public download catalog from the graywolf-maps Worker (GET <base>/manifest.json) and caches it in-process with a TTL. Stale-on-error: a refresh that fails after the catalog is warm continues serving the previous copy with a warning. A cold failure (no cached copy) returns the error.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache fetches and caches the worker catalog.
func New ¶
New constructs a Cache. baseURL is the maps host root (e.g. https://maps.nw5w.com). tokenProvider returns the current bearer token (may be empty for public testing). ttl is the cache lifetime; 0 means always refresh. Equivalent to NewWithDiskCache with no disk cache directory.
func NewWithDiskCache ¶ added in v0.13.12
func NewWithDiskCache(baseURL string, tokenProvider func(context.Context) string, ttl time.Duration, diskCacheDir string) *Cache
NewWithDiskCache constructs a Cache that also writes every successful manifest fetch to <diskCacheDir>/catalog.json and seeds the in-memory cache from that file on construction. The seeded entry is treated as already-stale (fetchedAt = mtime), so the next Get triggers a refresh; if the refresh fails the on-disk copy is served via the existing stale-on-error path. This lets the region picker show the last known catalog on an offline host instead of erroring.
The render path does NOT depend on this disk cache -- /api/maps/local-bounds is the offline-safe render-bounds source.
type Catalog ¶
type Catalog struct {
SchemaVersion int `json:"schemaVersion"`
GeneratedAt string `json:"generatedAt"`
Countries []Country `json:"countries"`
Provinces []Province `json:"provinces"`
States []State `json:"states"`
World *WorldMap `json:"world,omitempty"`
// contains filtered or unexported fields
}
func (*Catalog) HasSlug ¶
HasSlug reports whether slug names a published archive in this catalog. Slugs are namespaced ("state/colorado", "country/de", "province/ca/british-columbia"). O(1) when the index is populated (every catalog returned by Cache.Get is); falls back to a linear scan for hand-constructed Catalog values where indexSlugs has not run.
type WorldMap ¶ added in v0.14.0
type WorldMap struct {
Name string `json:"name"`
SizeBytes int64 `json:"sizeBytes"`
SHA256 string `json:"sha256"`
BBox *[4]float64 `json:"bbox,omitempty"`
MaxZoom int `json:"maxZoom"`
}
WorldMap is the single global low-zoom basemap archive. Unlike the regional entries it carries a MaxZoom: the archive is capped (e.g. z7), so the offline render path overzooms its top tile rather than requesting zooms the archive does not contain.