Skip to content

Commit f4c7ae7

Browse files
committed
fix: remove redundant parameter
from optimised split methods
1 parent d5be550 commit f4c7ae7

7 files changed

Lines changed: 85 additions & 52 deletions

File tree

.github/workflows/maven-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v5
1515
- name: Set up JDK
16-
uses: actions/setup-java@v4
16+
uses: actions/setup-java@v5
1717
with:
1818
java-version: '17'
1919
distribution: 'temurin'

.github/workflows/release-dry-run.yml

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,50 +21,88 @@ jobs:
2121
token: ${{ secrets.GITHUB_TOKEN }}
2222

2323
- name: Set up JDK 17
24-
uses: actions/setup-java@v4
24+
uses: actions/setup-java@v5
2525
with:
2626
java-version: '17'
2727
distribution: 'temurin'
2828
cache: maven
2929
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
3030
gpg-passphrase: GPG_PASSPHRASE
31-
32-
- name: Test version bump
31+
32+
- name: Configure Git
33+
run: |
34+
git config user.name "github-actions[bot]"
35+
git config user.email "github-actions[bot]@users.noreply.github.com"
36+
37+
- name: Set release version (dry-run)
3338
run: |
3439
echo "Current version: $(mvn -B help:evaluate -Dexpression=project.version -q -DforceStdout)"
3540
if [ -n "${{ github.event.inputs.version }}" ]; then
41+
echo "Would set version to ${{ github.event.inputs.version }}"
3642
mvn -B versions:set -DnewVersion=${{ github.event.inputs.version }}
37-
echo "Would set version to: ${{ github.event.inputs.version }}"
43+
echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
3844
else
39-
mvn -B build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}
40-
echo "Would bump to: $(mvn -B help:evaluate -Dexpression=project.version -q -DforceStdout)"
45+
echo "Would remove -SNAPSHOT suffix for release"
46+
mvn -B versions:set -DremoveSnapshot=true
47+
RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
48+
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
49+
echo "Would release version: $RELEASE_VERSION"
4150
fi
4251
mvn -B versions:commit
43-
44-
- name: Test build and verify
52+
53+
- name: Commit release version (dry-run)
54+
run: |
55+
git add pom.xml
56+
git commit -m "release: prepare release v${{ env.RELEASE_VERSION }}"
57+
echo "Committed release version locally (not pushed)"
58+
59+
- name: Build and verify
4560
run: mvn -B clean verify
46-
47-
- name: Test full release process (dry-run)
61+
62+
- name: Stage artifacts
4863
run: |
49-
echo "Staging artifacts..."
5064
mkdir -p target/staging-deploy
5165
mvn -B deploy -DaltDeploymentRepository=local::file:./target/staging-deploy -DskipTests
52-
echo "Testing full JReleaser release process..."
53-
mvn -B jreleaser:full-release
66+
67+
- name: Test full release process (dry-run)
68+
run: mvn -B jreleaser:full-release
5469
env:
5570
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5671
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
5772
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
5873
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
5974
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
6075
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.SONATYPE_TOKEN }}
76+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
6177
JRELEASER_DRY_RUN: true
6278

6379
- name: Show what would be released
6480
run: |
81+
echo "=== Release Summary ==="
82+
echo "Release version: ${{ env.RELEASE_VERSION }}"
83+
echo ""
6584
echo "=== Generated changelog ==="
6685
if [ -f target/jreleaser/release/CHANGELOG.md ]; then
6786
cat target/jreleaser/release/CHANGELOG.md
6887
else
6988
echo "No changelog found"
70-
fi
89+
fi
90+
echo ""
91+
echo "=== Next development version ==="
92+
mvn -B build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT
93+
mvn -B versions:commit
94+
NEXT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
95+
echo "Bumped to next development version: $NEXT_VERSION"
96+
97+
- name: Commit development version (dry-run)
98+
run: |
99+
git add pom.xml
100+
git commit -m "release: prepare for next development iteration"
101+
echo "Committed development version locally (not pushed)"
102+
103+
- name: Show final git status
104+
run: |
105+
echo "=== Local Git Status ==="
106+
git log --oneline -3
107+
echo ""
108+
echo "These commits were made locally but NOT pushed to the repository"

