How Far is my Morning Run
May 27, 2010
I always assumed my run was about 5k, but being out of shape it felt more like 7km. Eventually this bugged me enough that I spent a whole ten minutes at a coffee shop to learn the GPX library and make a program that converts my GPX traces (I carry a GPS logger on jogs) to a distance. Thank you hackage, thank you Tony.
module Main where import Data.Geo.GPX import Data.GPS import Control.Monad import System.Environment (getArgs) main = do file <- liftM head getArgs run <- readGpxFile file let cs = map (degreePairToDMS. latlon) . trkpts . head . trksegs . head . trks . head $ run pairs = zip cs (drop 1 cs) dist = sum (map (uncurry distance) pairs) print dist