Geohex command line utility
=======
$ gem install geohex-gen
This gem installs a command line tool named ghgen that:
- Given lat, lon return geohex level 10 code.
- Given a GH (any size), display center lat/lon and show GH4/5/6 that contains this location.
- Given a GH (any size) and a ring size, display geohex codes that form the ring(s).
$shell> ghgen -h
Usage: ghgen [options]
-a LAT Latitude. If used, must have longitude also
-o LON Longitude. If used, must have latitude also
-g GH Specify center geohex directly
-r [RING] Number of rings around center
$shell> ghgen -g PC22713455
Center GH is PC22713455, located at 32.91066810490208, -117.21383935375704
This location is included in
GH4: PC2271
GH5: PC22713
GH6: PC227134
Note that you can't always truncate a GH string to get to larger size.
Geohexes that are on apex ending with 2 or 6 ends up on parent with different code system. ghgen handles this properly.
$shell> ghgen -g PC2266666
Center GH is PC2266666, located at 32.70505659484853, -115.56470050297207
This location is included in
GH4: PC2500
GH5: PC25000
GH6: PC218888
$shell> ghgen -a 32.90475787738992 -o -117.20164609053498
Center GH is PC2271344444, located at 32.90475787738992, -117.20164609053498
This location is included in
GH4: PC2271
GH5: PC22713
GH6: PC227134
$shell> ghgen -g PC22751 -r 1
Center GH is PC22751, located at 33.14380613603259, -117.3662551440329
This location is included in
GH4: PC2275
GH5: PC22751
GH6: PC227514
Center PC22751, Ring(s) 1:
PC22727
PC22754
PC22752
PC22726
PC22755
PC22750
You can specify ring size with lat/lon, but the ring is always in GH10.