Skip to content

Commit

Permalink
fix: dont make me touch again
Browse files Browse the repository at this point in the history
  • Loading branch information
ToxicMushroom committed Jan 15, 2024
1 parent 3f14d69 commit bc7a6a1
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@ import org.jetbrains.kotlinx.dataframe.api.toMap
import org.jetbrains.kotlinx.kandy.dsl.continuous
import org.jetbrains.kotlinx.kandy.dsl.internal.LayerPlotContext
import org.jetbrains.kotlinx.kandy.dsl.plot
import org.jetbrains.kotlinx.kandy.ir.scale.PositionalTransform
import org.jetbrains.kotlinx.kandy.letsplot.export.toBufferedImage
import org.jetbrains.kotlinx.kandy.letsplot.layers.area
import org.jetbrains.kotlinx.kandy.letsplot.layers.vLine
import org.jetbrains.kotlinx.kandy.letsplot.scales.Transformation
import org.jetbrains.kotlinx.kandy.letsplot.settings.LineType
import org.jetbrains.kotlinx.kandy.util.color.Color
import org.jetbrains.letsPlot.letsPlot
import org.jetbrains.letsPlot.stat.statSmooth
import org.koin.core.component.inject
import java.awt.RenderingHints
import java.awt.image.BufferedImage
import kotlin.random.Random
import kotlin.random.nextUInt


@KordExtension
Expand Down Expand Up @@ -150,7 +154,7 @@ class WeatherExtension : Extension() {

private suspend fun fetchBuienAlarm(lat: Double, long: Double): Pair<RainAgain, Float>? {
val httpResp: HttpResponse = httpClient.httpClient.get(
"https://cdn-secure.buienalarm.nl/api/3.4/forecast.php?lat=$lat&lon=$long&region=be&unit=mm%2Fu&c=${Random.nextInt()}"
"https://cdn-secure.buienalarm.nl/api/3.4/forecast.php?lat=$lat&lon=$long&region=be&unit=mm%2Fu&c=${Random.nextUInt()}"
)

val resp = try {
Expand Down Expand Up @@ -182,8 +186,8 @@ class WeatherExtension : Extension() {
return null
}

val timePoints = resp.forecasts.associate { (time, precipitation) ->
val scaledPrecip = precipitation * 0.25
val timePoints = resp.forecasts.associate { (time, value) ->
val scaledPrecip = value * 0.25
time.time to scaledPrecip
}

Expand All @@ -208,7 +212,7 @@ data class BuienRadarResp(
@Serializable
data class Forecast(
val datetime: LocalDateTime,
val precipitation: Float
val value: Float
)
}

Expand Down

0 comments on commit bc7a6a1

Please sign in to comment.