Skip to content

Commit 804c498

Browse files
committed
feat: models options
Updated script to ease usage on historical API as well.
1 parent d82fbbd commit 804c498

4 files changed

Lines changed: 50 additions & 3 deletions

File tree

.github/scripts/options.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# run from root dir with `endpoint=ForecastOrOther .github/scripts/options.sh`
3+
# run from root dir with `models="" endpoint=Forecast .github/scripts/options.sh`
44

55
declare -A docs=(
66
[Forecast]="https://open-meteo.com/en/docs"
@@ -70,6 +70,13 @@ cd "lib/src/main/kotlin/$(echo "$package" | tr '.' '/')" || exit 1
7070
mkdir tmp
7171
curl -s "${docs[$endpoint]}" > "tmp/$endpoint.html"
7272

73+
if [ -v models ]; then
74+
name="models"
75+
options
76+
77+
echo # new line
78+
fi
79+
7380
name="hourly"
7481
options
7582

lib/src/main/kotlin/com/openmeteo/api/Forecast.kt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ object Forecast {
4141
@SerialName("precipitation_unit")
4242
override val precipitationUnit: PrecipitationUnit? = null,
4343
override val elevation: Float? = null,
44+
override val models: String? = null,
4445
) : Q.Coordinate, Q.Elevation, Q.Daily, Q.Hourly, Q.TimeFormat, Q.DateRange,
45-
Q.PastDays, Q.ForecastDays, Q.CurrentWeather, Q.Timezone,
46+
Q.PastDays, Q.ForecastDays, Q.CurrentWeather, Q.Timezone, Q.Models,
4647
Q.TemperatureUnit, Q.WindSpeedUnit, Q.PrecipitationUnit
4748

4849
@Serializable
@@ -63,6 +64,32 @@ object Forecast {
6364
override val currentWeather: R.CurrentWeather.CurrentWeather? = null,
6465
) : R.Coordinate, R.Elevation, R.GenerationTimed, R.TimeZone, R.Daily, R.Hourly, R.CurrentWeather
6566

67+
@Serializable
68+
object Models : Options.Models {
69+
const val bestMatch="best_match"
70+
const val ecmwfIfs04="ecmwf_ifs04"
71+
const val metnoNordic="metno_nordic"
72+
const val gfsSeamless="gfs_seamless"
73+
const val gfsGlobal="gfs_global"
74+
const val gfsHrrr="gfs_hrrr"
75+
const val jmaSeamless="jma_seamless"
76+
const val jmaMsm="jma_msm"
77+
const val jmaGsm="jma_gsm"
78+
const val iconSeamless="icon_seamless"
79+
const val iconGlobal="icon_global"
80+
const val iconEu="icon_eu"
81+
const val iconD2="icon_d2"
82+
const val gemSeamless="gem_seamless"
83+
const val gemGlobal="gem_global"
84+
const val gemRegional="gem_regional"
85+
const val gemHrdpsContinental="gem_hrdps_continental"
86+
const val meteofranceSeamless="meteofrance_seamless"
87+
const val meteofranceArpegeWorld="meteofrance_arpege_world"
88+
const val meteofranceArpegeEurope="meteofrance_arpege_europe"
89+
const val meteofranceAromeFrance="meteofrance_arome_france"
90+
const val meteofranceAromeFranceHd="meteofrance_arome_france_hd"
91+
}
92+
6693
@Serializable
6794
object Daily : Options.Daily {
6895
const val weathercode="weathercode"

lib/src/main/kotlin/com/openmeteo/api/common/Options.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ package com.openmeteo.api.common
22

33
import com.openmeteo.api.common.Options.Daily
44
import com.openmeteo.api.common.Options.Hourly
5+
import com.openmeteo.api.common.Options.Models
56

67
/**
7-
* A parent type for [Daily] and [Hourly] options.
8+
* A parent type for [Models], [Daily], [Hourly] options.
89
*/
910
interface Options {
1011

12+
/**
13+
* A generic type to identify [Models] options.
14+
*/
15+
interface Models : Options
16+
1117
/**
1218
* A generic type to identify [Daily] options.
1319
*/

lib/src/main/kotlin/com/openmeteo/api/common/query/Query.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,11 @@ interface Query {
188188
val precipitationUnit: com.openmeteo.api.common.units.PrecipitationUnit?
189189
}
190190

191+
/**
192+
* Query for resources that can use different data models.
193+
*/
194+
interface Models : Query {
195+
val models: String?
196+
}
197+
191198
}

0 commit comments

Comments
 (0)