113 lines
3.0 KiB
JavaScript
113 lines
3.0 KiB
JavaScript
|
|
import config from '../../config';
|
||
|
|
import CachePromise from '../../utils/cachepromise';
|
||
|
|
import { httpget } from '../../utils/request';
|
||
|
|
import apiurl from '../apiurl';
|
||
|
|
import moment from 'moment';
|
||
|
|
|
||
|
|
|
||
|
|
export const TestWeatherSet24h = new CachePromise(
|
||
|
|
() => httpget('./data/weather_set.json')
|
||
|
|
.then(({ data }) => data)
|
||
|
|
.catch(() => null),
|
||
|
|
1000 * 60
|
||
|
|
);
|
||
|
|
|
||
|
|
export const WeatherSet24h = new CachePromise(
|
||
|
|
async () => {
|
||
|
|
const latest = await ShqxYjhisLatest.get();
|
||
|
|
if (!latest) {
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
return httpget(apiurl.yjhis.weather, {
|
||
|
|
filename: latest.rainFile,
|
||
|
|
x1: config.extent[0],
|
||
|
|
y1: config.extent[1],
|
||
|
|
x2: config.extent[2],
|
||
|
|
y2: config.extent[3],
|
||
|
|
layers: '00.24,00.01,01.01,02.01,03.01,04.01,05.01,06.01,07.01,08.01,09.01,10.01,11.01,12.01,13.01,14.01,15.01,16.01,17.01,18.01,19.01,20.01,21.01,22.01,23.01,24.01'
|
||
|
|
}).then(({ data }) => data)
|
||
|
|
.catch(() => null)
|
||
|
|
},
|
||
|
|
1000 * 60
|
||
|
|
);
|
||
|
|
|
||
|
|
export const TestWeatherRadar = new CachePromise(
|
||
|
|
() => httpget('./data/radar.json')
|
||
|
|
.then(({ data }) => data)
|
||
|
|
.catch(() => null),
|
||
|
|
1000 * 60
|
||
|
|
);
|
||
|
|
|
||
|
|
export const WeatherRadar = new CachePromise(
|
||
|
|
async () => {
|
||
|
|
const latest = await ShqxRadarhisLatest.get();
|
||
|
|
if (!latest) {
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
return httpget(apiurl.radarhis.weather, {
|
||
|
|
filename: latest.rainFile,
|
||
|
|
x1: config.extent[0],
|
||
|
|
y1: config.extent[1],
|
||
|
|
x2: config.extent[2],
|
||
|
|
y2: config.extent[3],
|
||
|
|
}).then(({ data }) => data)
|
||
|
|
.catch(() => null)
|
||
|
|
},
|
||
|
|
1000 * 60
|
||
|
|
);
|
||
|
|
|
||
|
|
export const TestShqxYjhisLatest = new CachePromise(
|
||
|
|
() => httpget('./data/yjhis_latest.json')
|
||
|
|
.then(({ data }) => data)
|
||
|
|
.catch(() => null),
|
||
|
|
1000 * 60
|
||
|
|
);
|
||
|
|
|
||
|
|
export const ShqxYjhisLatest = new CachePromise(
|
||
|
|
() => httpget(apiurl.yjhis.latest, { adcd: config.ADCD6 })
|
||
|
|
.then(({ data }) => {
|
||
|
|
data.intv = 24 * 60;
|
||
|
|
return data;
|
||
|
|
})
|
||
|
|
.catch(() => null),
|
||
|
|
5000
|
||
|
|
);
|
||
|
|
|
||
|
|
export const ShqxRadarhisLatest = new CachePromise(
|
||
|
|
() => httpget(apiurl.radarhis.latest, { adcd: config.ADCD6 })
|
||
|
|
.then(({ data }) => {
|
||
|
|
data.intv = 2 * 60;
|
||
|
|
return data;
|
||
|
|
})
|
||
|
|
.catch(() => null),
|
||
|
|
5000
|
||
|
|
);
|
||
|
|
|
||
|
|
export const TestYjhisStat =
|
||
|
|
(tm) => httpget('./data/yjhis_stat.json', { adcd: config.ADCD6, tm })
|
||
|
|
.then(({ data }) => data)
|
||
|
|
.catch(() => null);
|
||
|
|
|
||
|
|
export const YjhisStat =
|
||
|
|
(tm) => httpget(apiurl.yjhis.stat, { adcd: config.ADCD6, tm: moment(tm).format('YYYYMMDDHH') })
|
||
|
|
.then(({ data }) => data)
|
||
|
|
.catch(() => null);
|
||
|
|
|
||
|
|
|
||
|
|
export const RadarhisStat =
|
||
|
|
(tm) => httpget(apiurl.radarhis.stat, { adcd: config.ADCD6, tm: moment(tm).format('YYYYMMDDHHmm') })
|
||
|
|
.then(({ data }) => data)
|
||
|
|
.catch(() => null);
|
||
|
|
|
||
|
|
export const YjImgList =
|
||
|
|
(tm) => httpget(apiurl.yjhis.imglist, { adcd: config.ADCD6, tm: moment(tm).format('YYYYMMDDHH') })
|
||
|
|
.then(({ data }) => data)
|
||
|
|
.catch(() => null);
|
||
|
|
|
||
|
|
export const YjRainImgList =
|
||
|
|
(tm) => httpget(apiurl.yjhis.rainimglist, { tm: moment(tm).format('YYYYMMDDHH') })
|
||
|
|
.then(({ data }) => data)
|
||
|
|
.catch(() => null);
|