Skip to content

Commit

Permalink
feat: cell selection
Browse files Browse the repository at this point in the history
  • Loading branch information
DadiBit committed Jun 6, 2023
1 parent 0231668 commit f5eee3c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/src/main/kotlin/com/openmeteo/api/Forecast.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion lib/src/main/kotlin/com/openmeteo/api/Historical.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down
15 changes: 15 additions & 0 deletions lib/src/main/kotlin/com/openmeteo/api/common/CellSelection.kt
Original file line number Diff line number Diff line change
@@ -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,
}
10 changes: 10 additions & 0 deletions lib/src/main/kotlin/com/openmeteo/api/common/query/Query.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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?
}

}

0 comments on commit f5eee3c

Please sign in to comment.