From 153144cbee10bb4999242bc62358ffe63ca9ceb9 Mon Sep 17 00:00:00 2001 From: jinpengyong <jpy123456> Date: Tue, 07 Jul 2020 09:30:04 +0800 Subject: [PATCH] update --- src/main/webapp/view/pollutionsource.jsp | 437 +++++++++++++++++++++++++++++++----------------------- 1 files changed, 251 insertions(+), 186 deletions(-) diff --git a/src/main/webapp/view/pollutionsource.jsp b/src/main/webapp/view/pollutionsource.jsp index bbcd5d6..927aa8c 100644 --- a/src/main/webapp/view/pollutionsource.jsp +++ b/src/main/webapp/view/pollutionsource.jsp @@ -104,7 +104,7 @@ top: 30px; right: 50px; display: inline-block; - width: 80px; + width: 100px; height: 40px; border-width: 0px; border-radius: 3px; @@ -122,8 +122,8 @@ <body> <div class="main_body"> - <input type="button" id="show" value="������"/> - <div id="cpm">������������������</div> + <input type="button" id="show" value="������������"/> + <div id="cpm"></div> <div id="mapCanvas"></div> <!-- ������������ --> <!-- ���sensorInfo,regionCode,regionName,monitorPoint,device--> <div id="pollutionSourceParams" style="display: none;"> @@ -162,54 +162,62 @@ var marker = new BMap.Marker(point, {icon: icon, offset: new BMap.Size(0, -20)}); map.addOverlay(marker); map.centerAndZoom(point, 16); - + var humidity = 0; + var temperature = 0; + if (!$.isEmptyObject(dirPoint) && !$.isEmptyObject(getPollutionSourceData) && typeof (getPollutionSourceData["e18"]) != "undefined" && typeof (getPollutionSourceData["e23"]) != "undefined" && getPollutionSourceData["e18"] != 0) { + var windSpeed = parseFloat(getPollutionSourceData["e18"]); + var windDir = parseFloat(getPollutionSourceData["e23"]); + var distance = windSpeed * 3600; + var winDirStart = 255 - windDir; + var winDirEnd = 285 - windDir; + var marker1 = new BMap.Marker(EOffsetBearing(dirPoint, distance * 0.15, winDirStart), { + icon: icon2, + offset: new BMap.Size(0, -20) + }); + var marker2 = new BMap.Marker(EOffsetBearing(dirPoint, distance * 0.31, winDirEnd), { + icon: icon2, + offset: new BMap.Size(0, -20) + }); + var marker3 = new BMap.Marker(EOffsetBearing(dirPoint, distance * 0.61, winDirStart), { + icon: icon1, + offset: new BMap.Size(0, -20) + }); + var marker4 = new BMap.Marker(EOffsetBearing(dirPoint, distance * 0.78, winDirEnd), { + icon: icon1, + offset: new BMap.Size(0, -20) + }); + map.addOverlay(marker1); + map.addOverlay(marker2); + map.addOverlay(marker3); + map.addOverlay(marker4); + } $("#show").one('click', function () { setTimeout(function () { - if ($.isEmptyObject(dirPoint) || $.isEmptyObject(getPollutionSourceData) || typeof (getPollutionSourceData["e6"]) == "undefined" || typeof (getPollutionSourceData["e7"]) == "undefined" || typeof (getPollutionSourceData["e18"]) == "undefined" || typeof (getPollutionSourceData["e23"]) == "undefined" || getPollutionSourceData["e18"] <= 0.03) { + if ($.isEmptyObject(dirPoint) || $.isEmptyObject(getPollutionSourceData) || typeof (getPollutionSourceData["e18"]) == "undefined" || typeof (getPollutionSourceData["e23"]) == "undefined" || getPollutionSourceData["e18"] === 0) { showNoData(); } else { - var humidity = parseFloat(getPollutionSourceData["e6"]); - var temperature = parseFloat(getPollutionSourceData["e7"]); + if (typeof (getPollutionSourceData["e6"]) != "undefined") { + humidity = parseFloat(getPollutionSourceData["e6"]); + } + if (typeof (getPollutionSourceData["e7"]) != "undefined") { + temperature = parseFloat(getPollutionSourceData["e7"]); + } var windSpeed = parseFloat(getPollutionSourceData["e18"]); var windDir = parseFloat(getPollutionSourceData["e23"]); - var iconDir = new BMap.Icon("/img/ico07.gif", new BMap.Size(50, 50)); - var markerDir = new BMap.Marker(dirPoint, {icon: iconDir, offset: new BMap.Size(0, -20)}); - - //centre:���������������,X:������������,Y:������������ - function add_oval(centre, x, y) { - var assemble = new Array(); - var angle; - var dot; - var tangent = x / y; - for (i = 0; i < 36; i++) { - angle = (2 * Math.PI / 36) * i; - dot = new BMap.Point(centre.lng + Math.sin(angle) * y * tangent, centre.lat + Math.cos(angle) * y); - assemble.push(dot); - } - return assemble; - } - - //��������������������������������������������� ���������point������������������������radius������������sDegree���eDegree��������� - function Sector(point, radius, sDegree, eDegree) { - var points = []; //��������������������������������� - var step = ((eDegree - sDegree) / 100) || 1; //������������������������������������������������������������10 - points.push(point); - for (var i = sDegree; i < eDegree + 0.001; i += step) { //������������������������������������������������������������ - points.push(EOffsetBearing(point, radius, i)); - } - points.push(point); - return points; - } - - //������������������������������������������������������������������ - function EOffsetBearing(point, dist, bearing) { - var lngConv = map.getDistance(point, new BMap.Point(point.lng + 0.1, point.lat)) * 10; //������������������������������ - var latConv = map.getDistance(point, new BMap.Point(point.lng, point.lat + 0.1)) * 10; //������������������������������ - var lat = dist * Math.sin(bearing * Math.PI / 180) / latConv; //������������������������������������������������������ - var lng = dist * Math.cos(bearing * Math.PI / 180) / lngConv; //������������������������������������������������������ - return new BMap.Point(point.lng + lng, point.lat + lat); - } + var selectSensorKey = getPollutionSourceData["selectSensorKey"]; + var markerDir = new BMap.Marker(dirPoint); + lab = new BMap.Label("���������������������������������������������</br>" + selectSensorKey + "������", { + position: dirPoint, + offset: new BMap.Size(20, -40) + }); + lab.setStyle({ + color: "#EE3B3B", + fontSize: "16px", + backgroundColor: "1", + fontWeight: "bold" + }); + map.addOverlay(lab); var distance = windSpeed * 3600; var winDirStartLeft = 240 - windDir; @@ -232,6 +240,9 @@ ], {strokeColor: "red", strokeWeight: 4, strokeOpacity: 1} ); + map.addOverlay(polyline1);// ��������������� + map.addOverlay(polyline2);// ��������������� + map.addOverlay(markerDir); setTimeout(function () { var ovalLeft = new BMap.Polygon(Sector(dirPoint, distance, winDirStartLeft, winDirEndLeft), { strokeColor: "#ADADAD", @@ -306,75 +317,57 @@ fillColor: "#ADADAD" }); map.addOverlay(ovalRight); - map.addOverlay(markerDir); - var marker1 = new BMap.Marker(EOffsetBearing(dirPoint, distance * 0.15, winDirStart), { - icon: icon2, - offset: new BMap.Size(0, -20) - }); - var marker2 = new BMap.Marker(EOffsetBearing(dirPoint, distance * 0.31, winDirEnd), { - icon: icon2, - offset: new BMap.Size(0, -20) - }); - var marker3 = new BMap.Marker(EOffsetBearing(dirPoint, distance * 0.61, winDirStart), { - icon: icon1, - offset: new BMap.Size(0, -20) - }); - var marker4 = new BMap.Marker(EOffsetBearing(dirPoint, distance * 0.78, winDirEnd), { - icon: icon1, - offset: new BMap.Size(0, -20) - }); - map.addOverlay(marker1); - map.addOverlay(marker2); - map.addOverlay(marker3); - map.addOverlay(marker4); map.addOverlay(oval); - map.addOverlay(polyline1);// ��������������� - map.addOverlay(polyline2);// ��������������� }, 500); - var winfowTextCause = "<p style='height: 44px;line-height: 22px'>���������������������������������������������������������������������������������������������������������������������</p>"; + var winfowTextCause = "<p style='height: 22px;line-height: 22px'>������������������������������������������������������������������</p>"; var winfowTextSource; var supplement; - if (month == 12 || month == 1 || month == 2) { - if (windSpeed >= 3.4) { - supplement = "���������������������������������������������������������������������������"; + if (selectSensorKey == "������") { + winfowTextCause = "<p style='height: 44px;line-height: 22px'>���������������������������������������������������������������������������������������������������������������������������������������������</p>"; + winfowTextSource = "<p style='height: 22px;line-height: 22px'>NOx������VOCs������������</p>"; + } else { + if (month == 12 || month == 1 || month == 2) { + if (windSpeed >= 3.4) { + supplement = "���������������������������������������������������������������������������"; + } + if (humidity >= 90.0) { + supplement = "������������������������������������������������������������������������"; + } else { + supplement = ""; + } + winfowTextSource = "<p style='height: 22px;line-height: 22px'>���������������������������������������������������������������������������������" + supplement + "</p>"; + } else if (month == 3 || month == 4 || month == 5) { + if (windSpeed >= 3.4) { + supplement = "���������������������������������������������������������������������������"; + } + if (humidity >= 90.0) { + supplement = "������������������������������������������������������������������������"; + } else { + supplement = ""; + } + winfowTextSource = "<p style='height: 22px;line-height: 22px'>���������������������������������������������������������������" + supplement + "</p>"; + } else if (month == 6 || month == 7) { + if (windSpeed >= 3.4) { + supplement = "������������������������������������"; + } + if (humidity >= 90.0) { + supplement = "���������������������������������������������������������������������������"; + } else { + supplement = ""; + } + winfowTextSource = "<p style='height: 22px;line-height: 22px'>���������������������������������������,���������������������" + supplement + "</p>"; + } else if (month == 8 || month == 9 || month == 10 || month == 11) { + if (windSpeed >= 3.4) { + supplement = "������������������������������������������"; + } + if (humidity >= 90.0) { + supplement = "������������������������������������������������������������������������"; + } else { + supplement = ""; + } + winfowTextSource = "<p style='height: 22px;line-height: 22px'>������������������������������������������������������������������������������������������������������" + supplement + "</p>"; } - if (humidity >= 90.0) { - supplement = "������������������������������������������������������������������������"; - } else { - supplement = ""; - } - winfowTextSource = "<p style='height: 22px;line-height: 22px'>���������������������������������������������������������������������������������" + supplement + "</p>"; - } else if (month == 3 || month == 4 || month == 5) { - if (windSpeed >= 3.4) { - supplement = "���������������������������������������������������������������������������"; - } - if (humidity >= 90.0) { - supplement = "������������������������������������������������������������������������"; - } else { - supplement = ""; - } - winfowTextSource = "<p style='height: 22px;line-height: 22px'>���������������������������������������������������������������" + supplement + "</p>"; - } else if (month == 6 || month == 7) { - if (windSpeed >= 3.4) { - supplement = "������������������������������������"; - } - if (humidity >= 90.0) { - supplement = "���������������������������������������������������������������������������"; - } else { - supplement = ""; - } - winfowTextSource = "<p style='height: 22px;line-height: 22px'>���������������������������������������,���������������������" + supplement + "</p>"; - } else if (month == 8 || month == 9 || month == 10 || month == 11) { - if (windSpeed >= 3.4) { - supplement = "������������������������������������������"; - } - if (humidity >= 90.0) { - supplement = "������������������������������������������������������������������������"; - } else { - supplement = ""; - } - winfowTextSource = "<p style='height: 22px;line-height: 22px'>������������������������������������������������������������������������������������������������������" + supplement + "</p>"; } var winfowText = '<div style="height:150px;" >'; @@ -393,86 +386,158 @@ this.openInfoWindow(infoWindow); }); } - - function addArrow(polyline, length, angleValue, temperature, humidity, windSpeed, windDir) { - var linePoint = polyline.getPath();// ��������������� - var arrowCount = linePoint.length; - for (var i = 1; i < arrowCount; i++) { // ������������������������ - var pixelStart = map.pointToPixel(linePoint[i - 1]); - var pixelEnd = map.pointToPixel(linePoint[i]); - var angle = angleValue;// ������������������������ - var r = length; // r/Math.sin(angle)������������������ - var delta = 0; // ��������������������������������� - var param = 0; // ������������������ - var pixelTemX, pixelTemY, poMiddleX, poMiddleY;// ��������������� - var pixelX, pixelY;// ��������������� - poMiddleX = (pixelEnd.x + pixelStart.x) / 2; - poMiddleY = (pixelEnd.y + pixelStart.y) / 2; - if (poMiddleX - pixelStart.x == 0) { // ������������������ - pixelTemX = poMiddleX; - if (poMiddleY > pixelStart.y) { - pixelTemY = poMiddleY - r; - } else { - pixelTemY = poMiddleY + r; - } - // ��������������������������������������������������������������������������������������� - pixelX = pixelTemX - r * Math.tan(angle); - pixelY = pixelTemY; - } else { // ��������������� - delta = (poMiddleY - pixelStart.y) / (poMiddleX - pixelStart.x); - param = Math.sqrt(delta * delta + 1); - if ((poMiddleX - pixelStart.x) < 0) { // ������������������ - pixelTemX = poMiddleX + r / param; - pixelTemY = poMiddleY + delta * r / param; - } else { // ������������������ - pixelTemX = poMiddleX - r / param; - pixelTemY = poMiddleY - delta * r / param; - } - // ��������������������������������������������������������������������������������������� - pixelX = pixelTemX + Math.tan(angle) * r * delta / param; - pixelY = pixelTemY - Math.tan(angle) * r / param; - } - var pointMiddle = map.pixelToPoint(new BMap.Pixel(poMiddleX, poMiddleY)); - var windDirection; - if (windDir == 0) { - windDirection = "������"; - } else if (windDir == 90) { - windDirection = "������"; - } else if (windDir == 180) { - windDirection = "������"; - } else if (windDir == 270) { - windDirection = "������"; - } else if (windDir > 0 && windDir < 90) { - windDirection = "���������"; - } else if (windDir > 90 && windDir < 180) { - windDirection = "���������"; - } else if (windDir > 180 && windDir < 270) { - windDirection = "���������"; - } else if (windDir > 270 && windDir < 360) { - windDirection = "���������"; - } - lab = new BMap.Label("<P>������:" + temperature + "���</p><P>������:" + humidity + "%</p><P>������:" + windSpeed + "m/s</p><P>������:" + windDirection + "</p>", { - position: pointMiddle, - offset: new BMap.Size(-50, -40) - }); - lab.setStyle({ - color: "#EE3B3B", - fontSize: "16px", - backgroundColor: "1", - border: "0", - fontWeight: "bold" - }); - map.addOverlay(lab); - } - }; - - function showNoData() { - map.centerAndZoom(point, 17); - setTimeout(function () { - document.getElementById("cpm").style.display = 'block'; - }, 250); - }; }, 1500); }); + //centre:���������������,X:������������,Y:������������ + function add_oval(centre, x, y) { + var assemble = new Array(); + var angle; + var dot; + var tangent = x / y; + for (i = 0; i < 36; i++) { + angle = (2 * Math.PI / 36) * i; + dot = new BMap.Point(centre.lng + Math.sin(angle) * y * tangent, centre.lat + Math.cos(angle) * y); + assemble.push(dot); + } + return assemble; + } + + //��������������������������������������������� ���������point������������������������radius������������sDegree���eDegree��������� + function Sector(point, radius, sDegree, eDegree) { + var points = []; //��������������������������������� + var step = ((eDegree - sDegree) / 100) || 1; //������������������������������������������������������������10 + points.push(point); + for (var i = sDegree; i < eDegree + 0.001; i += step) { //������������������������������������������������������������ + points.push(EOffsetBearing(point, radius, i)); + } + points.push(point); + return points; + } + + //������������������������������������������������������������������ + function EOffsetBearing(point, dist, bearing) { + var lngConv = map.getDistance(point, new BMap.Point(point.lng + 0.1, point.lat)) * 10; //������������������������������ + var latConv = map.getDistance(point, new BMap.Point(point.lng, point.lat + 0.1)) * 10; //������������������������������ + var lat = dist * Math.sin(bearing * Math.PI / 180) / latConv; //������������������������������������������������������ + var lng = dist * Math.cos(bearing * Math.PI / 180) / lngConv; //������������������������������������������������������ + return new BMap.Point(point.lng + lng, point.lat + lat); + } + + function addArrow(polyline, length, angleValue, temperature, humidity, windSpeed, windDir) { + var linePoint = polyline.getPath();// ��������������� + var arrowCount = linePoint.length; + for (var i = 1; i < arrowCount; i++) { // ������������������������ + var pixelStart = map.pointToPixel(linePoint[i - 1]); + var pixelEnd = map.pointToPixel(linePoint[i]); + var angle = angleValue;// ������������������������ + var r = length; // r/Math.sin(angle)������������������ + var delta = 0; // ��������������������������������� + var param = 0; // ������������������ + var pixelTemX, pixelTemY, poMiddleX, poMiddleY;// ��������������� + var pixelX, pixelY;// ��������������� + poMiddleX = (pixelEnd.x + pixelStart.x) / 2; + poMiddleY = (pixelEnd.y + pixelStart.y) / 2; + if (poMiddleX - pixelStart.x == 0) { // ������������������ + pixelTemX = poMiddleX; + if (poMiddleY > pixelStart.y) { + pixelTemY = poMiddleY - r; + } else { + pixelTemY = poMiddleY + r; + } + // ��������������������������������������������������������������������������������������� + pixelX = pixelTemX - r * Math.tan(angle); + pixelY = pixelTemY; + } else { // ��������������� + delta = (poMiddleY - pixelStart.y) / (poMiddleX - pixelStart.x); + param = Math.sqrt(delta * delta + 1); + if ((poMiddleX - pixelStart.x) < 0) { // ������������������ + pixelTemX = poMiddleX + r / param; + pixelTemY = poMiddleY + delta * r / param; + } else { // ������������������ + pixelTemX = poMiddleX - r / param; + pixelTemY = poMiddleY - delta * r / param; + } + // ��������������������������������������������������������������������������������������� + pixelX = pixelTemX + Math.tan(angle) * r * delta / param; + pixelY = pixelTemY - Math.tan(angle) * r / param; + } + var pointMiddle = map.pixelToPoint(new BMap.Pixel(poMiddleX, poMiddleY)); + var windDirection; + if (windDir == 0) { + windDirection = "������"; + } else if (windDir == 90) { + windDirection = "������"; + } else if (windDir == 180) { + windDirection = "������"; + } else if (windDir == 270) { + windDirection = "������"; + } else if (windDir > 0 && windDir < 90) { + windDirection = "���������"; + } else if (windDir > 90 && windDir < 180) { + windDirection = "���������"; + } else if (windDir > 180 && windDir < 270) { + windDirection = "���������"; + } else if (windDir > 270 && windDir < 360) { + windDirection = "���������"; + } + if (temperature != 0 && humidity != 0) { + lab = new BMap.Label("<P>������:" + temperature + "���</p><P>������:" + humidity + "%</p><P>������:" + windSpeed + "m/s</p><P>������:" + windDirection + "</p>", { + position: pointMiddle, + offset: new BMap.Size(-50, -40) + }); + } else if (temperature == 0 && humidity != 0) { + lab = new BMap.Label("<P>������:" + humidity + "%</p><P>������:" + windSpeed + "m/s</p><P>������:" + windDirection + "</p>", { + position: pointMiddle, + offset: new BMap.Size(-50, -40) + }); + } else if (temperature != 0 && humidity == 0) { + lab = new BMap.Label("<P>������:" + temperature + "���</p><P>������:" + windSpeed + "m/s</p><P>������:" + windDirection + "</p>", { + position: pointMiddle, + offset: new BMap.Size(-50, -40) + }); + } else { + lab = new BMap.Label("<P>������:" + windSpeed + "m/s</p><P>������:" + windDirection + "</p>", { + position: pointMiddle, + offset: new BMap.Size(-50, -40) + }); + } + lab.setStyle({ + color: "#EE3B3B", + fontSize: "16px", + backgroundColor: "1", + border: "0", + fontWeight: "bold" + }); + map.addOverlay(lab); + } + }; + + function showNoData() { + map.centerAndZoom(point, 17); + setTimeout(function () { + if (JSON.stringify(getPollutionSourceData) == JSON.stringify({})) { + document.getElementById("cpm").innerText = "���������������������������"; + } else { + if (getPollutionSourceData["e18"] === 0) { + document.getElementById("cpm").style.width = '380px'; + document.getElementById("cpm").innerText = "���������0���������������������"; + } + if (typeof (getPollutionSourceData["e18"]) == "undefined") { + document.getElementById("cpm").style.width = '400px'; + document.getElementById("cpm").innerText = "������������������������������������"; + } + if (typeof (getPollutionSourceData["e23"]) == "undefined") { + document.getElementById("cpm").style.width = '400px'; + document.getElementById("cpm").innerText = "������������������������������������"; + } + if (typeof (getPollutionSourceData["e18"]) == "undefined" && typeof (getPollutionSourceData["e23"]) == "undefined") { + document.getElementById("cpm").style.width = '500px'; + document.getElementById("cpm").innerText = "������������������������������������������������"; + } + } + document.getElementById("cpm").style.display = 'block'; + }, 250); + }; + </script> -- Gitblit v1.8.0