Documentation
¶
Overview ¶
Package wofclient is a small client for Who's-On-First (WOF) SQLite gazetteer distributions (https://whosonfirst.org) — per-country `.db.bz2` administrative-places dumps.
It covers two things: downloading + decompressing a distribution to a local SQLite file (Download), and reading its `spr`/`geojson` tables by placetype (DB.Placetype). It does not interpret WOF's own property schema (wof:id, wof:hierarchy, wof:name, ...) into any application's domain model — that mapping is application-specific and belongs in the caller, not in a generic client to this distribution format.
Both the download/decompress mechanics and the SQL query mirror an already-shipped, already-verified integration against this same distribution format: https://github.com/olehmushka/go-oikumenea/blob/main/internal/hermenea/fetcher/fetcher.go (its `WOFSQLite` streaming fetcher) and https://github.com/olehmushka/go-oikumenea/blob/main/internal/hermenea/wof/mapper.go (its D-GeoPlaces / M16 geo-places pipeline, which reads the exact query this package runs) — this package is that integration's fetch+read layer, extracted and generalized; the WOF-property-to-application-field mapping stays in the caller.
Index ¶
Constants ¶
const DefaultUserAgent = "go-wof-client/0.1 (+https://github.com/olehmushka/go-wof-client)"
DefaultUserAgent identifies this client when UserAgentEnv is unset.
const UserAgentEnv = "WOF_CLIENT_USER_AGENT"
UserAgentEnv lets an operator override the outbound User-Agent with their own contact.
Variables ¶
This section is empty.
Functions ¶
func Download ¶
Download streams a WOF distribution's `.db.bz2` from url, bzip2-decompresses it to dest (a local file path), and returns the sha256 checksum of the decompressed bytes (hex-encoded). The decompressed bytes are streamed straight to disk — a WOF distribution can be gigabytes of geometry, so this never buffers the whole thing in memory. client's own timeout (or the caller's ctx deadline, if client has none) governs how long this may run; a planet-scale distribution can take a while, so a caller downloading one of those should use an unbounded client (govapicore.NewHTTPClient(0)) bounded by ctx instead.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps an opened WOF SQLite distribution for read access.
func Open ¶
Open opens a WOF SQLite distribution at path (as produced by Download, or any WOF `.db` file already decompressed by other means).
func (*DB) Placetype ¶
Placetype streams every current-geometry feature for one WOF placetype (e.g. "country", "region", "county", "locality"), ordered by the distribution's internal id (parent-first within a single placetype's insert order — WOF's own convention), calling yield once per row so a caller can page without loading a whole placetype into memory. yield returning an error stops iteration and that error is returned.