flight-kml-1.0.0: Parsing of pilot tracklogs dumped as KML.

Copyright© 2018 Phil de Joux
© 2018 Block Scope Limited
LicenseMPL-2.0
MaintainerPhil de Joux <phil.dejoux@blockscope.com>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Flight.Kml

Contents

Description

Provides parsing of dumped tracklogs. In hang gliding and paragliding competitions when FS and GpsDump are paired in competition mode a pilot's tracklog is dumped as KML. This is exlained in detail on the FS wiki.

Synopsis

Usage

Working with the KML tracklog dump from the tracklog file "Phil de Joux.20120114-082221.21437.40.kml".

>>> Right mf@(MarkedFixes{mark0, fixes}) <- parse kml
>>> mark0
2012-01-14 02:12:55 UTC
>>> length fixes
6547
>>> head fixes
Fix {fixMark = 0s, fix = LLA {llaLat = -33.36160000°, llaLng = 147.93205000°, llaAltGps = 237m}, fixAltBaro = Just 239m}
>>> last fixes
Fix {fixMark = 13103s, fix = LLA {llaLat = -33.65073300°, llaLng = 147.56036700°, llaAltGps = 214m}, fixAltBaro = Just 238m}

The newtypes

newtype Seconds Source #

The number of seconds offset from the time of the first fix.

Constructors

Seconds Integer 
Instances
Eq Seconds Source # 
Instance details

Defined in Flight.Types

Methods

(==) :: Seconds -> Seconds -> Bool #

(/=) :: Seconds -> Seconds -> Bool #

Num Seconds Source # 
Instance details

Defined in Flight.Types

Ord Seconds Source # 
Instance details

Defined in Flight.Types

Show Seconds Source # 
Instance details

Defined in Flight.Types

Generic Seconds Source # 
Instance details

Defined in Flight.Types

Associated Types

type Rep Seconds :: * -> * #

Methods

from :: Seconds -> Rep Seconds x #

to :: Rep Seconds x -> Seconds #

ToJSON Seconds Source # 
Instance details

Defined in Flight.Types

FromJSON Seconds Source # 
Instance details

Defined in Flight.Types

DefaultDecimalPlaces Seconds Source # 
Instance details

Defined in Flight.Types

type Rep Seconds Source # 
Instance details

Defined in Flight.Types

type Rep Seconds = D1 (MetaData "Seconds" "Flight.Types" "flight-kml-1.0.0-EmlCX9TRxkFGW009dRTfgq" True) (C1 (MetaCons "Seconds" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Integer)))

newtype Latitude Source #

Latitude in degress.

Constructors

Latitude Rational 
Instances
Eq Latitude Source # 
Instance details

Defined in Flight.Types

Show Latitude Source # 
Instance details

Defined in Flight.Types

Generic Latitude Source # 
Instance details

Defined in Flight.Types

Associated Types

type Rep Latitude :: * -> * #

Methods

from :: Latitude -> Rep Latitude x #

to :: Rep Latitude x -> Latitude #

ToJSON Latitude Source # 
Instance details

Defined in Flight.Types

FromJSON Latitude Source # 
Instance details

Defined in Flight.Types

DefaultDecimalPlaces Latitude Source # 
Instance details

Defined in Flight.Types

type Rep Latitude Source # 
Instance details

Defined in Flight.Types

type Rep Latitude = D1 (MetaData "Latitude" "Flight.Types" "flight-kml-1.0.0-EmlCX9TRxkFGW009dRTfgq" True) (C1 (MetaCons "Latitude" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Rational)))

newtype Longitude Source #

Longitude in degress.

Constructors

Longitude Rational 
Instances
Eq Longitude Source # 
Instance details

Defined in Flight.Types

Show Longitude Source # 
Instance details

Defined in Flight.Types

Generic Longitude Source # 
Instance details

Defined in Flight.Types

Associated Types

type Rep Longitude :: * -> * #

ToJSON Longitude Source # 
Instance details

Defined in Flight.Types

FromJSON Longitude Source # 
Instance details

Defined in Flight.Types

DefaultDecimalPlaces Longitude Source # 
Instance details

Defined in Flight.Types

type Rep Longitude Source # 
Instance details

Defined in Flight.Types

type Rep Longitude = D1 (MetaData "Longitude" "Flight.Types" "flight-kml-1.0.0-EmlCX9TRxkFGW009dRTfgq" True) (C1 (MetaCons "Longitude" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Rational)))

