Skip to content

lyokato/objc-geohash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

=======================================================================
 INSTALL
=======================================================================

Copy all files under 'Classes/ARC' or 'Classes/NonARC' directory into your project.

=======================================================================
 USAGE
=======================================================================

#import "GeoHash.h"

/* Get GetHash by latitude, longitude, and hash-length */

NSString *hash = [GeoHash hashForLatitude:35.6894875
                               longitude:139.6917064 
                                   length:13];

/* hash equals to @"xn774c06kdtve" */


/* Decode GeoHash and get an area which the hash indicates */

GHArea *area = [GeoHash areaForHash:@"c216ne"];

area.latitude.max
area.latitude.min
area.longitude.max
area.longitude.min


/* Adjacent */
NSString *adjacentHash = [GeoHash adjacentForHash:@"dqcjq"
                                        direction:GHDirectionNorth];
/* @"dqcjw" */


GHNeighbors *neighbors = [GeoHash neighborsForHash:@"dqcw5"];

neighbors.north
neighbors.south
neighbors.east
neighbors.west
neighbors.northEast
neighbors.northWest
neighbors.southEast
neighbors.southWest


/* check invalid hash */
if (![GeoHash verifyHash:@"abw!@"])
{
    ...
}