diff --git a/lib/src/main/kotlin/com/openmeteo/api/Forecast.kt b/lib/src/main/kotlin/com/openmeteo/api/Forecast.kt index 9982c17..a4b4ee0 100644 --- a/lib/src/main/kotlin/com/openmeteo/api/Forecast.kt +++ b/lib/src/main/kotlin/com/openmeteo/api/Forecast.kt @@ -1,5 +1,6 @@ package com.openmeteo.api +import com.openmeteo.api.common.CellSelection import com.openmeteo.api.common.CurrentWeather import com.openmeteo.api.common.Options import com.openmeteo.api.common.http.Endpoint @@ -46,9 +47,10 @@ object Forecast : Endpoint( override val precipitationUnit: PrecipitationUnit? = null, override val elevation: Float? = null, override val models: String? = null, + override val cellSelection: CellSelection? = null, ) : Q.Coordinate, Q.Elevation, Q.Daily, Q.Hourly, Q.TimeFormat, Q.DateRange, Q.PastDays, Q.ForecastDays, Q.CurrentWeather, Q.Timezone, Q.Models, - Q.TemperatureUnit, Q.WindSpeedUnit, Q.PrecipitationUnit + Q.TemperatureUnit, Q.WindSpeedUnit, Q.PrecipitationUnit, Q.CellSelection @Serializable data class Response( diff --git a/lib/src/main/kotlin/com/openmeteo/api/Historical.kt b/lib/src/main/kotlin/com/openmeteo/api/Historical.kt index e462df3..b29fbb1 100644 --- a/lib/src/main/kotlin/com/openmeteo/api/Historical.kt +++ b/lib/src/main/kotlin/com/openmeteo/api/Historical.kt @@ -1,5 +1,6 @@ package com.openmeteo.api +import com.openmeteo.api.common.CellSelection import com.openmeteo.api.common.CurrentWeather import com.openmeteo.api.common.Options import com.openmeteo.api.common.http.Endpoint @@ -40,8 +41,9 @@ object Historical : Endpoint( override val precipitationUnit: PrecipitationUnit? = null, override val elevation: Float? = null, override val models: String? = null, + override val cellSelection: CellSelection? = null, ) : Q.Coordinate, Q.Elevation, Q.DateRange, Q.Daily, Q.Hourly, Q.TimeFormat, Q.Timezone, - Q.TemperatureUnit, Q.WindSpeedUnit, Q.PrecipitationUnit, Q.Models + Q.TemperatureUnit, Q.WindSpeedUnit, Q.PrecipitationUnit, Q.Models, Q.CellSelection @Serializable data class Response( diff --git a/lib/src/main/kotlin/com/openmeteo/api/common/CellSelection.kt b/lib/src/main/kotlin/com/openmeteo/api/common/CellSelection.kt new file mode 100644 index 0000000..fe05493 --- /dev/null +++ b/lib/src/main/kotlin/com/openmeteo/api/common/CellSelection.kt @@ -0,0 +1,15 @@ +package com.openmeteo.api.common + +import kotlinx.serialization.SerialName + +/** + * Preference how grid-cells are selected + */ +enum class CellSelection { + @SerialName("land") + Land, + @SerialName("sea") + Sea, + @SerialName("nearest") + Nearest, +} diff --git a/lib/src/main/kotlin/com/openmeteo/api/common/query/Query.kt b/lib/src/main/kotlin/com/openmeteo/api/common/query/Query.kt index 294a2e8..527417d 100644 --- a/lib/src/main/kotlin/com/openmeteo/api/common/query/Query.kt +++ b/lib/src/main/kotlin/com/openmeteo/api/common/query/Query.kt @@ -195,4 +195,14 @@ interface Query { val models: String? } + /** + * Query for resources that can have different cell selection. + */ + interface CellSelection : Query { + /** + * The requested cell selection + */ + val cellSelection: com.openmeteo.api.common.CellSelection? + } + }