-
Notifications
You must be signed in to change notification settings - Fork 33
/
README.tex
66 lines (48 loc) · 1.75 KB
/
README.tex
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
\documentclass{article}
\title{libgeohash}
\author{Derek Smith \\ derek@simplegeo.com}
\begin{document}
\maketitle
\begin{abstract}
A static library used for encoding/decoding geohashes.
\end{abstract}
\section{Description}
\section{Usage}
To use \textit{libgeohash} just run \texttt{make}. Link \textbf{libgeohash.a} and include \textbf{geohash.h} into your project.
\subsection{Encode}
\begin{verbatim}
char* geohash_encode(double lat, double lng, int precision);
\end{verbatim}
Takes in latitude and longitude with a desired precision and returns the correct hash value. If
\(precision < 0\) or \(precision > 20\), a default value of \texttt{12} will be used.
\subsection{Decode}
\begin{verbatim}
GeoCoord geohash_decode(char* hash);
\end{verbatim}
Produces an allocated GeoCoord structure which contains the \texttt{latitude} and \texttt{longitude} that was decoded from
the geohash. A GeoCoord also provides the bounding box for the geohash (\texttt{north}, \texttt{east}, \texttt{south}, \texttt{west}).
\subsection{Neighbors}
\begin{verbatim}
char** geohash_neighbors(char* hash);
\end{verbatim}
Uses the bounding box declared at \texttt{hash} and calculates the 8 neighboring boxes. An example is show below.
\begin{center}
\begin{tabular}{| c | c | c |}
\hline
ezefx & ezs48 & ezs49 \\ \hline
ezefr & \textbf{ezs42} & ezs43 \\ \hline
ezefp & ezs40 & ezs41 \\ \hline
\end{tabular}
\end{center}
The value returned is an array of \texttt{char*} with length of 8. The neighboring positions of values are shown below with each box representing the index of the array.
\begin{center}
\begin{tabular}{| c | c | c |}
\hline
7 & 0 & 1 \\ \hline
6 & & 2 \\ \hline
5 & 4 & 3 \\ \hline
\end{tabular}
\end{center}
\section{Contact Information}
derek@simplegeo.com
\end{document}