Skip to content

Commit

Permalink
feat: models options
Browse files Browse the repository at this point in the history
Updated script to ease usage on historical API as well.
  • Loading branch information
DadiBit committed Jun 4, 2023
1 parent d82fbbd commit 804c498
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
9 changes: 8 additions & 1 deletion .github/scripts/options.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

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

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

if [ -v models ]; then
name="models"
options

echo # new line
fi

name="hourly"
options

Expand Down
29 changes: 28 additions & 1 deletion lib/src/main/kotlin/com/openmeteo/api/Forecast.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ object Forecast {
@SerialName("precipitation_unit")
override val precipitationUnit: PrecipitationUnit? = null,
override val elevation: Float? = null,
override val models: String? = null,
) : Q.Coordinate, Q.Elevation, Q.Daily, Q.Hourly, Q.TimeFormat, Q.DateRange,
Q.PastDays, Q.ForecastDays, Q.CurrentWeather, Q.Timezone,
Q.PastDays, Q.ForecastDays, Q.CurrentWeather, Q.Timezone, Q.Models,
Q.TemperatureUnit, Q.WindSpeedUnit, Q.PrecipitationUnit

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

@Serializable
object Models : Options.Models {
const val bestMatch="best_match"
const val ecmwfIfs04="ecmwf_ifs04"
const val metnoNordic="metno_nordic"
const val gfsSeamless="gfs_seamless"
const val gfsGlobal="gfs_global"
const val gfsHrrr="gfs_hrrr"
const val jmaSeamless="jma_seamless"
const val jmaMsm="jma_msm"
const val jmaGsm="jma_gsm"
const val iconSeamless="icon_seamless"
const val iconGlobal="icon_global"
const val iconEu="icon_eu"
const val iconD2="icon_d2"
const val gemSeamless="gem_seamless"
const val gemGlobal="gem_global"
const val gemRegional="gem_regional"
const val gemHrdpsContinental="gem_hrdps_continental"
const val meteofranceSeamless="meteofrance_seamless"
const val meteofranceArpegeWorld="meteofrance_arpege_world"
const val meteofranceArpegeEurope="meteofrance_arpege_europe"
const val meteofranceAromeFrance="meteofrance_arome_france"
const val meteofranceAromeFranceHd="meteofrance_arome_france_hd"
}

@Serializable
object Daily : Options.Daily {
const val weathercode="weathercode"
Expand Down
8 changes: 7 additions & 1 deletion lib/src/main/kotlin/com/openmeteo/api/common/Options.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ package com.openmeteo.api.common

import com.openmeteo.api.common.Options.Daily
import com.openmeteo.api.common.Options.Hourly
import com.openmeteo.api.common.Options.Models

/**
* A parent type for [Daily] and [Hourly] options.
* A parent type for [Models], [Daily], [Hourly] options.
*/
interface Options {

/**
* A generic type to identify [Models] options.
*/
interface Models : Options

/**
* A generic type to identify [Daily] options.
*/
Expand Down
7 changes: 7 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 @@ -188,4 +188,11 @@ interface Query {
val precipitationUnit: com.openmeteo.api.common.units.PrecipitationUnit?
}

/**
* Query for resources that can use different data models.
*/
interface Models : Query {
val models: String?
}

}

0 comments on commit 804c498

Please sign in to comment.