From aa1ad9f8444674cb3fe6a63c9b357fe31716cddf Mon Sep 17 00:00:00 2001 From: Wilco Krikke Date: Tue, 21 Dec 2021 21:01:10 +0100 Subject: [PATCH] AW-3135 --- .../common/src/fm/services/weather.service.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/projects/common/src/fm/services/weather.service.ts b/projects/common/src/fm/services/weather.service.ts index f2b0511..bd2ddfd 100644 --- a/projects/common/src/fm/services/weather.service.ts +++ b/projects/common/src/fm/services/weather.service.ts @@ -49,6 +49,22 @@ export class WeatherService { return this.getWeatherRange(centroid, startDateString, endDateString); } + public getDailyHistoricalObservations(centroid: number[], startDate: string, endDate: string): Observable { + const endpoint = this.appConfig.getConfig('weatherApiEndPoint'); + const apiKey = this.appConfig.getConfig('weatherApiKey'); + + // weather does not support UTC format, also remove Z + const sd = encodeURIComponent(startDate); + + const edHistoricalDate = new Date(); + edHistoricalDate.setHours(edHistoricalDate.getHours(), 0, 0, 0); + const edHistorical = moment(edHistoricalDate).local().format('YYYY-MM-DD[T]HH:mm:ss'); + + const historical = `${endpoint}${this.apiObservation}/?c=${centroid[0]},${centroid[1]}&sd=${sd}&ed=${edHistorical}&t=cleanedobservation&interval=daily&key=${apiKey}`; + + return this.httpClient.get(historical); + } + public getWeatherRange(centroid: number[], startDate: string, endDate: string): Observable { const endpoint = this.appConfig.getConfig('weatherApiEndPoint'); const apiKey = this.appConfig.getConfig('weatherApiKey');