packages feed

HSlippyMap (empty) → 0.1.0.0

raw patch · 6 files changed

+136/−0 lines, 6 filesdep +basesetup-changed

Dependencies added: base

Files

+ HSlippyMap.cabal view
@@ -0,0 +1,21 @@+-- Initial HSlippyMap.cabal generated by cabal init.  For further+-- documentation, see http://haskell.org/cabal/users-guide/++name:                HSlippyMap+version:             0.1.0.0+synopsis:            OpenStreetMap Slippy Map+description:	     Use OpenStreetMap Slippy Map with Haskell : http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Haskell+homepage:            https://github.com/j4/HSlippyMap+license:             BSD3+license-file:        LICENSE+author:              Jean-Alexandre Peyroux+maintainer:          m@j4.pe+-- copyright:+category:            Development+build-type:          Simple+cabal-version:       >=1.8++library+  exposed-modules:  HSlippyMap +  -- other-modules:       +  build-depends:       base ==4.6.*
+ HSlippyMap.hs view
@@ -0,0 +1,46 @@+module HSlippyMap (+    -- * HSlippyMap+    Tile,+    tileFromLatLong,+    tileFromGPS+) where++type Lat = Float+type Long = Float+type GpsX = Integer+type GpsY = Integer+type ZLevel = Integer++data Tile = Tile {+  lat :: Lat,+  long :: Long,+  x :: GpsX,+  y :: GpsY,+  z :: ZLevel }++instance Show Tile where+  show (Tile lat long x y z) = "http://tile.openstreetmap.org/" ++ show z ++ "/" ++ show x ++ "/" ++ show y ++ ".png"++-- | Create Tile from Lat Long+tileFromLatLong :: Lat -> Long -> ZLevel -> Tile+tileFromLatLong lat lon z = Tile lat lon x y z+    where+        x = long2tilex lon z+        y = lat2tiley lat z++-- | Create Tile from GPS X Y+tileFromGPS :: GpsX -> GpsY -> ZLevel -> Tile+tileFromGPS x y z = Tile lat lon x y z+    where+        lat = tilex2long x z+        lon = tiley2lat y z++long2tilex lon z = floor((lon + 180) / 360 * (2** fromInteger(z)::Long))++lat2tiley lat z = floor((1.0 - log( tan(lat * pi/180.0) + 1.0 / cos(lat * pi/180.0)) / pi) / 2.0 * (2 ** fromInteger(z)::Long))++tilex2long x z = (fromInteger(x)::Long) / (2.0 ** fromInteger(z)::Long) * 360.0 - 180++tiley2lat y z = 180.0 / pi * atan(0.5 * (exp(n) - exp(-n)))+    where+        n = pi - 2.0 * pi * (fromInteger(y)::Long) / (2.0 ** fromInteger(z)::Long)
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2013, Jean-Alexandre Peyroux++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Jean-Alexandre Peyroux nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,26 @@+http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Haskell++```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+```
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ hsl.hs view
@@ -0,0 +1,11 @@+import HSlippyMap++main = do+  putStrLn $ show $ tileFromLatLong lat long z+  putStrLn $ show $ tileFromGPS x y z+  where+      lat = 48.8152+      long = 2.2712+      x = 66362+      y = 45115+      z = 19