newtype Altitude Source #

Altitude in metres.

Constructors

Altitude Integer 
Instances
Eq Altitude Source # 
Instance details

Defined in Flight.Types

Num Altitude Source # 
Instance details

Defined in Flight.Types

Ord Altitude Source # 
Instance details

Defined in Flight.Types

Show Altitude Source # 
Instance details

Defined in Flight.Types

Generic Altitude Source # 
Instance details

Defined in Flight.Types

Associated Types

type Rep Altitude :: * -> * #

Methods

from :: Altitude -> Rep Altitude x #

to :: Rep Altitude x -> Altitude #

ToJSON Altitude Source # 
Instance details

Defined in Flight.Types

FromJSON Altitude Source # 
Instance details

Defined in Flight.Types

DefaultDecimalPlaces Altitude Source # 
Instance details

Defined in Flight.Types

type Rep Altitude Source # 
Instance details

Defined in Flight.Types

type Rep Altitude = D1 (MetaData "Altitude" "Flight.Types" "flight-kml-1.0.0-EmlCX9TRxkFGW009dRTfgq" True) (C1 (MetaCons "Altitude" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Integer)))

Typeclasses

class LatLngAlt a where Source #

Class for a fix made up of latitude, longitude and GPS altitude.

Minimal complete definition

lat, lng, altGps

Methods

lat :: a -> Latitude Source #

lng :: a -> Longitude Source #

altGps :: a -> Altitude Source #

Instances
LatLngAlt Fix Source # 
Instance details

Defined in Flight.Types

LatLngAlt LLA Source # 
Instance details

Defined in Flight.Types

class LatLngAlt a => FixMark a where Source #

Class for a tracklog relative fix, offset in seconds, with an optional barometric pressure altitude.

Minimal complete definition

mark, altBaro

Methods

mark :: a -> Seconds Source #

Seconds offset from first fix.

altBaro :: a -> Maybe Altitude Source #

Barometric pressure altitude.

Instances
FixMark Fix Source # 
Instance details

Defined in Flight.Types

Tracklog as a list of marked fixes

data LLA Source #

Latitude, longitude and GPS altitude. Use mkPosition to construct a LLA.

Constructors

LLA 
Instances
Eq LLA Source # 
Instance details

Defined in Flight.Types

Methods

(==) :: LLA -> LLA -> Bool #

(/=) :: LLA -> LLA -> Bool #

Show LLA Source # 
Instance details

Defined in Flight.Types

Methods

showsPrec :: Int -> LLA -> ShowS #

show :: LLA -> String #

showList :: [LLA] -> ShowS #

Generic LLA Source # 
Instance details

Defined in Flight.Types

Associated Types

type Rep LLA :: * -> * #

Methods

from :: LLA -> Rep LLA x #

to :: Rep LLA x -> LLA #

ToJSON LLA Source # 
Instance details

Defined in Flight.Types

FromJSON LLA Source # 
Instance details

Defined in Flight.Types

LatLngAlt LLA Source # 
Instance details

Defined in Flight.Types

type Rep LLA Source # 
Instance details

Defined in Flight.Types

mkPosition :: (Latitude, Longitude, Altitude) -> LLA Source #

Constructs a LLA from its parts.

>>> mkPosition (Latitude (-33.65073300), Longitude 147.56036700, Altitude 214)
LLA {llaLat = -33.65073300°, llaLng = 147.56036700°, llaAltGps = 214m}

data Fix Source #

Latitude, longitude and GPS altitude with a relative time offset in seconds and possibly a barometric pressure altitude.

Constructors

Fix 

Fields

Instances
Eq Fix Source # 
Instance details

Defined in Flight.Types

Methods

(==) :: Fix -> Fix -> Bool #

(/=) :: Fix -> Fix -> Bool #

Show Fix Source # 
Instance details

Defined in Flight.Types

Methods

showsPrec :: Int -> Fix -> ShowS #

show :: Fix -> String #

showList :: [Fix] -> ShowS #

Generic Fix Source # 
Instance details

Defined in Flight.Types

Associated Types

type Rep Fix :: * -> * #

Methods

from :: Fix -> Rep Fix x #

to :: Rep Fix x -> Fix #

ToJSON Fix Source # 
Instance details

Defined in Flight.Types

FromJSON Fix Source # 
Instance details

Defined in Flight.Types

FixMark Fix Source # 
Instance details

Defined in Flight.Types

LatLngAlt Fix Source # 
Instance details

