diff --git a/build/library/Cmd.hs b/build/library/Cmd.hs index a1e437fa6..73565f24e 100644 --- a/build/library/Cmd.hs +++ b/build/library/Cmd.hs @@ -112,9 +112,12 @@ docTestPkgs :: [Pkg] docTestPkgs = [ "detour-via-sci" , "detour-via-uom" + , "siggy-chardust" + , "flight-clip" , "flight-comp" , "flight-kml" - , "siggy-chardust" + , "flight-igc" + , "flight-track" ] -- | The names of the test app executables. diff --git a/build/library/Pkg.hs b/build/library/Pkg.hs index a6485b4fa..11caca191 100644 --- a/build/library/Pkg.hs +++ b/build/library/Pkg.hs @@ -27,6 +27,7 @@ dhallCabal = , ("detour-via-uom", "detour-via-uom") , ("build", "build-flare-timing") , ("cmd", "flight-cmd") + , ("clip", "flight-clip") , ("comp", "flight-comp") , ("earth", "flight-earth") , ("flare-timing", "flare-timing") diff --git a/clip/flight-clip.cabal b/clip/flight-clip.cabal index 8534868ce..6ba9bb131 100644 --- a/clip/flight-clip.cabal +++ b/clip/flight-clip.cabal @@ -4,7 +4,7 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: 98b4436612a14203211e87cf0ae7b726d38aec855817c078eeedba6e520b372c +-- hash: 0aa3327ce5795dd195dc0dd48a939da8e440e0f0e2b27ba0bfbf4f6fce55e802 name: flight-clip version: 1.1.0 @@ -15,7 +15,7 @@ homepage: https://github.com/blockscope/flare-timing/tree/master/clip#read bug-reports: https://github.com/blockscope/flare-timing/issues author: Phil de Joux maintainer: phil.dejoux@blockscope.com -copyright: © 2017-2018 Phil de Joux, © 2017-2018 Block Scope Limited +copyright: © 2017-2019 Phil de Joux, © 2017-2019 Block Scope Limited license: MPL-2.0 license-file: LICENSE.md tested-with: GHC == 8.2.2 @@ -33,6 +33,7 @@ source-repository head library exposed-modules: Flight.Clip + Flight.Track.Range other-modules: Paths_flight_clip hs-source-dirs: @@ -41,5 +42,25 @@ library ghc-options: -Wall -Werror build-depends: base >=4.10.1.0 && <5 + , split + , time + default-language: Haskell2010 + +test-suite doctest + type: exitcode-stdio-1.0 + main-is: DocTest.hs + other-modules: + Flight.Clip + Flight.Track.Range + Paths_flight_clip + hs-source-dirs: + library + test-suite-doctest + default-extensions: DataKinds DeriveFunctor DeriveGeneric DeriveAnyClass DerivingStrategies DisambiguateRecordFields FlexibleContexts FlexibleInstances GeneralizedNewtypeDeriving GADTs LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns OverloadedStrings PackageImports ParallelListComp PartialTypeSignatures PatternSynonyms QuasiQuotes RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving TemplateHaskell TypeApplications TypeFamilies TypeOperators TypeSynonymInstances TupleSections UndecidableInstances + ghc-options: -Wall -Werror -rtsopts -threaded -with-rtsopts=-N + build-depends: + base >=4.10.1.0 && <5 + , doctest + , split , time default-language: Haskell2010 diff --git a/comp/library/Flight/Track/Range.hs b/clip/library/Flight/Track/Range.hs similarity index 100% rename from comp/library/Flight/Track/Range.hs rename to clip/library/Flight/Track/Range.hs diff --git a/clip/package.dhall b/clip/package.dhall index a421a8fd0..45cd64c78 100644 --- a/clip/package.dhall +++ b/clip/package.dhall @@ -17,13 +17,24 @@ in defs , homepage = "https://github.com/blockscope/flare-timing/tree/master/clip#readme" , dependencies = - defs.dependencies - # [ "time" ] + defs.dependencies # [ "split", "time" ] , library = { source-dirs = "library" , exposed-modules = - [ "Flight.Clip" ] + [ "Flight.Clip", "Flight.Track.Range" ] } - , tests = ./../default-tests.dhall + , tests = + ./../default-tests.dhall + ⫽ { doctest = + { dependencies = + [ "doctest" ] + , ghc-options = + [ "-rtsopts", "-threaded", "-with-rtsopts=-N" ] + , main = + "DocTest.hs" + , source-dirs = + [ "library", "test-suite-doctest" ] + } + } } diff --git a/clip/test-suite-doctest/DocTest.hs b/clip/test-suite-doctest/DocTest.hs new file mode 100644 index 000000000..a429a4f7d --- /dev/null +++ b/clip/test-suite-doctest/DocTest.hs @@ -0,0 +1,12 @@ +module Main (main) where + +import Test.DocTest (doctest) + +arguments :: [String] +arguments = + [ "-isrc" + , "library/Flight/Track/Range.hs" + ] + +main :: IO () +main = doctest arguments diff --git a/comp/flight-comp.cabal b/comp/flight-comp.cabal index 2785c2ee9..af7e2d720 100644 --- a/comp/flight-comp.cabal +++ b/comp/flight-comp.cabal @@ -4,7 +4,7 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: 12d01f3be25cdedc30b7ec0735e95ee621b846db052e51afc3c5365eda52bfcf +-- hash: 5b329991e69cbcc90c4d84310cc8b0515a58f61bc8867728a15003a942ec4868 name: flight-comp version: 0.1.0 @@ -44,7 +44,6 @@ library Flight.Track.Arrival Flight.Track.Lead Flight.Track.Distance - Flight.Track.Range other-modules: Flight.Path Flight.Pilot @@ -99,7 +98,6 @@ test-suite comp Flight.Track.Mask Flight.Track.Place Flight.Track.Point - Flight.Track.Range Flight.Track.Speed Flight.Track.Tag Flight.Track.Time @@ -160,7 +158,6 @@ test-suite doctest Flight.Track.Mask Flight.Track.Place Flight.Track.Point - Flight.Track.Range Flight.Track.Speed Flight.Track.Tag Flight.Track.Time diff --git a/comp/package.dhall b/comp/package.dhall index cdfbc734d..6bf3a07d3 100644 --- a/comp/package.dhall +++ b/comp/package.dhall @@ -60,7 +60,6 @@ in defs , "Flight.Track.Arrival" , "Flight.Track.Lead" , "Flight.Track.Distance" - , "Flight.Track.Range" ] } , tests = diff --git a/comp/test-suite-doctest/DocTest.hs b/comp/test-suite-doctest/DocTest.hs index 7d2fa28af..13d46c5b0 100644 --- a/comp/test-suite-doctest/DocTest.hs +++ b/comp/test-suite-doctest/DocTest.hs @@ -5,7 +5,6 @@ import Test.DocTest (doctest) arguments :: [String] arguments = [ "-isrc" - , "library/Flight/Track/Range.hs" , "library/Flight/Track/Place.hs" ] diff --git a/igc/flight-igc.cabal b/igc/flight-igc.cabal index 693d6c617..8cb000abe 100644 --- a/igc/flight-igc.cabal +++ b/igc/flight-igc.cabal @@ -4,7 +4,7 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: dbaae0f568b25d4943462b13086927fdfca114153881d79ce87adb1c9cfe88b4 +-- hash: 1666739a67ca5c70d5828e33f6acef6445288227159b70fc3229cb2401e986f1 name: flight-igc version: 2.0.0 @@ -38,6 +38,7 @@ library exposed-modules: Flight.Igc other-modules: + Flight.Igc.Fix Flight.Igc.Parse Flight.Igc.Record Paths_flight_igc @@ -48,6 +49,7 @@ library build-depends: base >=4.10.1.0 && <5 , bytestring + , flight-clip , megaparsec , utf8-string default-language: Haskell2010 @@ -57,6 +59,7 @@ test-suite doctest main-is: DocTest.hs other-modules: Flight.Igc + Flight.Igc.Fix Flight.Igc.Parse Flight.Igc.Record Paths_flight_igc @@ -69,6 +72,7 @@ test-suite doctest base >=4.10.1.0 && <5 , bytestring , doctest + , flight-clip , megaparsec , utf8-string default-language: Haskell2010 diff --git a/igc/library/Flight/Igc.hs b/igc/library/Flight/Igc.hs index db5fe1a2c..961d72280 100644 --- a/igc/library/Flight/Igc.hs +++ b/igc/library/Flight/Igc.hs @@ -37,7 +37,11 @@ module Flight.Igc -- * Record classification , isMark , isFix + -- * Fix Checking and Conversion + , igcEqOrEqOnTime + , igcBumpOver ) where import Flight.Igc.Record import Flight.Igc.Parse +import Flight.Igc.Fix diff --git a/igc/library/Flight/Igc/Fix.hs b/igc/library/Flight/Igc/Fix.hs new file mode 100644 index 000000000..1bc6f290e --- /dev/null +++ b/igc/library/Flight/Igc/Fix.hs @@ -0,0 +1,36 @@ +module Flight.Igc.Fix + ( igcEqOrEqOnTime + , igcBumpOver + ) where + +import Flight.Igc.Record +import Flight.Track.Range (asRollovers) + +igcEqOrEqOnTime :: IgcRecord -> IgcRecord -> Bool +igcEqOrEqOnTime (B t0 _ _ _ _) (B t1 _ _ _ _) = t0 == t1 +igcEqOrEqOnTime a b = a == b + +-- | The B record only records time of day. If the sequence is not increasing +-- then for every rollback add a bump 24 hrs. +-- +-- >>> asRollovers [7,9,2,3] +-- [[7,9],[2,3]] +igcBumpOver :: [IgcRecord] -> [IgcRecord] +igcBumpOver xs = + bumpOver + (flip $ addHoursIgc . Hour . show) + [0 :: Integer, 24..] + xs + +-- | Apply a bump from a list every time there is a roll over. +-- +-- >>> bumpOver (+) [0,10..] [7,9,2,3,1] +-- [7,9,12,13,21] +bumpOver :: Ord a => (a -> b -> a) -> [b] -> [a] -> [a] +bumpOver add ns xs = + concat + [ (`add` n) <$> ys + | ys <- asRollovers xs + | n <- ns + ] + diff --git a/igc/package.dhall b/igc/package.dhall index 1e3c88728..05612d4e8 100644 --- a/igc/package.dhall +++ b/igc/package.dhall @@ -17,7 +17,8 @@ in defs , extra-source-files = defs.extra-source-files # [ "**/*.igc" ] , dependencies = - defs.dependencies # [ "megaparsec", "bytestring", "utf8-string" ] + defs.dependencies + # [ "megaparsec", "bytestring", "flight-clip", "utf8-string" ] , library = { source-dirs = "library", exposed-modules = "Flight.Igc" } , tests = diff --git a/track/library/Flight/TrackLog.hs b/track/library/Flight/TrackLog.hs index a4e086669..b0b879018 100644 --- a/track/library/Flight/TrackLog.hs +++ b/track/library/Flight/TrackLog.hs @@ -43,7 +43,7 @@ import Flight.Igc , Year(..), Month(..), Day(..), Hour(..), HMS(..) , Lat(..), Lng(..), Altitude(..), AltGps(..), AltBaro(..) , IgcRecord(..) - , isMark, isFix, addHoursIgc + , isMark, isFix ) import Flight.Comp ( Pilot(..) @@ -53,7 +53,7 @@ import Flight.Comp , TaskFolder(..) , IxTask(..) ) -import Flight.Track.Range (asRollovers) +import Flight.Igc (igcEqOrEqOnTime, igcBumpOver) ixTasks :: [IxTask] ixTasks = IxTask <$> [ 1 .. ] @@ -176,34 +176,6 @@ makeAbsolute nullMarkedFixes :: K.MarkedFixes nullMarkedFixes = K.MarkedFixes (UTCTime (ModifiedJulianDay 0) 0) [] -igcEqOrEqOnTime :: IgcRecord -> IgcRecord -> Bool -igcEqOrEqOnTime (B t0 _ _ _ _) (B t1 _ _ _ _) = t0 == t1 -igcEqOrEqOnTime a b = a == b - --- | The B record only records time of day. If the sequence is not increasing --- then for every rollback add a bump 24 hrs. --- --- >>> asRollovers [7,9,2,3] --- [[7,9],[2,3]] -bumpOverIgc :: [Flight.Igc.IgcRecord] -> [Flight.Igc.IgcRecord] -bumpOverIgc xs = - bumpOver - (flip $ addHoursIgc . Hour . show) - [0 :: Integer, 24..] - xs - --- | Apply a bump from a list every time there is a roll over. --- --- >>> bumpOver (+) [0,10..] [7,9,2,3,1] --- [7,9,12,13,21] -bumpOver :: Ord a => (a -> b -> a) -> [b] -> [a] -> [a] -bumpOver add ns xs = - concat - [ (`add` n) <$> ys - | ys <- asRollovers xs - | n <- ns - ] - igcMarkedFixes :: [Flight.Igc.IgcRecord] -> K.MarkedFixes igcMarkedFixes xs = maybe nullMarkedFixes (`mark` zs) date @@ -214,7 +186,7 @@ igcMarkedFixes xs = . filter isMark $ xs - ys = bumpOverIgc $ filter isFix xs + ys = igcBumpOver $ filter isFix xs -- NOTE: Some loggers will be using sub-second logging. The columns in -- the B record holding the s or ss, tenths or hundredths of a second,