Permalink
Browse files

Move to download-curl and avoid the unpack/pack of an IO String for e…

…ach PNG.
  • Loading branch information...
1 parent 6889125 commit b26bf44c5d80eabe6b389fa700681312217d4c0b @TomMD TomMD committed Sep 3, 2011
Showing with 7 additions and 6 deletions.
  1. +5 −4 Data/GPS/Gps2HtmlReport/DrawOsm.hs
  2. +2 −2 gps2htmlReport.cabal
@@ -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
@@ -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

0 comments on commit b26bf44

Please sign in to comment.