HSlippyMap 2.2 → 2.3
raw patch · 4 files changed
+12/−161 lines, 4 filesdep ~basenew-uploader
Dependency ranges changed: base
Files
- HSlippyMap.cabal +8/−6
- HSlippyMap.hs +4/−19
- README.md +0/−114
- hsl.hs +0/−22
HSlippyMap.cabal view
@@ -2,20 +2,22 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: HSlippyMap-version: 2.2+version: 2.3 synopsis: OpenStreetMap Slippy Map -- description:-homepage: https://github.com/j4/HSlippyMap+homepage: https://github.com/apeyroux/HSlippyMap license: BSD3 license-file: LICENSE-author: Jean-Alexandre Peyroux-maintainer: m@j4.pe+author: Alexandre Peyroux+maintainer: alex@xn--wxa.email+description: OpenStreetMap Slippy Map algorithm -- copyright: category: Development build-type: Simple-cabal-version: >=1.8+cabal-version: >=1.10 library exposed-modules: HSlippyMap+ default-language: Haskell2010 -- other-modules:- build-depends: base ==4.6.*+ build-depends: base ==4.9.*
HSlippyMap.hs view
@@ -1,19 +1,3 @@-{---let tl=tileFromLatLong 48.90 1.80 10-let tr=tileFromLatLong 48.90 2.62 10-let br=tileFromLatLong 48.70 2.70 10-let bl=tileFromLatLong 48.70 2.80 10--let max = tileFromLatLong 48.9031 2.5214 10-let min = tileFromLatLong 48.8146 2.1732 10-- [(x,[11266..11278]) | x <- [16581..16613]]--map (\(x,y) -> map (\y'-> "/15/" ++ show x ++ "/" ++ show y' ++ ".png") y) [(x,[11266..11278]) | x <- [16581..16613]]-map (\(x,y) -> map (\y'-> "http//http://tile.openstreetmap.org/" ++ show zlevel ++ "/" ++ show x ++ "/" ++ show y' ++ ".png") y) [(x,[11266..11278]) | x <- [16581..16613]]----}- module HSlippyMap ( Tile, tlat, tlong, tx, ty, tz, tilesFromBBox,@@ -32,19 +16,20 @@ tlong :: Long, tx :: X, ty :: Y,- tz :: ZLevel } + tz :: ZLevel } instance Show Tile where show (Tile lat long x y z) = "http://tile.openstreetmap.org/" ++ show z ++ "/" ++ show x ++ "/" ++ show y ++ ".png" -- ajouter un test si z1 == z2 puis maybe tilesFromBBox :: Tile -> Tile -> [Tile]-tilesFromBBox min max = concat $ map (\(x,y) -> map (\y'-> Tile (tlat min) (tlong min) x y' z) y) [(x,[(minimum [tymin, tymax])..(maximum [tymin,tymax])]) | x <- [(minimum [txmin, txmax])..(maximum [txmin, txmax])]]+tilesFromBBox min max = concat $ map (\(x,y) -> map (\y'-> Tile (tlat min) (tlong min) x y' z) y)+ [(x,[(minimum [tymin, tymax])..(maximum [tymin,tymax])]) | x <- [(minimum [txmin, txmax])..(maximum [txmin, txmax])]] where txmax = tx max txmin = tx min tymax = ty max- tymin = ty min + tymin = ty min z = tz min tileFromLatLong :: Lat -> Long -> ZLevel -> Tile
− README.md
@@ -1,114 +0,0 @@-Algo-------http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Haskell--GHCI-------```-ja@x220:~/codaz/HSlippyMap$ ghci-GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help-Loading package ghc-prim ... linking ... done.-Loading package integer-gmp ... linking ... done.-Loading package base ... linking ... done.-[1 of 1] Compiling HSlippyMap ( HSlippyMap.hs, interpreted )-Ok, modules loaded: HSlippyMap.-*HSlippyMap> :load HSlippyMap-*HSlippyMap> let max = tileFromLatLong 48.9031 2.5214 12-*HSlippyMap> let min = tileFromLatLong 48.8146 2.1732 12-*HSlippyMap> :t max-max :: Tile-*HSlippyMap> tilesFromBBox min max-[http://tile.openstreetmap.org/12/2072/1409.png,http://tile.openstreetmap.org/12/2073/1409.png,http://tile.openstreetmap.org/12/2074/1409.png,http://tile.openstreetmap.org/12/2075/1409.png,http://tile.openstreetmap.org/12/2076/1409.png]-```--Exemple----------Gist : https://gist.github.com/j4/8117832--```haskell-import HSlippyMap--main = do - mapM (\(x,y) -> mapM (\y'-> print $ "http://openstreetmap.asi.mi/" ++ show z ++ "/" ++ show x ++ "/" ++ show y' ++ ".png") y) [(x,\-[(minimum [tymin, tymax])..(maximum [tymin,tymax])]) | x <- [(minimum [txmin, txmax])..(maximum [txmin, txmax])]]- where- min = tileFromLatLong 49.13 3.05 8- max = tileFromLatLong 48.57 1.66 8- txmin = tx min- txmax = tx max- tymax = ty min- tymin = ty max- z = tz min-```--Result :--```bash-ja@x220 ~ $ ./hsl | xargs wget -nv -O NULL --output-file osm.asi.log -ja@x220 ~ $ cat osm.asi.log -2013-12-24 22:04:46 URL:http://tile.openstreetmap.org/8/129/87.png [37753/37753] -> "NULL" [1]-2013-12-24 22:04:46 URL:http://tile.openstreetmap.org/8/129/88.png [36997/36997] -> "NULL" [1]-2013-12-24 22:04:46 URL:http://tile.openstreetmap.org/8/130/87.png [36749/36749] -> "NULL" [1]-2013-12-24 22:04:47 URL:http://tile.openstreetmap.org/8/130/88.png [35550/35550] -> "NULL" [1]-FINISHED --2013-12-24 22:04:47---Total wall clock time: 0,7s-Downloaded: 4 files, 144K in 0,4s (364 KB/s)-```--Other exemple----------------```haskell-mapM (\z-> putStrLn $ show $ tileFromLatLong 12.3 3.3 z) [0..18]-```--```-http://tile.openstreetmap.org/0/0/0.png-http://tile.openstreetmap.org/1/1/0.png-http://tile.openstreetmap.org/2/2/1.png-http://tile.openstreetmap.org/3/4/2.png-http://tile.openstreetmap.org/4/8/5.png-http://tile.openstreetmap.org/5/16/11.png-http://tile.openstreetmap.org/6/32/22.png-http://tile.openstreetmap.org/7/64/44.png-http://tile.openstreetmap.org/8/129/88.png-http://tile.openstreetmap.org/9/259/176.png-http://tile.openstreetmap.org/10/518/352.png-http://tile.openstreetmap.org/11/1036/704.png-http://tile.openstreetmap.org/12/2073/1409.png-http://tile.openstreetmap.org/13/4147/2819.png-http://tile.openstreetmap.org/14/8295/5639.png-http://tile.openstreetmap.org/15/16590/11278.png-http://tile.openstreetmap.org/16/33181/22557.png-http://tile.openstreetmap.org/17/66362/45115.png-http://tile.openstreetmap.org/18/132725/90230.png-```---```haskell-long2tilex lon z = floor((lon + 180.0) / 360.0 * (2.0 ** z))- -lat2tiley lat z = floor((1.0 - log( tan(lat * pi/180.0) + 1.0 / cos(lat * pi/180.0)) / pi) / 2.0 * (2.0 ** z))- -tilex2long x z = x / (2.0 ** z) * 360.0 - 180- -tiley2lat y z = 180.0 / pi * atan(0.5 * (exp(n) - exp(-n)))- where- n = pi - 2.0 * pi * y / (2.0 ** z)- --- Exemple-main = do- --print $ long2tilex 2.2712 17- --print $ lat2tiley 48.8152 17- --print $ tilex2long 66362 17- --print $ tiley2lat 45115 17- putStrLn "gps: (lat=48.8152,long=2.2712)"- putStrLn $ "http://tile.openstreetmap.org/17/" ++ show x ++ "/" ++ show y ++ ".png"- where- z = 17- x = long2tilex 2.2712 z- y = lat2tiley 48.8152 z-```
− hsl.hs
@@ -1,22 +0,0 @@--- HSlippyMap Exemple-import HSlippyMap--{---let max = tileFromLatLong 48.9031 2.5214 10-let min = tileFromLatLong 48.8146 2.1732 10-mapM (\(x,y) -> mapM (\y'-> print $ "http://tile.openstreetmap.org/" ++ show z ++ "/" \-++ show x ++ "/" ++ show y' ++ ".png") y) [(x,[(minimum [tymin, tymax])..(maximum [tymin\-,tymax])]) | x <- [(minimum [txmin, txmax])..(maximum [txmin, txmax])]]---}--main = do - --mapM (print . show . tileFromLatLong lat long) [0..18]- mapM (\(x,y) -> mapM (\y'-> print $ "http://tile.openstreetmap.org/" ++ show z ++ "/" ++ show x ++ "/" ++ show y' ++ ".png") y) [(x,[(minimum [tymin, tymax])..(maximum [tymin,tymax])]) | x <- [(minimum [txmin, txmax])..(maximum [txmin, txmax])]]- where- min = tileFromLatLong 49.13 3.05 8- max = tileFromLatLong -48.57 1.66 8- txmin = tx min- txmax = tx max- tymax = ty min- tymin = ty max- z = tz min