Created
April 23, 2012 18:44
-
-
Save robinkraft/2472994 to your computer and use it in GitHub Desktop.
notes on converting latlon to google maps tile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; work in progress! | |
| (defn mf | |
| [lat lon zoom] | |
| (let [min-lat -90])) | |
| (defn my-func | |
| [lat lon zoom] | |
| (let [tile-range (bit-shift-left 1 zoom) | |
| y lat | |
| x lon] | |
| (cond (or (< y 0) (>= y tile-range)) nil | |
| (or (< x 0) (>= x tile-range)) {:y y :x (mod | |
| (+ tile-range | |
| (mod x tile-range)) | |
| tile-range)}))) | |
| (defn normalize-lat | |
| [lat] | |
| (- lat -90)) | |
| (defn normalize-lon | |
| [lon] | |
| (- lon -180)) | |
| (defn calc-x | |
| [lon zoom] | |
| (let [tile-range (bit-shift-left 1 zoom) | |
| norm-lon (normalize-lon lon) | |
| norm-lat (normalize-lat) | |
| deg-x (/ 360 tile-range) | |
| deg-y (/ 180 tile-range)] | |
| (prn (str "deg-per-tile: " deg-x)) | |
| (prn (str "normalized: " norm-lon)) | |
| (int (/ norm-lon deg-x)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment