Skip to content

Commit

Permalink
Use sol Time readings helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Oct 13, 2023
1 parent bb3f4d7 commit 64a5efa
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import com.kylecorry.sol.science.astronomy.meteors.MeteorShowerPeak
import com.kylecorry.sol.science.astronomy.moon.MoonPhase
import com.kylecorry.sol.science.astronomy.moon.MoonTruePhase
import com.kylecorry.sol.science.shared.Season
import com.kylecorry.sol.time.Time
import com.kylecorry.sol.time.Time.toZonedDateTime
import com.kylecorry.sol.units.Bearing
import com.kylecorry.sol.units.Coordinate
import com.kylecorry.sol.units.Reading
import com.kylecorry.trail_sense.shared.extensions.getReadings
import java.time.Clock
import java.time.Duration
import java.time.LocalDate
Expand Down Expand Up @@ -54,7 +54,7 @@ class AstronomyService(private val clock: Clock = Clock.systemDefaultZone()) {
): List<Reading<Float>> {
val startTime = time.minusHours(12)
val endTime = time.plusHours(12)
return getReadings(
return Time.getReadings(
startTime,
endTime,
altitudeGranularity
Expand All @@ -64,7 +64,7 @@ class AstronomyService(private val clock: Clock = Clock.systemDefaultZone()) {
}

fun getMoonAltitudes(location: Coordinate, date: LocalDate): List<Reading<Float>> {
return getReadings(
return Time.getReadings(
date,
ZoneId.systemDefault(),
altitudeGranularity
Expand Down Expand Up @@ -122,7 +122,7 @@ class AstronomyService(private val clock: Clock = Clock.systemDefaultZone()) {
}

fun getSunAltitudes(location: Coordinate, date: LocalDate): List<Reading<Float>> {
return getReadings(
return Time.getReadings(
date,
ZoneId.systemDefault(),
altitudeGranularity
Expand All @@ -137,7 +137,7 @@ class AstronomyService(private val clock: Clock = Clock.systemDefaultZone()) {
): List<Reading<Float>> {
val startTime = time.minusHours(12)
val endTime = time.plusHours(12)
return getReadings(
return Time.getReadings(
startTime,
endTime,
altitudeGranularity
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.kylecorry.sol.science.oceanography.Tide
import com.kylecorry.sol.science.oceanography.TideType
import com.kylecorry.sol.time.Time
import com.kylecorry.sol.units.Reading
import com.kylecorry.trail_sense.shared.extensions.getReadings
import com.kylecorry.trail_sense.tools.tides.domain.range.TideTableRangeCalculator
import com.kylecorry.trail_sense.tools.tides.domain.waterlevel.TideTableWaterLevelCalculator
import java.time.*
Expand Down Expand Up @@ -36,7 +35,7 @@ class TideService : ITideService {
}

override fun getWaterLevels(table: TideTable, date: LocalDate): List<Reading<Float>> {
return getReadings(
return Time.getReadings(
date,
ZoneId.systemDefault(),
Duration.ofMinutes(10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.kylecorry.sol.time.Time.daysUntil
import com.kylecorry.sol.units.Coordinate
import com.kylecorry.sol.units.Reading
import com.kylecorry.sol.units.Temperature
import com.kylecorry.trail_sense.shared.extensions.getReadings
import com.kylecorry.trail_sense.shared.extensions.onDefault
import com.kylecorry.trail_sense.weather.infrastructure.temperatures.calculators.DailyTemperatureCalculator
import java.time.Duration
Expand Down Expand Up @@ -42,7 +41,7 @@ internal class HistoricTemperatureRepo(private val context: Context) : ITemperat
): List<Reading<Temperature>> {
val calculator = DailyTemperatureCalculator(location, this::getDailyRange)

return getReadings(start, end, Duration.ofMinutes(10)) {
return Time.getReadings(start, end, Duration.ofMinutes(10)) {
calculator.calculate(it)
}
}
Expand Down

0 comments on commit 64a5efa

Please sign in to comment.