Skip to content

Commit

Permalink
Move module Track.Range to flight-clip, add modlue Igc.Fix, #249.
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Mar 15, 2019
1 parent 20192da commit b358cb4
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 46 deletions.
5 changes: 4 additions & 1 deletion build/library/Cmd.hs
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions build/library/Pkg.hs
Expand Up @@ -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")
Expand Down
25 changes: 23 additions & 2 deletions clip/flight-clip.cabal
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -33,6 +33,7 @@ source-repository head
library
exposed-modules:
Flight.Clip
Flight.Track.Range
other-modules:
Paths_flight_clip
hs-source-dirs:
Expand All @@ -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
File renamed without changes.
19 changes: 15 additions & 4 deletions clip/package.dhall
Expand Up @@ -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" ]
}
}
}
12 changes: 12 additions & 0 deletions 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
5 changes: 1 addition & 4 deletions comp/flight-comp.cabal
Expand Up @@ -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
Expand Down Expand Up @@ -44,7 +44,6 @@ library
Flight.Track.Arrival
Flight.Track.Lead
Flight.Track.Distance
Flight.Track.Range
other-modules:
Flight.Path
Flight.Pilot
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion comp/package.dhall
Expand Up @@ -60,7 +60,6 @@ in defs
, "Flight.Track.Arrival"
, "Flight.Track.Lead"
, "Flight.Track.Distance"
, "Flight.Track.Range"
]
}
, tests =
Expand Down
1 change: 0 additions & 1 deletion comp/test-suite-doctest/DocTest.hs
Expand Up @@ -5,7 +5,6 @@ import Test.DocTest (doctest)
arguments :: [String]
arguments =
[ "-isrc"
, "library/Flight/Track/Range.hs"
, "library/Flight/Track/Place.hs"
]

Expand Down
6 changes: 5 additions & 1 deletion igc/flight-igc.cabal
Expand Up @@ -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
Expand Down Expand Up @@ -38,6 +38,7 @@ library
exposed-modules:
Flight.Igc
other-modules:
Flight.Igc.Fix
Flight.Igc.Parse
Flight.Igc.Record
Paths_flight_igc
Expand All @@ -48,6 +49,7 @@ library
build-depends:
base >=4.10.1.0 && <5
, bytestring
, flight-clip
, megaparsec
, utf8-string
default-language: Haskell2010
Expand All @@ -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
Expand All @@ -69,6 +72,7 @@ test-suite doctest
base >=4.10.1.0 && <5
, bytestring
, doctest
, flight-clip
, megaparsec
, utf8-string
default-language: Haskell2010
4 changes: 4 additions & 0 deletions igc/library/Flight/Igc.hs
Expand Up @@ -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
36 changes: 36 additions & 0 deletions 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
]

3 changes: 2 additions & 1 deletion igc/package.dhall
Expand Up @@ -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 =
Expand Down
34 changes: 3 additions & 31 deletions track/library/Flight/TrackLog.hs
Expand Up @@ -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(..)
Expand All @@ -53,7 +53,7 @@ import Flight.Comp
, TaskFolder(..)
, IxTask(..)
)
import Flight.Track.Range (asRollovers)
import Flight.Igc (igcEqOrEqOnTime, igcBumpOver)

ixTasks :: [IxTask]
ixTasks = IxTask <$> [ 1 .. ]
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit b358cb4

Please sign in to comment.