.github/workflows/release.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
token: ${{ secrets.GITHUB_TOKEN }}
2222

2323
- name: Set up JDK 17
24-
uses: actions/setup-java@v4
24+
uses: actions/setup-java@v5
2525
with:
2626
java-version: '17'
2727
distribution: 'temurin'
@@ -87,5 +87,4 @@ jobs:
8787
8888
- name: Push changes
8989
run: |
90-
git push origin master
91-
git push origin --tags
90+
git push origin master

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ included to validate against the reference code and other sources.
1717
<dependency>
1818
<groupId>net.e175.klaus</groupId>
1919
<artifactId>solarpositioning</artifactId>
20-
<version>2.0.8</version>
20+
<version>2.0.9</version>
2121
</dependency>
2222
```
2323

@@ -83,7 +83,7 @@ final var timeDependent = SPA.calculateSpaTimeDependentParts(dateTime, deltaT);
8383
// Reuse for multiple coordinates (up to 10x faster)
8484
for(var coordinate: coordinates) {
8585
var position = SPA.calculateSolarPositionWithTimeDependentParts(
86-
dateTime, coordinate.lat, coordinate.lon, coordinate.elevation, timeDependent);
86+
coordinate.lat, coordinate.lon, coordinate.elevation, timeDependent);
8787
}
8888
```
8989
See the Javadoc for more methods.

pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@
118118
<changelog>
119119
<formatted>ALWAYS</formatted>
120120
<preset>conventional-commits</preset>
121+
<contributors>
122+
<enabled>false</enabled>
123+
</contributors>
121124
</changelog>
122125
</github>
123126
</release>

