Crate umsh_regiondb

Crate umsh_regiondb 

Source
Expand description

Reader and lookup for the UMSH geographic region database.

A .regiondb answers one question: given a position, which UMSH regions should a repeater there normally be configured to accept? All of the hard geography — nearest-airport partitions, commercial-service classification, metropolitan boundaries, jurisdiction boundaries, manual corrections — happens in the build, in tools/regiondb-build/. Nothing in this crate knows how any of it was derived, and the radio knows even less: it is handed ordinary region strings through the existing repeater configuration path.

Only core geometry is stored. A region’s expansion margin — the overlap that lets a repeater near a border serve both sides — is a distance resolved at lookup time by the sampled-dilation rule in sampling: the position itself and a fixed pattern of points around it are tested against the core polygons, and a hit on any of them is membership. A hit on the position itself is a core match; on any other sample, an expanded match.

use umsh_regiondb::RegionDb;

let database = RegionDb::open("world.regiondb")?;
let result = database.lookup_codes(42.1946, -122.7095)?;
for region in &result.radio_regions {
    println!("{} {}", region.name, region.code);
}

The file itself is an ordinary SQLite database, and every implementation that reads one — this crate, the Python builder, and eventually the browser — must return identical results for identical positions. That is not left to good intentions: regions/tests/conformance.json is replayed by all of them, and the geometry codec, grid arithmetic, and sample pattern here are written to match their Python counterparts operation for operation.

Re-exports§

pub use blob::GeometryError;
pub use morton::MortonError;

Modules§

blob
The compiled geometry encoding.
morton
The fixed lookup grid.
sampling
The sampled-dilation membership rule.

Structs§

RadioRegion
A region as the radio sees it: a name and its 2-byte code.
RegionDb
An opened region database.
RegionLookup
The result of a lookup.
RegionMatch
One semantic region covering a position.

Enums§

Membership
Whether a position falls in a region’s own area or only in its expansion margin.
RegionDbError
Anything that can go wrong opening or querying a region database.

Constants§

FORMAT_VERSION
The database format this crate implements.