| Did you know ... | Search Documentation: |
| Pack logtalk -- logtalk-3.100.1/docs/handbook/_sources/libraries/geohash.rst.txt |
.. _library_geohash:
geohash
The geohash library provides a geohash_protocol protocol and a
geohash object for encoding and decoding geographic coordinates
using the standard geohash algorithm.
It uses the standard geohash base-32 alphabet:
0123456789bcdefghjkmnpqrstuvwxyz
The library complements the geospatial library and uses the same
geographic(Latitude,Longitude) coordinate representation and
bbox(geographic(MinLatitude,MinLongitude),geographic(MaxLatitude,MaxLongitude))
bounding-box representation.
For encoding, longitudes are canonicalized to the [-180.0,180.0[
range so that geographic(Latitude,180.0) and
geographic(Latitude,-180.0) encode to the same geohash.
Open the `../../apis/library_index.html#geohash <../../apis/library_index.html#geohash>`__ link in a web browser.
To load all entities in this library, load the loader.lgt file:
::
| ?- logtalk_load(geohash(loader)).
To test this library predicates, load the tester.lgt file:
::
| ?- logtalk_load(geohash(tester)).
The library provides predicates for:
Encode a coordinate at a selected precision:
::
| ?- geohash::encode(geographic(42.6, -5.6), 5, Geohash).
Geohash = 'ezs42'
yes
| ?- geohash::encode(geographic(57.64911, 10.40744), 11, Geohash).
Geohash = 'u4pruydqqvj'
yes
Decode a geohash to its center coordinate and bounding box:
::
| ?- geohash::decode('ezs42', Coordinate).
Coordinate = geographic(42.60498046875, -5.60302734375)
yes
| ?- geohash::bounding_box('ezs42', BoundingBox).
BoundingBox = bbox(geographic(42.5830078125, -5.625), geographic(42.626953125, -5.5810546875))
yes
Inspect cell precision metadata:
::
| ?- geohash::precision(5, LatitudeError, LongitudeError).
| ?- geohash::cell_dimensions(5, LatitudeSpan, LongitudeSpan).
Compute adjacent cells and neighbors:
::
| ?- geohash::adjacent('ezs42', north, North).
| ?- geohash::neighbors('ezs42', Neighbors).
Cover a bounding box with geohashes of a fixed precision:
::
| ?- geohash::covering(bbox(geographic(42.58, -5.63), geographic(42.63, -5.58)), 5, Geohashes).
Compute adaptive and compact covers:
::
| ?- geohash::covering(bbox(geographic(42.58, -5.63), geographic(42.63, -5.58)), max_precision(6), Geohashes, []).
| ?- geohash::covering(bbox(geographic(42.58, -5.63), geographic(42.63, -5.58)), precision(6), Geohashes, [compact(true), min_precision(4)]).
Inspect hierarchy and integer representations:
::
| ?- geohash::parent('ezs42', Parent).
| ?- geohash::children('ezs4', Children).
| ?- geohash::encode_int(geographic(42.6, -5.6), 5, HashInteger).
| ?- geohash::bounding_box_int(HashInteger, 5, BoundingBox).
| ?- geohash::geohash_to_int('ezs42', HashInteger).
| ?- geohash::int_to_geohash(HashInteger, 5, Geohash).
| ?- geohash::encode_bits(geographic(42.6, -5.6), 25, HashInteger).
| ?- geohash::expand('ezs42', ExpandedGeohashes).
Cover polygons and polylines:
::
| ?- geohash::polygon_covering(
| [geographic(42.5830078125, -5.625), geographic(42.626953125, -5.625), geographic(42.626953125, -5.5810546875), geographic(42.5830078125, -5.5810546875)],
| precision(5),
| Geohashes,
| []
| ).
| ?- geohash::polyline_covering(
| [geographic(42.60498046875, -5.60302734375), geographic(42.60498046875, -5.55)],
| precision(5),
| Geohashes,
| [buffer(0.1)]
| ).
180.0 to -180.0 so
dateline-equivalent coordinates map to the same hash.CoverSpec argument with precision(Precision)
and max_precision(MaxPrecision) forms.geohash now imports the shared options library and uses it to
validate and merge covering options.compact(Boolean)
and min_precision(PositiveInteger) options. Compact covers never
compress below the selected minimum precision.buffer(Distance) option
where the distance is expressed in kilometers.geospatial geometry predicates and currently do not support
antimeridian-crossing input geometries.