Skip to content

Commit

Permalink
docs: minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
klausbrunner committed Oct 21, 2023
1 parent b6b73af commit 4375cfe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Java 17 or newer. No additional runtime dependencies.

### Code

The API is intentionally "flat", comprising a handful of static methods and simple record classes.
The API is intentionally "flat", comprising a handful of static methods and simple records as results.
To get refraction-corrected topocentric coordinates:

```java
Expand All @@ -59,14 +59,21 @@ public class App {
}
```

The SPA class includes a method to calculate the times of sunrise, sun transit, and sunset in one fell swoop:
The SPA class includes methods to calculate the times of sunrise, sun transit, and sunset in one fell swoop. The actual
return type depends on the type of day (regular day, polar day, polar night).

```java
var result=SPA.calculateSunriseTransitSet(
dateTime,
70.978, // latitude
25.974, // longitude
69); // delta T

if(result instanceof SunriseResult.RegularDay regular) {
System.out.println(regular);
} else {
System.out.println("no sunrise or sunset today!");
}
```

Twilight start and end times can be obtained like sunrise and sunset, but assuming a different horizon:
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/net/e175/klaus/solarpositioning/SPA.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ private record AlphaDelta(double alpha, double delta) {}
* and Terrestrial Time), in seconds. See {@link JulianDate#JulianDate(ZonedDateTime, double)}
* and {@link DeltaT}.
* @throws IllegalArgumentException for nonsensical latitude/longitude
* @return An implementation of {@link SunriseResult} depending on the type of day.
*/
public static SunriseResult calculateSunriseTransitSet(
final ZonedDateTime day, final double latitude, final double longitude, final double deltaT) {
Expand All @@ -234,6 +235,7 @@ private record RiseSetParams(double nuDegrees, AlphaDelta[] alphaDeltas, double[
* @param horizon Horizon (basically, elevation angle) to use as the sunrise/sunset definition.
* This can be used to calculate twilight times.
* @throws IllegalArgumentException for nonsensical latitude/longitude
* @return An implementation of {@link SunriseResult} depending on the type of day.
*/
public static SunriseResult calculateSunriseTransitSet(
final ZonedDateTime day,
Expand Down Expand Up @@ -268,8 +270,8 @@ public static SunriseResult calculateSunriseTransitSet(
* and {@link DeltaT}.
* @param horizons Horizons (basically, elevation angles) to use as the sunrise/sunset definition.
* This can be used to calculate twilight times.
* @return A Map with one key-value pair for each unique horizon type and result. This map may or
* may not be mutable.
* @return A Map with one key-value pair for each unique horizon type and {@link SunriseResult}.
* This map may or may not be mutable.
* @throws IllegalArgumentException for nonsensical latitude/longitude
*/
public static Map<Horizon, SunriseResult> calculateSunriseTransitSet(
Expand Down

0 comments on commit 4375cfe

Please sign in to comment.