diff --git a/src/models/index.ts b/src/models/index.ts index 522a96a..e623840 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -4,16 +4,13 @@ import { map } from "./map" import overallview from "./overallview"; import realview from "./realview"; import { runtime } from "./runtime"; -import rcview from "./rcview"; -import shyjview from "./shyjview"; + import systemSwitch from "./systemSwitch"; export interface RootModel extends Models { map: typeof map; overallview: typeof overallview; runtime: typeof runtime; - rcview: typeof rcview; - shyjview: typeof shyjview; auth: typeof auth; systemSwitch: typeof systemSwitch; } @@ -23,8 +20,7 @@ export const models: RootModel = { overallview, realview, runtime, - rcview, - shyjview, + auth, systemSwitch }; diff --git a/src/models/rcview/calculator.js b/src/models/rcview/calculator.js deleted file mode 100644 index cd08f9c..0000000 --- a/src/models/rcview/calculator.js +++ /dev/null @@ -1,932 +0,0 @@ -import interpolate from '@turf/interpolate'; -import flattern from '@turf/flatten'; -import intersect from '@turf/intersect'; -import area from '@turf/area'; -import buffer from '@turf/buffer'; -import { featureCollection } from "@turf/helpers"; -import { drpShColor, drpColorLevel } from "../../utils/renutils"; -import clone from "clone"; -import {config} from "../../config"; -import {WeatherSet24h, WeatherSetRightQx, WeatherSetRightQx2, WeatherRadar,WeatherRadar2,WeatherSetTm24h} from "../_/shqxjs"; -import { DrpRealPromiseWX } from "../_/real"; -import { BouaPromise } from "../_/base"; -import { isobandsCustomer } from "./isobandsCustomer"; -import { getStPptnRHListApi } from "../../service/forecastModule/rainfall"; -import moment from "moment"; - -function calCellSize() { - const [x1, y1, x2, y2] = config.extent; - const w = (x2 - x1) / 40; - const h = (y2 - y1) / 40; - return (w + h) * 0.5; -} - -const WEIGHT = 5; -const CELLSIZE = calCellSize(); - - -function createBouaContour(boua, z1, z2) { - const ret = clone(boua); - ret.features[0].properties = { - z1, z2, - // fill: drpShColor(z1, true, 0.7), - fill: drpColorLevel(z1), - } - return ret; -} - - -function FeaturePt(x, y, z) { - return { - type: 'Feature', - properties: { z }, - geometry: { - type: 'Point', - coordinates: [x, y], - } - }; -} - -export async function calRealContour(list,type) { - //type 1:站点雨量 2:雨情时间轴 - const tm = Date.now(); - //const drpReal = await DrpRealPromise.get(); - let testData = [ - { - "countycode": "420529000000", - "stcd": "0529000003", - "lgtd": 110.48687485, - "lttd": 30.08361939, - "source": "SH", - "drp": 0, - "tm": "2023-09-20 20:00:00" - }, - { - "countycode": "420529000000", - "stcd": "0529000004", - "lgtd": 110.48029378, - "lttd": 30.08072148, - "source": "SH", - "drp": 0, - "tm": "2023-09-20 20:00:00" - }, - { - "countycode": "420529000000", - "stcd": "0529000006", - "lgtd": 110.44770565, - "lttd": 30.05067071, - "source": "SH", - "drp": 0, - "tm": "2023-09-20 20:00:00" - }, - { - "countycode": "420529000000", - "stcd": "0529000015", - "lgtd": 110.4712541, - "lttd": 30.05237389, - "source": "SH", - "drp": 7.5, - "tm": "2023-09-20 20:00:00" - }, - { - "countycode": "420529000000", - "stcd": "0529000018", - "lgtd": 110.3665342, - "lttd": 30.06455589, - "source": "SH", - "drp": 7, - "tm": "2023-09-20 20:00:00" - }, - { - "countycode": "420529000000", - "stcd": "0529000017", - "lgtd": 110.3915608, - "lttd": 30.09455766, - "source": "SH", - "drp": 6, - "tm": "2023-09-20 20:00:00" - }, - { - "countycode": "420529000000", - "stcd": "0529020014", - "lgtd": 110.40418321, - "lttd": 30.01706327, - "source": "SH", - "drp": 0, - "tm": "2023-09-20 20:00:00" - }, - { - "countycode": "420529000000", - "stcd": "0529020015", - "lgtd": 110.40095006, - "lttd": 30.04342534, - "source": "SH", - "drp": 0, - "tm": "2023-09-20 20:00:00" - }, - { - "countycode": "420529000000", - "stcd": "0529020001", - "lgtd": 110.49619987, - "lttd": 30.11764172, - "source": "SH", - "drp": 0, - "tm": "2023-09-20 20:00:00" - }, - { - "countycode": "420529000000", - "stcd": "0529020005", - "lgtd": 110.44345916, - "lttd": 30.06382503, - "source": "SH", - "drp": 0, - "tm": "2023-09-20 20:00:00" - }, - { - "countycode": "420529000000", - "stcd": "0529020002", - "lgtd": 110.47222902, - "lttd": 30.09723556, - "source": "SH", - "drp": 0, - "tm": "2023-09-20 20:00:00" - }, - { - "countycode": "420529000000", - "stcd": "0529020008", - "lgtd": 110.42067152, - "lttd": 30.06479346, - "source": "SH", - "drp": 0, - "tm": "2023-09-20 20:00:00" - }, - { - "countycode": "420529000000", - "stcd": "0529020007", - "lgtd": 110.42852499, - "lttd": 30.04141522, - "source": "SH", - "drp": 0, - "tm": "2023-09-20 20:00:00" - }, - { - "countycode": "420529000000", - "stcd": "0529020003", - "lgtd": 110.48687485, - "lttd": 30.08361939, - "source": "SH", - "drp": 0, - "tm": "2023-09-20 20:00:00" - }, - { - "countycode": "420529000000", - "stcd": "0529020011", - "lgtd": 110.40631381, - "lttd": 30.03815157, - "source": "SH", - "drp": 0, - "tm": "2023-09-20 20:00:00" - }, - { - "countycode": "420529000000", - "stcd": "0529020006", - "lgtd": 110.44770565, - "lttd": 30.05067071, - "source": "SH", - "drp": 0, - "tm": "2023-09-20 20:00:00" - }, - { - "countycode": "420529000000", - "stcd": "0529020009", - "lgtd": 110.42001971, - "lttd": 30.01753668, - "source": "SH", - "drp": 0, - "tm": "2023-09-20 20:00:00" - } - ]; - - const drpReal = list// type===1?await DrpRealPromiseWX.get():testData; - const boua = await BouaPromise.get(); - console.log("52@@@站点实时雨量",drpReal); - if (!drpReal) { - return { msg: '获取实时数据失败' }; - } - if (!boua) { - return { msg: '获取边界数据失败' }; - } - - let points = - drpReal - .filter(o => o.lgtd && o.lttd) - // .map(o => FeaturePt(o.lgtd, o.lttd, o[interval])); - .map(o => FeaturePt(o.lgtd, o.lttd, o.drp)); - - - if (points.length < 1) { - return { msg: '无法获得有效实时数据站点数据' }; - } - //console.log("68@@@站点实时雨量",points); - let total = 0; - points.forEach(pt => { - total += pt.properties.z; - }); - const av = total / points.length; - - // points.push(FeaturePt(config.extent[0], config.extent[1], av)); - points.push(FeaturePt(108.615000, 29.315000, av)); - // points.push(FeaturePt(config.extent[2], config.extent[3], av)); - points.push(FeaturePt(109.345000, 30.055000, av)); - - - const clt = featureCollection(points); - - const grid = interpolate(clt, CELLSIZE, { - gridType: 'point', - property: 'z', - units: 'degrees', - weight: WEIGHT - }); - - let maxVal = 0; - grid.features.forEach(pt => { - if (pt.properties.z > maxVal) { - maxVal = pt.properties.z; - } - }); - if (maxVal <= 0.1) { - return { - breaks: [0], - shp: createBouaContour(boua, 0, 0), - // interval, - interval: "h12", - type: 'real', - tm, - } - } - - maxVal = Math.ceil(maxVal); - - const step = Math.max(1, Math.ceil(maxVal / 10)); - - const breaks = [0, 0.1]; - - for (let i = step; i <= maxVal; i += step) { - breaks.push(i); - } - - /* - let bands = isobands(grid, breaks, { - zProperty: 'z', - breaksProperties: breaks.map(z1 => ({ - z1, - fill: drpShColor(z1, true) - })) - }); - */ - - let bands = isobandsCustomer(grid, breaks); - - - bands = flattern(bands); - - let clipped = []; - bands.features.forEach(band => { - let intersection = null; - try { - intersection = intersect(band, boua.features[0]); - } catch (e) { - console.log(e); - try { - band = buffer(band, 0.0001); - intersection = intersect(band, boua.features[0]); - } catch (e) { - console.log(e); - } - } - - if (intersection) { - intersection.properties = band.properties; - clipped.push(intersection); - } - }) - bands.features = clipped; - - let areaInfo = {}; - bands.features.forEach(o => { - const z1 = o.properties.z1; - o.properties.area = area(o); - areaInfo[z1] = areaInfo[z1] || 0; - areaInfo[z1] += o.properties.area; - - }); - - return { - shp: bands, - breaks, - step, - interval: "h12", - type: 'real', - tm, - areaInfo, - label: 'z', - } -} - -export async function calRealContourLdy(drpReal, interval) { - //type 1:站点雨量 2:雨情时间轴 getStPptnRHListApi - const tm = Date.now(); - //const drpReal = await DrpRealPromise.get(); - - const boua = await BouaPromise.get(); - //console.log("@@@落地雨488",drpReal); - if (!drpReal) { - return { msg: '获取实时数据失败' }; - } - if (!boua) { - return { msg: '获取边界数据失败' }; - } - - let points = - drpReal - .filter(o => o.lgtd && o.lttd) - .map(o => FeaturePt(o.lgtd, o.lttd, o[interval])); - - if (points.length < 1) { - return { msg: '无法获得有效实时数据站点数据' }; - } - //console.log("@@@落地雨504",points); - let total = 0; - points.forEach(pt => { - total += pt.properties.z; - }); - const av = total / points.length; - - points.push(FeaturePt(config.extent[0], config.extent[1], av)); - points.push(FeaturePt(config.extent[2], config.extent[3], av)); - - const clt = featureCollection(points); - - const grid = interpolate(clt, CELLSIZE, { - gridType: 'point', - property: 'z', - units: 'degrees', - weight: WEIGHT - }); - - let maxVal = 0; - grid.features.forEach(pt => { - if (pt.properties.z > maxVal) { - maxVal = pt.properties.z; - } - }); - if (maxVal <= 0.1) { - return { - breaks: [0], - shp: createBouaContour(boua, 0, 0), - interval, - type: 'real', - tm, - } - } - - maxVal = Math.ceil(maxVal); - - const breaks = [...config.commonBreaks]; - - let bands = isobandsCustomer(grid, breaks); - - bands = flattern(bands); - - let clipped = []; - bands.features.forEach(band => { - let intersection = null; - try { - intersection = intersect(band, boua.features[0]); - } catch (e) { - console.log(e); - try { - band = buffer(band, 0.0001); - intersection = intersect(band, boua.features[0]); - } catch (e) { - console.log(e); - } - } - - if (intersection) { - intersection.properties = band.properties; - clipped.push(intersection); - } - }) - bands.features = clipped; - - let areaInfo = {}; - bands.features.forEach(o => { - const z1 = o.properties.z1; - o.properties.area = area(o); - areaInfo[z1] = areaInfo[z1] || 0; - areaInfo[z1] += o.properties.area; - - }); - - return { - shp: bands - } -} - -export async function calFzdxContour(interval, minValue) { - const tm = Date.now(); - - //const drpReal = await DrpRealPromise.get(); - const drpReal = await DrpRealPromiseWX.get(); - const boua = await BouaPromise.get(); - - if (!drpReal) { - return { msg: '获取实时数据失败' }; - } - if (!boua) { - return { msg: '获取边界数据失败' }; - } - - const points = - drpReal - .filter(o => o.state === 1 && o.lgtd && o.lttd) - .map(o => FeaturePt(o.lgtd, o.lttd, o[interval])); - - if (points < 1) { - return { msg: '无法获得有效实时数据站点数据' }; - } - - let total = 0; - points.forEach(pt => { - total += pt.properties.z; - }); - const av = total / points.length; - - points.push(FeaturePt(config.extent[0], config.extent[1], av)); - points.push(FeaturePt(config.extent[2], config.extent[3], av)); - - const clt = featureCollection(points); - - const grid = interpolate(clt, CELLSIZE, { - gridType: 'point', - property: 'z', - units: 'degrees', - weight: WEIGHT - }); - - const breaks = [minValue, 9999]; - - /* - let bands = isobands(grid, breaks, { - zProperty: 'z', - breaksProperties: breaks.map(z1 => ({ - z1, - fill: colors.red[300], - })) - }); - */ - - let bands = isobandsCustomer(grid, breaks); - - bands = flattern(bands); - - let clipped = []; - bands.features.forEach(band => { - let intersection = null; - try { - intersection = intersect(band, boua.features[0]); - } catch (e) { - console.log(e); - try { - band = buffer(band, 0.0001); - intersection = intersect(band, boua.features[0]); - } catch (e) { - console.log(e); - } - } - - if (intersection) { - intersection.properties = band.properties; - clipped.push(intersection); - } - }) - bands.features = clipped; - - let areaInfo = 0; - bands.features.forEach(o => { - o.properties.area = area(o); - areaInfo += o.properties.area; - - }) - - return { - shp: bands, - breaks, - interval, - type: 'fzdx', - tm, - areaInfo - } -} - - -export function calGridContour(griddata, breaks, boua) { - if (!griddata) { - return null; - } - const features = []; - const bin = griddata.data; - if (!bin || !bin[0]) { - return null; - } - const { x1, y1, dw, dh } = griddata; - const nh = bin.length, nw = bin[0].length; - let minz = 99999, maxz = 0; - for (let ix = 0; ix < nw; ix++) { - for (let iy = 0; iy < nh; iy++) { - const z = bin[iy][ix]; - features.push({ - type: 'Feature', - properties: { - z, - }, - geometry: { - type: 'Point', - coordinates: [x1 + ix * dw, y1 + iy * dh], - } - }); - - minz = Math.min(z, minz); - maxz = Math.max(z, maxz); - } - } - - for (let i = 1; i < breaks.length; i++) { - if (minz >= breaks[i - 1] && maxz <= breaks[i]) { - return createBouaContour(boua, breaks[i - 1], breaks[i]); - } - } - - /* - let bands = isobands(featureCollection(features), breaks, { - zProperty: 'z', - breaksProperties: breaks.map(z1 => ({ - z1, - fill: drpShColor(z1, true), - })) - }); - */ - //console.log("480 features+++",featureCollection(features)); - - let bands = isobandsCustomer(featureCollection(features), breaks); - - bands = flattern(bands); - - let clipped = []; - bands.features.forEach(band => { - let intersection = null; - try { - intersection = intersect(band, boua.features[0]); - } catch (e) { - console.log(e); - try { - band = buffer(band, 0.0001); - intersection = intersect(band, boua.features[0]); - } catch (e) { - console.log(e); - } - } - - if (intersection) { - intersection.properties = band.properties; - clipped.push(intersection); - } - }); - - bands.features = clipped; - - return bands; -} - -//图层弹窗-预报数据-气象局24小时预报 -export async function calWeatherContour24H(progress,type,myTm) { - const weatherSet = type===1?await WeatherSet24h.get():await WeatherSetRightQx2(myTm); - - const boua = await BouaPromise.get(); - //console.log("boua 522 ++++",boua); - - if (!weatherSet) { - return { msg: '获取天气数据失败' }; - } - if (!boua) { - return { msg: '获取边界数据失败' }; - } - - //console.log(weatherSet); - let data24h = weatherSet.find(o => o?.tmRange?.interval === 24);//气象局24小时预报 - let data1h = weatherSet.filter(o => o?.tmRange?.interval === 1);//预报-雨情-当前及右侧 - - data1h = data1h.sort((a, b) => (a?.tmRange.tm1 > b?.tmRange.tm1 ? 1 : -1)); - - const breaks = [...config.commonBreaks]; - - const shps = [], tms = []; - - // shps.push(calGridContour(data24h, breaks, boua)); - // tms.push(data24h?.tmRange.tm1); - - - //落地雨 - let currentY = moment().format("Y"); - let currentH = moment().format("H"); - let currentM = moment().format("m"); - let currentD = moment().format("MM-DD"); - - let currentT = null; - if(Number(currentM)>15){ - currentT = currentH; - }else{ - currentT = Number(currentH) - 1; - } - - let currentTime = currentY+"-"+currentD+" "+currentT+":00"; - //console.log("currentTime 503#####",currentTime); - - const endDateTime = new Date(currentTime); - const startDateTime = new Date(endDateTime.getTime() - 24 * 60 * 60 * 1000); - - const timeArray = []; - while (startDateTime.getTime() <= endDateTime.getTime()) { - const timeString = startDateTime.toLocaleString('en-US', { - year: 'numeric', - month: '2-digit', - day: '2-digit', - hour: 'numeric', - minute: 'numeric', - }); - timeArray.push(moment(timeString).format("YYYY-MM-DD HH:mm:ss")); - startDateTime.setTime(startDateTime.getTime() + 60 * 60 * 1000); - } - - //console.log("521@@@@@@@@",timeArray); - const resultArray = []; - for (let i = 0; i < timeArray.length - 1; i++) { - resultArray.push([timeArray[i], timeArray[i + 1]]); - } - - //console.log("527@@@@++++",resultArray); - - /*if(resultArray.length>0){ - resultArray.map(async(item)=>{ - let params = { - "adcd": "420529", - "source": ["SH","SW","SK","QX"], - "stm": item[0], - "etm": item[1] - }; - let drpReal = []; - const resData = await getStPptnRHListApi(params); - if(resData.code === 200){ - drpReal = resData.data; - } - - const ldyData = await calRealContourLdy(drpReal,"drp",2); - shps.push(ldyData.shp); - }); - }*/ - // console.log("690@@@@",timeArray); - // let params = { - // "adcd": "420529", - // "source": ["SH","SW","SK","QX"], - // "stm": timeArray[0], - // "etm": moment(endDateTime).format("YYYY-MM-DD HH:mm:ss") - // }; - // let drpReal = []; - // const resData = await getStPptnRHListApi(params); - // if(resData.code === 200){ - // drpReal = resData.data; - // //console.log("701+++++",drpReal); - // const result = []; - // const groupedData = drpReal.reduce((acc, item) => { - // const key = item.tm; - // if (!acc[key]) { - // acc[key] = []; - // } - // acc[key].push(item); - // return acc; - // }, {}); - - // for (const key in groupedData) { - // result.push(groupedData[key]); - // } - - // //console.log("716+++++@@@@@",result); - // if(result.length>0){ - // result.map(async(item)=>{ - // const ldyData = await calRealContourLdy(item,"drp"); - // shps.push(ldyData.shp); - // }); - // } - // } - - let i = 1; - if (progress) { - await progress(i++); - } - - for (const o of data1h) { - shps.push(calGridContour(o, breaks, boua)); - tms.push(o?.tmRange.tm1); - - if (progress) { - await progress(i++); - } - } - - //console.log("554@@@@shps++++",shps); - - return { - shps, - index: 0, - breaks, - type: 'wf24h', - tm: data24h?.tmRange.tm1, - tms, - label: 'z', - }; -} - -//时间选择24小时预报 -export async function calWeatherContourTm24H(progress,type) { - const weatherSet = await WeatherSetTm24h(moment().format('YYYYMMDD08'));//type===1?await WeatherSet24h.get():await WeatherSetRightQx.get(); - const boua = await BouaPromise.get(); - //console.log("boua 522 ++++",boua); - - if (!weatherSet) { - return { msg: '获取天气数据失败' }; - } - if (!boua) { - return { msg: '获取边界数据失败' }; - } - - //console.log(weatherSet); - let data24h = weatherSet.find(o => o?.tmRange?.interval === 24);//气象局24小时预报 - let data1h = weatherSet.filter(o => o?.tmRange?.interval === 1);//预报-雨情-当前及右侧 - - data1h = data1h.sort((a, b) => (a?.tmRange.tm1 > b?.tmRange.tm1 ? 1 : -1)); - - const breaks = [...config.commonBreaks]; - - const shps = [], tms = []; - - shps.push(calGridContour(data24h, breaks, boua)); - tms.push(data24h?.tmRange.tm1); - - - //落地雨 - let currentY = moment().format("Y"); - let currentH = moment().format("H"); - let currentM = moment().format("m"); - let currentD = moment().format("MM-DD"); - - let currentT = null; - if(Number(currentM)>15){ - currentT = currentH; - }else{ - currentT = Number(currentH) - 1; - } - - let currentTime = currentY+"-"+currentD+" "+currentT+":00"; - //console.log("currentTime 503#####",currentTime); - - const endDateTime = new Date(currentTime); - const startDateTime = new Date(endDateTime.getTime() - 24 * 60 * 60 * 1000); - - const timeArray = []; - while (startDateTime.getTime() <= endDateTime.getTime()) { - const timeString = startDateTime.toLocaleString('en-US', { - year: 'numeric', - month: '2-digit', - day: '2-digit', - hour: 'numeric', - minute: 'numeric', - }); - timeArray.push(moment(timeString).format("YYYY-MM-DD HH:mm:ss")); - startDateTime.setTime(startDateTime.getTime() + 60 * 60 * 1000); - } - - //console.log("521@@@@@@@@",timeArray); - const resultArray = []; - for (let i = 0; i < timeArray.length - 1; i++) { - resultArray.push([timeArray[i], timeArray[i + 1]]); - } - - //console.log("527@@@@++++",resultArray); - - /*if(resultArray.length>0){ - resultArray.map(async(item)=>{ - let params = { - "adcd": "420529", - "source": ["SH","SW","SK","QX"], - "stm": item[0], - "etm": item[1] - }; - let drpReal = []; - const resData = await getStPptnRHListApi(params); - if(resData.code === 200){ - drpReal = resData.data; - } - - const ldyData = await calRealContourLdy(drpReal,"drp",2); - shps.push(ldyData.shp); - }); - }*/ - console.log("690@@@@",timeArray); - let params = { - "adcd": "420529", - "source": ["SH","SW","SK","QX"], - "stm": timeArray[0], - "etm": moment(endDateTime).format("YYYY-MM-DD HH:mm:ss") - }; - let drpReal = []; - const resData = await getStPptnRHListApi(params); - if(resData.code === 200){ - drpReal = resData.data; - //console.log("701+++++",drpReal); - const result = []; - const groupedData = drpReal.reduce((acc, item) => { - const key = item.tm; - if (!acc[key]) { - acc[key] = []; - } - acc[key].push(item); - return acc; - }, {}); - - for (const key in groupedData) { - result.push(groupedData[key]); - } - - //console.log("716+++++@@@@@",result); - if(result.length>0){ - result.map(async(item)=>{ - const ldyData = await calRealContourLdy(item,"drp"); - shps.push(ldyData.shp); - }); - } - } - - let i = 1; - if (progress) { - await progress(i++); - } - - for (const o of data1h) { - shps.push(calGridContour(o, breaks, boua)); - tms.push(o?.tmRange.tm1); - - if (progress) { - await progress(i++); - } - } - - //console.log("554@@@@shps++++",shps); - - return { - shps, - index: 0, - breaks, - type: 'wf24h', - tm: data24h?.tmRange.tm1, - tms, - label: 'z', - }; -} - -////图层弹窗-预报数据-气象局2小时预报? -export async function calWeatherContourRadar({myTm}) { - - let weatherData = await WeatherRadar2(myTm); - const boua = await BouaPromise.get(); - - if (!weatherData) { - return { msg: '获取天气数据失败' }; - } - if (!boua) { - return { msg: '获取边界数据失败' }; - } - - const breaks = [...config.commonBreaks]; - - const shp = calGridContour(weatherData, breaks, boua); - - return { - shp, - breaks, - type: 'wf2h', - tm: weatherData?.tmRange.tm1, - label: 'z', - }; -} diff --git a/src/models/rcview/contour.def b/src/models/rcview/contour.def deleted file mode 100644 index 3255bba..0000000 --- a/src/models/rcview/contour.def +++ /dev/null @@ -1,9 +0,0 @@ -{ - shp | shps , index; - breaks, - type: fzdx | real | wf24h | wf2h - tm: - interval for rcmap - areaInfo: number or numberMap - label: filed -} \ No newline at end of file diff --git a/src/models/rcview/index.js b/src/models/rcview/index.js deleted file mode 100644 index fe71a00..0000000 --- a/src/models/rcview/index.js +++ /dev/null @@ -1,83 +0,0 @@ -import { wait } from '../../utils/tools'; -import appconsts from '../../service/appconsts'; -import { calRealContour, calFzdxContour } from './calculator'; - -function initState() { - return { - type: 'real', // 'real', 'h24', 'fzdx' - - fzdxList: null, - flrvvlgList: null, - adList: null, - searchType: 'fzdx', - - warnDealingInfoType: appconsts.warnDealingInfo.RAIN_ORANGE, - }; -} - -const rcview = { - state: initState(), - reducers: { - setType(state, val) { - return { ...state, type: val }; - }, - setFzdxList(state, val) { - return { ...state, fzdxList: val }; - }, - setFlrvvlgList(state, val) { - return { ...state, flrvvlgList: val }; - }, - setAdList(state, val) { - return { ...state, adList: val }; - }, - clearFzdxResult(state) { - return { ...state, fzdxList: null, flrvvlgList: null, adList: null } - }, - setSearchType(state, val) { - return { ...state, searchType: val }; - }, - setWarnDealingInfoType(state, val) { - return { ...state, warnDealingInfoType: val }; - }, - - reset() { - return initState(); - } - }, - effects: dispatch => ({ - async showRealContour(interval) { - //console.log("站点面雨量 实时"); - //根据传入的数据-面雨量 - dispatch.runtime.setCalculating(true); - - await wait(100); - try { - const contour = await calRealContour(interval,1); - dispatch.runtime.setLayerSetting({ contour, dem: false }); - dispatch.map.setLayerVisible({ ContourLayer: true }); - } finally { - dispatch.runtime.setCalculating(false); - } - - //dispatch.runtime.setHome(); - }, - - async showFzdxContour({ interval, minValue }) { - dispatch.runtime.setCalculating(true); - - await wait(100); - try { - const contour = await calFzdxContour(interval, minValue); - - dispatch.runtime.setLayerSetting({ contour, dem: false }); - dispatch.map.setLayerVisible({ ContourLayer: true }); - } finally { - dispatch.runtime.setCalculating(false); - } - - dispatch.runtime.setHome(); - }, - }) -}; - -export default rcview; diff --git a/src/models/rcview/isobandsCustomer.js b/src/models/rcview/isobandsCustomer.js deleted file mode 100644 index fa85fbe..0000000 --- a/src/models/rcview/isobandsCustomer.js +++ /dev/null @@ -1,129 +0,0 @@ -import difference from '@turf/difference'; -import buffer from '@turf/buffer'; -import { contours } from 'd3-contour'; -import { drpShColor, drpColorLevel } from '../../utils/renutils'; - -function getGridWH(features) { - let x = features[0].geometry.coordinates[0]; - let w = 1, h = 1; - for (; h < features.length; h++) { - if (features[h].geometry.coordinates[0] !== x) { - break; - } - } - w = features.length / h; - if (w !== Math.round(w) || w === 1 || h === 1) { - return { w: 0, h: 0 }; - } - return { w, h }; -} - -function transC(coordinates, x1, y1, dx, dy) { - return coordinates.map(polygon => polygon.map(ring => ring.map(([x, y]) => ([x1 + (x - 0.5) * dx, y1 + (y - 0.5) * dy])))); -} - -function diffFeatures(features) { - let lastGeometry = null; - - const ret = []; - for (let i = features.length - 1; i >= 0; i -= 1) { - const { geometry } = features[i]; - if (!geometry.coordinates.length) { - continue; - } - let clippedGeometry = features[i]; - - try { - let currentSub = lastGeometry; - - try { - lastGeometry = clippedGeometry; - if (currentSub != null) { - clippedGeometry = difference(clippedGeometry, currentSub); - } - } catch (e) { - clippedGeometry = buffer(clippedGeometry, 0); - lastGeometry = clippedGeometry; - if (currentSub != null) { - clippedGeometry = difference(clippedGeometry, currentSub); - } - } - - if (clippedGeometry) { - ret.push(clippedGeometry); - } - } catch (e) { - console.log(e); - continue; - } - } - return ret; -} - -export function isobandsCustomer(grid, breaks) { - const gridfeatures = grid.features; - const { w, h } = getGridWH(gridfeatures); - if (!w || !h) { - console.error('w, h error'); - return; - } - const values = new Array(w * h); - - for (let ih = 0; ih < h; ih++) { - for (let iw = 0; iw < w; iw++) { - values[ih * w + iw] = gridfeatures[iw * h + ih].properties.z; - } - } - const [x1, y1] = gridfeatures[0].geometry.coordinates; - const dy = gridfeatures[1].geometry.coordinates[1] - y1; - const dx = gridfeatures[h].geometry.coordinates[0] - x1; - const contour = contours().size([w, h]).thresholds(breaks)(values); - const geojson = { - "type": "FeatureCollection", - "features": contour.map(({ type, value, coordinates }, index) => { - if (!coordinates || !coordinates.length || value !== breaks[index] || type !== 'MultiPolygon') { - return null; - } - return { - type: 'Feature', - properties: { - z1: value, - // fill: drpShColor(value, true, 0.9), - fill: drpColorLevel(value), - z: `${value}-${breaks[index + 1] || '-'}` - }, - geometry: { type, coordinates: transC(coordinates, x1, y1, dx, dy) } - }; - }).filter(Boolean) - }; - - geojson.features = diffFeatures(geojson.features); - - return geojson; -} - - -export function isobandsCustomerGridData(w, h, x1, y1, dx, dy, values, breaks) { - const contour = contours().size([w, h]).thresholds(breaks)(values); - const geojson = { - "type": "FeatureCollection", - "features": contour.map(({ type, value, coordinates }, index) => { - if (!coordinates || !coordinates.length || value !== breaks[index] || type !== 'MultiPolygon') { - return null; - } - return { - type: 'Feature', - properties: { - z1: value, - fill: drpShColor(value, true), - z: `${value}-${breaks[index + 1] || '-'}` - }, - geometry: { type, coordinates: transC(coordinates, x1, y1, dx, dy) } - }; - }).filter(Boolean) - }; - - geojson.features = diffFeatures(geojson.features); - - return geojson; -} diff --git a/src/models/rcview/planeArea.def b/src/models/rcview/planeArea.def deleted file mode 100644 index ee95427..0000000 --- a/src/models/rcview/planeArea.def +++ /dev/null @@ -1,3 +0,0 @@ -{ - shp | shps , index; -} \ No newline at end of file diff --git a/src/models/shyjview/index.js b/src/models/shyjview/index.js deleted file mode 100644 index fa12289..0000000 --- a/src/models/shyjview/index.js +++ /dev/null @@ -1,113 +0,0 @@ -import { wait } from '../../utils/tools'; -import { calWeatherContour24H, calWeatherContourRadar, calWeatherContourTm24H } from '../rcview/calculator'; - -function initState() { - return { - overallType: '24h', // 24h, radar - }; -} - -const shyjview = { - state: initState(), - reducers: { - setOverallType(state, val) { - return { ...state, overallType: val } - }, - reset() { - return initState(); - } - }, - effects: dispatch => ({ - async showWeather24h(_, state) { - /*const progress = (idx) => { - dispatch.runtime.setCalculating([idx, 25]); - return wait(100); - } - - await progress(0);*/ - - dispatch.runtime.setCalculating(true); - await wait(100); - - try { - //const contour = await calWeatherContour24H(progress); - // const contour = await calWeatherContour24H(null,1); - const contour = await calWeatherContourTm24H(null,1); - //console.log("showWeather24h 32++++++++++++++",contour); - dispatch.runtime.setLayerSetting({ contour, dem: false }); - dispatch.map.setLayerVisible({ ContourLayer: true }); - } finally { - dispatch.runtime.setCalculating(false); - } - - // dispatch.runtime.setHome(); - }, - - async showWeather24h1(_, state) { - const progress = (idx) => { - dispatch.runtime.setCalculating([idx, 25]); - return wait(100); - } - - await progress(0); - - dispatch.runtime.setCalculating(true); - await wait(100); - - try { - const contour = await calWeatherContour24H(progress,2); - //console.log("showWeather24h 32++++++++++++++",contour); - dispatch.runtime.setLayerSettingLoop({ contour, dem: false }); - //dispatch.map.setLayerVisible({ ContourLayerLoop: true }); - } finally { - dispatch.runtime.setCalculatingLoop(false); - } - - // dispatch.runtime.setHome(); - }, - - //24h面雨量逐时间 - async showWeather24h1h({myTm}) { - const progress = (idx) => { - dispatch.runtime.setCalculating([idx, 24]); - return wait(100); - } - - await progress(0); - - dispatch.runtime.setCalculating(true); - await wait(100); - - try { - const contour = await calWeatherContour24H(progress,2,myTm); - //console.log("showWeather24h 32++++++++++++++",contour); - dispatch.runtime.setLayerSettingLoop({ contour, dem: false }); - //dispatch.map.setLayerVisible({ ContourLayerLoop: true }); - } finally { - dispatch.runtime.setCalculatingLoop(false); - } - - // dispatch.runtime.setHome(); - }, - - - async showWeatherRadar({myTm}, state) { - - dispatch.runtime.setCalculating(true); - await wait(100); - try { - const contour = await calWeatherContourRadar({myTm}); - //console.log("showWeatherRadar 47+++++",contour); - dispatch.runtime.setLayerSetting({ contour, dem: false }); - dispatch.map.setLayerVisible({ ContourLayer: true }); - } finally { - dispatch.runtime.setCalculating(false); - } - - - // dispatch.runtime.setHome(); - } - }) -}; - -export default shyjview; diff --git a/src/service/forecastModule/imageSummary.js b/src/service/forecastModule/imageSummary.js deleted file mode 100644 index f77e3ff..0000000 --- a/src/service/forecastModule/imageSummary.js +++ /dev/null @@ -1,22 +0,0 @@ -import { httppost1, httppost2, httpget } from "../../utils/request"; -import { message } from 'antd'; -import apiurl from '../apiurl'; - - -//图像监控汇总 -export async function txPage(params = {}) { - const myParams = { - countycode: localStorage.getItem('ADCD6'), - ...params - } - - const { data, code, msg } = await httppost2(apiurl.imageSummary.page, myParams) || {}; - - if (code !== 200) { - message.error(msg || '请求失败'); - return { list: [], totalRow: 0 }; - } - console.log(data); - return data; -} - diff --git a/src/service/forecastModule/rainfall.js b/src/service/forecastModule/rainfall.js deleted file mode 100644 index 0e565fc..0000000 --- a/src/service/forecastModule/rainfall.js +++ /dev/null @@ -1,38 +0,0 @@ -import { httppost1, httppost2, httpget } from "../../utils/request"; -import { message } from 'antd'; -import apiurl from '../apiurl'; - -//预报-雨情-站点雨量-汇总雨情 -export async function page(params = {}) { - const myParams = { - countycode:localStorage.getItem('ADCD6'), - ...params - } - - const { data, code, msg } = await httppost2(apiurl.rainfall.summaryRain, myParams) || {}; - - if (code !== 200) { - message.error(msg || '请求失败'); - return { list: [], totalRow: 0 }; - } - return data; -} - -//预报-雨情-小流域面雨量 -export async function queryCountycodeBasinAreaRainfallApi(params = {}) { - const myParams = { - adcd:localStorage.getItem('ADCD6'), - ...params - }; - - const res = await httppost2(apiurl.rainfall.queryCountycodeBasinAreaRainfall,myParams) || {}; - - return res; -} - -//预报-雨情 小时雨量-落地雨 -export async function getStPptnRHListApi(params = {}) { - const res = await httppost2(apiurl.rainfall.getStPptnRHList,params) || {}; - - return res; -} \ No newline at end of file diff --git a/src/service/forecastModule/waterSituation.js b/src/service/forecastModule/waterSituation.js deleted file mode 100644 index 12cfbe1..0000000 --- a/src/service/forecastModule/waterSituation.js +++ /dev/null @@ -1,48 +0,0 @@ -import { httppost1, httppost2, httpget } from "../../utils/request"; -import { message } from 'antd'; -import apiurl from '../apiurl'; -import appconsts from '../../service/appconsts'; - -//汇总河道水情 -export async function hdPage(params = {}) { - const myParams = { - countycode:localStorage.getItem('ADCD6'), - ...params - } - - const { data, code, msg } = await httppost2(apiurl.waterSituation.riverWaterRegime, myParams) || {}; - - if (code !== 200) { - message.error(msg || '请求失败'); - return { list: [], totalRow: 0 }; - } - return data; -} - -//汇总水库水情 -export async function skPage(params = {}) { - const myParams = { - countycode:localStorage.getItem('ADCD6'), - ...params - } - - const { data, code, msg } = await httppost2(apiurl.waterSituation.reservoirWaterRegime, myParams) || {}; - - if (code !== 200) { - message.error(msg || '请求失败'); - return { list: [], totalRow: 0 }; - } - return data; -} - -//小流域列表查询 -//汇总水库水情 -export async function getWaterList(params = {}) { - const myParams = { - adcd:localStorage.getItem('ADCD6'), - ...params - } - const { data } = await httppost2(apiurl.getWaterList, myParams) || {}; - console.log(data); - return data || []; -} \ No newline at end of file diff --git a/src/service/warnModule/forecastWarn.js b/src/service/warnModule/forecastWarn.js deleted file mode 100644 index a39ec3a..0000000 --- a/src/service/warnModule/forecastWarn.js +++ /dev/null @@ -1,11 +0,0 @@ -import { httppost1, httppost2, httpget } from "../../utils/request"; -import { message } from 'antd'; -import apiurl from '../apiurl'; -import appconsts from '../../service/appconsts'; - -//预报预警 弹窗页的通讯录 -export async function getAddressBookApi(adcd) { - const { data, code, msg } = await httppost1(apiurl.ybyj.getAddressBook, { adcd }) || {}; - - return { data, code, msg }; -} \ No newline at end of file diff --git a/src/service/warnModule/monitorEarlyWarn.js b/src/service/warnModule/monitorEarlyWarn.js deleted file mode 100644 index 31f8614..0000000 --- a/src/service/warnModule/monitorEarlyWarn.js +++ /dev/null @@ -1,16 +0,0 @@ -import { httppost1, httppost2, httpget } from "../../utils/request"; -import { message } from 'antd'; -import apiurl from '../apiurl'; -import appconsts from '../../service/appconsts'; - -//预警-监测预警-雨量、水位监测预警 -export async function getDataListApi(params = {}) { - const myParams = { - countycode:localStorage.getItem('ADCD6') + '000000', - ...params - } - - const res = await httppost2(apiurl.shyj.find, myParams) || {}; - - return res; -} \ No newline at end of file