src/main/java/net/e175/klaus/solarpositioning/SPA.java

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public double elevation() {
6767
/**
6868
* Calculate time-dependent parts of the SPA algorithm (steps 1-11). These calculations depend
6969
* only on the date/time and can be computed once for bulk processing at a fixed time with varying
70-
* coordinates.
70+
* coordinates. Use with {@link #calculateSolarPositionWithTimeDependentParts} for significant
71+
* performance improvements when calculating positions for multiple coordinates at the same time.
7172
*
7273
* @param date Observer's local date and time.
7374
* @param deltaT Difference between earth rotation time and terrestrial time (or Universal Time
@@ -85,19 +86,19 @@ public static SpaTimeDependent calculateSpaTimeDependentParts(
8586

8687
// calculate Earth heliocentric longitude, L
8788
final double[] lTerms = calculateLBRTerms(jme, TERMS_L);
88-
final double lDegrees = limitDegreesTo360(toDegrees(calculateLBRPolynomial(jme, lTerms)));
89+
final double lDegrees = limitTo(toDegrees(calculateLBRPolynomial(jme, lTerms)), 360);
8990

9091
// calculate Earth heliocentric latitude, B
9192
final double[] bTerms = calculateLBRTerms(jme, TERMS_B);
92-
final double bDegrees = limitDegreesTo360(toDegrees(calculateLBRPolynomial(jme, bTerms)));
93+
final double bDegrees = limitTo(toDegrees(calculateLBRPolynomial(jme, bTerms)), 360);
9394

9495
// calculate Earth radius vector, R
9596
final double[] rTerms = calculateLBRTerms(jme, TERMS_R);
9697
final double r = calculateLBRPolynomial(jme, rTerms);
9798
assert r != 0;
9899

99100
// calculate geocentric longitude, theta
100-
final double thetaDegrees = limitDegreesTo360(lDegrees + 180);
101+
final double thetaDegrees = limitTo(lDegrees + 180, 360);
101102
// calculate geocentric latitude, beta
102103
final double betaDegrees = -bDegrees;
103104
final double beta = toRadians(betaDegrees);
@@ -146,7 +147,6 @@ public static SpaTimeDependent calculateSpaTimeDependentParts(
146147
* #calculateSpaTimeDependentParts}. Used together, these provide significant speedup for
147148
* coordinate sweeps at fixed time.
148149
*
149-
* @param date Observer's local date and time (must match the date used for timeDependent).
150150
* @param latitude Observer's latitude, in degrees (negative south of equator).
151151
* @param longitude Observer's longitude, in degrees (negative west of Greenwich).
152152
* @param elevation Observer's elevation, in meters.
@@ -161,7 +161,6 @@ public static SpaTimeDependent calculateSpaTimeDependentParts(
161161
* @see SolarPosition
162162
*/
163163
public static SolarPosition calculateSolarPositionWithTimeDependentParts(
164-
final ZonedDateTime date,
165164
final double latitude,
166165
final double longitude,
167166
final double elevation,
@@ -176,7 +175,7 @@ public static SolarPosition calculateSolarPositionWithTimeDependentParts(
176175
final double deltaDegrees = timeDependent.deltaDegrees;
177176

178177
// Calculate observer local hour angle
179-
final double hDegrees = limitDegreesTo360(timeDependent.nuDegrees + longitude - alphaDegrees);
178+
final double hDegrees = limitTo(timeDependent.nuDegrees + longitude - alphaDegrees, 360);
180179
final double h = toRadians(hDegrees);
181180

182181
// Calculate the topocentric sun right ascension and sun declination
@@ -234,14 +233,13 @@ public static SolarPosition calculateSolarPosition(
234233
final double temperature) {
235234
final SpaTimeDependent timeDependent = calculateSpaTimeDependentParts(date, deltaT);
236235
return calculateSolarPositionWithTimeDependentParts(
237-
date, latitude, longitude, elevation, pressure, temperature, timeDependent);
236+
latitude, longitude, elevation, pressure, temperature, timeDependent);
238237
}
239238

240239
/**
241240
* Calculate topocentric solar position using pre-computed time-dependent parts. This method does
242241
* not perform refraction correction.
243242
*
244-
* @param date Observer's local date and time (must match the date used for timeDependent).
245243
* @param latitude Observer's latitude, in degrees (negative south of equator).
246244
* @param longitude Observer's longitude, in degrees (negative west of Greenwich).
247245
* @param elevation Observer's elevation, in meters.
@@ -252,13 +250,12 @@ public static SolarPosition calculateSolarPosition(
252250
* @see SolarPosition
253251
*/
254252
public static SolarPosition calculateSolarPositionWithTimeDependentParts(
255-
final ZonedDateTime date,
256253
final double latitude,
257254
final double longitude,
258255
final double elevation,
259256
final SpaTimeDependent timeDependent) {
260257
return calculateSolarPositionWithTimeDependentParts(
261-
date, latitude, longitude, elevation, Double.NaN, Double.NaN, timeDependent);
258+
latitude, longitude, elevation, Double.NaN, Double.NaN, timeDependent);
262259
}
263260

264261
/**
@@ -647,7 +644,7 @@ private static AlphaDelta calculateAlphaDelta(
647644
double jme, double deltaPsi, double epsilonDegrees) {
648645
// calculate Earth heliocentric latitude, B
649646
final double[] bTerms = calculateLBRTerms(jme, TERMS_B);
650-
final double bDegrees = limitDegreesTo360(toDegrees(calculateLBRPolynomial(jme, bTerms)));
647+
final double bDegrees = limitTo(toDegrees(calculateLBRPolynomial(jme, bTerms)), 360);
651648

652649
// calculate Earth radius vector, R
653650
final double[] rTerms = calculateLBRTerms(jme, TERMS_R);
@@ -656,10 +653,10 @@ private static AlphaDelta calculateAlphaDelta(
656653

657654
// calculate Earth heliocentric longitude, L
658655
final double[] lTerms = calculateLBRTerms(jme, TERMS_L);
659-
final double lDegrees = limitDegreesTo360(toDegrees(calculateLBRPolynomial(jme, lTerms)));
656+
final double lDegrees = limitTo(toDegrees(calculateLBRPolynomial(jme, lTerms)), 360);
660657

661658
// calculate geocentric longitude, theta
662-
final double thetaDegrees = limitDegreesTo360(lDegrees + 180);
659+
final double thetaDegrees = limitTo(lDegrees + 180, 360);
663660

664661
// calculate geocentric latitude, beta
665662
final double betaDegrees = -bDegrees;
@@ -701,8 +698,8 @@ private static SolarPosition calculateTopocentricSolarPosition(
701698

702699
// Calculate the topocentric azimuth angle
703700
final double gamma = atan2(sin(hPrime), cosHPrime * sinPhi - tan(deltaPrime) * cosPhi);
704-
final double gammaDegrees = limitDegreesTo360(toDegrees(gamma));
705-
final double topocentricAzimuthAngle = limitDegreesTo360(gammaDegrees + 180);
701+
final double gammaDegrees = limitTo(toDegrees(gamma), 360);
702+
final double topocentricAzimuthAngle = limitTo(gammaDegrees + 180, 360);
706703

707704
return new SolarPosition(topocentricAzimuthAngle, topocentricZenithAngle);
708705
}
@@ -737,7 +734,7 @@ private static double calculateGeocentricSunRightAscension(
737734
final double alpha =
738735
atan2(sin(lambdaRad) * cos(epsilonRad) - tan(betaRad) * sin(epsilonRad), cos(lambdaRad));
739736

740-
return limitDegreesTo360(toDegrees(alpha));
737+
return limitTo(toDegrees(alpha), 360);
741738
}
742739

743740
private static double calculateTrueObliquityOfEcliptic(
@@ -749,10 +746,11 @@ private static double calculateTrueObliquityOfEcliptic(
749746
private static double calculateApparentSiderealTimeAtGreenwich(
750747
final JulianDate jd, final double deltaPsi, final double epsilonDegrees) {
751748
final double nu0degrees =
752-
limitDegreesTo360(
749+
limitTo(
753750
280.46061837
754751
+ 360.98564736629 * (jd.julianDate() - 2451545)
755-
+ pow(jd.julianCentury(), 2) * (0.000387933 - jd.julianCentury() / 38710000));
752+
+ pow(jd.julianCentury(), 2) * (0.000387933 - jd.julianCentury() / 38710000),
753+
360);
756754

757755
return nu0degrees + deltaPsi * cos(toRadians(epsilonDegrees));
758756
}
@@ -790,10 +788,6 @@ private static double[] calculateNutationTerms(final double jce) {
790788
return x;
791789
}
792790

793-
private static double limitDegreesTo360(final double degrees) {
794-
return limitTo(degrees, 360.0);
795-
}
796-
797791
private static double calculateLBRPolynomial(final double jme, final double[] terms) {
798792
return polynomial(jme, terms) / 1e8;
799793
}

src/test/java/net/e175/klaus/solarpositioning/test/SPABulkProcessingTest.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void timeDependentPartsProduceIdenticalResults() {
3737
SPA.SpaTimeDependent timeDependent = SPA.calculateSpaTimeDependentParts(dateTime, deltaT);
3838
SolarPosition optimized =
3939
SPA.calculateSolarPositionWithTimeDependentParts(
40-
dateTime, latitude, longitude, elevation, pressure, temperature, timeDependent);
40+
latitude, longitude, elevation, pressure, temperature, timeDependent);
4141

4242
assertThat(optimized.azimuth()).isCloseTo(traditional.azimuth(), within(TOLERANCE));
4343
assertThat(optimized.zenithAngle()).isCloseTo(traditional.zenithAngle(), within(TOLERANCE));
@@ -60,7 +60,7 @@ void timeDependentPartsProduceIdenticalResultsWithoutRefraction() {
6060
SPA.SpaTimeDependent timeDependent = SPA.calculateSpaTimeDependentParts(dateTime, deltaT);
6161
SolarPosition optimized =
6262
SPA.calculateSolarPositionWithTimeDependentParts(
63-
dateTime, latitude, longitude, elevation, timeDependent);
63+
latitude, longitude, elevation, timeDependent);
6464

6565
assertThat(optimized.azimuth()).isCloseTo(traditional.azimuth(), within(TOLERANCE));
6666
assertThat(optimized.zenithAngle()).isCloseTo(traditional.zenithAngle(), within(TOLERANCE));
@@ -95,7 +95,7 @@ void bulkProcessingWithFixedTime() {
9595
// Calculate optimized way
9696
SolarPosition optimized =
9797
SPA.calculateSolarPositionWithTimeDependentParts(
98-
dateTime, coord.latitude, coord.longitude, coord.elevation, timeDependent);
98+
coord.latitude, coord.longitude, coord.elevation, timeDependent);
9999

100100
assertThat(optimized.azimuth())
101101
.as("Azimuth for lat=%f, lon=%f", coord.latitude, coord.longitude)
@@ -131,7 +131,7 @@ void bulkProcessingWithRandomCoordinates() {
131131
// Calculate optimized way
132132
SolarPosition optimized =
133133
SPA.calculateSolarPositionWithTimeDependentParts(
134-
dateTime, latitude, longitude, elevation, pressure, temperature, timeDependent);
134+
latitude, longitude, elevation, pressure, temperature, timeDependent);
135135

136136
assertThat(optimized.azimuth())
137137
.as("Azimuth for random coordinate #%d", i)
@@ -168,8 +168,7 @@ void recycleTimeDependentPartsForMultipleCoordinates() {
168168

169169
// Calculate using recycled time-dependent parts
170170
SolarPosition optimized =
171-
SPA.calculateSolarPositionWithTimeDependentParts(
172-
dateTime, lat, lon, elevation, timeDependent);
171+
SPA.calculateSolarPositionWithTimeDependentParts(lat, lon, elevation, timeDependent);
173172

174173
assertThat(optimized.azimuth())
175174
.as("Azimuth for coordinate lat=%f, lon=%f", lat, lon)
@@ -215,7 +214,7 @@ void performanceBenefitOfBulkProcessing() {
215214
SPA.SpaTimeDependent timeDependent = SPA.calculateSpaTimeDependentParts(dateTime, deltaT);
216215
for (Coordinate coord : coordinates) {
217216
SPA.calculateSolarPositionWithTimeDependentParts(
218-
dateTime, coord.latitude, coord.longitude, coord.elevation, timeDependent);
217+
coord.latitude, coord.longitude, coord.elevation, timeDependent);
219218
}
220219
long optimizedTime = System.nanoTime() - startOptimized;
221220

@@ -246,7 +245,7 @@ void timeDependentPartsWithExtremeValues() {
246245
SPA.calculateSolarPosition(dateTime, latitude, longitude, elevation, deltaT);
247246
SolarPosition optimized =
248247
SPA.calculateSolarPositionWithTimeDependentParts(
249-
dateTime, latitude, longitude, elevation, timeDependent);
248+
latitude, longitude, elevation, timeDependent);
250249

251250
assertThat(optimized.azimuth()).isCloseTo(traditional.azimuth(), within(TOLERANCE));
252251
assertThat(optimized.zenithAngle()).isCloseTo(traditional.zenithAngle(), within(TOLERANCE));
@@ -256,7 +255,7 @@ void timeDependentPartsWithExtremeValues() {
256255
traditional = SPA.calculateSolarPosition(dateTime, latitude, longitude, elevation, deltaT);
257256
optimized =
258257
SPA.calculateSolarPositionWithTimeDependentParts(
259-
dateTime, latitude, longitude, elevation, timeDependent);
258+
latitude, longitude, elevation, timeDependent);
260259

261260
assertThat(optimized.azimuth()).isCloseTo(traditional.azimuth(), within(TOLERANCE));
262261
assertThat(optimized.zenithAngle()).isCloseTo(traditional.zenithAngle(), within(TOLERANCE));

0 commit comments

Comments
 (0)