Location codes for MoonBit: Geohash, Open Location Code (Plus Codes), Maidenhead locators, RFC 5870 geo URIs and degrees/minutes/seconds, with a unified cell/point model carrying region, resolution and uncertainty, plus bounds, neighbourhoods, geohash covering, free-text scanning and bounded cell-to-geo-URI conversion; no runtime dependencies
let p = @geocodec.LatLng::new(39.9042, 116.4074).unwrap()
@geocodec.geohash_encode(p, 9) // Some("wx4g0bm6c")
@geocodec.pluscode_encode(p, code_length=10) // Some("8PFRWC34+MX")
@geocodec.maidenhead_encode(p, precision=8) // Some("OM89EV87")| Notation | Encoding | Decoding | Bounds | Extras |
|---|---|---|---|---|
| Geohash | 1–12 characters | centre | yes | neighbours, covering, precision for metres |
| Plus Codes | 2–15 digits | centre | yes | shorten/recover, neighbours, padding |
| Maidenhead | 2–10 characters | centre | yes | fields through extended squares |
| Geo URI | RFC 5870 | RFC 5870 | — | altitude, uncertainty, CRS |
| DMS | format | parse | — | symbols, d/m/s, colons, hemispheres |
moon add sssssurf/geocodec
moon run --target js cmd/main -- demo| Field | Meaning |
|---|---|
| format / kind | notation and Cell/Point |
| point / region | representative point and exact cell or conservative u envelope |
| resolution_m | approximate cell size, point uncertainty diameter, or 0 |
| uncertainty_m | Double?: None means unknown; Some(0) means explicit zero |
| cell_radius_m | optional geometric cell radius; independent of source accuracy |
| area_m2 | approximate or nominal envelope area |
| altitude_m / crs / raw | source altitude, CRS label and original notation |
pub struct Location {
format : LocationFormat
kind : LocationKind
point : LatLng
region : BoundingBox
resolution_m : Double
uncertainty_m : Double?
cell_radius_m : Double?
area_m2 : Double
altitude_m : Double?
crs : String?
raw : String
} derive(Eq)fn Location::convert_to_cell(self : Location, format : LocationFormat, precision : Int) -> LocationConversion?impl Show for LocationFormatimpl Show for LocationKindlet GEOHASH_MAX_PRECISION : Intlet PLUSCODE_ALPHABET : Stringlet PLUSCODE_SEPARATOR : Charfn ascii_upper_char(c : Char) -> Charfn clamp_lat(lat : Double) -> Doublefn decimal_notation(value : Double) -> Stringfn format_dms(value : Double, is_lat : Bool) -> Stringfn format_fixed(x : Double, digits : Int) -> Stringfn format_latlng(lat : Double, lng : Double, digits : Int) -> Stringfn geohash_adjacent(code : String, dx : Int, dy : Int) -> String?fn geohash_precision_for_meters(meters : Double) -> Int?fn hemisphere_suffix(value : Double, is_lat : Bool) -> Stringfn is_ascii(s : String) -> Boolfn is_finite(x : Double) -> Boolfn lng_delta(a : Double, b : Double) -> Doublefn normalize_lng(lng : Double) -> Doublefn parse_decimal(text : String) -> Double?fn parse_dms(input : String, is_lat : Bool) -> Double?fn pluscode_adjacent(code : String, dx : Int, dy : Int) -> String?fn pluscode_code_length(code : String) -> Intfn pluscode_is_full(code : String) -> Boolfn pluscode_is_short(code : String) -> Boolfn pluscode_is_valid(code : String) -> Boolfn round_to(x : Double, digits : Int) -> Doublefn trim_fraction(text : String) -> StringInstall
Download zipLocation codes for MoonBit: Geohash, Open Location Code (Plus Codes), Maidenhead locators, RFC 5870 geo URIs and degrees/minutes/seconds, with a unified cell/point model carrying region, resolution and uncertainty, plus bounds, neighbourhoods, geohash covering, free-text scanning and bounded cell-to-geo-URI conversion; no runtime dependencies