Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added GetObjectRiseObjectSetTimesInUTCForDay() to dusk module. #120

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 64 additions & 59 deletions coverage.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
37 changes: 35 additions & 2 deletions pkg/dusk/transit.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ 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
@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 {
func GetObjectRiseObjectSetTimesInUTCForDay(datetime time.Time, eq EquatorialCoordinate, latitude float64, longitude float64) Transit {
if !GetDoesObjectRiseOrSet(eq, latitude) {
return Transit{
Rise: nil,
Expand Down Expand Up @@ -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()

Expand Down
8 changes: 6 additions & 2 deletions pkg/dusk/transit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down