Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Another fromJust bug is guarded against

  • Loading branch information...
commit 00c2ad6e8baefc936e1a7725fa37771de2b718f0 1 parent c8a35cc
Rob Stewart authored
View
6 Data/GPS/Gps2HtmlReport/JourneyStats.hs
@@ -30,7 +30,7 @@ speedAtPoints' prev [x]
| isJust (time x) = [(lclTime $ fromJust (time x), fromJust $ speed prev x)]
| otherwise = []
speedAtPoints' prev (x:xs)
- | isJust (time x) = (lclTime $ fromJust (time x), fromJust $ speed prev x) : speedAtPoints' x xs
+ | isJust (time x) && isJust (speed prev x) = (lclTime $ fromJust (time x), fromJust $ speed prev x) : speedAtPoints' x xs
| otherwise = [] ++ speedAtPoints' x xs
-- | Takes all WayPoints, and creates a list of tuples containing (TimeStamp,JourneyDistanceAtPoint)
@@ -78,8 +78,8 @@ meanElevation points =
-- | Calculates the total journey time
journeyTime :: Time a => [a] -> NominalDiffTime
-journeyTime [] = fromInteger 0
-journeyTime [_] = fromInteger 0
+journeyTime [] = 0
+journeyTime [_] = 0
journeyTime (point:points) =
let startTime = toUTCTime (fromJust (time point))
endTime = toUTCTime (fromJust (time $ last points))
View
11 Data/GPS/Gps2HtmlReport/Main.hs
@@ -69,7 +69,7 @@ processGps fullReport = do
createEmptyDir :: FilePath -> IO ()
createEmptyDir dir = do
exists <- doesDirectoryExist dir
- (if exists then removeDirectoryRecursive dir >> createDirectory dir else createDirectory dir)
+ if exists then removeDirectoryRecursive dir >> createDirectory dir else createDirectory dir
-- | Generates the HTML report for each .gpx file,
-- or simply an osm.png file if the '--imageonly' argument
@@ -81,9 +81,7 @@ generateReport webDir gpxFile fullReport = do
0 -> putStr "Unable to parse GPX file. Skipping..."
_ -> do
createEmptyDir webDir
- case fullReport
- of
- True -> do
+ if fullReport then do
putStr "Generating statistical charts...\n"
renderToPng (chart1 points) (webDir++"/chart1.png")
renderToPng (chart2 points) (webDir++"/chart2.png")
@@ -91,8 +89,7 @@ generateReport webDir gpxFile fullReport = do
putStr "Downloading OpenStreetMap tiles...\n"
generateOsmMap webDir points
putStr $ "Processing '"++gpxFile++"' complete. Report saved in: "++webDir++"/index.html\n"
- _ -> do
+ else do
putStr "Downloading OpenStreetMap tiles...\n"
generateOsmMap webDir points
- putStr $ "Processing '"++gpxFile++"' complete. Image saved in: "++webDir++"/osm.png\n"
- return ()
+ putStr $ "Processing '"++gpxFile++"' complete. Image saved in: "++webDir++"/osm.png\n"
Please sign in to comment.
Something went wrong with that request. Please try again.