diff --git a/coverage.txt b/coverage.txt index 1641d6f..b6434a1 100644 --- a/coverage.txt +++ b/coverage.txt @@ -1,6 +1,45 @@ mode: atomic -github.com/observerly/dusk/pkg/dusk/epoch.go:31.56,33.2 1 6 -github.com/observerly/dusk/pkg/dusk/epoch.go:41.48,46.2 2 116990 +github.com/observerly/dusk/pkg/dusk/lawrence.go:15.59,24.12 3 3 +github.com/observerly/dusk/pkg/dusk/lawrence.go:28.2,28.11 1 3 +github.com/observerly/dusk/pkg/dusk/lawrence.go:24.12,26.3 1 0 +github.com/observerly/dusk/pkg/dusk/lawrence.go:37.62,50.11 5 12991 +github.com/observerly/dusk/pkg/dusk/lawrence.go:54.2,54.10 1 12991 +github.com/observerly/dusk/pkg/dusk/lawrence.go:50.11,52.3 1 12991 +github.com/observerly/dusk/pkg/dusk/lawrence.go:64.78,80.11 7 12980 +github.com/observerly/dusk/pkg/dusk/lawrence.go:85.2,92.3 3 12980 +github.com/observerly/dusk/pkg/dusk/lawrence.go:80.11,82.3 1 4328 +github.com/observerly/dusk/pkg/dusk/lawrence.go:101.82,111.12 5 0 +github.com/observerly/dusk/pkg/dusk/lawrence.go:116.2,121.3 2 0 +github.com/observerly/dusk/pkg/dusk/lawrence.go:111.12,113.3 1 0 +github.com/observerly/dusk/pkg/dusk/lawrence.go:130.62,144.2 5 25984 +github.com/observerly/dusk/pkg/dusk/lawrence.go:152.58,160.2 3 12996 +github.com/observerly/dusk/pkg/dusk/lawrence.go:170.70,178.14 3 12995 +github.com/observerly/dusk/pkg/dusk/lawrence.go:182.2,182.11 1 12995 +github.com/observerly/dusk/pkg/dusk/lawrence.go:178.14,180.3 1 0 +github.com/observerly/dusk/pkg/dusk/trigonometry.go:10.30,12.2 1 273696 +github.com/observerly/dusk/pkg/dusk/trigonometry.go:14.30,16.2 1 194894 +github.com/observerly/dusk/pkg/dusk/trigonometry.go:18.44,20.2 1 541 +github.com/observerly/dusk/pkg/dusk/trigonometry.go:22.30,24.2 1 13037 +github.com/observerly/dusk/pkg/dusk/trigonometry.go:26.31,28.2 1 38984 +github.com/observerly/dusk/pkg/dusk/trigonometry.go:30.31,32.2 1 13022 +github.com/observerly/dusk/pkg/dusk/trigonometry.go:34.31,36.2 1 1 +github.com/observerly/dusk/pkg/dusk/trigonometry.go:38.36,40.2 1 25976 +github.com/observerly/dusk/pkg/dusk/utils.go:15.34,17.2 1 7 +github.com/observerly/dusk/pkg/dusk/utils.go:26.55,31.12 2 12986 +github.com/observerly/dusk/pkg/dusk/utils.go:35.2,35.11 1 12986 +github.com/observerly/dusk/pkg/dusk/utils.go:31.12,33.3 1 0 +github.com/observerly/dusk/pkg/dusk/utils.go:47.84,49.2 1 4 +github.com/observerly/dusk/pkg/dusk/utils.go:60.84,62.2 1 12986 +github.com/observerly/dusk/pkg/dusk/utils.go:72.85,74.2 1 9 +github.com/observerly/dusk/pkg/dusk/utils.go:83.57,85.2 1 2 +github.com/observerly/dusk/pkg/dusk/utils.go:93.51,95.2 1 3 +github.com/observerly/dusk/pkg/dusk/utils.go:103.52,106.2 2 1 +github.com/observerly/dusk/pkg/dusk/astrometry.go:14.52,18.12 2 12985 +github.com/observerly/dusk/pkg/dusk/astrometry.go:22.2,22.11 1 12985 +github.com/observerly/dusk/pkg/dusk/astrometry.go:18.12,20.3 1 1795 +github.com/observerly/dusk/pkg/dusk/astrometry.go:34.73,42.2 4 4 +github.com/observerly/dusk/pkg/dusk/epoch.go:31.56,33.2 1 10 +github.com/observerly/dusk/pkg/dusk/epoch.go:41.48,46.2 2 116998 github.com/observerly/dusk/pkg/dusk/epoch.go:53.45,55.2 1 79 github.com/observerly/dusk/pkg/dusk/epoch.go:63.60,93.13 15 12988 github.com/observerly/dusk/pkg/dusk/epoch.go:97.2,97.12 1 12988 @@ -19,14 +58,14 @@ github.com/observerly/dusk/pkg/dusk/epoch.go:226.77,248.12 10 3 github.com/observerly/dusk/pkg/dusk/epoch.go:252.2,252.11 1 3 github.com/observerly/dusk/pkg/dusk/epoch.go:248.12,250.3 1 0 github.com/observerly/dusk/pkg/dusk/epoch.go:262.70,267.2 2 34 -github.com/observerly/dusk/pkg/dusk/epoch.go:276.95,280.13 2 5 -github.com/observerly/dusk/pkg/dusk/epoch.go:284.2,284.12 1 5 +github.com/observerly/dusk/pkg/dusk/epoch.go:276.95,280.13 2 9 +github.com/observerly/dusk/pkg/dusk/epoch.go:284.2,284.12 1 9 github.com/observerly/dusk/pkg/dusk/epoch.go:280.13,282.3 1 0 -github.com/observerly/dusk/pkg/dusk/epoch.go:294.92,312.12 9 5 -github.com/observerly/dusk/pkg/dusk/epoch.go:317.2,317.13 1 5 -github.com/observerly/dusk/pkg/dusk/epoch.go:321.2,324.11 2 5 -github.com/observerly/dusk/pkg/dusk/epoch.go:328.2,328.21 1 5 -github.com/observerly/dusk/pkg/dusk/epoch.go:312.12,314.3 1 5 +github.com/observerly/dusk/pkg/dusk/epoch.go:294.92,312.12 9 9 +github.com/observerly/dusk/pkg/dusk/epoch.go:317.2,317.13 1 9 +github.com/observerly/dusk/pkg/dusk/epoch.go:321.2,324.11 2 9 +github.com/observerly/dusk/pkg/dusk/epoch.go:328.2,328.21 1 9 +github.com/observerly/dusk/pkg/dusk/epoch.go:312.12,314.3 1 9 github.com/observerly/dusk/pkg/dusk/epoch.go:317.13,319.3 1 0 github.com/observerly/dusk/pkg/dusk/epoch.go:324.11,326.3 1 1 github.com/observerly/dusk/pkg/dusk/lunar.go:32.47,37.11 2 13006 @@ -107,48 +146,6 @@ github.com/observerly/dusk/pkg/dusk/lunar.go:855.30,857.4 1 4 github.com/observerly/dusk/pkg/dusk/lunar.go:874.106,877.16 2 2 github.com/observerly/dusk/pkg/dusk/lunar.go:881.2,884.8 1 2 github.com/observerly/dusk/pkg/dusk/lunar.go:877.16,879.3 1 0 -github.com/observerly/dusk/pkg/dusk/transit.go:22.77,30.2 3 9 -github.com/observerly/dusk/pkg/dusk/transit.go:41.129,42.43 1 3 -github.com/observerly/dusk/pkg/dusk/transit.go:51.2,74.3 9 2 -github.com/observerly/dusk/pkg/dusk/transit.go:42.43,48.3 1 1 -github.com/observerly/dusk/pkg/dusk/transit.go:86.134,87.43 1 2 -github.com/observerly/dusk/pkg/dusk/transit.go:95.2,100.16 3 1 -github.com/observerly/dusk/pkg/dusk/transit.go:104.2,114.8 4 1 -github.com/observerly/dusk/pkg/dusk/transit.go:87.43,92.3 1 1 -github.com/observerly/dusk/pkg/dusk/transit.go:100.16,102.3 1 0 -github.com/observerly/dusk/pkg/dusk/utils.go:15.34,17.2 1 7 -github.com/observerly/dusk/pkg/dusk/utils.go:26.55,31.12 2 12986 -github.com/observerly/dusk/pkg/dusk/utils.go:35.2,35.11 1 12986 -github.com/observerly/dusk/pkg/dusk/utils.go:31.12,33.3 1 0 -github.com/observerly/dusk/pkg/dusk/utils.go:47.84,49.2 1 4 -github.com/observerly/dusk/pkg/dusk/utils.go:60.84,62.2 1 12986 -github.com/observerly/dusk/pkg/dusk/utils.go:72.85,74.2 1 5 -github.com/observerly/dusk/pkg/dusk/utils.go:83.57,85.2 1 2 -github.com/observerly/dusk/pkg/dusk/utils.go:93.51,95.2 1 3 -github.com/observerly/dusk/pkg/dusk/utils.go:100.52,103.2 2 1 -github.com/observerly/dusk/pkg/dusk/astrometry.go:14.52,18.12 2 12985 -github.com/observerly/dusk/pkg/dusk/astrometry.go:22.2,22.11 1 12985 -github.com/observerly/dusk/pkg/dusk/astrometry.go:18.12,20.3 1 1795 -github.com/observerly/dusk/pkg/dusk/astrometry.go:34.73,42.2 4 4 -github.com/observerly/dusk/pkg/dusk/coordinates.go:101.108,124.2 10 12982 -github.com/observerly/dusk/pkg/dusk/coordinates.go:136.149,151.2 6 12983 -github.com/observerly/dusk/pkg/dusk/lawrence.go:15.59,24.12 3 3 -github.com/observerly/dusk/pkg/dusk/lawrence.go:28.2,28.11 1 3 -github.com/observerly/dusk/pkg/dusk/lawrence.go:24.12,26.3 1 0 -github.com/observerly/dusk/pkg/dusk/lawrence.go:37.62,50.11 5 12991 -github.com/observerly/dusk/pkg/dusk/lawrence.go:54.2,54.10 1 12991 -github.com/observerly/dusk/pkg/dusk/lawrence.go:50.11,52.3 1 12991 -github.com/observerly/dusk/pkg/dusk/lawrence.go:64.78,80.11 7 12980 -github.com/observerly/dusk/pkg/dusk/lawrence.go:85.2,92.3 3 12980 -github.com/observerly/dusk/pkg/dusk/lawrence.go:80.11,82.3 1 4328 -github.com/observerly/dusk/pkg/dusk/lawrence.go:101.82,111.12 5 0 -github.com/observerly/dusk/pkg/dusk/lawrence.go:116.2,121.3 2 0 -github.com/observerly/dusk/pkg/dusk/lawrence.go:111.12,113.3 1 0 -github.com/observerly/dusk/pkg/dusk/lawrence.go:130.62,144.2 5 25984 -github.com/observerly/dusk/pkg/dusk/lawrence.go:152.58,160.2 3 12996 -github.com/observerly/dusk/pkg/dusk/lawrence.go:170.70,178.14 3 12995 -github.com/observerly/dusk/pkg/dusk/lawrence.go:182.2,182.11 1 12995 -github.com/observerly/dusk/pkg/dusk/lawrence.go:178.14,180.3 1 0 github.com/observerly/dusk/pkg/dusk/solar.go:23.45,26.2 1 42 github.com/observerly/dusk/pkg/dusk/solar.go:35.50,38.2 1 32 github.com/observerly/dusk/pkg/dusk/solar.go:47.62,50.2 1 31 @@ -166,17 +163,25 @@ github.com/observerly/dusk/pkg/dusk/solar.go:189.70,200.2 4 4 github.com/observerly/dusk/pkg/dusk/solar.go:208.74,222.12 6 2 github.com/observerly/dusk/pkg/dusk/solar.go:226.2,229.3 1 2 github.com/observerly/dusk/pkg/dusk/solar.go:222.12,224.3 1 2 -github.com/observerly/dusk/pkg/dusk/trigonometry.go:10.30,12.2 1 273692 -github.com/observerly/dusk/pkg/dusk/trigonometry.go:14.30,16.2 1 194890 -github.com/observerly/dusk/pkg/dusk/trigonometry.go:18.44,20.2 1 541 -github.com/observerly/dusk/pkg/dusk/trigonometry.go:22.30,24.2 1 13021 -github.com/observerly/dusk/pkg/dusk/trigonometry.go:26.31,28.2 1 38984 -github.com/observerly/dusk/pkg/dusk/trigonometry.go:30.31,32.2 1 13018 -github.com/observerly/dusk/pkg/dusk/trigonometry.go:34.31,36.2 1 1 -github.com/observerly/dusk/pkg/dusk/trigonometry.go:38.36,40.2 1 25976 +github.com/observerly/dusk/pkg/dusk/transit.go:22.77,30.2 3 13 +github.com/observerly/dusk/pkg/dusk/transit.go:41.135,42.43 1 4 +github.com/observerly/dusk/pkg/dusk/transit.go:51.2,74.3 9 4 +github.com/observerly/dusk/pkg/dusk/transit.go:42.43,48.3 1 0 +github.com/observerly/dusk/pkg/dusk/transit.go:86.129,87.43 1 3 +github.com/observerly/dusk/pkg/dusk/transit.go:95.2,98.62 2 2 +github.com/observerly/dusk/pkg/dusk/transit.go:103.2,107.3 1 2 +github.com/observerly/dusk/pkg/dusk/transit.go:87.43,93.3 1 1 +github.com/observerly/dusk/pkg/dusk/transit.go:98.62,101.3 2 2 +github.com/observerly/dusk/pkg/dusk/transit.go:119.134,120.43 1 2 +github.com/observerly/dusk/pkg/dusk/transit.go:128.2,133.16 3 1 +github.com/observerly/dusk/pkg/dusk/transit.go:137.2,147.8 4 1 +github.com/observerly/dusk/pkg/dusk/transit.go:120.43,125.3 1 1 +github.com/observerly/dusk/pkg/dusk/transit.go:133.16,135.3 1 0 github.com/observerly/dusk/pkg/dusk/twilight.go:38.163,49.16 5 9 github.com/observerly/dusk/pkg/dusk/twilight.go:53.2,57.18 1 9 github.com/observerly/dusk/pkg/dusk/twilight.go:49.16,51.3 1 0 github.com/observerly/dusk/pkg/dusk/twilight.go:69.139,74.2 2 3 github.com/observerly/dusk/pkg/dusk/twilight.go:85.142,90.2 2 3 github.com/observerly/dusk/pkg/dusk/twilight.go:101.146,106.2 2 3 +github.com/observerly/dusk/pkg/dusk/coordinates.go:101.108,124.2 10 12982 +github.com/observerly/dusk/pkg/dusk/coordinates.go:136.149,151.2 6 12983 diff --git a/pkg/dusk/transit.go b/pkg/dusk/transit.go index 1071dec..a1e8dc2 100644 --- a/pkg/dusk/transit.go +++ b/pkg/dusk/transit.go @@ -30,7 +30,7 @@ func GetDoesObjectRiseOrSet(eq EquatorialCoordinate, latitude float64) bool { } /* - GetObjectRiseObjectSetTimesInUTC() + GetObjectRiseObjectSetTimesInUTCForDay() @param datetime - the time to calculate the rise and set times for @param eq - the EquatorialCoordinate{} of the object to calculate the rise and set times for @@ -38,7 +38,7 @@ func GetDoesObjectRiseOrSet(eq EquatorialCoordinate, latitude float64) bool { @param longitude - the longitude of the observer @returns a Transit struct which contains the rise and set times of the object in UTC */ -func GetObjectRiseObjectSetTimesInUTC(datetime time.Time, eq EquatorialCoordinate, latitude float64, longitude float64) Transit { +func GetObjectRiseObjectSetTimesInUTCForDay(datetime time.Time, eq EquatorialCoordinate, latitude float64, longitude float64) Transit { if !GetDoesObjectRiseOrSet(eq, latitude) { return Transit{ Rise: nil, @@ -74,6 +74,39 @@ func GetObjectRiseObjectSetTimesInUTC(datetime time.Time, eq EquatorialCoordinat } } +/* + GetObjectRiseObjectSetTimesInUTC() + + @param datetime - the time to calculate the rise and set times for + @param eq - the EquatorialCoordinate{} of the object to calculate the rise and set times for + @param latitude - the latitude of the observer + @param longitude - the longitude of the observer + @returns a Transit struct which contains the rise and set times of the object in UTC +*/ +func GetObjectRiseObjectSetTimesInUTC(datetime time.Time, eq EquatorialCoordinate, latitude float64, longitude float64) Transit { + if !GetDoesObjectRiseOrSet(eq, latitude) { + return Transit{ + Rise: nil, + Set: nil, + Duration: 0, + } + } + + transit := GetObjectRiseObjectSetTimesInUTCForDay(datetime, eq, latitude, longitude) + + // We need to ensure that if the transit rise is before the transit set, + if transit.Rise != nil && transit.Set.Before(*transit.Rise) { + tomorrow := GetObjectRiseObjectSetTimesInUTCForDay(datetime.Add(time.Hour*24), eq, latitude, longitude) + transit.Set = tomorrow.Set + } + + return Transit{ + Rise: transit.Rise, + Set: transit.Set, + Duration: transit.Rise.Sub(*transit.Set), + } +} + /* GetObjectRiseObjectSetTimes() diff --git a/pkg/dusk/transit_test.go b/pkg/dusk/transit_test.go index ef9d348..7ccb80e 100644 --- a/pkg/dusk/transit_test.go +++ b/pkg/dusk/transit_test.go @@ -66,7 +66,7 @@ func TestGetObjectRiseObjectSetTimesInUTCLawrenceChapter5Exercise2(t *testing.T) var rise = time.Date(2015, 6, 6, 20, 57, 48, 562000000, time.UTC) - var set = time.Date(2015, 6, 6, 11, 59, 51, 410000000, time.UTC) + var set = time.Date(2015, 6, 7, 11, 55, 55, 501000000, time.UTC) if got.Rise.String() != rise.String() { t.Errorf("got %v, wanted %v", *got.Rise, rise) @@ -108,7 +108,11 @@ func TestGetObjectRiseObjectSetTimesChapter5Exercise2(t *testing.T) { var rise = time.Date(2015, 6, 6, 16, 57, 48, 562000000, timezone) - var set = time.Date(2015, 6, 6, 7, 59, 51, 410000000, timezone) + var set = time.Date(2015, 6, 7, 7, 55, 55, 501000000, timezone) + + if rise.After(set) { + t.Errorf("the object must rise before it sets") + } if got.Rise.String() != rise.String() { t.Errorf("got %v, wanted %v", *got.Rise, rise)