gps2htmlReport 0.2 → 0.2.1
raw patch · 5 files changed
+41/−42 lines, 5 filesdep +http-enumeratordep −download-curldep ~gpsdep ~xsd
Dependencies added: http-enumerator
Dependencies removed: download-curl
Dependency ranges changed: gps, xsd
Files
- Data/GPS/Gps2HtmlReport/DrawOsm.hs +12/−11
- Data/GPS/Gps2HtmlReport/Main.hs +21/−27
- LiberationMono-Bold.ttf binary
- README.md +1/−1
- gps2htmlReport.cabal +7/−3
Data/GPS/Gps2HtmlReport/DrawOsm.hs view
@@ -4,7 +4,10 @@ import Prelude import Data.GPS import Graphics.Transform.Magick.Types hiding (Image, minimum, maximum)-import Network.Curl.Download+import Network.HTTP.Enumerator+import qualified Data.ByteString as B+import qualified Data.ByteString.Lazy as L+import Control.Monad import Data.Bits import Graphics.GD import Data.Maybe@@ -111,10 +114,8 @@ -- | Takes the URL of a given OSM tile and uses curl to download it downloadFile :: String -> IO Image downloadFile url = do- response <- openURI url- case response of- Left err -> error err- Right img -> loadPngByteString img+ response <- liftM (B.concat . L.toChunks) (simpleHttp url)+ loadPngByteString response -- | Takes the boundaries of the OSM tiles covering the -- the 'Trail', uses 'placeTile' to download the tile@@ -176,18 +177,18 @@ end = pixelPosForCoord [head wpts] tCoord zoom minEle = fromMaybe 0 $ fmap snd $ findPoint wpts wpt ele (<) maxEle = fromMaybe 0 $ fmap snd $ findPoint wpts wpt ele (>)- drawLine' start end img (minEle,fromJust $ ele wpt,maxEle) 0+ drawLine' start end img (minEle,fromMaybe 0 $ ele wpt,maxEle) 0 drawLines wpts tCoord img zoom -- | This is a fix on the fact that the 'drawLine' function -- provided by the GD bindings do not provid a `width' parameter drawLine' :: Point -> Point -> Image -> (Double,Double,Double) -> Int -> IO () drawLine' start end img (minEle,ele',maxEle) i- | i < 6 = do- drawLine (fst start+(i-1),snd start-(i-1)) (fst end+(i-1),snd end-(i-1)) color' img- drawLine (fst start+(i+1),snd start-(i-1)) (fst end+(i+1),snd end-(i-1)) color' img- drawLine (fst start+(i+1),snd start-(i+1)) (fst end+(i+1),snd end-(i+1)) color' img- drawLine (fst start+(i-1),snd start-(i+1)) (fst end+(i-1),snd end-(i+1)) color' img+ | i < 4 = do+ drawLine (fst start+(i-2),snd start-(i-2)) (fst end+(i-2),snd end-(i-2)) color' img+ drawLine (fst start+(i+2),snd start-(i-2)) (fst end+(i+2),snd end-(i-2)) color' img+ drawLine (fst start+(i+2),snd start-(i+2)) (fst end+(i+2),snd end-(i+2)) color' img+ drawLine (fst start+(i-2),snd start-(i+2)) (fst end+(i-2),snd end-(i+2)) color' img drawLine' start end img (minEle,ele',maxEle) (i+1) | otherwise = return () where range = maxEle - minEle
Data/GPS/Gps2HtmlReport/Main.hs view
@@ -33,7 +33,7 @@ &= program _PROGRAM_NAME _PROGRAM_NAME = "gps2HtmlReport"-_PROGRAM_VERSION = "0.2"+_PROGRAM_VERSION = "0.2.1" _PROGRAM_INFO = _PROGRAM_NAME ++ " version " ++ _PROGRAM_VERSION _PROGRAM_ABOUT = "A Haskell utility to generate HTML page reports of GPS Tracks and Track overlays on OpenStreetMap tiles" _COPYRIGHT = "(C) Rob Stewart 2011"@@ -63,9 +63,7 @@ let allFilesSplit = map splitExtension allFiles let gpxFiles = filter (\(_,b) -> b==".gpx") allFilesSplit putStr ("Processing "++show (length gpxFiles)++" file(s)...\n")- if fullReport- then mapM (\(a,b) -> generateReport (curDir++"/"++a) (a++b)) gpxFiles- else mapM (\(a,b) -> generateImgOnly (curDir++"/"++a) (a++b)) gpxFiles+ mapM (\(a,b) -> generateReport (curDir++"/"++a) (a++b) fullReport) gpxFiles -- | Creates empty directory for each web report createEmptyDir :: FilePath -> IO ()@@ -73,32 +71,28 @@ exists <- doesDirectoryExist dir (if exists then removeDirectoryRecursive dir >> createDirectory dir else createDirectory dir) --- | Generates the HTML report for each .gpx file-generateReport :: FilePath -> FilePath -> IO ()-generateReport webDir gpxFile = do- points <- readGPX gpxFile- case length points of- 0 -> putStr "Unable to parse GPX file. Skipping..."- _ -> do- createEmptyDir webDir- putStr "Generating statistical charts...\n"- renderToPng (chart1 points) (webDir++"/chart1.png")- renderToPng (chart2 points) (webDir++"/chart2.png")- writeFile (webDir++"/index.html") $ renderHtml $ generateHtmlPage points- putStr "Downloading OpenStreetMap tiles...\n"- generateOsmMap webDir points- putStr $ "Processing '"++gpxFile++"' complete. Report saved in: "++webDir++"/index.html\n"- return ()---- | Generates the HTML report for each .gpx file-generateImgOnly :: FilePath -> FilePath -> IO ()-generateImgOnly webDir gpxFile = do+-- | Generates the HTML report for each .gpx file,+-- or simply an osm.png file if the '--imageonly' argument+-- is used+generateReport :: FilePath -> FilePath -> Bool -> IO ()+generateReport webDir gpxFile fullReport = do points <- readGPX gpxFile case length points of 0 -> putStr "Unable to parse GPX file. Skipping..." _ -> do createEmptyDir webDir- putStr "Downloading OpenStreetMap tiles...\n"- generateOsmMap webDir points- putStr $ "Processing '"++gpxFile++"' complete. Image saved in: "++webDir++"/osm.png\n"+ case fullReport+ of+ True -> do+ putStr "Generating statistical charts...\n" + renderToPng (chart1 points) (webDir++"/chart1.png")+ renderToPng (chart2 points) (webDir++"/chart2.png")+ writeFile (webDir++"/index.html") (renderHtml $ generateHtmlPage points)+ putStr "Downloading OpenStreetMap tiles...\n"+ generateOsmMap webDir points+ putStr $ "Processing '"++gpxFile++"' complete. Report saved in: "++webDir++"/index.html\n"+ _ -> do+ putStr "Downloading OpenStreetMap tiles...\n"+ generateOsmMap webDir points+ putStr $ "Processing '"++gpxFile++"' complete. Image saved in: "++webDir++"/osm.png\n" return ()
LiberationMono-Bold.ttf view
binary file changed (105428 → 105456 bytes)
README.md view
@@ -11,7 +11,7 @@ An example can be seen [HERE](http://www.macs.hw.ac.uk/~rs46/gps2htmlreport/3/index.html). -The Haddock documentation pages can be found [here](http://www.macs.hw.ac.uk/~rs46/gps2htmlreport/doc/).+The hackage page is [here](http://hackage.haskell.org/package/gps2htmlReport). Installation ------------
gps2htmlReport.cabal view
@@ -1,6 +1,6 @@ Name: gps2htmlReport-Version: 0.2-Cabal-Version: >=1.2+Version: 0.2.1+Cabal-Version: >=1.6 Description: Generate a HTML summary report of GPS tracks synopsis: GPS to HTML Summary Report License: BSD3@@ -19,5 +19,9 @@ Main-is: Data/GPS/Gps2HtmlReport/Main.hs library- Build-Depends: base >= 4 && < 5, html, gps >= 0.8.1, time, cairo, Chart, random, data-accessor, colour, xsd, filepath, directory, process, gd, bytestring, download-curl, hsmagick, cmdargs+ Build-Depends: base >= 4 && < 5, html, gps >= 0.8.4, time, cairo, Chart, random, data-accessor, colour, xsd >= 0.3.5, filepath, directory, process, gd, bytestring, http-enumerator, hsmagick, cmdargs Exposed-Modules: Data.GPS.Gps2HtmlReport.HTMLGenerator, Data.GPS.Gps2HtmlReport.JourneyStats, Data.GPS.Gps2HtmlReport.JourneyCharts, Data.GPS.Gps2HtmlReport.DrawOsm++source-repository head+ type: git+ location: git://github.com/robstewart57/Gps2HtmlReport.git