-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeohash.h
32 lines (21 loc) · 806 Bytes
/
geohash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef GEOHASH_H
#define GEOHASH_H
#include <stdint.h>
#include <stdbool.h>
#define MAX_GEOHASH_LENGTH 17
typedef struct s_geohash
{
double latitude;
double longitude;
char hash[MAX_GEOHASH_LENGTH + 1];
uint32_t latitudebits;
uint32_t longitudebits;
} CCGeohashStruct;
// creates a neighbour from another geohash
// longitude and latitude are block based unit offset
CCGeohashStruct init_neighbour(CCGeohashStruct *geohash, int longitude, int latitude);
// fills the latitude and longitude fields given a CCGeohashStruct containing a hash in the hash field
void init_from_hash(CCGeohashStruct *geohash);
// fills the hash field given a CCGeohashStruct containing a latitude and longitude
void init_from_coordinates(CCGeohashStruct *geohash);
#endif // GEOHASH_H