tils-first-weather-widget
Version:
An example development EXB widget (Grant Caroll, spatial-innovation.co.nz)
121 lines (109 loc) • 3.25 kB
text/typescript
import Accessor from "@arcgis/core/core/Accessor.js";
import { property } from "@arcgis/core/core/accessorSupport/decorators.js";
import WeatherCondition, { IWeatherCondition } from "./weather-condition";
import AirQuality, { IAirQuality } from "./air-quality";
export interface ICurrent extends IWeather{
last_updated_epoch: number,
last_updated: string,
air_quality: IAirQuality
}
export interface IWeather {
temp_c: number,
temp_f: number,
is_day: number,
condition: IWeatherCondition,
wind_mph: number,
wind_kph: number,
wind_degree: number,
wind_dir: string,
pressure_mb: number,
pressure_in: number,
precip_mm: number,
precip_in: number,
humidity: number,
cloud: number,
feelslike_c: number,
feelslike_f: number,
vis_km: number,
vis_miles: number,
uv: number,
gust_mph: number,
gust_kph: number,
}
export default class Weather extends Accessor implements ICurrent {
last_updated_epoch: number;
last_updated: string;
temp_c: number;
temp_f: number;
is_day: number;
condition: IWeatherCondition;
wind_mph: number;
wind_kph: number;
wind_degree: number;
wind_dir: string;
pressure_mb: number;
pressure_in: number;
precip_mm: number;
precip_in: number;
humidity: number;
cloud: number;
feelslike_c: number;
feelslike_f: number;
vis_km: number;
vis_miles: number;
uv: number;
gust_mph: number;
gust_kph: number;
air_quality: IAirQuality;
constructor(currentWeather: ICurrent) {
super();
this.last_updated_epoch = currentWeather.last_updated_epoch;
this.last_updated = currentWeather.last_updated;
this.temp_c = currentWeather.temp_c;
this.temp_f = currentWeather.temp_f;
this.is_day = currentWeather.is_day;
this.condition = new WeatherCondition(currentWeather.condition);
this.wind_mph = currentWeather.wind_mph;
this.wind_kph = currentWeather.wind_kph;
this.wind_degree = currentWeather.wind_degree;
this.wind_dir = currentWeather.wind_dir;
this.pressure_mb = currentWeather.pressure_mb;
this.pressure_in = currentWeather.pressure_in;
this.precip_mm = currentWeather.precip_mm;
this.precip_in = currentWeather.precip_in;
this.humidity = currentWeather.humidity;
this.cloud = currentWeather.cloud;
this.feelslike_c = currentWeather.feelslike_c;
this.feelslike_f = currentWeather.feelslike_f
this.vis_km = currentWeather.vis_km;
this.vis_miles = currentWeather.vis_miles;
this.uv = currentWeather.uv;
this.gust_mph = currentWeather.gust_mph;
this.gust_kph = currentWeather.gust_kph;
this.air_quality= new AirQuality(currentWeather.air_quality);
}
}