Commits

Ning Sun  committed 96e40ef

improve encode interface

  • Participants
  • Parent commits 3ed51c9

Comments (0)

Files changed (2)

File src/geohash/core.clj

         lon-err (/ (- (:maxlon bbox) (:minlon bbox)) 2)]
     {:lat lat :lon lon :lat-err lat-err :lon-err lon-err}))
 
-(defn encode [lat lon prec]
+(defn encode 
+  ([lat lon] (encode lat lon 9))
+  ([lat lon prec]
   (do-encode lat lon prec 
-    (struct geocode-data 180 -180 90 -90 true 0 0 "")))
+    (struct geocode-data 180 -180 90 -90 true 0 0 ""))))

File test/geohash/test/core.clj

   (:use [clojure.test]))
 
 (deftest test-encode 
-  (is (= "ww8p1r4t8" (encode 37.8324 112.5584 9))))
+  (is (= "ww8p1r4t8" (encode 37.8324 112.5584)))
+  (is (= "wtsnstbgzys5" (encode 32.112343 118.324122 12))))
 
 (deftest test-decode
   (let [geodata (decode "ww8p1r4t8")]