made hourly weather data static typed.
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
parent
773bf3f5e7
commit
9f1f6934ee
@ -9,3 +9,14 @@ export interface WeatherData {
|
|||||||
wCardinal: string;
|
wCardinal: string;
|
||||||
wDir: number;
|
wDir: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface HourlyWeatherData {
|
||||||
|
time: Date;
|
||||||
|
iconCode: number;
|
||||||
|
temperature: number;
|
||||||
|
relativeHumidity: number;
|
||||||
|
rain: number;
|
||||||
|
windSpeed: number;
|
||||||
|
windDirectionCardinal: string;
|
||||||
|
windDirection: number;
|
||||||
|
}
|
||||||
|
@ -8,7 +8,7 @@ import {DatePipe} from '@angular/common';
|
|||||||
import {AppConfig} from '../shared/app.config';
|
import {AppConfig} from '../shared/app.config';
|
||||||
import {WeatherCurrentObservation} from '../models/weatherCurrentObservation';
|
import {WeatherCurrentObservation} from '../models/weatherCurrentObservation';
|
||||||
import {IItem} from '../models/item';
|
import {IItem} from '../models/item';
|
||||||
import {WeatherData} from '../models/WeatherData';
|
import {HourlyWeatherData, WeatherData} from '../models/WeatherData';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@ -32,7 +32,7 @@ export class WeatherService {
|
|||||||
return this.httpClient.get<WeatherCurrentObservation>(observationUrl);
|
return this.httpClient.get<WeatherCurrentObservation>(observationUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getWeatherRangeForItem(item: IItem, daysBefore = 10, daysAfter = 10): Observable<WeatherData[]> {
|
public getWeatherRangeForItem(item: IItem, daysBefore = 10, daysAfter = 10): Observable<HourlyWeatherData[]> {
|
||||||
const geometry = this.format.readGeometry(item.geometry);
|
const geometry = this.format.readGeometry(item.geometry);
|
||||||
const centroid = getCenter(geometry.getExtent());
|
const centroid = getCenter(geometry.getExtent());
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ export class WeatherService {
|
|||||||
return this.getWeatherRange(centroid, startDateString, endDateString);
|
return this.getWeatherRange(centroid, startDateString, endDateString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getWeatherRange(centroid: number[], startDate: string, endDate: string): Observable<WeatherData[]> {
|
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');
|
||||||
|
|
||||||
@ -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]);
|
const days = this.groupBy(hourlyWeatherData, hi => hi.time.split('T')[0]);
|
||||||
return Object.entries(days)
|
return Object.entries(days)
|
||||||
.reduce ( (result, entry) => {
|
.reduce ( (result, entry) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user