Created
January 4, 2018 09:10
-
-
Save talaj/0eb3dd220172d9134a4d6dbe1633dace to your computer and use it in GitHub Desktop.
Envelope of a tile in Spherical Mercator
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
(defconstant EARTH_RADIUS 6378137.0) | |
(defconstant HALF_OF_EQUATOR (* PI EARTH_RADIUS)) | |
(defun tile-size (zoom) (/ (* 2 HALF_OF_EQUATOR) (expt 2 zoom))) | |
(defun tile-envelope (x y z) | |
(let ((size (tile-size z))) | |
(list | |
(+ (- HALF_OF_EQUATOR) (* x size)) | |
(- (+ HALF_OF_EQUATOR) (* (+ y 1) size)) | |
(+ (- HALF_OF_EQUATOR) (* (+ x 1) size)) | |
(- (+ HALF_OF_EQUATOR) (* y size))))) | |
(format t "~{~6$~^ ~}" (tile-envelope 112 672 11)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment