Skip to content

Commit

Permalink
Documentation of Elm package
Browse files Browse the repository at this point in the history
  • Loading branch information
andys8 committed Mar 19, 2017
1 parent 8aaea1e commit 571abc6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions Geohash.elm
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@

module Geohash exposing (encode)

{-| This module is a Pure Elm implementation for Geohashes.
{-| This module is an Geohash Elm implementation.
Thanks to Sun Ning for the JavaScript implementation.
Thanks to [Ning Sun](https://github.com/sunng87) for the [JavaScript implementation](https://github.com/sunng87/node-geohash).
# What is a geohash?
The geohash preserves **spatial locality** so that points close to each other in space are close to each other on disk. This is because the arrangement of the result is comparable with space filling **Z-order curves**. The length of geohashes can be chosen individually and depending on the degree of accuracy. Characters at the end are less significant. Truncating the geohash can be used to cover larger areas. In fact this can be used to build range queries based on the prefix of the primary key.
The geohash is constructed bitwise. The range of both dimensions will be cut in half. If the target point is located in the greater half of the range, the value of the first bit is `1`. Otherwise it’s `0`. The example longitude `11.53..°` would result in a `1-bit` as first value because it’s part of range `[0°, +180°]` and not `[-180°, 0°)`. This binary partitioning approach will be repeated alternately for both axes (beginning with longitude). Because the encoding is weaving the bits together, the geohash has the spatial locality property.
# Functions
@docs encode
-}

import String
import Char
import Dict exposing (Dict)
import Array exposing (Array)
import Bitwise
Expand Down Expand Up @@ -62,7 +66,9 @@ type alias EncodeState =
}


{-| Encodes latitude/longitude to geohash, either to specified precision or to automatically evaluated precision.
{-| Encodes latitude, longitude, precision to geohash.
encode 57.648 10.41 6 == "u4pruy"
-}
encode : Float -> Float -> Int -> String
encode latitude longitude numberOfChars =
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ geohash = Geohash.encode -25.38262 -49.26561 8
```

## Javascript
Thanks to the authors of the javascript version ([github.com/sunng87/node-geohash](https://github.com/sunng87/node-geohash)).
Thanks to [Ning Sun](https://github.com/sunng87) for the [JavaScript implementation](https://github.com/sunng87/node-geohash).

0 comments on commit 571abc6

Please sign in to comment.