mirror of
https://github.com/PranshulGG/WeatherMaster.git
synced 2026-10-23 11:33:42 -05:00
update primary and secondary weather condition selection in ComputeDailyWeatherCondition.kt
This commit is contained in:
1 parent
2fe1a1e0af
commit
2872f5bfa9
2 files changed
+18
-5
No files matched your search
-1
@@ -64,7 +64,6 @@ enum class WeatherCondition {
|
||||
// ------- MAP TO ICONS -------
|
||||
|
||||
fun WeatherCondition.toIcon(daily: WeatherDaily? = null, targetTimeMilli: Long): Int {
|
||||
|
||||
val isDay = if (daily != null) {
|
||||
targetTimeMilli in daily.sunrise..daily.sunset
|
||||
} else {
|
||||
|
||||
+18
-4
@@ -54,17 +54,31 @@ fun computeDailyWeatherCondition(
|
||||
.fold(0) { acc, w -> acc + weight(w) }
|
||||
|
||||
// Pick the top 2, we keep the order as is so they don't flip, ignore weak stuff
|
||||
val topTwo = counts
|
||||
// val topTwo = counts
|
||||
// .filter { it.value > 2 }
|
||||
// .keys
|
||||
// .sortedBy { weather ->
|
||||
// dataNormalized.indexOf(weather)
|
||||
// }
|
||||
// .take(2)
|
||||
//
|
||||
// val topSecondary = counts.keys.sortedByDescending { it }
|
||||
|
||||
// Pick the top primary, we keep the order as is so they don't flip, ignore weak stuff
|
||||
val topPrimary = counts
|
||||
.filter { it.value > 2 }
|
||||
.keys
|
||||
.sortedBy { weather ->
|
||||
dataNormalized.indexOf(weather)
|
||||
}
|
||||
.take(2)
|
||||
|
||||
.take(1)
|
||||
|
||||
val primary = topTwo.getOrNull(0)
|
||||
val secondary = topTwo.getOrNull(1)
|
||||
// Pick the dominant one for secondary
|
||||
val topSecondary = counts.keys.sortedByDescending { it }.take(1)
|
||||
|
||||
val primary = topPrimary.getOrNull(0)
|
||||
val secondary = topSecondary.getOrNull(0)
|
||||
|
||||
|
||||
val primaryCount = primary?.let { counts[it] } ?: 0
|
||||
|
||||
Reference in new issue
Block a user