AW-3135
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Wilco Krikke 2021-12-21 21:01:10 +01:00
parent cc4726e85c
commit aa1ad9f844

View File

@ -49,6 +49,22 @@ export class WeatherService {
return this.getWeatherRange(centroid, startDateString, endDateString); return this.getWeatherRange(centroid, startDateString, endDateString);
} }
public getDailyHistoricalObservations(centroid: number[], startDate: string, endDate: string): Observable<HourlyWeatherData[]> {
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<any[]>(historical);
}
public getWeatherRange(centroid: number[], startDate: string, endDate: string): Observable<HourlyWeatherData[]> { public getWeatherRange(centroid: number[], startDate: string, endDate: string): Observable<HourlyWeatherData[]> {
const endpoint = this.appConfig.getConfig('weatherApiEndPoint'); const endpoint = this.appConfig.getConfig('weatherApiEndPoint');
const apiKey = this.appConfig.getConfig('weatherApiKey'); const apiKey = this.appConfig.getConfig('weatherApiKey');