Skip to content

Commit

Permalink
chore: improved forecast fields function with input variables for labels
Browse files Browse the repository at this point in the history
  • Loading branch information
claustres committed Aug 30, 2024
1 parent 21837ec commit a61207a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions map/client/composables/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export function useWeather (options = {}) {
// data

// functions
function getProbedLocationForecastFields () {
return {
function getProbedLocationForecastFields (variables) {
const fields = {
// Only wind/temperature can be available at different levels now
windDirection: {
property: (activity.forecastLevel ? `properties.windDirection-${activity.forecastLevel}` : 'properties.windDirection')
Expand Down Expand Up @@ -54,6 +54,15 @@ export function useWeather (options = {}) {
property: 'properties.name'
}
}
// Any given variables to extract labels from ?
if (variables && variables.length > 0) {
_.forOwn(fields, (value, key) => {
// Take care that weather fields are prefixed by 'properties.' because they target feature
const variable = _.find(variables, { name: `${value.property.replace('properties.', '')}` })
if (variable) value.label = variable.label
})
}
return fields
}
function isWeatherProbe (feature) {
const { windDirection, windSpeed } = getProbedLocationForecastFields()
Expand Down

0 comments on commit a61207a

Please sign in to comment.