Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
geo / geo-geohash-decodeOpenRuns on Liberas

Geohash decode

The cell of a geohash as {south, west, north, east} in degrees. hash is 1 to 12 characters of 0123456789bcdefghjkmnpqrstuvwxyz, ASCII uppercase letters read as lowercase; anything else (including a, i, l, o), an empty string or more than 12 characters is an error. Each character is 5 bits, most significant first; the bits alternate longitude, latitude, longitude, …, starting from lon [−180, 180] and lat [−90, 90]: for each bit, mid = (lo + hi) ÷ 2 (exact in binary64), then a 1 bit sets lo = mid and a 0 bit sets hi = mid. south and north are the final latitude lo and hi, west and east the longitude lo and hi; every value is exact, so the result matches bit for bit.

From your terminal

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init geo-geohash-decode --lang rust
cd geo-geohash-decode && liberas build && liberas submit

Save a token once with liberas login (make it on your page, /me, after signing in). init scaffolds the interface, the vectors and a stub in Rust (--lang js for light specs).

Interface (WIT)23 lines›
geo-geohash-decode.wit
package root:component;

world root {
  import liberas:geo/types@0.1.0;

  export liberas:geo/geohash-decode@0.1.0;
}
package liberas:geo@0.1.0 {
  interface types {
    record bbox {
      south: f64,
      west: f64,
      north: f64,
      east: f64,
    }
  }
  interface geohash-decode {
    use types.{bbox};

    decode: func(hash: string) -> result<bbox, string>;
  }
}
Test vectors15›
geo-geohash-decode.cases.json
[
  {
    "args": {
      "hash": "ezs42"
    }
  },
  {
    "args": {
      "hash": "u4pruydqqvj"
    }
  },
  {
    "args": {
      "hash": "s"
    }
  },
  {
    "args": {
      "hash": "0"
    }
  },
  {
    "args": {
      "hash": "z"
    }
  },
  {
    "args": {
      "hash": "zzzzzzzzzzzz"
    }
  },
  {
    "args": {
      "hash": "000000000000"
    }
  },
  {
    "args": {
      "hash": "EZS42"
    }
  },
  {
    "args": {
      "hash": "wydm9qy"
    }
  },
  {
    "args": {
      "hash": ""
    }
  },
  {
    "args": {
      "hash": "ezs42a"
    }
  },
  {
    "args": {
      "hash": "a"
    }
  },
  {
    "args": {
      "hash": "1234567890123"
    }
  },
  {
    "args": {
      "hash": "ezs4 "
    }
  },
  {
    "args": {
      "hash": "한"
    }
  }
]
Verification6›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 15 vectors plus ones generated from the interface's types: edge values and random ones seeded by your component's hash.
  • Components may import nothing but specs: no files, no network, no clock.
  • Runs on Liberas: the component never leaves the platform, and every call is metered on the ledger.
  • A remote call may execute up to 1,000,000 instructions.
  • Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.