Commits

Ning Sun committed 75c180a

update readme, fix decode-bbox bug

Comments (0)

Files changed (4)

README

-# geohash
-
-FIXME: write description
-
-## Usage
-
-FIXME: write
-
-## License
-
-Copyright (C) 2011 FIXME
-
-Distributed under the Eclipse Public License, the same as Clojure.
+# geohash
+
+[Geohash](http://en.wikipedia.org/wiki/Geohash "geohash") library for clojure.
+
+## Usage
+
+Include geohash with leiningen:
+
+    (defproject your-project "1.0.0-SNAPSHOT"
+        :dependencies [[org.clojars.sunng/geohash "1.0.0"]])
+        
+Encode coordinate into geohash:
+
+    (use [geohash.core])
+    (encode 37.8324 112.5584 9)
+    "ww8p1r4t8"
+    
+Decode geohash into coordinate:
+
+    (decode "ww8p1r4t8")
+    {:lat 37.83238649368286,
+     :lon 112.55838632583618,
+     :lat-err 2.1457672119140625E-5,
+     :lon-err 2.1457672119140625E-5}
+    
+Decode geohash into bound box:
+
+    (decode-bbox "ww8p1r4t8")
+    {:minlon 112.55836486816406,
+     :maxlon 112.5584077835083,
+     :minlat 37.83236503601074,
+     :maxlat 37.83240795135498}       
+
+## License
+
+Copyright (C) 2011 Sun Ning <classicning@gmail.com>
+
+Distributed under the Eclipse Public License, the same as Clojure.
-(defproject org.clojars.sunng/geohash "1.0.0"
+(defproject org.clojars.sunng/geohash "1.0.1"
   :description "Geohash in clojure"
   :dependencies [[org.clojure/clojure "1.2.1"]]
   :dev-dependencies [[lein-clojars "0.6.0"]])

src/geohash/core.clj

   (let [
         hashcodes (map base32-index hashstring)
         bbox (do-decode-bbox hashcodes (struct geocode-data 180.0 -180.0 90.0 -90.0 true nil nil nil))]
-    (dissoc bbox :islon :bits :hashcode :hashstring)))
+    {
+      :minlon (:minlon bbox)
+      :maxlon (:maxlon bbox)
+      :minlat (:minlat bbox)
+      :maxlat (:maxlat bbox)}))
 
 (defn decode [hashstring]
   (let [
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.