Skip to main content

Base Entities

|

Weather-related functionalities are organized into distinct classes, each designed to encapsulate specific weather data. These include LocationForecast, Conditions, and WeatherParameter. This document provides a detailed explanation of each class and its purpose.

LocationForecast class

This class is responsible for retaining data such as the forecast update timestamp, the geographic location and forecast data.

PropertyTypeDescription
updatedTime?Forecast update timestamp (UTC)
coordinatesCoordinates?Geographic location
forecastConditionsList?Forecast data
Current Weather Forecast explained

Conditions class

This class is responsible for retaining weather conditions for a given timestamp.

PropertyTypeDescription
typeString?For possible values see add ref[PredefinedParameterTypeValues]
timestampTime?Timestamp for condition (UTC)
imageImage?Image representation
descriptionString?Description translated according to the current SDK language
daylightEDaylightDaylight condition
parametersWeatherParameterList?Parameter list

PredefinedParameterTypeValues

This class contains the common values for Parameter.type and Conditions.type.

PropertyDescriptionUnit
airQuality'AirQuality'-
dewPoint'DewPoint'°C
feelsLike'FeelsLike'°C
humidity'Humidity'%
pressure'Pressure'mb
sunRise'Sunrise'-
sunSet'Sunset'-
temperature'Temperature'°C
uv'UV'-
visibility'Visibility'km
windDirection'WindDirection'°
windSpeed'WindSpeed'km/h
temperatureLow'TemperatureLow'°C
temperatureHigh'TemperatureHigh'°C
danger

The WeatherService may return data with varying property types, depending on data availability. A response might include only a subset of the values listed above.

WeatherParameter class

Class responsible for containing weather parameter data.

PropertyTypeDescription
typeString?For possible values see add ref[PredefinedParameterTypeValues]
valueDoubleValue
nameString?Name translated according to the current SDK language
unitString?Unit

Usage Example

Here's how to use these classes in Kotlin:

// Initialize WeatherService
val weatherService = WeatherService()

// Define coordinates for the location
val coordinates = Coordinates().apply {
latitude = 48.864716 // Paris latitude
longitude = 2.349014 // Paris longitude
}
val coordinatesList = CoordinatesList().apply { add(coordinates) }

// Get current weather forecast
weatherService.getCurrent(coordinatesList, onCompleted = { results, error, message ->
if (error == GemError.NoError) {
results.firstOrNull()?.let { locationForecast ->
// Access forecast update timestamp
val updated = locationForecast.updated

// Access geographic location
val location = locationForecast.coordinates

// Access forecast data
locationForecast.forecast?.forEach { condition ->
// Access condition properties
val type = condition.type
val timestamp = condition.timestamp
val description = condition.description
val daylight = condition.daylight
val image = condition.image

// Access weather parameters
condition.parameters?.forEach { parameter ->
val paramType = parameter.type
val paramValue = parameter.value
val paramName = parameter.name
val paramUnit = parameter.unit

// Process parameter data based on type
when (paramType) {
"Temperature" -> {
// Handle temperature data
}
"Humidity" -> {
// Handle humidity data
}
// Handle other parameter types...
}
}
}
}
} else {
// Handle error
Log.e("WeatherService", "Error getting weather: $message")
}
})