| | |
| | | import { Factor } from "./Factor"; |
| | | import calculate from "@/utils/map/calculate"; |
| | | import { Factor } from './Factor'; |
| | | import calculate from '@/utils/map/calculate'; |
| | | import { Legend } from './Legend'; |
| | | import moment from 'moment'; |
| | | |
| | | /** |
| | | * |
| | |
| | | // 监测因子数据,Map<String, Factor> |
| | | this.factor = new Map(); |
| | | |
| | | if (options != undefined) { |
| | | this.times = options.times; |
| | | this.lnglats_GPS = options.lnglats_GPS; |
| | | this.lnglats_GD = options.lnglats_GD; |
| | | this.coors_GD = options.coors_GD; |
| | | this.factor = options.factor; |
| | | this.legendType = Legend.S_TYPE; //图例模式 |
| | | |
| | | // if (options != undefined) { |
| | | // this.times = options.times; |
| | | // this.lnglats_GPS = options.lnglats_GPS; |
| | | // this.lnglats_GD = options.lnglats_GD; |
| | | // this.coors_GD = options.coors_GD; |
| | | // this.factor = options.factor; |
| | | // this.legendType = options.legendType; |
| | | // } |
| | | |
| | | if (typeof options === 'object') { |
| | | for (const key in options) { |
| | | if (Object.prototype.hasOwnProperty.call(options, key)) { |
| | | const value = options[key]; |
| | | this[key] = value; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | }] |
| | | */ |
| | | setData: function (dataList, drawMode, callback) { |
| | | if (dataList.length == 0) { |
| | | return; |
| | | } |
| | | this.clearData(); |
| | | |
| | | dataList.forEach((d) => { |
| | |
| | | d.values.forEach((v) => { |
| | | var f = this.factor[v.factorId]; |
| | | if (f == undefined) { |
| | | f = new Factor(); |
| | | f = new Factor({ |
| | | legendType: this.legendType |
| | | }); |
| | | this.factor[v.factorId] = f; |
| | | } |
| | | f.pushData(v, drawMode == undefined ? 0 : drawMode); |
| | | }); |
| | | }); |
| | | |
| | | |
| | | |
| | | this.convertGPS(this.lnglats_GPS, callback); |
| | | }, |
| | | |
| | | // 新增一个新数据 |
| | | addData: function (dataList, drawMode, callback) { |
| | | if (dataList.length == 0) { |
| | | return; |
| | | } |
| | | |
| | | var newGps = []; |
| | | dataList.forEach((data) => { |
| | | this.times.push(data.time); |
| | |
| | | |
| | | // 设置绘图范围 |
| | | setRange: function (key, range) { |
| | | this.factor[key].setRange(range); |
| | | this.legendType = Legend.C_TYPE; |
| | | if (key != undefined) { |
| | | this.factor[key].setRange(range); |
| | | } else { |
| | | for (const k in this.factor) { |
| | | this.factor[k].setRange(range); |
| | | } |
| | | } |
| | | }, |
| | | |
| | | // 重置绘图范围 |
| | | resetRange: function (key) { |
| | | this.factor[key].clearRange(); |
| | | this.legendType = Legend.D_TYPE; |
| | | if (key != undefined) { |
| | | this.factor[key].clearRange(); |
| | | } else { |
| | | for (const k in this.factor) { |
| | | this.factor[k].clearRange(); |
| | | } |
| | | } |
| | | }, |
| | | |
| | | // 设置为标准绘图范围 |
| | | standardRange: function (key) { |
| | | this.factor[key].standardRange(); |
| | | this.legendType = Legend.S_TYPE; |
| | | if (key != undefined) { |
| | | this.factor[key].standardRange(); |
| | | } else { |
| | | for (const k in this.factor) { |
| | | this.factor[k].standardRange(); |
| | | } |
| | | } |
| | | }, |
| | | |
| | | // 根据当前绘图范围重新计算绘图高度 |
| | |
| | | }); |
| | | }, |
| | | |
| | | getByDate(s, e) { |
| | | const sTime = moment(s).format('YYYY-MM-DD HH:mm:ss'); |
| | | const eTime = moment(e).format('YYYY-MM-DD HH:mm:ss'); |
| | | const sIndex = this.times.findIndex((v) => { |
| | | return v == sTime; |
| | | }); |
| | | const eIndex = this.times.findIndex((v) => { |
| | | return v == eTime; |
| | | }); |
| | | if (sIndex != -1 && eIndex != -1) { |
| | | return this.getByIndex(sIndex, eIndex); |
| | | } |
| | | }, |
| | | |
| | | // 获取数据长度 |
| | | length: function () { |
| | | return this.lnglats_GD.length; |
| | | }, |
| | | } |
| | | }; |
| | | |
| | | export { FactorDatas }; |