|
@@ -0,0 +1,1677 @@
|
|
|
+import { containsCoordinate, intersects } from 'ol/extent';
|
|
|
+import { OLMap } from "@/assets/map/OLMap";
|
|
|
+import '@/assets/map/popup.css'
|
|
|
+import '@/assets/map/siteinfo.css'
|
|
|
+import { gradientColors, markerZoomSize, labelZoomSize, colorRGBtoHex, jqAjax, isNumber } from "@/assets/map/maptool";
|
|
|
+import { getMax, getMin, getAverage } from "@/assets/map/maptool";
|
|
|
+import $ from "@/assets/map/jquery.min";
|
|
|
+import { Draw } from 'ol/interaction';
|
|
|
+import { createBox } from 'ol/interaction/Draw';
|
|
|
+import { Style, Icon, Text, Fill, Stroke, Circle } from 'ol/style';
|
|
|
+import { fromLonLat, transform } from 'ol/proj';
|
|
|
+import { createStringXY, format } from 'ol/coordinate';
|
|
|
+import LayerVector from 'ol/layer/Vector';
|
|
|
+import SourceVector from 'ol/source/Vector';
|
|
|
+import { Map, View, Feature, Overlay } from 'ol';
|
|
|
+
|
|
|
+/***
|
|
|
+ * weather.js页面用于业务请求处理
|
|
|
+ * 更新时间:2023.04.28
|
|
|
+ */
|
|
|
+
|
|
|
+/**
|
|
|
+ * +++++weather.js页面函数汇总+++++
|
|
|
+ * -----OLMap类扩展函数-----
|
|
|
+ * eventViewChange()
|
|
|
+ * eventOverlayClose()
|
|
|
+ * markerIsExistById()
|
|
|
+ * markerIsExistByName()
|
|
|
+ * drawRectangle()
|
|
|
+ *
|
|
|
+ *
|
|
|
+ * -----常规函数-----
|
|
|
+ * calcScope()
|
|
|
+ * createBoxByMouse()
|
|
|
+ * displayPopup()
|
|
|
+ * drawRectangle()
|
|
|
+ * getSiteStateColor()
|
|
|
+ * getTableStyle()
|
|
|
+ * getSiteLabel()
|
|
|
+ * getSiteStateColor()
|
|
|
+ * getSiteLabelColor()
|
|
|
+ * getSiteSudokuLable()
|
|
|
+ * hiddenOverlaysByLevel()
|
|
|
+ * objCopy()
|
|
|
+ * rmOverlaysByLevel()
|
|
|
+ * strOmit()
|
|
|
+ * ...
|
|
|
+ * updateSites()
|
|
|
+ * updateTagName()
|
|
|
+ *
|
|
|
+ * 涉及气象数据单位,小数位数截留等函数:
|
|
|
+ * load_data()
|
|
|
+ * updateMarkerAndLabel()
|
|
|
+ * updatePopupByFeature()
|
|
|
+ *
|
|
|
+ * 本页面请求站点查询(urlSiteQuery)调用AJAX函数
|
|
|
+ * 无
|
|
|
+ */
|
|
|
+
|
|
|
+//OLMap类扩展函数
|
|
|
+OLMap.prototype.eventViewChange = function (func) { //根据地图缩放级别控制popup弹窗的显隐
|
|
|
+ var view = this.map.getView();
|
|
|
+ var map = this.map;
|
|
|
+ var geoToMrc = this.geoToMrc;
|
|
|
+ var popupN = 0; //设置弹窗自动显示数量
|
|
|
+ view.on('change:resolution', function (event) {
|
|
|
+ let z = view.getZoom();
|
|
|
+ let r = view.getResolution();
|
|
|
+ var region = view.calculateExtent(map.getSize());
|
|
|
+ //console.log('extent: '+region);
|
|
|
+ var overlays = map.getOverlays().getArray();
|
|
|
+ var popups = []; //记录popup
|
|
|
+ //查找marker和label
|
|
|
+ for (var k in overlays) {
|
|
|
+ let oid = overlays[k].getId();
|
|
|
+ //console.log("zoom: "+z+", "+event.target.get(event.key));
|
|
|
+ // 记录位于当前视图的popup
|
|
|
+ if (oid.indexOf("popup") >= 0) {
|
|
|
+ let ep = overlays[k].get('element');
|
|
|
+ let params = JSON.parse(ep.getAttribute("desc"));
|
|
|
+ let pos = geoToMrc(params.pos);
|
|
|
+ let pt = [parseFloat(pos[0]), parseFloat(pos[1])];
|
|
|
+ //console.log('pos'+"_"+pt);
|
|
|
+ if (containsCoordinate(region, pt)) {
|
|
|
+ popups.push(overlays[k]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取当前视图下的Overlay要素
|
|
|
+ //console.log('zoom: '+z+'_'+popups.length)
|
|
|
+ if (popups.length <= popupN) {
|
|
|
+ for (var p in popups) {
|
|
|
+ if (popups[p].getPosition() != undefined) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ let ep = popups[p].get('element');
|
|
|
+ let params = JSON.parse(ep.getAttribute("desc"));
|
|
|
+ let pos = geoToMrc(params.pos);
|
|
|
+ let pt = [parseFloat(pos[0]), parseFloat(pos[1])];
|
|
|
+ //popups[p].setPosition(pt); //设置为当前站点位置
|
|
|
+ let id = popups[p].getId().split("popup_")[1];
|
|
|
+ func(id, popups[p], pt);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ view.on('change:center', function (event) {
|
|
|
+ let z = view.getZoom();
|
|
|
+ let r = view.getResolution();
|
|
|
+ var region = view.calculateExtent(map.getSize());
|
|
|
+ //console.log('chang-extent: '+region);
|
|
|
+ var overlays = map.getOverlays().getArray();
|
|
|
+ var popups = []; //记录popup
|
|
|
+ for (var k in overlays) {
|
|
|
+ let oid = overlays[k].getId();
|
|
|
+ // 记录位于当前视图的popup
|
|
|
+ if (oid.indexOf("popup") >= 0) {
|
|
|
+ let ep = overlays[k].get('element');
|
|
|
+ let params = JSON.parse(ep.getAttribute("desc"));
|
|
|
+ let pos = geoToMrc(params.pos);
|
|
|
+ let pt = [parseFloat(pos[0]), parseFloat(pos[1])];
|
|
|
+ //console.log('pos'+"_"+pt);
|
|
|
+ if (containsCoordinate(region, pt)) {
|
|
|
+ popups.push(overlays[k]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取当前视图下的Overlay要素
|
|
|
+ //console.log('zoom: '+z.toFixed(1)+'_popups: '+popups.length)
|
|
|
+ if (popups.length <= popupN) {
|
|
|
+ for (var p in popups) {
|
|
|
+ if (popups[p].getPosition() != undefined) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ let ep = popups[p].get('element');
|
|
|
+ let params = JSON.parse(ep.getAttribute("desc"));
|
|
|
+ let pos = geoToMrc(params.pos);
|
|
|
+ let pt = [parseFloat(pos[0]), parseFloat(pos[1])];
|
|
|
+ //popups[p].setPosition(pt); //设置为当前站点位置
|
|
|
+ let id = popups[p].getId().split("popup_")[1];
|
|
|
+ func(id, popups[p], pt);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+OLMap.prototype.eventOverlayClose = function () {//关闭所有弹窗
|
|
|
+ var mapDiv = this.mapDiv;
|
|
|
+ var geoToMrc = this.geoToMrc;
|
|
|
+ this.map.on('click', function (evt) {
|
|
|
+ //console.log("事件源:"+evt.target.tagName+", 类型:"+evt.type+",是否冒泡事件:"+evt.bubbles);
|
|
|
+ //去除所有Popup
|
|
|
+ var overlays = this.getOverlays().getArray();
|
|
|
+ //console.log(overlays.length);
|
|
|
+ for (var k in overlays) {
|
|
|
+ let oid = overlays[k].getId();
|
|
|
+ if (oid.indexOf("label_") >= 0) { //显示所有的Marker标注
|
|
|
+ let ep = overlays[k].get('element');
|
|
|
+ let params = JSON.parse(ep.getAttribute("desc"));
|
|
|
+ let pos = geoToMrc(params.pos);
|
|
|
+ if (params.display) { //如果标注为显示,则显示标注,这里是为了协调固定站和便携站
|
|
|
+ let pt = [parseFloat(pos[0]), parseFloat(pos[1])];
|
|
|
+ //console.log('pos'+"_"+pt);
|
|
|
+ overlays[k].setPosition(pt); //设置为当前站点位置
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (oid.indexOf("popup_") >= 0) {
|
|
|
+ overlays[k].setPosition(undefined); //隐藏所有POPUP
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+OLMap.prototype.getMarkerById = function (fid) {
|
|
|
+ var overlays = this.map.getOverlays().getArray();
|
|
|
+ for (var k in overlays) {
|
|
|
+ let layer = overlays[k];
|
|
|
+ let oid = layer.getId();
|
|
|
+ let ediv = layer.get('element');
|
|
|
+ let params = JSON.parse(ediv.getAttribute("desc"));
|
|
|
+ let id = params.id;
|
|
|
+ let name = params.name;
|
|
|
+ if (oid.indexOf("marker") >= 0 && id == fid) {
|
|
|
+ return layer;//layer.getPosition();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return undefined;
|
|
|
+}
|
|
|
+
|
|
|
+OLMap.prototype.getMarkerByName = function (fname) {
|
|
|
+ var overlays = this.map.getOverlays().getArray();
|
|
|
+ for (var k in overlays) {
|
|
|
+ let layer = overlays[k];
|
|
|
+ let oid = layer.getId();
|
|
|
+ let ediv = layer.get('element');
|
|
|
+ let params = JSON.parse(ediv.getAttribute("desc"));
|
|
|
+ let id = params.id;
|
|
|
+ let name = params.name;
|
|
|
+ if (oid.indexOf("marker") >= 0 && name == fname) {
|
|
|
+ return layer;//layer.getPosition();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return undefined;
|
|
|
+}
|
|
|
+
|
|
|
+//使用鼠标绘制矩形
|
|
|
+OLMap.prototype.drawRectangle = function (resObj) {
|
|
|
+ var source = new SourceVector({ wrapX: false });
|
|
|
+ var vector = new LayerVector({
|
|
|
+ source: source,
|
|
|
+ });
|
|
|
+ this.map.addLayer(vector); //将绘制层添加到地图容器中
|
|
|
+ var draw = new Draw({ //绘制矩形
|
|
|
+ source: source,
|
|
|
+ type: 'LineString',
|
|
|
+ style: new Style({
|
|
|
+ fill: new Fill({
|
|
|
+ color: 'rgba(255, 255, 255, 0.2)'
|
|
|
+ }),
|
|
|
+ stroke: new Stroke({
|
|
|
+ color: '#ffcc33',
|
|
|
+ width: 2
|
|
|
+ }),
|
|
|
+ image: new Circle({
|
|
|
+ radius: 7,
|
|
|
+ fill: new Fill({
|
|
|
+ color: '#ffcc33'
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }),
|
|
|
+ maxPoints: 2,
|
|
|
+ geometryFunction: createBox(),
|
|
|
+ });
|
|
|
+ this.map.addInteraction(draw);
|
|
|
+ var map = this.map;
|
|
|
+ var showZoom = this.showZoom;
|
|
|
+ var zoomMax = this.zoomMax;
|
|
|
+ var zoomMin = this.zoomMin;
|
|
|
+ draw.on('drawstart', function (e) {
|
|
|
+ source.clear(); //绘制新图形之前先清除之前的形状
|
|
|
+ resObj.html("<div style='margin:10px;color:#f00'>请在视图区使用鼠标左键点击地图<br>"
|
|
|
+ + "绘制矩形框,并确保【便携站】按<br>"
|
|
|
+ + "钮处于打开状态!</div>"); //清空便携台站数据展示页面内容
|
|
|
+ });
|
|
|
+ draw.on('drawend', function (e) { //输出绘制矩形的坐标
|
|
|
+ var coordinates_Polygon = e.feature.getGeometry().getCoordinates();
|
|
|
+ var x = [];
|
|
|
+ var y = [];
|
|
|
+ //console.log("矩形坐标:");
|
|
|
+ for (var i = 0; i < coordinates_Polygon[0].length; i++) {
|
|
|
+ //console.log(coordinates_Polygon[0][i]);
|
|
|
+ x.push(coordinates_Polygon[0][i][0]);
|
|
|
+ y.push(coordinates_Polygon[0][i][1]);
|
|
|
+ }
|
|
|
+ var xmin = getMin(x);
|
|
|
+ var xmax = getMax(x);
|
|
|
+ var ymin = getMin(y);
|
|
|
+ var ymax = getMax(y);
|
|
|
+
|
|
|
+ //查询地图中的便携点
|
|
|
+ var overlays = map.getOverlays().getArray();
|
|
|
+ var ids = []; //标记点
|
|
|
+ var cds = []; //对应的坐标点
|
|
|
+ for (var k in overlays) {
|
|
|
+ let oid = overlays[k].getId();
|
|
|
+ let ediv = overlays[k].get('element');
|
|
|
+ let params = JSON.parse(ediv.getAttribute("desc"));
|
|
|
+ let id = params.id;
|
|
|
+ let name = params.name;
|
|
|
+ let lx = params.type;
|
|
|
+ if (oid.indexOf('marker') >= 0) {
|
|
|
+ //获取当前处于显示状态标记点的坐标
|
|
|
+ if (lx == "便携站") {
|
|
|
+ let pos = overlays[k].getPosition();
|
|
|
+ if (typeof (pos) !== 'undefined') {
|
|
|
+ let _x = pos[0];
|
|
|
+ let _y = pos[1];
|
|
|
+ if (_x >= xmin && _x <= xmax && _y >= ymin && _y <= ymax) {
|
|
|
+ //console.log('拉框中的点,oid: ' + oid + ', pos: ' + pos);
|
|
|
+ ids.push(oid.split('marker_')[1]);
|
|
|
+ cds.push([_x, _y]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //console.log('CDS: ',cds);
|
|
|
+ if (ids.length == 0) {
|
|
|
+ resObj.html("<div style='margin:10px;'>无数据</div>");
|
|
|
+ } else {
|
|
|
+ //查询拉框中的标记点
|
|
|
+ //向resObj中写入数据
|
|
|
+ resObj.html(""); //清空便携台站数据展示页面内容
|
|
|
+ //let i = 0;
|
|
|
+ for (var k in overlays) {
|
|
|
+ let oid = overlays[k].getId();
|
|
|
+ let ediv = overlays[k].get('element');
|
|
|
+ let params = JSON.parse(ediv.getAttribute("desc"));
|
|
|
+ let fid = params.id;
|
|
|
+ let fname = params.name;
|
|
|
+ //console.log(fid, ids.includes(fid));
|
|
|
+ //获取弹窗中的气象信息,写入展示页面
|
|
|
+ if (oid.indexOf('popup') >= 0 && ids.includes(fid)) {
|
|
|
+ //i = i + 1;
|
|
|
+ let ftag = fid + "(" + fname + ")";
|
|
|
+ let $time = $(ediv).find("#time");
|
|
|
+ let time = $time.html();
|
|
|
+ let timeCJ = $time.attr('title');
|
|
|
+ //获取弹窗中的表格元素
|
|
|
+ let trs = $(ediv).find("table tr");
|
|
|
+ let tr1 = $(trs[1]).find("td");
|
|
|
+ let tr2 = $(trs[2]).find("td");
|
|
|
+
|
|
|
+ let wd = tr1[0].innerHTML;
|
|
|
+ let qy = tr1[2].innerHTML;
|
|
|
+ let sd = tr1[1].innerHTML;
|
|
|
+ let fx = tr2[0].innerHTML;
|
|
|
+ let fs = tr2[1].innerHTML;
|
|
|
+ let yl = tr2[2].innerHTML;
|
|
|
+
|
|
|
+ //将数据填入表格
|
|
|
+ let table = `<table class='siteTable'>`;
|
|
|
+ table = table + `<tr><td colspan=2 style='background-color:#a1bbf7;' class='siteTable-Title' id='siteTable_${k}' title='点击缩放至该台站'>${ftag}</td><td style='background-color:#a1bbf7;' class='siteTable-Time' title='${timeCJ}'>${time}<td></tr>`;
|
|
|
+ table = table + `<tr><td style='width:32%'>气温</td><td style='width:32%'>湿度</td><td>气压</td></tr>`;
|
|
|
+ table = table + `<tr><td>${wd}</td><td>${sd}</td><td>${qy}</td></tr>`;
|
|
|
+ table = table + `<tr><td>风向</td><td>风速</td><td>雨量</td></tr>`;
|
|
|
+ table = table + `<tr><td>${fx}</td><td>${fs}</td><td>${yl}</td></tr>`;
|
|
|
+ table = table + `</table>`;
|
|
|
+ let tableJq = $(table);
|
|
|
+ //点击缩放至该台站操作
|
|
|
+ tableJq.find("#siteTable_" + k).click(() => {
|
|
|
+ //根据id查找当前marker
|
|
|
+ let idx = ids.indexOf(fid);
|
|
|
+ let pos = cds[idx];
|
|
|
+ //console.log(fid,idx,pos,ids.length,cds.length);
|
|
|
+ let view = map.getView();
|
|
|
+ //let newZoom = view.getZoom() + 3;
|
|
|
+ //newZoom = newZoom <= 15 ? newZoom : 15;
|
|
|
+ let newZoom = 12;
|
|
|
+ let _view = new View({
|
|
|
+ center: pos,//fromLonLat([lon, lat]),
|
|
|
+ zoom: newZoom,
|
|
|
+ minZoom: zoomMin,
|
|
|
+ maxZoom: zoomMax,
|
|
|
+ projection: 'EPSG:3857', //设置墨卡托投影坐标系
|
|
|
+ enableRotation: false, //禁止地图旋转
|
|
|
+ });
|
|
|
+ map.setView(_view);
|
|
|
+ showZoom('mzoom', map);
|
|
|
+ });
|
|
|
+ resObj.append(tableJq);
|
|
|
+ resObj.append($('<hr/>'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return { 'source': source, 'vector': vector, 'draw': draw };
|
|
|
+}
|
|
|
+
|
|
|
+var source = null;
|
|
|
+var vector = null;
|
|
|
+var draw = null;
|
|
|
+export function createBoxByMouse(mapDiv, boxValue, resObj) {
|
|
|
+ var map = mapDiv.map;
|
|
|
+ if (boxValue) {
|
|
|
+ //alert("获取鼠标位置!");
|
|
|
+ //获取标记点
|
|
|
+ //let ids = getALLMarkersId(map);
|
|
|
+ var svd = mapDiv.drawRectangle(resObj);
|
|
|
+ source = svd.source;
|
|
|
+ vector = svd.vector;
|
|
|
+ draw = svd.draw;
|
|
|
+ } else {
|
|
|
+ map.removeInteraction(draw); //停止绘制
|
|
|
+ source = null;
|
|
|
+ if (vector != null) {
|
|
|
+ vector.setSource(source);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//更新标签名:站名和站号切换
|
|
|
+export function updateTagName(map, zhValue, zmValue) {
|
|
|
+ var types = ['tag'];
|
|
|
+ var layers = map.getOverlays().getArray();
|
|
|
+ for (let i = 0; i < layers.length; i++) {
|
|
|
+ const layer = layers[i];
|
|
|
+ let oid = layer.getId();
|
|
|
+ let ea = layer.get('element');
|
|
|
+ let params = JSON.parse(ea.getAttribute("desc"));
|
|
|
+ let id = params.id;
|
|
|
+ let name = params.name;
|
|
|
+ for (let i in types) {
|
|
|
+ if (oid.indexOf(types[i]) >= 0) { //根据切换按钮更改标签显示内容
|
|
|
+ let sname = '';
|
|
|
+ let width = 36;
|
|
|
+ let left = -18;
|
|
|
+ ea.style.setProperty('border-width', '0px');
|
|
|
+ if (zhValue && zmValue) {
|
|
|
+ sname = id + "(" + name + ")";
|
|
|
+ width = 48 + name.length * 12;
|
|
|
+ left = -width / 2 + 5;
|
|
|
+ }
|
|
|
+ if (zhValue && !zmValue) {
|
|
|
+ sname = id;
|
|
|
+ }
|
|
|
+ if (!zhValue && zmValue) {
|
|
|
+ sname = name;
|
|
|
+ width = sname.length * 12;
|
|
|
+ left = -width / 2;
|
|
|
+ }
|
|
|
+ if (!zhValue && !zmValue) {
|
|
|
+ sname = "";
|
|
|
+ width = 0;
|
|
|
+ left = 0;
|
|
|
+ ea.style.setProperty('border-width', '0px');
|
|
|
+ }
|
|
|
+ //let sname = switch_flag ? strOmit(name, 8) : id; //显示站名、站号
|
|
|
+ ea.innerHTML = sname;
|
|
|
+ ea.style.setProperty('width', width + 'px');
|
|
|
+ ea.style.setProperty('left', left + 'px');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+//更新站点类型:固定站和便携站切换
|
|
|
+export function updateSites(mapDiv, siteType, isDisplay) {
|
|
|
+ //params:
|
|
|
+ //siteType:站点类型,取值:固定站和便携站
|
|
|
+ //isDisplay: 是否显示站点,取值:true和false
|
|
|
+ var map = mapDiv.map;
|
|
|
+ var layers = map.getOverlays().getArray();
|
|
|
+ var popup_display = [];
|
|
|
+ for (var p in layers) { //筛选处于弹窗开启状态的站点ID,即切换按钮九宫格控制的台站
|
|
|
+ let layer = layers[p];
|
|
|
+ let oid = layer.getId();
|
|
|
+ let ea = layer.get('element');
|
|
|
+ let params = JSON.parse(ea.getAttribute("desc"));
|
|
|
+ if (oid.indexOf("popup_") >= 0 && params.display == true) {
|
|
|
+ popup_display.push(params.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (var i in layers) {
|
|
|
+ let layer = layers[i];
|
|
|
+ let oid = layer.getId();
|
|
|
+ let ea = layer.get('element');
|
|
|
+ let params = JSON.parse(ea.getAttribute("desc"));
|
|
|
+ let id = params.id;
|
|
|
+ //let name = params.name;
|
|
|
+ let type = params.type; //类型
|
|
|
+ let pos = mapDiv.geoToMrc(params.pos);
|
|
|
+ let pt = [parseFloat(pos[0]), parseFloat(pos[1])];
|
|
|
+ if (type == siteType) {
|
|
|
+ if (isDisplay) { //显示便携站|固定站
|
|
|
+ //显示标记和标签
|
|
|
+ if (oid.indexOf("marker_") >= 0 ||
|
|
|
+ oid.indexOf("tag_") >= 0) { //marker,label,tag
|
|
|
+ layer.setPosition(pt);
|
|
|
+ }
|
|
|
+ //有条件显示标注
|
|
|
+ if (oid.indexOf("label_") >= 0) {//如果九宫格处于关闭状态,则显示标注
|
|
|
+ if (popup_display.includes(id)) {
|
|
|
+ layer.setPosition(undefined);
|
|
|
+ } else {
|
|
|
+ layer.setPosition(pt);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //如果九宫格是显示状态,则打开
|
|
|
+ if (oid.indexOf("popup_") >= 0 && params.display == true) {
|
|
|
+ layer.setPosition(pt); //只显示标记点
|
|
|
+ }
|
|
|
+ if (oid.indexOf("label") >= 0) {
|
|
|
+ params.display = true;
|
|
|
+ }
|
|
|
+ } else { //隐藏便携站|固定站
|
|
|
+ //console.log('隐藏便携站id:', oid);
|
|
|
+ if (oid.indexOf("label_") >= 0 || oid.indexOf("marker_") >= 0 ||
|
|
|
+ oid.indexOf("tag_") || oid.indexOf("popup_") >= 0) {
|
|
|
+ params.display = false;
|
|
|
+ }
|
|
|
+ layer.setPosition(undefined);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $(ea).attr('desc', JSON.stringify(params)); //更新参数
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export function rmOverlaysByLevel(map, levels = [3], types = ['marker', 'tag', 'popup', 'pin']) {
|
|
|
+ /*清除指定Level的Markers*/
|
|
|
+ var layers = map.getOverlays().getArray();
|
|
|
+ //console.log('删除前图层数: '+layers.length);
|
|
|
+ var overlays = []
|
|
|
+ for (let i = 0; i < layers.length; i++) {
|
|
|
+ const layer = layers[i];
|
|
|
+ let oid = layer.getId();
|
|
|
+ let ediv = layer.get('element');
|
|
|
+ let params = JSON.parse(ediv.getAttribute("desc"));
|
|
|
+ let level = params.level;
|
|
|
+ for (let i in types) {
|
|
|
+ for (let j in levels) {
|
|
|
+ if (oid.indexOf(types[i]) >= 0 && level == levels[j]) {
|
|
|
+ overlays.push(layer);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (let i in overlays) {
|
|
|
+ map.removeOverlay(overlays[i]);
|
|
|
+ }
|
|
|
+ //layers = map.getOverlays().getArray();
|
|
|
+ //console.log('删除后图层数: '+layers.length);
|
|
|
+}
|
|
|
+
|
|
|
+export function hiddenOverlaysByLevel(map, hidden = true, levels = [3], types = ['marker', 'tag', 'popup', 'pin']) {
|
|
|
+ //关闭指定Level的Markers
|
|
|
+ var layers = map.getOverlays().getArray();
|
|
|
+ for (let i = 0; i < layers.length; i++) {
|
|
|
+ const layer = layers[i];
|
|
|
+ let oid = layer.getId();
|
|
|
+ let ediv = layer.get('element');
|
|
|
+ let params = JSON.parse(ediv.getAttribute("desc"));
|
|
|
+ let level = params.level;
|
|
|
+ for (let i in types) {
|
|
|
+ for (let j in levels) {
|
|
|
+ if (oid.indexOf(types[i]) >= 0 && level == levels[j]) {
|
|
|
+ if (hidden) {
|
|
|
+ ediv.classList.add("hidden");
|
|
|
+ } else {
|
|
|
+ ediv.classList.remove("hidden");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//更新所有台站九宫格颜色状态,根据设定的离线时间间隔
|
|
|
+export function updateOfflinePopups(mapDiv, offlineTime) {
|
|
|
+ //获取所有的popup
|
|
|
+ var overlays = mapDiv.map.getOverlays().getArray();
|
|
|
+ for (var k in overlays) {
|
|
|
+ let oid = overlays[k].getId();
|
|
|
+ if (oid.indexOf('popup') >= 0) {
|
|
|
+ let div = overlays[k].get('element');
|
|
|
+ let params = JSON.parse(div.getAttribute("desc"));
|
|
|
+ let id = params.id;
|
|
|
+ let zt = params.status;
|
|
|
+ let timeCJ = params.cjsj;
|
|
|
+
|
|
|
+ let trs = $(div).find("table tr");
|
|
|
+ let tr1 = $(trs[1]).find("td");
|
|
|
+ let tr2 = $(trs[2]).find("td");
|
|
|
+ //let tr3 = $(trs[3]).find("td");
|
|
|
+ let $time = $(div).find("#time");
|
|
|
+
|
|
|
+ let timeCaiji = new Date(timeCJ).getTime();
|
|
|
+ let timeNow = new Date().getTime();
|
|
|
+ let timeDiff = (timeNow - timeCaiji) / 1000 / 60 / 60 / 24;//单位:天
|
|
|
+ let setOffline = timeDiff > Number(offlineTime) ? true : false;
|
|
|
+ let title = $time.attr("title");
|
|
|
+ if (setOffline) {
|
|
|
+ $time.removeClass("normal");
|
|
|
+ $time.addClass("unnormal");
|
|
|
+ $time.attr("title", title.split(' (')[0] + ' (离线)');
|
|
|
+ } else {
|
|
|
+ $time.removeClass("unnormal");
|
|
|
+ $time.addClass("normal");
|
|
|
+ $time.attr("title", title.split(' (')[0]);
|
|
|
+ }
|
|
|
+ //console.log('更新离线弹窗:'+timeCJ+", "+timeDiff+", "+offlineTime+", "+setOffline);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function getSiteLabelColorList(dataFactor) {
|
|
|
+ var statis = null;
|
|
|
+ //console.log("气象因子: "+dataFactor);
|
|
|
+ switch (dataFactor) {
|
|
|
+ case 'wd':
|
|
|
+ statis = { 'min': -60, 'max': 60 };
|
|
|
+ break;
|
|
|
+ case 'wdzg':
|
|
|
+ statis = { 'min': -60, 'max': 60 };
|
|
|
+ break;
|
|
|
+ case 'wdzd':
|
|
|
+ statis = { 'min': -60, 'max': 60 };
|
|
|
+ break;
|
|
|
+ case 'qy':
|
|
|
+ statis = { 'min': 900, 'max': 1100 };
|
|
|
+ break;
|
|
|
+ case 'sd':
|
|
|
+ statis = { 'min': 0, 'max': 100 };
|
|
|
+ break;
|
|
|
+ case 'fs':
|
|
|
+ statis = { 'min': 0, 'max': 80 };
|
|
|
+ break;
|
|
|
+ case 'fx':
|
|
|
+ statis = { 'min': 0, 'max': 360 };
|
|
|
+ break;
|
|
|
+ case 'yl':
|
|
|
+ statis = { 'min': 0, 'max': 1000 };
|
|
|
+ break;
|
|
|
+ case 'yun':
|
|
|
+ statis = { 'min': 0, 'max': 100 };
|
|
|
+ break;
|
|
|
+ case 'njd':
|
|
|
+ statis = { 'min': 0, 'max': 5000 };
|
|
|
+ break;
|
|
|
+ case 'tq':
|
|
|
+ statis = null;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ statis = null;
|
|
|
+ }
|
|
|
+ var max = 0, min = 0;
|
|
|
+ if (statis != null) {
|
|
|
+ max = parseFloat(statis.max) + 1; //防止色带数溢出,最大值需加1
|
|
|
+ min = parseFloat(statis.min) - 1; //防止色带数溢出,最小值需减1
|
|
|
+ }
|
|
|
+ var colors = gradientColors("#0000FF", "#FF0000", parseInt(max - min));
|
|
|
+ var res = { 'color': colors, 'max': max, 'min': min };
|
|
|
+ return res;
|
|
|
+}
|
|
|
+
|
|
|
+//使用服务器端数据进行九宫格数据切换,向后台发请求
|
|
|
+//更新标记(包含坐标),标注及参数中的站点状态
|
|
|
+export function updateMarkerAndLabel(mapDiv, data, dataFactor, isUpdatePos = true) {
|
|
|
+ var map = mapDiv.map;
|
|
|
+ if (data.code == 0) { //OK
|
|
|
+ //获取数据列表
|
|
|
+ var feas = data.datas.list; //同时刻不同位置站点数据
|
|
|
+ var colorList = getSiteLabelColorList(dataFactor);
|
|
|
+ var color = colorList.color;
|
|
|
+ var min = colorList.min;
|
|
|
+ var max = colorList.max;
|
|
|
+ var overlays = map.getOverlays().getArray();
|
|
|
+ //查找pin
|
|
|
+ for (var k in overlays) {
|
|
|
+ let oid = overlays[k].getId();
|
|
|
+ let pos_chk = overlays[k].getPosition(); //判断marker的坐标是否为空
|
|
|
+ //如果为空,仅更新参数坐标,不更新实体坐标
|
|
|
+ let ediv = overlays[k].get('element');
|
|
|
+ let params = JSON.parse(ediv.getAttribute("desc"));
|
|
|
+ let id = params.id;
|
|
|
+ for (var i = 0; i < feas.length; i++) {
|
|
|
+ var fea = feas[i];
|
|
|
+ var fid = fea.ZHAN_HAO;
|
|
|
+ //var fname = fea.MING_CHENG;
|
|
|
+ var lon = fea.JING_DU; //便携站的坐标在变化
|
|
|
+ var lat = fea.WEI_DU;
|
|
|
+ var lx = fea.ZHAN_TYPE; //固定站、便携站点
|
|
|
+ var zt = fea.state; //站点状态码:正常、故障、停用、未知
|
|
|
+ var timeCJ = fea.cjsj;
|
|
|
+ zt = statusMap(zt);
|
|
|
+ var labelv = getSiteLabel(fea, dataFactor);
|
|
|
+ var label = labelv.label;
|
|
|
+ var cv = labelv.value;
|
|
|
+ // 符号化
|
|
|
+ let scolor = "#FF0000";
|
|
|
+ if (lx == "便携站") {
|
|
|
+ scolor = "#0000FF";
|
|
|
+ }
|
|
|
+ //let scolor = getSiteStateColor(zt); //站点颜色状态
|
|
|
+ let bcolor = "#FFF";
|
|
|
+ if (isNumber(cv)) {
|
|
|
+ cv = parseFloat(cv);
|
|
|
+ cv = cv > max ? max : cv;
|
|
|
+ cv = cv < min ? min : cv;
|
|
|
+ let color_idx = Math.floor((cv - min), 0);
|
|
|
+ bcolor = color[color_idx];
|
|
|
+ }
|
|
|
+ //console.log("Color: "+fcolor+", "+color_idx+", "+cv);
|
|
|
+ //更新marker样式
|
|
|
+ if (oid.split('marker_')[1] == fid) {
|
|
|
+ ediv.style.setProperty('background-color', scolor);
|
|
|
+ ediv.style.setProperty('border', '1px solid #FFF');
|
|
|
+ //更新坐标和状态参数
|
|
|
+ let pos = mapDiv.geoToMrc([lon, lat]);
|
|
|
+ let pt = [parseFloat(pos[0]), parseFloat(pos[1])];
|
|
|
+
|
|
|
+ if (isUpdatePos) {
|
|
|
+ if (typeof (pos_chk) !== 'undefined') {
|
|
|
+ overlays[k].setPosition(pt);
|
|
|
+ }
|
|
|
+ params.pos = [lon, lat];
|
|
|
+ }
|
|
|
+ params.status = zt;
|
|
|
+ params.cjsj = timeCJ;
|
|
|
+ ediv.setAttribute("desc", JSON.stringify(params));
|
|
|
+ //console.log("updateMarkerAndLabel 更新站点:" + fid + ",坐标:" + params.pos);
|
|
|
+ break; //取消要素集feas的剩余遍历
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新marker上面的文字内容及样式
|
|
|
+ if (oid.split('label_')[1] == fid) {
|
|
|
+ ediv.innerHTML = label; //更新标记文字内容
|
|
|
+ ediv.style.setProperty('color', bcolor); //更新样式
|
|
|
+ //更新坐标和状态参数
|
|
|
+ let pos = mapDiv.geoToMrc([lon, lat]);
|
|
|
+ let pt = [parseFloat(pos[0]), parseFloat(pos[1])];
|
|
|
+ if (isUpdatePos) {
|
|
|
+ if (params.display && typeof (pos_chk) !== 'undefined') {
|
|
|
+ overlays[k].setPosition(pt);
|
|
|
+ } else {
|
|
|
+ overlays[k].setPosition(undefined);
|
|
|
+ }
|
|
|
+ params.pos = [lon, lat];
|
|
|
+ }
|
|
|
+ params.status = zt;
|
|
|
+ params.cjsj = timeCJ;
|
|
|
+ ediv.setAttribute("desc", JSON.stringify(params));
|
|
|
+ break;//取消要素集feas的剩余遍历
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新标记下面的标签位置及状态参数
|
|
|
+ if (oid.split('tag_')[1] == fid) {
|
|
|
+ //更新坐标和状态参数
|
|
|
+ let pos = mapDiv.geoToMrc([lon, lat]);
|
|
|
+ let pt = [parseFloat(pos[0]), parseFloat(pos[1])];
|
|
|
+ if (isUpdatePos) {
|
|
|
+ if (typeof (pos_chk) !== 'undefined') {
|
|
|
+ overlays[k].setPosition(pt);
|
|
|
+ }
|
|
|
+ params.pos = [lon, lat];
|
|
|
+ }
|
|
|
+ params.status = zt;
|
|
|
+ params.cjsj = timeCJ;
|
|
|
+ ediv.setAttribute("desc", JSON.stringify(params));
|
|
|
+ break;//取消要素集feas的剩余遍历
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新弹窗状态参数
|
|
|
+ if (oid.split('popup_')[1] == fid) {
|
|
|
+ //更新坐标和状态参数
|
|
|
+ let pos = mapDiv.geoToMrc([lon, lat]);
|
|
|
+ let pt = [parseFloat(pos[0]), parseFloat(pos[1])];
|
|
|
+ if (isUpdatePos) {
|
|
|
+ if (params.display && typeof (pos_chk) !== 'undefined') {
|
|
|
+ overlays[k].setPosition(pt);
|
|
|
+ } else {
|
|
|
+ overlays[k].setPosition(undefined);
|
|
|
+ }
|
|
|
+ params.pos = [lon, lat];
|
|
|
+ }
|
|
|
+ params.status = zt;
|
|
|
+ params.cjsj = timeCJ;
|
|
|
+ ediv.setAttribute("desc", JSON.stringify(params));
|
|
|
+ break;//取消要素集feas的剩余遍历
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+//获取地图中站点的九宫格气象标签数据
|
|
|
+function getSiteSudokuLable(mapDiv, dataFactor) {
|
|
|
+ var map = mapDiv.map;
|
|
|
+ var overlays = map.getOverlays().getArray();
|
|
|
+ var res = new Map();
|
|
|
+ for (var k in overlays) {
|
|
|
+ let oid = overlays[k].getId();
|
|
|
+ let div = overlays[k].get('element');
|
|
|
+ let params = JSON.parse(div.getAttribute("desc"));
|
|
|
+ if (oid.indexOf('popup_') >= 0) { //获取所有的popup
|
|
|
+ let id = params.id;
|
|
|
+ //let div = popup.getElement();
|
|
|
+ let trs = $(div).find("table tr");
|
|
|
+ let tr1 = $(trs[1]).find("td");
|
|
|
+ let tr2 = $(trs[2]).find("td");
|
|
|
+ let val= $(trs[3]).find("input[id='"+dataFactor+"']")[0].value;
|
|
|
+ let wdzg = $(trs[3]).find("input[id='wdzg']")[0].value;
|
|
|
+ let wdzd = $(trs[3]).find("input[id='wdzd']")[0].value;
|
|
|
+ //console.log("-->"+val);
|
|
|
+ //向九宫格中赋新值
|
|
|
+ let wd = tr1[0].innerHTML;
|
|
|
+ let sd = tr1[1].innerHTML;
|
|
|
+ let qy = tr1[2].innerHTML;
|
|
|
+ let fx = tr2[0].innerHTML;
|
|
|
+ let fs = tr2[1].innerHTML;
|
|
|
+ let yl = tr2[2].innerHTML;
|
|
|
+ let label = "";
|
|
|
+ switch (dataFactor) {
|
|
|
+ case 'wd':
|
|
|
+ label = wd;
|
|
|
+ break;
|
|
|
+ case 'wdzg':
|
|
|
+ label = wdzg + "°C";
|
|
|
+ break;
|
|
|
+ case 'wdzd':
|
|
|
+ label = wdzd + "°C";
|
|
|
+ break;
|
|
|
+ case 'qy':
|
|
|
+ label = qy;
|
|
|
+ break;
|
|
|
+ case 'sd':
|
|
|
+ label = sd;
|
|
|
+ break;
|
|
|
+ case 'fx':
|
|
|
+ label = fx;
|
|
|
+ break;
|
|
|
+ case 'yl':
|
|
|
+ label = yl;
|
|
|
+ break;
|
|
|
+ case 'fs':
|
|
|
+ label = fs;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ label = wd;
|
|
|
+ }
|
|
|
+ res.set(id, { 'label': label, 'value': val, 'all': { 'wd': wd, 'wdzg': wdzg, 'wdzd': wdzd, 'sd': sd, 'qy': qy, 'fx': fx, 'fs': fs, 'yl': yl } });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+}
|
|
|
+//使用本地数据进行九宫格数据切换,不向后台发请求
|
|
|
+export function sudokuSwitch(mapDiv, dataFactor) {
|
|
|
+ var map = mapDiv.map;
|
|
|
+ var colorList = getSiteLabelColorList(dataFactor);
|
|
|
+ var color = colorList.color;
|
|
|
+ var min = colorList.min;
|
|
|
+ var max = colorList.max;
|
|
|
+ var overlays = map.getOverlays().getArray();
|
|
|
+ for (var k in overlays) {
|
|
|
+ let oid = overlays[k].getId();
|
|
|
+ let ediv = overlays[k].get('element');
|
|
|
+ let params = JSON.parse(ediv.getAttribute("desc"));
|
|
|
+ //更新marker上面的文字内容及样式
|
|
|
+ if (oid.indexOf('label_') >= 0) {
|
|
|
+ let fid = oid.split('label_')[1];
|
|
|
+ let labelv = getSiteSudokuLable(mapDiv, dataFactor).get(fid);
|
|
|
+ //console.log(dataFactor + ", " + JSON.stringify(labelv));
|
|
|
+ let label = labelv.label;
|
|
|
+ let value = labelv.value;
|
|
|
+ let bcolor = "#FFF"; //设置label样式
|
|
|
+ if (isNumber(value)) {
|
|
|
+ let cv = parseFloat(value);
|
|
|
+ cv = cv > max ? max : cv;
|
|
|
+ cv = cv < min ? min : cv;
|
|
|
+ let color_idx = Math.floor((cv - min), 0);
|
|
|
+ bcolor = color[color_idx];
|
|
|
+ }
|
|
|
+ ediv.innerHTML = label; //更新标记文字内容
|
|
|
+ ediv.style.setProperty('color', bcolor); //更新样式
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export function getTableStyle(flag) {
|
|
|
+ var styleList = [["正常", "popup_normal_border", "popup_normal_tdborder", "popup_normal_bg", "popup_normal_triangle"],
|
|
|
+ ["故障", "popup_abnormal_border", "popup_abnormal_tdborder", "popup_abnormal_bg", "popup_abnormal_triangle"],
|
|
|
+ ["异常", "popup_abnormal_border", "popup_abnormal_tdborder", "popup_abnormal_bg", "popup_abnormal_triangle"],
|
|
|
+ ["停用", "popup_cease_border", "popup_cease_tdborder", "popup_cease_bg", "popup_cease_triangle"],
|
|
|
+ ["危险", "popup_danger_border", "popup_danger_tdborder", "popup_danger_bg", "popup_danger_triangle"],
|
|
|
+ ["危险天气", "popup_danger_border", "popup_danger_tdborder", "popup_danger_bg", "popup_danger_triangle"],
|
|
|
+ ["离线", "popup_offline_border", "popup_offline_tdborder", "popup_offline_bg", "popup_offline_triangle"],
|
|
|
+ ["未知", "popup_unknown_border", "popup_unknown_tdborder", "popup_unknown_bg", "popup_unknown_triangle"]];
|
|
|
+ var arr;
|
|
|
+ for (var i in styleList) {
|
|
|
+ arr = styleList[i];
|
|
|
+ if (arr[0] == flag) {
|
|
|
+ return arr.slice(1, 5);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return arr.slice(1, 5);
|
|
|
+}
|
|
|
+
|
|
|
+export function getAllMarkersId(map) {
|
|
|
+ var overlays = map.getOverlays().getArray();
|
|
|
+ var ids = [];
|
|
|
+ for (var k in overlays) {
|
|
|
+ let oid = overlays[k].getId();
|
|
|
+ let ep = overlays[k].get('element');
|
|
|
+ let params = JSON.parse(ep.getAttribute("desc"));
|
|
|
+ let id = params.id;
|
|
|
+ if (oid.indexOf('marker_') >= 0) {
|
|
|
+ ids.push(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ids;
|
|
|
+}
|
|
|
+
|
|
|
+export function getAllMarkersIdAndName(map) {
|
|
|
+ var overlays = map.getOverlays().getArray();
|
|
|
+ var res = [];
|
|
|
+ for (var k in overlays) {
|
|
|
+ let oid = overlays[k].getId();
|
|
|
+ let ep = overlays[k].get('element');
|
|
|
+ let params = JSON.parse(ep.getAttribute("desc"));
|
|
|
+ let id = params.id;
|
|
|
+ let name = params.name;
|
|
|
+ if (oid.indexOf('marker_') >= 0) {
|
|
|
+ res.push({ 'id': id, 'name': name });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+}
|
|
|
+
|
|
|
+//字符串截留,超过长度n的字符串将被截断
|
|
|
+function strOmit(str, N = 8) {
|
|
|
+ var n = str.length; //字的长度
|
|
|
+ if (n > N) {
|
|
|
+ return str.slice(0, N);
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+}
|
|
|
+
|
|
|
+//根据要素数据集更新弹窗内容
|
|
|
+export function updatePopupByFeature(mapDiv, data, showPopup = false) {
|
|
|
+ //console.log(JSON.stringify(data));
|
|
|
+ var feas = data.datas.list;
|
|
|
+ var map = mapDiv.map;
|
|
|
+ var overlays = map.getOverlays().getArray();
|
|
|
+ for (var k in overlays) {
|
|
|
+ let oid = overlays[k].getId();
|
|
|
+ let div = overlays[k].get('element');
|
|
|
+ let params = JSON.parse(div.getAttribute("desc"));
|
|
|
+ let id = params.id;
|
|
|
+ let name = params.name;
|
|
|
+ if (oid.indexOf('popup_') >= 0) { //获取所有的popup
|
|
|
+ //获取弹窗中的表格元素
|
|
|
+ //let div = popup.getElement();
|
|
|
+ let trs = $(div).find("table tr");
|
|
|
+ let tr1 = $(trs[1]).find("td"); //设置带单位的气温等
|
|
|
+ let tr2 = $(trs[2]).find("td"); //设置带单位的风向等
|
|
|
+ let tr3 = $(trs[3]).find("input"); //设置气象数据
|
|
|
+ let $time = $(div).find("#time");
|
|
|
+ //遍历feature
|
|
|
+ for (let i in feas) {
|
|
|
+ let fea = feas[i];
|
|
|
+ let fid = fea.ZHAN_HAO;
|
|
|
+ if (fid == id) {
|
|
|
+ let fname = fea.MING_CHENG;
|
|
|
+ let lon = fea.JING_DU;
|
|
|
+ let lat = fea.WEI_DU;
|
|
|
+
|
|
|
+ let wdv = fea.qiwen != '' && fea.qiwen != '无数据' ? (parseFloat(fea.qiwen).toFixed(1)) : '';
|
|
|
+ let wdzgv = fea.qiwen_max != '' && fea.qiwen_max != '无数据' ? (parseFloat(fea.qiwen_max).toFixed(1)) : '';
|
|
|
+ let wdzdv = fea.qiwen_min != '' && fea.qiwen_min != '无数据' ? (parseFloat(fea.qiwen_min).toFixed(1)) : '';
|
|
|
+ let qyv = fea.qiya != '' && fea.qiya != '无数据' ? (parseFloat(fea.qiya).toFixed(1)) : '';
|
|
|
+ let sdv = fea.shidu != '' && fea.shidu != '无数据' ? (parseFloat(fea.shidu).toFixed(1)) : '';
|
|
|
+ let fxv = fea.fengxiang != '' && fea.fengxiang != '无数据' ? (parseFloat(fea.fengxiang).toFixed(0)) : '';
|
|
|
+ let ylv = fea.yuliang != '' && fea.yuliang != '无数据' ? (parseFloat(fea.yuliang).toFixed(1)) : '';
|
|
|
+ let fsv = fea.fengsu != '' && fea.fengsu != '无数据' ? (parseFloat(fea.fengsu).toFixed(1)) : '';
|
|
|
+
|
|
|
+ let wd = wdv + "°C";
|
|
|
+ let wdzg = wdzgv + "°C";
|
|
|
+ let wdzd = wdzdv + "°C";
|
|
|
+ let qy = qyv + "hPa";
|
|
|
+ let sd = sdv + "%";
|
|
|
+ let fx = fxv + "°";
|
|
|
+ let yl = ylv + "mm";
|
|
|
+ let fs = fsv + "m/s";
|
|
|
+
|
|
|
+ let time = fea.cjsj.split(' ')[1]; //截取“时:分”
|
|
|
+ time = time != undefined ? time : '';
|
|
|
+ let timeCJ = fea.cjsj; //采集时间
|
|
|
+
|
|
|
+ let zt = fea.state; //站点状态码:正常、故障、停用、未知
|
|
|
+ zt = statusMap(zt);
|
|
|
+ let styles = getTableStyle(zt);
|
|
|
+ $time.html(time);
|
|
|
+ $time.attr('title', '采集时间:' + timeCJ);
|
|
|
+
|
|
|
+ //获取容器元素设置样式
|
|
|
+ //console.log("showPopup: " + fid + ", " + zt);
|
|
|
+ $(div).find("table[name='style0']").removeClass();
|
|
|
+ $(div).find("tr[name='style2']").removeClass();
|
|
|
+ $(div).find("td[name='style1']").removeClass();
|
|
|
+ $(div).find("div[name='style3']").removeClass();
|
|
|
+
|
|
|
+ $(div).find("table[name='style0']").addClass(styles[0]);
|
|
|
+ $(div).find("tr[name='style2']").addClass(styles[2]);
|
|
|
+ $(div).find("td[name='style1']").addClass(styles[1]);
|
|
|
+ $(div).find("div[name='style3']").addClass(styles[3]);
|
|
|
+
|
|
|
+ //向九宫格中赋新值
|
|
|
+ tr1[0].innerHTML = wd;
|
|
|
+ tr1[1].innerHTML = sd;
|
|
|
+ tr1[2].innerHTML = qy;
|
|
|
+
|
|
|
+ tr2[0].innerHTML = fx;
|
|
|
+ tr2[1].innerHTML = fs;
|
|
|
+ tr2[2].innerHTML = yl;
|
|
|
+
|
|
|
+ tr3[0].value = wdv;
|
|
|
+ tr3[1].value = wdzgv;
|
|
|
+ tr3[2].value = wdzdv;
|
|
|
+ tr3[3].value = sdv;
|
|
|
+ tr3[4].value = qyv;
|
|
|
+ tr3[5].value = fxv;
|
|
|
+ tr3[6].value = fsv;
|
|
|
+ tr3[7].value = ylv;
|
|
|
+
|
|
|
+ //更新容器参数值
|
|
|
+ //var params = { level: sitelevel, status: zt, name: fname, id: fid, pos: [lon, lat] };
|
|
|
+ let params = JSON.parse($(div).attr('desc'));
|
|
|
+ params.status = zt;//更新状态
|
|
|
+ params.cjsj = timeCJ;
|
|
|
+ //params.pos=[lon,lat];
|
|
|
+ if (showPopup) {
|
|
|
+ popup.setPosition(cpoint); //设置为当前站点位置
|
|
|
+ params.display = true;
|
|
|
+ }
|
|
|
+ $(div).attr('desc', JSON.stringify(params));
|
|
|
+ //console.log('弹窗更新后信息:'+$(div).html());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function displayPopup(marker_div, id, popup_obj) {
|
|
|
+ //查找当前标记点的坐标位置
|
|
|
+ let params = JSON.parse(marker_div.getAttribute("desc"));
|
|
|
+ let pos = params.pos;
|
|
|
+ let pt = fromLonLat(pos);
|
|
|
+ //alert("当前坐标:"+pos);
|
|
|
+ //更新当前popup的坐标参数
|
|
|
+ let pop_ep = popup_obj.get('element');
|
|
|
+ let pop_params = JSON.parse(pop_ep.getAttribute("desc"));
|
|
|
+ pop_params.pos = pos;
|
|
|
+ pop_params.display = true; //设置弹窗显示标记为ture
|
|
|
+ //利用当前标记点的坐标更新对应的弹窗坐标!
|
|
|
+ pop_ep.setAttribute("desc", JSON.stringify(pop_params));
|
|
|
+ popup_obj.setPosition(pt); //设置为当前站点位置
|
|
|
+}
|
|
|
+
|
|
|
+function getSiteStateColor(zt) { //获取站点状态颜色
|
|
|
+ var c = ['#3861b5', //总数
|
|
|
+ '#419b3e', //正常
|
|
|
+ '#f1970f', //故障
|
|
|
+ '#b0413e', //危险
|
|
|
+ '#444444', //停用
|
|
|
+ '#00000']; //未知
|
|
|
+ let res = c[-1];
|
|
|
+ if (zt == "正常") { res = c[1]; }
|
|
|
+ if (zt == "故障" || zt == "异常") { res = c[2]; }
|
|
|
+ if (zt == "危险" || zt == "危险天气") { res = c[3]; }
|
|
|
+ if (zt == "停用") { res = c[4]; }
|
|
|
+ if (zt == "未知") { res = c[5]; }
|
|
|
+ return res;
|
|
|
+}
|
|
|
+
|
|
|
+function objCopy(obj) { //对象深复制
|
|
|
+ return JSON.parse(JSON.stringify(obj));
|
|
|
+}
|
|
|
+
|
|
|
+//根据要素获取弹窗表格内容
|
|
|
+function getPopupTableContent(feature) {
|
|
|
+ var fea = feature;
|
|
|
+ var fid = fea.ZHAN_HAO;
|
|
|
+ var fname = fea.MING_CHENG;
|
|
|
+ var lon = fea.JING_DU;
|
|
|
+ var lat = fea.WEI_DU;
|
|
|
+ var zt = fea.state; //站点状态码:正常、故障、停用、未知
|
|
|
+ zt = statusMap(zt);
|
|
|
+ var lx = fea.ZHAN_TYPE; //固定站、便携站点
|
|
|
+ var styles = getTableStyle(zt);
|
|
|
+ var stitle = lx + ": " + fid + "(" + fname + ")"; //站号(站名)
|
|
|
+
|
|
|
+ let wdv = fea.qiwen != '' && fea.qiwen != '无数据' ? (parseFloat(fea.qiwen).toFixed(1)) : '';
|
|
|
+ let wdzgv = fea.qiwen_max != '' && fea.qiwen_max != '无数据' ? (parseFloat(fea.qiwen_max).toFixed(1)) : '';
|
|
|
+ let wdzdv = fea.qiwen_min != '' && fea.qiwen_min != '无数据' ? (parseFloat(fea.qiwen_min).toFixed(1)) : '';
|
|
|
+ let qyv = fea.qiya != '' && fea.qiya != '无数据' ? (parseFloat(fea.qiya).toFixed(1)) : '';
|
|
|
+ let sdv = fea.shidu != '' && fea.shidu != '无数据' ? (parseFloat(fea.shidu).toFixed(1)) : '';
|
|
|
+ let fxv = fea.fengxiang != '' && fea.fengxiang != '无数据' ? (parseFloat(fea.fengxiang).toFixed(0)) : '';
|
|
|
+ let ylv = fea.yuliang != '' && fea.yuliang != '无数据' ? (parseFloat(fea.yuliang).toFixed(1)) : '';
|
|
|
+ let fsv = fea.fengsu != '' && fea.fengsu != '无数据' ? (parseFloat(fea.fengsu).toFixed(1)) : '';
|
|
|
+
|
|
|
+ let wd = wdv + "°C";
|
|
|
+ let wdzg = wdzgv + "°C";
|
|
|
+ let wdzd = wdzdv + "°C";
|
|
|
+ let qy = qyv + "hPa";
|
|
|
+ let sd = sdv + "%";
|
|
|
+ let fx = fxv + "°";
|
|
|
+ let yl = ylv + "mm";
|
|
|
+ let fs = fsv + "m/s";
|
|
|
+
|
|
|
+ let time = fea.cjsj.split(' ')[1]; //截取“时:分”
|
|
|
+ let timeCJ = fea.cjsj; //采集时间
|
|
|
+ time = time != undefined ? time : '';
|
|
|
+ //这里使用模板字符串便于将DOM转换为JS对象
|
|
|
+ let styleh = 'popup';
|
|
|
+ let style0 = styles[0];
|
|
|
+ let style1 = styles[1];
|
|
|
+ let style2 = styles[2];
|
|
|
+ let style3 = styles[3];
|
|
|
+ let div = `<div class='${styleh}'>`;
|
|
|
+ let table = `<table name='style0' class='${style0}' title='鼠标【左/右键】点击九宫格查看【详细信息/快捷菜单】'>`
|
|
|
+ + `<tr name='style2' class='${style2}' style='color:#FFF' title='点击[x]或弹窗外任意区域关闭弹窗'>`
|
|
|
+ + `<td style='height:22px' colspan=2><span id='flag_switch' style='margin-left:18px; font-size:13px; font-weight:bold' title='${stitle}'>${fid}</span></td>`
|
|
|
+ + `<td style='text-align:center; font-size:13px' id='time' title='采集时间:${timeCJ}'>${time}</td>`
|
|
|
+ + `</tr>`
|
|
|
+ + `<tr style='font-size:12px;background-color: #FFF;'>`
|
|
|
+ + `<td title='气温' style='width:50px;height:23px' name='style1' class='${style1}'>${wd}</td>`
|
|
|
+ + `<td title='湿度' style='width:50px;height:23px' name='style1' class='${style1}'>${sd}</td>`
|
|
|
+ + `<td title='气压' name='style1' class='${style1}'>${qy}</td>`
|
|
|
+ + `</tr>`
|
|
|
+ + `<tr style='font-size:12px;background-color: #FFF;'>`
|
|
|
+ + `<td title='风向' style='width:50px;height:23px' name='style1' class='${style1}'>${fx}</td>`
|
|
|
+ + `<td title='风速' name='style1' class='${style1}'>${fs}</td>`
|
|
|
+ + `<td title='雨量' name='style1' class='${style1}'>${yl}</td>`
|
|
|
+ + `</tr>`
|
|
|
+ + `<tr><td style='height:0px'>`
|
|
|
+ + `<input type='hidden' id='wd' value='${wdv}' />`
|
|
|
+ + `<input type='hidden' id='wdzg' value='${wdzgv}' />`
|
|
|
+ + `<input type='hidden' id='wdzd' value='${wdzdv}' />`
|
|
|
+ + `<input type='hidden' id='sd' value='${sdv}' />`
|
|
|
+ + `<input type='hidden' id='qy' value='${qyv}' />`
|
|
|
+ + `<input type='hidden' id='fx' value='${fxv}' />`
|
|
|
+ + `<input type='hidden' id='fs' value='${fsv}' />`
|
|
|
+ + `<input type='hidden' id='yl' value='${ylv}' />`
|
|
|
+ + `</td></tr>`
|
|
|
+ + `</table>`;
|
|
|
+ let info = div + table + `<div id='arrow' name='style3' class='${style3}'></div></div>`;
|
|
|
+ return info;
|
|
|
+}
|
|
|
+
|
|
|
+//映射站点状态
|
|
|
+function statusMap(state) {
|
|
|
+ var zt = "未知";
|
|
|
+ if (state == "不可用") { zt = "停用"; }
|
|
|
+ if (state == "超时") { zt = "故障"; }
|
|
|
+ if (state == "正常") { zt = "正常"; }
|
|
|
+ if (state == "离线") { zt = "未知"; }
|
|
|
+ //站点状态码:正常、故障、停用、未知
|
|
|
+ return zt;
|
|
|
+}
|
|
|
+//或取站点label,即marker上方的标记内容
|
|
|
+function getSiteLabel(fea, dataFactor) { //输入数据feature和气象factor
|
|
|
+ var wd = '气温'
|
|
|
+ var sd = '湿度';
|
|
|
+ var qy = '气压';
|
|
|
+ var fx = '风向';
|
|
|
+ var yun = '云量';
|
|
|
+ var yl = '雨量';
|
|
|
+ var fs = '风速';
|
|
|
+ var njd = '能见度';
|
|
|
+ var tq = '天气';
|
|
|
+ var label = '';
|
|
|
+ var cv = 0;
|
|
|
+ var fd = null;
|
|
|
+ switch (dataFactor) {
|
|
|
+ case 'wd':
|
|
|
+ fd = fea.qiwen; //fd: feature data
|
|
|
+ wd = fd != '' && fd != '无数据' ? parseFloat(fd).toFixed(1) : '';
|
|
|
+ label = wd != '' ? (wd + "°C") : '';
|
|
|
+ cv = wd;
|
|
|
+ break;
|
|
|
+ case 'wdzg':
|
|
|
+ fd = fea.qiwen_max; //fd: feature data
|
|
|
+ wd = fd != '' && fd != '无数据' ? parseFloat(fd).toFixed(1) : '';
|
|
|
+ label = wd != '' ? (wd + "°C") : '';
|
|
|
+ cv = wd;
|
|
|
+ break;
|
|
|
+ case 'wdzd':
|
|
|
+ fd = fea.qiwen_min; //fd: feature data
|
|
|
+ wd = fd != '' && fd != '无数据' ? parseFloat(fd).toFixed(1) : '';
|
|
|
+ label = wd != '' ? (wd + "°C") : '';
|
|
|
+ cv = wd;
|
|
|
+ break;
|
|
|
+ case 'qy':
|
|
|
+ fd = fea.qiya;
|
|
|
+ qy = fd != '' && fd != '无数据' ? parseFloat(fd).toFixed(1) : '';
|
|
|
+ label = qy != '' ? (qy + "hPa") : '';
|
|
|
+ cv = qy;
|
|
|
+ break;
|
|
|
+ case 'sd':
|
|
|
+ fd = fea.shidu;
|
|
|
+ sd = fd != '' && fd != '无数据' ? parseFloat(fd).toFixed(1) : '';
|
|
|
+ label = sd != '' ? (sd + "%") : '';
|
|
|
+ cv = sd;
|
|
|
+ break;
|
|
|
+ case 'fx':
|
|
|
+ fd = fea.fengxiang;
|
|
|
+ fx = fd != '' && fd != '无数据' ? parseFloat(fd).toFixed(0) : '';
|
|
|
+ label = fx != '' ? (fx + "°") : '';
|
|
|
+ cv = fx;
|
|
|
+ break;
|
|
|
+ case 'yun':
|
|
|
+ fd = fea.yunliang;
|
|
|
+ yun = fd != '' && fd != '无数据' ? parseFloat(fd).toFixed(1) : '';
|
|
|
+ label = yun != '' ? (yun + "%") : '';
|
|
|
+ cv = yun;
|
|
|
+ break;
|
|
|
+ case 'yl':
|
|
|
+ fd = fea.yuliang;
|
|
|
+ yl = fd != '' && fd != '无数据' ? parseFloat(fd).toFixed(1) : '';
|
|
|
+ label = yl != '' ? (yl + "mm") : '';
|
|
|
+ cv = yl;
|
|
|
+ break;
|
|
|
+ case 'fs':
|
|
|
+ fd = fea.fengsu;
|
|
|
+ fs = fd != '' && fd != '无数据' ? parseFloat(fd).toFixed(1) : '';
|
|
|
+ label = fs != '' ? (fs + "m/s") : '';
|
|
|
+ cv = fs;
|
|
|
+ break;
|
|
|
+ case 'njd':
|
|
|
+ fd = fea.njd;
|
|
|
+ njd = fd != '' && fd != '无数据' ? parseFloat(fd).toFixed(0) : '';
|
|
|
+ label = njd != '' ? (njd + "km") : '';
|
|
|
+ cv = njd;
|
|
|
+ break;
|
|
|
+ case 'tq':
|
|
|
+ fd = fea.tqxx;
|
|
|
+ tq = fd != '' && fd != '无数据' ? fd : '';
|
|
|
+ label = tq + '';
|
|
|
+ cv = tq;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ fd = fea.qiwen;
|
|
|
+ wd = fd != '' ? parseFloat(fd).toFixed(1) : '';
|
|
|
+ label = fd != '' ? (wd + "°C") : '';
|
|
|
+ cv = wd;
|
|
|
+ }
|
|
|
+ return { 'label': label, 'value': cv };
|
|
|
+}
|
|
|
+
|
|
|
+//加载台站数据主函数
|
|
|
+export function load_data(mapDiv, data, dataFactor, sitelevel, leftClick, rightClick, jggChange, setView = false, showTag = false) {
|
|
|
+ var ids = [];//记录新添加到地图中的站点编号
|
|
|
+ if (data.code == 0) { //状态: OK
|
|
|
+ var feas = data.datas.list;
|
|
|
+ var colorList = getSiteLabelColorList(dataFactor);
|
|
|
+ var color = colorList.color;
|
|
|
+ var min = colorList.min;
|
|
|
+ var max = colorList.max;
|
|
|
+ if (dataFactor == 'fx') { //风向-蓝色
|
|
|
+ color = "#0000FF";
|
|
|
+ }
|
|
|
+ if (dataFactor == 'qy') { //气压-绿色
|
|
|
+ color = "#00FF00";
|
|
|
+ }
|
|
|
+ var lons = [];
|
|
|
+ var lats = [];
|
|
|
+ //添加点位
|
|
|
+ for (var i = 0; i < feas.length; i++) {
|
|
|
+ var fea = feas[i];
|
|
|
+ var fid = fea.ZHAN_HAO;
|
|
|
+ var fname = fea.MING_CHENG;
|
|
|
+ var lon = fea.JING_DU;
|
|
|
+ var lat = fea.WEI_DU;
|
|
|
+
|
|
|
+ var zt = fea.state; //站点状态码:正常、故障、停用、未知
|
|
|
+ if (zt == "离线") continue; //如果返回状态为空,不加载站点
|
|
|
+
|
|
|
+ zt = statusMap(zt); //转换站点状态
|
|
|
+ var lx = fea.ZHAN_TYPE; //固定站、便携站点
|
|
|
+ var time = fea.cjsj.split(' ')[1]; //截取“时:分”
|
|
|
+ var timeCJ = fea.cjsj; //采集时间
|
|
|
+ //time = time != undefined ? time : '';
|
|
|
+ //var style = getTableStyle(zt);
|
|
|
+ //var stitle = lx + ": " + fid + "(" + fname + ")"; //站号(站名)
|
|
|
+ var params = { level: sitelevel, status: zt, name: fname, id: fid, pos: [lon, lat], type: lx, cjsj: timeCJ };
|
|
|
+ var params_label = objCopy(params);
|
|
|
+ params_label.display = true; //标注默认显示
|
|
|
+ var params_popup = objCopy(params);
|
|
|
+ params_popup.display = false; //弹窗默认不显示
|
|
|
+
|
|
|
+ lons.push(lon);
|
|
|
+ lats.push(lat);
|
|
|
+
|
|
|
+ var labelv = getSiteLabel(fea, dataFactor);
|
|
|
+ var label = labelv.label;
|
|
|
+ var cv = labelv.value;
|
|
|
+
|
|
|
+ document.oncontextmenu = function (e) {
|
|
|
+ //去掉默认的contextmenu事件,否则会和右键事件同时出现。
|
|
|
+ e.preventDefault();
|
|
|
+ };
|
|
|
+
|
|
|
+ // 符号化
|
|
|
+ let scolor = "#FF0000";
|
|
|
+ if (lx == "便携站") {
|
|
|
+ scolor = "#0000FF";
|
|
|
+ }
|
|
|
+
|
|
|
+ //let scolor = getSiteStateColor(zt);
|
|
|
+ let bcolor = "#FFF"; //设置label样式
|
|
|
+ if (isNumber(cv)) {
|
|
|
+ cv = parseFloat(cv);
|
|
|
+ cv = cv > max ? max : cv;
|
|
|
+ cv = cv < min ? min : cv;
|
|
|
+ let color_idx = Math.floor((cv - min), 0);
|
|
|
+ bcolor = color[color_idx];
|
|
|
+ }
|
|
|
+
|
|
|
+ //点位去重检查
|
|
|
+ //var m = mapDiv.markerIsExist([lon, lat]);
|
|
|
+ var m = mapDiv.markerIsExistById(fid); //站点编号不重复,坐标有可能重复
|
|
|
+ //console.log("站点是否存在:" + fid + ", " + m);
|
|
|
+ if (!m) { //站点不存在就添加
|
|
|
+ let jggInfo = getPopupTableContent(fea); //获取弹窗表格内容
|
|
|
+ mapDiv.addPopup([lon, lat], 0, fid, jggInfo, leftClick, rightClick, jggChange,
|
|
|
+ params_popup); //点击台站显示的九宫格弹窗
|
|
|
+ mapDiv.addMarkerLabel([lon, lat], 1, fid, label, params_label,
|
|
|
+ { color: bcolor }) //台站标记上方的属性标注,如900hPa
|
|
|
+ mapDiv.addMarker([lon, lat], fid, label, scolor, 0.8, params,
|
|
|
+ { width: '8px', height: '8px' }, displayPopup, jggChange); //台站标记,绿、橙、红、黑
|
|
|
+
|
|
|
+ if (showTag) { //台站标记下方的标签
|
|
|
+ let tag = fid;
|
|
|
+ mapDiv.addTag([lon, lat], fid, tag, params, { color: '#000', fontSize: '11px' })
|
|
|
+ }
|
|
|
+ ids.push(fid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //mapDiv.eventOverlayClose(); //添加单击地图关闭弹窗事件
|
|
|
+ mapDiv.eventViewChange(displayPopup);
|
|
|
+ //设置当前显示范围
|
|
|
+ if (setView && lats.length>0 && lons.length>0) {
|
|
|
+ let scope = calcScope(lons, lats, 1);
|
|
|
+ mapDiv.setViewByExtent(scope);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw ("加载数据失败,数据标识:" + data.msg);
|
|
|
+ }
|
|
|
+ return ids;
|
|
|
+}
|
|
|
+
|
|
|
+function calcScope(lonArr, latArr, offset = 0) {
|
|
|
+ let lonMin = Math.min(...lonArr) - offset;
|
|
|
+ let lonMax = Math.max(...lonArr) + offset;
|
|
|
+ let latMin = Math.min(...latArr) - offset;
|
|
|
+ let latMax = Math.max(...latArr) + offset;
|
|
|
+ return [lonMin, latMin, lonMax, latMax];
|
|
|
+}
|
|
|
+
|
|
|
+//筛选新入库站点的feature
|
|
|
+export function getAddSitesData(ids_old, data) {
|
|
|
+ var data_new = objCopy(data); //新站点数据
|
|
|
+ data_new.datas.list = []; //清空列表
|
|
|
+ var ids_add = [];
|
|
|
+ var len = 0;
|
|
|
+ if (data.code == 0) { //状态:OK
|
|
|
+ var feas = data.datas.list;
|
|
|
+ for (var i = 0; i < feas.length; i++) {
|
|
|
+ var fea = feas[i]; //ids_old:[1,2,3]
|
|
|
+ var fid = fea.ZHAN_HAO; //fid:[3,4,5]
|
|
|
+ var fs=fea.state;
|
|
|
+ if (!ids_old.includes(fid) && fs!="离线") { //当前的fid是新入库站点
|
|
|
+ data_new.datas.list.push(fea);
|
|
|
+ ids_add.push(fid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ len = data_new.datas.list.length;
|
|
|
+ return { 'data': data_new, 'ids': ids_add, 'length': len };
|
|
|
+}
|
|
|
+
|
|
|
+//筛选被删掉站点的id
|
|
|
+export function getDelSitesData(ids_old, data) {
|
|
|
+ var len = 0;
|
|
|
+ var data_remain = objCopy(data); //刷新后待保留的站点
|
|
|
+ data_remain.datas.list = []; //清空列表
|
|
|
+ let ids_new = [];
|
|
|
+ let ids_del = [];
|
|
|
+ if (data.code == 0) { //状态:OK
|
|
|
+ var feas = data.datas.list;
|
|
|
+ for (var i = 0; i < feas.length; i++) {
|
|
|
+ var fea = feas[i];
|
|
|
+ var fid = fea.ZHAN_HAO;
|
|
|
+ ids_new.push(fid);
|
|
|
+ if (ids_old.includes(fid)) { //ids_old:[1,2,3]
|
|
|
+ //ids_new:[3,4,5]
|
|
|
+ data_remain.datas.list.push(fea);//保留点[3]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (let i in ids_old) {//ids_old:[1,2,3]
|
|
|
+ let fid = ids_old[i]; //ids_new:[3,4,5]
|
|
|
+ if (!ids_new.includes(fid)) { //当前的fid是已被删掉的站点
|
|
|
+ ids_del.push(fid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ len = ids_del.length;
|
|
|
+ return { 'ids': ids_del, 'length': len, 'remainData': data_remain };
|
|
|
+}
|
|
|
+///////////////////////////////////////////////////////////////////
|
|
|
+
|
|
|
+function getRandom(m, n) {
|
|
|
+ return Math.random() * (n - m) + m;
|
|
|
+}
|
|
|
+function getPosRand(offset = 0) {
|
|
|
+ let latn = 42;
|
|
|
+ let lats = 25;
|
|
|
+ let lonw = 96;
|
|
|
+ let lone = 121;
|
|
|
+ let lat = getRandom(lats, latn) + offset;
|
|
|
+ let lon = getRandom(lonw, lone) + offset;
|
|
|
+ return { 'lat': lat, 'lon': lon };
|
|
|
+}
|
|
|
+
|
|
|
+function timeFormat(date = new Date()) {
|
|
|
+ //var date = new Date();
|
|
|
+ let year = date.getFullYear();
|
|
|
+ let month = date.getMonth() + 1;
|
|
|
+ let day = date.getDate();
|
|
|
+ let hours = date.getHours();
|
|
|
+ let minutes = date.getMinutes();
|
|
|
+ let seconds = date.getSeconds();
|
|
|
+ let res = year + "-" + month + "-" + day + " " + hours + ":" + minutes +
|
|
|
+ ":" + seconds;
|
|
|
+ return res;
|
|
|
+}
|
|
|
+//模拟返回数据
|
|
|
+export function res_data_simu0() {
|
|
|
+ var data = {
|
|
|
+ "code": 0,
|
|
|
+ "msg": "OK",
|
|
|
+ "datas": {
|
|
|
+ "list": [
|
|
|
+ { "ZI_DONG_ZHAN_ID": "5D0D05FF50B64D9D921C1C82F6E98BD8", "MING_CHENG": "1号站点", "ZHAN_HAO": "1", "ZHAN_TYPE": "固定站", "JING_DU": "119", "WEI_DU": "34", "DATA_TYPE": "--", "qiwen": "23.4", "qiwen_min": "19.8", "qiwen_max": "33.5", "qiya": "1013.5", "shidu": "56", "fengxiang": "177", "yuliang": "0.000000", "fengsu": "4.5", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-02-21 10:11:26", "cjsjc": "1676945460", "data_update_time": "1676945381", "meta_update_time": "1676620809", "state": "正常", "danger": "" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "5D0D05FF50B64D9D921C1C82F6E98BD9", "MING_CHENG": "2号站点", "ZHAN_HAO": "2", "ZHAN_TYPE": "便携站", "JING_DU": 119.07276805058684, "WEI_DU": 33.57725633349737, "DATA_TYPE": "--", "qiwen": "23.4", "qiwen_min": "19.8", "qiwen_max": "33.5", "qiya": "1013.5", "shidu": "56", "fengxiang": "177", "yuliang": "0.000000", "fengsu": "4.5", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-03-21 15:11:01", "cjsjc": "1676945460", "data_update_time": "1676945381", "meta_update_time": "1676620809", "state": "正常", "danger": "大风" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "5D0D05FF50B64D9D921C1C82F6E98BD9", "MING_CHENG": "3号站点", "ZHAN_HAO": "3", "ZHAN_TYPE": "便携站", "JING_DU": 120.37001083785111, "WEI_DU": 31.31200379255739, "DATA_TYPE": "--", "qiwen": "23.4", "qiwen_min": "19.8", "qiwen_max": "33.5", "qiya": "1013.5", "shidu": "56", "fengxiang": "177", "yuliang": "0.000000", "fengsu": "4.5", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-04-21 20:11:34", "cjsjc": "1676945460", "data_update_time": "1676945381", "meta_update_time": "1676620809", "state": "超时", "danger": "" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "5D0D05FF50B64D9D921C1C82F6E98BD9", "MING_CHENG": "4号站点", "ZHAN_HAO": "4", "ZHAN_TYPE": "便携站", "JING_DU": 120.94426237086982, "WEI_DU": 32.161930989038005, "DATA_TYPE": "--", "qiwen": "23.4", "qiwen_min": "19.8", "qiwen_max": "33.5", "qiya": "1013.5", "shidu": "56", "fengxiang": "177", "yuliang": "0.000000", "fengsu": "4.5", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-02-21 10:11:06", "cjsjc": "1676945460", "data_update_time": "1676945381", "meta_update_time": "1676620809", "state": "正常", "danger": "" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "E6B84175CDEE4481A65D19E4F1C4A095", "MING_CHENG": "M1号站点", "ZHAN_HAO": "M1", "ZHAN_TYPE": "便携站", "JING_DU": 109.33988134137039, "WEI_DU": 27.862424830783905, "DATA_TYPE": "--", "qiwen": -31, "qiwen_min": -36, "qiwen_max": -26, "qiya": "949.5", "shidu": "54", "fengxiang": "325", "yuliang": "0.00", "fengsu": "4.30", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-11-27 20:22:5", "cjsjc": "1670915880", "data_update_time": "1670915903", "meta_update_time": "1671691090", "state": "正常", "danger": "冰雹" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "E6B84175CDEE4481A65D19E4F1C4A095", "MING_CHENG": "M2号站点", "ZHAN_HAO": "M2", "ZHAN_TYPE": "便携站", "JING_DU": 117.02682959359893, "WEI_DU": 32.11829392952986, "DATA_TYPE": "--", "qiwen": -5, "qiwen_min": -10, "qiwen_max": 0, "qiya": "949.5", "shidu": "54", "fengxiang": "325", "yuliang": "0.00", "fengsu": "4.30", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-11-27 20:22:5", "cjsjc": "1670915880", "data_update_time": "1670915903", "meta_update_time": "1671691090", "state": "超时", "danger": "冰雹" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "E6B84175CDEE4481A65D19E4F1C4A095", "MING_CHENG": "M5号站点", "ZHAN_HAO": "M5", "ZHAN_TYPE": "固定站", "JING_DU": 103.48072941367461, "WEI_DU": 31.509770277237656, "DATA_TYPE": "--", "qiwen": 28, "qiwen_min": 23, "qiwen_max": 33, "qiya": "949.5", "shidu": "54", "fengxiang": "325", "yuliang": "0.00", "fengsu": "4.30", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-11-27 20:22:5", "cjsjc": "1670915880", "data_update_time": "1670915903", "meta_update_time": "1671691090", "state": "超时", "danger": "冰雹" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "E6B84175CDEE4481A65D19E4F1C4A095", "MING_CHENG": "M6号站点", "ZHAN_HAO": "M6", "ZHAN_TYPE": "便携站", "JING_DU": 118.8144837593801, "WEI_DU": 28.33239418178894, "DATA_TYPE": "--", "qiwen": -26, "qiwen_min": -31, "qiwen_max": -21, "qiya": "949.5", "shidu": "54", "fengxiang": "325", "yuliang": "0.00", "fengsu": "4.30", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-11-27 20:22:5", "cjsjc": "1670915880", "data_update_time": "1670915903", "meta_update_time": "1671691090", "state": "正常", "danger": "冰雹" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "E6B84175CDEE4481A65D19E4F1C4A095", "MING_CHENG": "M4号站点", "ZHAN_HAO": "M4", "ZHAN_TYPE": "便携站", "JING_DU": 98.67928314600218, "WEI_DU": 30.683067214473823, "DATA_TYPE": "--", "qiwen": 36, "qiwen_min": 31, "qiwen_max": 41, "qiya": "949.5", "shidu": "54", "fengxiang": "325", "yuliang": "0.00", "fengsu": "4.30", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-11-27 20:22:5", "cjsjc": "1670915880", "data_update_time": "1670915903", "meta_update_time": "1671691090", "state": "不可用", "danger": "冰雹" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "E6B84175CDEE4481A65D19E4F1C4A095", "MING_CHENG": "M3号站点", "ZHAN_HAO": "M3", "ZHAN_TYPE": "便携站", "JING_DU": 102.07964462186851, "WEI_DU": 40.94762732290464, "DATA_TYPE": "--", "qiwen": 30, "qiwen_min": 25, "qiwen_max": 35, "qiya": "949.5", "shidu": "54", "fengxiang": "325", "yuliang": "0.00", "fengsu": "4.30", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-11-27 20:22:5", "cjsjc": "1670915880", "data_update_time": "1670915903", "meta_update_time": "1671691090", "state": "", "danger": "冰雹" }]
|
|
|
+ ,
|
|
|
+ "numbers": {
|
|
|
+ "state_running_count": 3,
|
|
|
+ "state_stop_count": 1,
|
|
|
+ "state_error_count": 2,
|
|
|
+ "state_danger_count": 6,
|
|
|
+ },
|
|
|
+ "global_qiwen": {
|
|
|
+ "min": "-20.799999",
|
|
|
+ "max": "33.5"
|
|
|
+ },
|
|
|
+ "global_qiya": {
|
|
|
+ "min": "0.000000",
|
|
|
+ "max": "1013.5"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "elapsed time": "423548us"
|
|
|
+ };
|
|
|
+ return data;
|
|
|
+}
|
|
|
+export function res_data_simu(dynamic = false) {
|
|
|
+ if (!dynamic) { //静态站点
|
|
|
+ var data = {
|
|
|
+ "code": 0,
|
|
|
+ "msg": "OK",
|
|
|
+ "datas": {
|
|
|
+ "list": [
|
|
|
+ { "ZI_DONG_ZHAN_ID": "5D0D05FF50B64D9D921C1C82F6E98BD8", "MING_CHENG": "1号站点", "ZHAN_HAO": "1", "ZHAN_TYPE": "固定站", "JING_DU": 119, "WEI_DU": 34, "DATA_TYPE": "--", "qiwen": "23.4", "qiwen_min": "19.8", "qiwen_max": "33.5", "qiya": "1013.5", "shidu": "56", "fengxiang": "177", "yuliang": "0.000000", "fengsu": "4.5", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-02-21 10:11:01", "cjsjc": "1676945460", "data_update_time": "1676945381", "meta_update_time": "1676620809", "state": "正常", "danger": "" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "5D0D05FF50B64D9D921C1C82F6E98BD9", "MING_CHENG": "2号站点", "ZHAN_HAO": "2", "ZHAN_TYPE": "便携站", "JING_DU": 119.29704363940438, "WEI_DU": 32.316579115599914, "DATA_TYPE": "--", "qiwen": "23.4", "qiwen_min": "19.8", "qiwen_max": "33.5", "qiya": "1000.5", "shidu": "56", "fengxiang": "177", "yuliang": "0.000000", "fengsu": "4.5", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-03-21 10:31:08", "cjsjc": "1676945460", "data_update_time": "1676945381", "meta_update_time": "1676620809", "state": "正常", "danger": "大风" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "5D0D05FF50B64D9D921C1C82F6E98BD9", "MING_CHENG": "3号站点", "ZHAN_HAO": "3", "ZHAN_TYPE": "便携站", "JING_DU": 120.63246664260988, "WEI_DU": 32.743683255511314, "DATA_TYPE": "--", "qiwen": "23.4", "qiwen_min": "19.8", "qiwen_max": "33.5", "qiya": "800.5", "shidu": "56", "fengxiang": "177", "yuliang": "0.000000", "fengsu": "4.5", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-04-21 10:11:34", "cjsjc": "1676945460", "data_update_time": "1676945381", "meta_update_time": "1676620809", "state": "超时", "danger": "" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "5D0D05FF50B64D9D921C1C82F6E98BD9", "MING_CHENG": "4号站点", "ZHAN_HAO": "4", "ZHAN_TYPE": "便携站", "JING_DU": 120.04603494157196, "WEI_DU": 32.1159969158977, "DATA_TYPE": "--", "qiwen": "23.4", "qiwen_min": "19.8", "qiwen_max": "33.5", "qiya": "900.5", "shidu": "56", "fengxiang": "177", "yuliang": "0.000000", "fengsu": "4.5", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-04-25 10:11:21", "cjsjc": "1676945460", "data_update_time": "1676945381", "meta_update_time": "1676620809", "state": "超时", "danger": "" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "E6B84175CDEE4481A65D19E4F1C4A095", "MING_CHENG": "M1号站点", "ZHAN_HAO": "M1", "ZHAN_TYPE": "便携站", "JING_DU": 105.27518105770783, "WEI_DU": 27.747750119537017, "DATA_TYPE": "--", "qiwen": 13, "qiwen_min": 8, "qiwen_max": 18, "qiya": "949.5", "shidu": "54", "fengxiang": "325", "yuliang": "0.00", "fengsu": "4.30", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-09-22 15:41:29", "cjsjc": "1670915880", "data_update_time": "1670915903", "meta_update_time": "1671691090", "state": "超时", "danger": "冰雹" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "E6B84175CDEE4481A65D19E4F1C4A095", "MING_CHENG": "M2号站点", "ZHAN_HAO": "M2", "ZHAN_TYPE": "便携站", "JING_DU": 113.71362071076472, "WEI_DU": 36.191964410795535, "DATA_TYPE": "--", "qiwen": -27, "qiwen_min": -32, "qiwen_max": -22, "qiya": "949.5", "shidu": "54", "fengxiang": "325", "yuliang": "0.00", "fengsu": "4.30", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-11-23 15:41:29", "cjsjc": "1670915880", "data_update_time": "1670915903", "meta_update_time": "1671691090", "state": "正常", "danger": "冰雹" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "E6B84175CDEE4481A65D19E4F1C4A095", "MING_CHENG": "M5号站点", "ZHAN_HAO": "M5", "ZHAN_TYPE": "便携站", "JING_DU": 98.45219490225608, "WEI_DU": 36.330597566836886, "DATA_TYPE": "--", "qiwen": -41, "qiwen_min": -46, "qiwen_max": -36, "qiya": "949.5", "shidu": "54", "fengxiang": "325", "yuliang": "0.00", "fengsu": "4.30", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-11-24 15:41:29", "cjsjc": "1670915880", "data_update_time": "1670915903", "meta_update_time": "1671691090", "state": "超时", "danger": "冰雹" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "E6B84175CDEE4481A65D19E4F1C4A095", "MING_CHENG": "M4号站点", "ZHAN_HAO": "M4", "ZHAN_TYPE": "便携站", "JING_DU": 115.7280218752159, "WEI_DU": 36.74062592459678, "DATA_TYPE": "--", "qiwen": 0.1, "qiwen_min": -5, "qiwen_max": 5, "qiya": "949.5", "shidu": "54", "fengxiang": "325", "yuliang": "0.00", "fengsu": "4.30", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-11-25 15:41:29", "cjsjc": "1670915880", "data_update_time": "1670915903", "meta_update_time": "1671691090", "state": "正常", "danger": "冰雹" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "E6B84175CDEE4481A65D19E4F1C4A095", "MING_CHENG": "M3号站点", "ZHAN_HAO": "M3", "ZHAN_TYPE": "便携站", "JING_DU": 113.15779455530073, "WEI_DU": 39.22608953803255, "DATA_TYPE": "--", "qiwen": 11, "qiwen_min": 6, "qiwen_max": 16, "qiya": "949.5", "shidu": "54", "fengxiang": "325", "yuliang": "0.00", "fengsu": "4.30", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-11-26 15:41:29", "cjsjc": "1670915880", "data_update_time": "1670915903", "meta_update_time": "1671691090", "state": "超时", "danger": "冰雹" },
|
|
|
+ { "ZI_DONG_ZHAN_ID": "E6B84175CDEE4481A65D19E4F1C4A095", "MING_CHENG": "M6号站点", "ZHAN_HAO": "M6", "ZHAN_TYPE": "便携站", "JING_DU": 109.82567827010885, "WEI_DU": 42.27176743020384, "DATA_TYPE": "--", "qiwen": '0', "qiwen_min": -11, "qiwen_max": 8, "qiya": "949.5", "shidu": "54", "fengxiang": "325", "yuliang": "0.00", "fengsu": "4.30", "njd": "-16777215", "tqxx": "无数据", "cjsj": "2023-11-26 15:41:29", "cjsjc": "1670915880", "data_update_time": "1670915903", "meta_update_time": "1671691090", "state": "正常", "danger": "冰雹" }
|
|
|
+ ],
|
|
|
+ "numbers": {
|
|
|
+ "state_running_count": 5,
|
|
|
+ "state_stop_count": 0,
|
|
|
+ "state_error_count": 5,
|
|
|
+ "state_danger_count": 7,
|
|
|
+ },
|
|
|
+ "global_qiwen": {
|
|
|
+ "min": "-20.799999",
|
|
|
+ "max": "33.5"
|
|
|
+ },
|
|
|
+ "global_qiya": {
|
|
|
+ "min": "0.000000",
|
|
|
+ "max": "1013.5"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "elapsed time": "423548us"
|
|
|
+ };
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+ if (dynamic) { //动态站点
|
|
|
+ var data = {
|
|
|
+ "code": 0,
|
|
|
+ "msg": "OK",
|
|
|
+ "datas": {
|
|
|
+ "list": [
|
|
|
+ {
|
|
|
+ "ZI_DONG_ZHAN_ID": "5D0D05FF50B64D9D921C1C82F6E98BD8",
|
|
|
+ "MING_CHENG": "1号站点",
|
|
|
+ "ZHAN_HAO": "1",
|
|
|
+ "ZHAN_TYPE": "固定站",
|
|
|
+ "JING_DU": "119",
|
|
|
+ "WEI_DU": "34",
|
|
|
+ "DATA_TYPE": "--",
|
|
|
+ "qiwen": "23.4",
|
|
|
+ "qiwen_min": "19.8",
|
|
|
+ "qiwen_max": "33.5",
|
|
|
+ "qiya": "1013.5",
|
|
|
+ "shidu": "56",
|
|
|
+ "fengxiang": "177",
|
|
|
+ "yuliang": "0.000000",
|
|
|
+ "fengsu": "4.5",
|
|
|
+ "njd": "-16777215",
|
|
|
+ "tqxx": "无数据",
|
|
|
+ "cjsj": "2023-02-21 10:11:26",
|
|
|
+ "cjsjc": "1676945460",
|
|
|
+ "data_update_time": "1676945381",
|
|
|
+ "meta_update_time": "1676620809",
|
|
|
+ "state": "离线",
|
|
|
+ "danger": ""
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "ZI_DONG_ZHAN_ID": "5D0D05FF50B64D9D921C1C82F6E98BD9",
|
|
|
+ "MING_CHENG": "2号站点",
|
|
|
+ "ZHAN_HAO": "2",
|
|
|
+ "ZHAN_TYPE": "便携站",
|
|
|
+ "JING_DU": 120 + getRandom(-1, 1),
|
|
|
+ "WEI_DU": 33 + getRandom(-1, 1),
|
|
|
+ "DATA_TYPE": "--",
|
|
|
+ "qiwen": "23.4",
|
|
|
+ "qiwen_min": "19.8",
|
|
|
+ "qiwen_max": "33.5",
|
|
|
+ "qiya": "1013.5",
|
|
|
+ "shidu": "56",
|
|
|
+ "fengxiang": "177",
|
|
|
+ "yuliang": "0.000000",
|
|
|
+ "fengsu": "4.5",
|
|
|
+ "njd": "-16777215",
|
|
|
+ "tqxx": "无数据",
|
|
|
+ "cjsj": "2023-03-21 15:11:01",
|
|
|
+ "cjsjc": "1676945460",
|
|
|
+ "data_update_time": "1676945381",
|
|
|
+ "meta_update_time": "1676620809",
|
|
|
+ "state": "正常",
|
|
|
+ "danger": "大风"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "ZI_DONG_ZHAN_ID": "5D0D05FF50B64D9D921C1C82F6E98BD9",
|
|
|
+ "MING_CHENG": "3号站点",
|
|
|
+ "ZHAN_HAO": "3",
|
|
|
+ "ZHAN_TYPE": "固定站",
|
|
|
+ "JING_DU": 120 + getRandom(-1, 1),
|
|
|
+ "WEI_DU": 33 + getRandom(-1, 1),
|
|
|
+ "DATA_TYPE": "--",
|
|
|
+ "qiwen": "23.4",
|
|
|
+ "qiwen_min": "19.8",
|
|
|
+ "qiwen_max": "33.5",
|
|
|
+ "qiya": "1013.5",
|
|
|
+ "shidu": "56",
|
|
|
+ "fengxiang": "177",
|
|
|
+ "yuliang": "0.000000",
|
|
|
+ "fengsu": "4.5",
|
|
|
+ "njd": "-16777215",
|
|
|
+ "tqxx": "无数据",
|
|
|
+ "cjsj": "2023-03-21 15:11:01",
|
|
|
+ "cjsjc": "1676945460",
|
|
|
+ "data_update_time": "1676945381",
|
|
|
+ "meta_update_time": "1676620809",
|
|
|
+ "state": "不可用",
|
|
|
+ "danger": "大风"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "ZI_DONG_ZHAN_ID": "5D0D05FF50B64D9D921C1C82F6E98BD9",
|
|
|
+ "MING_CHENG": "4号站点",
|
|
|
+ "ZHAN_HAO": "4",
|
|
|
+ "ZHAN_TYPE": "便携站",
|
|
|
+ "JING_DU": 121 + getRandom(-1, 1),
|
|
|
+ "WEI_DU": 32 + getRandom(-1, 1),
|
|
|
+ "DATA_TYPE": "--",
|
|
|
+ "qiwen": "23.4",
|
|
|
+ "qiwen_min": "19.8",
|
|
|
+ "qiwen_max": "33.5",
|
|
|
+ "qiya": "1013.5",
|
|
|
+ "shidu": "56",
|
|
|
+ "fengxiang": "177",
|
|
|
+ "yuliang": "0.000000",
|
|
|
+ "fengsu": "4.5",
|
|
|
+ "njd": "-16777215",
|
|
|
+ "tqxx": "无数据",
|
|
|
+ "cjsj": "2023-04-21 20:11:34",
|
|
|
+ "cjsjc": "1676945460",
|
|
|
+ "data_update_time": "1676945381",
|
|
|
+ "meta_update_time": "1676620809",
|
|
|
+ "state": "超时",
|
|
|
+ "danger": ""
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "ZI_DONG_ZHAN_ID": "5D0D05FF50B64D9D921C1C82F6E98BD9",
|
|
|
+ "MING_CHENG": "5号站点",
|
|
|
+ "ZHAN_HAO": "5",
|
|
|
+ "ZHAN_TYPE": "便携站",
|
|
|
+ "JING_DU": 121 + getRandom(-1, 1),
|
|
|
+ "WEI_DU": 32 + getRandom(-1, 1),
|
|
|
+ "DATA_TYPE": "--",
|
|
|
+ "qiwen": "23.4",
|
|
|
+ "qiwen_min": "19.8",
|
|
|
+ "qiwen_max": "33.5",
|
|
|
+ "qiya": "1013.5",
|
|
|
+ "shidu": "56",
|
|
|
+ "fengxiang": "177",
|
|
|
+ "yuliang": "0.000000",
|
|
|
+ "fengsu": "4.5",
|
|
|
+ "njd": "-16777215",
|
|
|
+ "tqxx": "无数据",
|
|
|
+ "cjsj": "2023-02-21 10:11:06",
|
|
|
+ "cjsjc": "1676945460",
|
|
|
+ "data_update_time": "1676945381",
|
|
|
+ "meta_update_time": "1676620809",
|
|
|
+ "state": getRandom(-1, 1) > 0 ? "正常" : "超时",
|
|
|
+ "danger": ""
|
|
|
+ }
|
|
|
+
|
|
|
+ ],
|
|
|
+ "numbers": {
|
|
|
+ "state_running_count": 1,
|
|
|
+ "state_stop_count": 1,
|
|
|
+ "state_error_count": 2,
|
|
|
+ "state_danger_count": 1
|
|
|
+ },
|
|
|
+ "global_qiwen": {
|
|
|
+ "min": "-20.799999",
|
|
|
+ "max": "33.5"
|
|
|
+ },
|
|
|
+ "global_qiya": {
|
|
|
+ "min": "0.000000",
|
|
|
+ "max": "1013.5"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "elapsed time": "423548us"
|
|
|
+ };
|
|
|
+
|
|
|
+ for (let i = 0; i < 5; i++) {
|
|
|
+ let p = getPosRand(i * 0.1);
|
|
|
+ let qw = Math.round(getRandom(-60, 40), 1);
|
|
|
+ let timeNow = new Date();
|
|
|
+ let cjsj = timeFormat(timeNow);
|
|
|
+ let id = Math.floor(getRandom(1, 99));
|
|
|
+ let sid = 'M' + id;
|
|
|
+ let sname = sid + '号站点';
|
|
|
+ let state = getRandom(0, 9) > 7 ? "正常" : "超时";
|
|
|
+ let danger = getRandom(0, 9) > 5 ? "冰雹" : "";
|
|
|
+ data.datas.list.push({
|
|
|
+ "ZI_DONG_ZHAN_ID": "E6B84175CDEE4481A65D19E4F1C4A095",
|
|
|
+ "MING_CHENG": sname,
|
|
|
+ "ZHAN_HAO": sid,
|
|
|
+ "ZHAN_TYPE": "便携站",
|
|
|
+ "JING_DU": p.lon,
|
|
|
+ "WEI_DU": p.lat,
|
|
|
+ "DATA_TYPE": "--",
|
|
|
+ "qiwen": qw,
|
|
|
+ "qiwen_min": qw - 5,
|
|
|
+ "qiwen_max": qw + 5,
|
|
|
+ "qiya": "949.5",
|
|
|
+ "shidu": "54",
|
|
|
+ "fengxiang": "325",
|
|
|
+ "yuliang": "0.00",
|
|
|
+ "fengsu": "4.30",
|
|
|
+ "njd": "-16777215",
|
|
|
+ "tqxx": "无数据",
|
|
|
+ "cjsj": cjsj,
|
|
|
+ "cjsjc": "1670915880",
|
|
|
+ "data_update_time": "1670915903",
|
|
|
+ "meta_update_time": "1671691090",
|
|
|
+ "state": state,
|
|
|
+ "danger": "冰雹"
|
|
|
+ });
|
|
|
+ if (state == "超时") {
|
|
|
+ data.datas.numbers.state_error_count++;
|
|
|
+ } else if (state == "正常") {
|
|
|
+ data.datas.numbers.state_running_count++;
|
|
|
+ }
|
|
|
+ if (danger == "冰雹") {
|
|
|
+ data.datas.numbers.state_danger_count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+}
|