Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1 from TomMD/master

Some bug fixes from TomMD
  • Loading branch information...
commit c45e1f8106c4598d2685edce7f78075e1b564e5a 2 parents 6889125 + 0d124ae
robstewart57 authored
View
13 Data/GPS/Gps2HtmlReport/DrawOsm.hs
@@ -6,7 +6,7 @@ import Prelude
import Data.GPS
import Data.ByteString.Char8 hiding (head)
import Graphics.Transform.Magick.Types hiding (Image)
-import Network.Curl
+import Network.Curl.Download
import Data.Bits
import Graphics.GD
import Data.Maybe
@@ -75,9 +75,10 @@ rectangle x' y' = Rectangle {width=256, height=256, x = x'*256, y = y'*256}
downloadFile :: String -> IO Image
downloadFile url = do
- response <- curlGetString url []
- let imgBlob::ByteString = pack $ snd response
- loadPngByteString imgBlob
+ response <- openURI url
+ case response of
+ Left err -> error err
+ Right img -> loadPngByteString img
makeOSMLayer :: TileCoords -> IO Image
makeOSMLayer tCoords = do
@@ -124,8 +125,8 @@ drawLines [_] _ img = return img
drawLines (wpt:wpts) tCoord img = do
let start = pixelPosForCoord [wpt] tCoord
end = pixelPosForCoord [head wpts] tCoord
- minEle = snd $ fromJust $ findPoint wpts wpt ele (<)
- maxEle = snd $ fromJust $ findPoint wpts wpt ele (>)
+ 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
drawLines wpts tCoord img
View
4 Data/GPS/Gps2HtmlReport/JourneyStats.hs
@@ -57,8 +57,8 @@ journeyDistance [_] = 0.0
journeyDistance (point:points) = distance point (head points) + journeyDistance points
-- | Calculates the average speed of the journey
-meanJourneySpeed :: (Lat a, Lon a) => [a] -> Distance
-meanJourneySpeed points = journeyDistance points / fromIntegral (length points)
+meanJourneySpeed :: (Lat a, Lon a, Time a) => [a] -> Distance
+meanJourneySpeed points = journeyDistance points / realToFrac (journeyTime points)
-- | Calculates the maximum speed
maxSpeed :: [WptType] -> Speed
View
4 gps2htmlReport.cabal
@@ -19,6 +19,6 @@ Executable gps2htmlReport
Main-is: Data/GPS/Gps2HtmlReport/Main.hs
library
- Build-Depends: base >= 4 && < 5, html, gps >= 0.7, time, cairo, Chart, random, data-accessor, colour, xsd, filepath, directory, process, gd, bytestring, curl, hsmagick
+ Build-Depends: base >= 4 && < 5, html, gps >= 0.7, time, cairo, Chart, random, data-accessor, colour, xsd, filepath, directory, process, gd, bytestring, download-curl, hsmagick
Extensions: ScopedTypeVariables
- Exposed-Modules: Data.GPS.Gps2HtmlReport.HTMLGenerator, Data.GPS.Gps2HtmlReport.JourneyStats, Data.GPS.Gps2HtmlReport.JourneyCharts, Data.GPS.Gps2HtmlReport.DrawOsm
+ Exposed-Modules: Data.GPS.Gps2HtmlReport.HTMLGenerator, Data.GPS.Gps2HtmlReport.JourneyStats, Data.GPS.Gps2HtmlReport.JourneyCharts, Data.GPS.Gps2HtmlReport.DrawOsm
Please sign in to comment.
Something went wrong with that request. Please try again.