Defined in Flight.Types

type Rep Fix Source # 
Instance details

Defined in Flight.Types

data MarkedFixes Source #

A tracklog is a list of fixes along with the UTC time of the first fix.

Constructors

MarkedFixes 

Fields

Instances
Eq MarkedFixes Source # 
Instance details

Defined in Flight.Types

Show MarkedFixes Source # 
Instance details

Defined in Flight.Types

Generic MarkedFixes Source # 
Instance details

Defined in Flight.Types

Associated Types

type Rep MarkedFixes :: * -> * #

ToJSON MarkedFixes Source # 
Instance details

Defined in Flight.Types

FromJSON MarkedFixes Source # 
Instance details

Defined in Flight.Types

type Rep MarkedFixes Source # 
Instance details

Defined in Flight.Types

type Rep MarkedFixes = D1 (MetaData "MarkedFixes" "Flight.Types" "flight-kml-1.0.0-EmlCX9TRxkFGW009dRTfgq" False) (C1 (MetaCons "MarkedFixes" PrefixI True) (S1 (MetaSel (Just "mark0") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 UTCTime) :*: S1 (MetaSel (Just "fixes") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Fix])))

Parsing

parse :: String -> IO (Either String MarkedFixes) Source #

Parse the tracklog from the KML string as MarkedFixes.

>>> Right MarkedFixes{mark0, fixes} <- parse kml
>>> mark0
2012-01-14 02:12:55 UTC
>>> length fixes
6547
>>> head fixes
Fix {fixMark = 0s, fix = LLA {llaLat = -33.36160000°, llaLng = 147.93205000°, llaAltGps = 237m}, fixAltBaro = Just 239m}
>>> last fixes
Fix {fixMark = 13103s, fix = LLA {llaLat = -33.65073300°, llaLng = 147.56036700°, llaAltGps = 214m}, fixAltBaro = Just 238m}

GPSDump KML

Here's an example of a tracklog dump from the last day of the Hang Gliding Pre-Worlds Forbes 2012. The flight instrument is a Flytec 6030. The pilot with CIVL ID 21437 is me, the author of this package, Phil de Joux.

<?xml version="1.0" encoding="UTF-8"?>
<Document>
<open>1</open>
  <Folder>
    <Metadata src="GpsDump" v="4.66" type="trip"/>
    <open>1</open>
    <name>Trip</name>
    <description><![CDATA[Tracklog from GpsDump competition mode
<pre>
Flight statistics
Date                 2012-01-14
Start/finish         02:12:55 - 05:51:18
Duration             3 : 38 : 23
Max.min. height     2392  214 m
Max. meantop speed  72 kmh  82 kmh
Maxmin climb rate   4.35  -4.23 m/s over 60s
Total distance       166.89 km
</pre>]]>
    </description>
...
    <Placemark>
      <Metadata src="GpsDump" v="4.66" type="track">
        <FsInfo time_of_first_point="2012-01-14T02:12:55Z"
                civl_pilot_id="21437" comp_pilot_id="40"
                instrument="6030 SN06451 SW3.30"
                downloaded="2012-01-14T08:22:21Z"
                hash="61168B84FE0DAC55F3D65EFBA888B08F72834DDF">
          <SecondsFromTimeOfFirstPoint>
0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48
...
13061 13063 13065 13067 13069 13071 13073 13075 13077 13079 13081 13083 13085 13087 13089 13091 13093 13095 13097 13099 13101 13103
          </SecondsFromTimeOfFirstPoint>
          <PressureAltitude>
239 240 240 239 239 239 239 239 239 240 239 240 239 239 240 239 240 240 240 240 239 239 240 240 240 
...
237 237 237 237 237 237 237 238 238 237 238 237 237 238 237 237 238 238 237 238 237 238
          </PressureAltitude>
        </FsInfo>
      </Metadata>
      <name>Tracklog</name>
      <LineString>
        <altitudeMode>absolute</altitudeMode>
        <coordinates>
147.932050,-33.361600,237 147.932050,-33.361600,238 147.932050,-33.361600,238 147.932050,-33.361600,238 147.932067,-33.361600,238 
...
147.560367,-33.650733,215 147.560367,-33.650733,215 147.560367,-33.650733,214 147.560367,-33.650733,214 147.560367,-33.650733,214 
147.560367,-33.650733,214 147.560367,-33.650733,214
        </coordinates>
      </LineString>
    </Placemark>
  </Folder>
</Document>