diff --git a/projects/common/src/fm/models/WeatherData.ts b/projects/common/src/fm/models/WeatherData.ts index e2de3f9..786ba8f 100644 --- a/projects/common/src/fm/models/WeatherData.ts +++ b/projects/common/src/fm/models/WeatherData.ts @@ -9,3 +9,14 @@ export interface WeatherData { wCardinal: string; wDir: number; } + +export interface HourlyWeatherData { + time: Date; + iconCode: number; + temperature: number; + relativeHumidity: number; + rain: number; + windSpeed: number; + windDirectionCardinal: string; + windDirection: number; +} diff --git a/projects/common/src/fm/services/weather.service.ts b/projects/common/src/fm/services/weather.service.ts index 6fea431..4f75993 100644 --- a/projects/common/src/fm/services/weather.service.ts +++ b/projects/common/src/fm/services/weather.service.ts @@ -8,7 +8,7 @@ import {DatePipe} from '@angular/common'; import {AppConfig} from '../shared/app.config'; import {WeatherCurrentObservation} from '../models/weatherCurrentObservation'; import {IItem} from '../models/item'; -import {WeatherData} from '../models/WeatherData'; +import {HourlyWeatherData, WeatherData} from '../models/WeatherData'; @Injectable({ providedIn: 'root', @@ -32,7 +32,7 @@ export class WeatherService { return this.httpClient.get(observationUrl); } - public getWeatherRangeForItem(item: IItem, daysBefore = 10, daysAfter = 10): Observable { + public getWeatherRangeForItem(item: IItem, daysBefore = 10, daysAfter = 10): Observable { const geometry = this.format.readGeometry(item.geometry); const centroid = getCenter(geometry.getExtent()); @@ -47,7 +47,7 @@ export class WeatherService { return this.getWeatherRange(centroid, startDateString, endDateString); } - public getWeatherRange(centroid: number[], startDate: string, endDate: string): Observable { + public getWeatherRange(centroid: number[], startDate: string, endDate: string): Observable { const endpoint = this.appConfig.getConfig('weatherApiEndPoint'); const apiKey = this.appConfig.getConfig('weatherApiKey'); @@ -71,7 +71,7 @@ export class WeatherService { ); } - public hourlyToDaily(hourlyWeatherData: any[]): WeatherData[] { + public hourlyToDaily(hourlyWeatherData: HourlyWeatherData[]): WeatherData[] { const days = this.groupBy(hourlyWeatherData, hi => hi.time.split('T')[0]); return Object.entries(days) .reduce ( (result, entry) => {