From e2c9154d3381b365ef4fff5367840725e0c4a57b Mon Sep 17 00:00:00 2001
From: ZhuDongming <773644075@qq.com>
Date: Mon, 02 Sep 2019 17:41:54 +0800
Subject: [PATCH] 污染传播接口修改

---
 src/main/webapp/view/pollutionsource.jsp |  292 +++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 165 insertions(+), 127 deletions(-)

diff --git a/src/main/webapp/view/pollutionsource.jsp b/src/main/webapp/view/pollutionsource.jsp
index 0991f1b..c47f7ba 100644
--- a/src/main/webapp/view/pollutionsource.jsp
+++ b/src/main/webapp/view/pollutionsource.jsp
@@ -79,10 +79,29 @@
         top: 35px !important;
         border-radius: 5px;
     }
+
+    #cpm {
+        width: 300px;
+        height: 100px;
+        position: absolute;
+        background-color: #ffffff;
+        display: none;
+        left: 50%;
+        top: 50%;
+        margin-left: -150px;
+        margin-top: -50px;
+        z-index: 11;
+        color: #000000;
+        border: 2px solid #FF7F50;
+        font-size: 28px;
+        line-height: 100px;
+        text-align: center;
+    }
 </style>
 
 <body>
 <div class="main_body">
+    <div id="cpm">������������</div>
     <div id="mapCanvas"></div> <!-- ������������ -->
     <!-- ���sensorInfo,regionCode,regionName,monitorPoint,device-->
     <div id="pollutionSourceParams" style="display: none;">
@@ -99,14 +118,13 @@
         style: "normal" // ������������������������������
     };
     var params = $.parseJSON($("#pollutionSourceParams").html());
-    var weatherInfoToday = params["weatherInfoToday"];
-    var weatherInfoForecast = params["weatherInfoForecast"];
-    var isToday = params["isToday"];
     var month = params["month"];
     var device = params["device"];
-    var cityName = params["weatherInfoToday"]["cityName"];
+    var dirPoint=params["dirPoint"];
+    console.log(dirPoint.lng);
+    console.log(dirPoint.lat);
+    var getPollutionSourceData=params["getPollutionSourceData"];
     var map = new BMap.Map("mapCanvas", {enableMapClick: false});
-    map.setCurrentCity("������");
     map.setMapStyle(mapStyle);
     map.enableScrollWheelZoom(true); // ������������������������
     var navigation = new BMap.NavigationControl({
@@ -115,115 +133,139 @@
     });
     map.addControl(navigation);
     map.addControl(new BMap.ScaleControl());
-    var longitude = params["device"]["longitude"];
-    var latitude = params["device"]["latitude"];
-    var point = new BMap.Point(longitude, latitude);
-    var icon = new BMap.Icon("/img/ico00.png", new BMap.Size(50, 50));
-    var marker = new BMap.Marker(point, {icon: icon, offset: new BMap.Size(0, -20)});
-    map.addOverlay(marker);
-    map.setCurrentCity(cityName);
-    map.centerAndZoom(point, 19);
-    var bounds = map.getBounds(); //������������������������
-    var sw = bounds.getSouthWest(); //���������������������������(������������)
-    var ne = bounds.getNorthEast(); //���������������������������(������������)
-    var wn = new BMap.Point(sw.lng, ne.lat); //���������������������������(������������)
-    var es = new BMap.Point(ne.lng, sw.lat); //���������������������������(������������)
-    var n = new BMap.Point(longitude, ne.lat);
-    var s = new BMap.Point(longitude, sw.lat);
-    var w = new BMap.Point(sw.lng, latitude);
-    var e = new BMap.Point(ne.lng, latitude);
-    var dirPoint;
-    var windLevel;
-    var condition;
-    if (Object.keys(weatherInfoForecast).length === 0) {
-        var windDir = weatherInfoToday["windDir"];
-        dirPoint = getWindDir(windDir, dirPoint);
-        windLevel = weatherInfoToday["windLevel"];
-        condition = weatherInfoToday["condition"];
-    } else {
-        if (isToday) {
-            var windDir = weatherInfoToday["windDir"];
-            dirPoint = getWindDir(windDir, dirPoint);
-            windLevel = weatherInfoToday["windLevel"];
-            condition = weatherInfoToday["condition"];
+    if ($.isEmptyObject(dirPoint)||$.isEmptyObject(getPollutionSourceData)||getPollutionSourceData["e18"]==0) {
+        showNoData();
+    }else{
+        var humidity=getPollutionSourceData["e6"];
+        var windSpeed=getPollutionSourceData["e18"];
+        var longitude = params["device"]["longitude"];
+        var latitude = params["device"]["latitude"];
+        var point = new BMap.Point(longitude, latitude);
+        var icon = new BMap.Icon("/img/ico00.png", new BMap.Size(50, 50));
+        var marker = new BMap.Marker(point, {icon: icon, offset: new BMap.Size(0, -20)});
+        map.addOverlay(marker);
+        map.centerAndZoom(point, 17);
+        var polyline1 = new BMap.Polyline([
+                dirPoint,
+                new BMap.Point(point.lng+0.01, point.lat+0.01)
+            ],
+            {strokeColor: "#5298FF", strokeWeight: 4, strokeOpacity: 1}
+        );
+        var polyline2 = new BMap.Polyline([
+                dirPoint,
+                new BMap.Point( point.lng-0.02,  point.lat-0.01)
+            ],
+            {strokeColor: "#5298FF", strokeWeight: 4, strokeOpacity: 1}
+        );
+        var distance=windSpeed*3600;
+        console.log(distance);
+        var arrowLength;//���������������������
+        if (distance <= 5) {
+            arrowLength = 0;
+        } else if (distance > 5 && distance <= 20) {
+            arrowLength = 2;
+        } else if (distance > 20 && distance <= 50) {
+            arrowLength = 3;
+        } else if (distance > 50 && distance <= 100) {
+            arrowLength = 5;
+        } else if (distance > 100 && distance <= 200) {
+            arrowLength = 10;
+        } else if (distance > 200 && distance <= 500) {
+            arrowLength = 20;
+        } else if (distance > 500 && distance <= 1000) {
+            arrowLength = 40;
+        } else if (distance > 1000 && distance <= 2000) {
+            arrowLength = 80;
+        } else if (distance > 2000 && distance <= 3000) {
+            arrowLength = 120;
+        } else if (distance > 3000 && distance <= 10000) {
+            arrowLength = 500;
+        } else if (distance > 10000 && distance <= 20000) {
+            arrowLength = 1000;
+        } else if (distance > 20000 && distance <= 50000) {
+            arrowLength = 2500;
+        } else if (distance > 50000 && distance <= 100000) {
+            arrowLength = 5000;
+        } else if (distance > 100000 && distance <= 200000) {
+            arrowLength = 10000;
+        } else if (distance > 200000 && distance <= 500000) {
+            arrowLength = 25000;
+        } else if (distance > 500000 && distance <= 1000000) {
+            arrowLength = 50000;
+        } else if (distance > 1000000 && distance <= 2000000) {
+            arrowLength = 100000;
         } else {
-            var windDir = weatherInfoForecast["windDirDay"];
-            dirPoint = getWindDir(windDir, dirPoint);
-            windLevel = weatherInfoForecast["windLevelDay"];
-            condition = weatherInfoForecast["conditionDay"];
+            arrowLength = 150000;
         }
-    }
-    var polyline = new BMap.Polyline([
-            dirPoint,
-            point
-        ],
-        {strokeColor: "#5298FF", strokeWeight: 4, strokeOpacity: 1}
-    );
-    map.addOverlay(polyline);// ���������������
-    addArrow(polyline, 50, Math.PI / 7);
-    var winfowTextCause = "<p style='height: 44px;line-height: 22px'>���������������������������������������������������������������������������������������������������������������������</p>";
-    var winfowTextSource;
-    var supplement;
-    if (month == 12 || month == 1 || month == 2) {
-        if (windLevel >= 3) {
-            supplement = "���������������������������������������������������������������������������";
+        map.addOverlay(polyline1);// ���������������
+        addArrow(polyline1, arrowLength, Math.PI / 7,windSpeed);
+        map.addOverlay(polyline2);// ���������������
+        addArrow(polyline2, arrowLength, Math.PI / 7,windSpeed);
+        var winfowTextCause = "<p style='height: 44px;line-height: 22px'>���������������������������������������������������������������������������������������������������������������������</p>";
+        var winfowTextSource;
+        var supplement;
+        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 (condition.indexOf("���") != -1) {
-            supplement = "������������������������������������������������������������������������";
-        }else{
-            supplement ="";
+
+        var winfowText = '<div style="height:150px;" >';
+        var opts = {
+            width: 380,
+            title: '<h3>������������</h3>',
+            enableMessage: false //���������������������������������
         }
-        winfowTextSource = "<p style='height: 22px;line-height: 22px'>���������������������������������������������������������������������������������" + supplement + "</p>";
-    } else if (month == 3 || month == 4 || month == 5) {
-        if (windLevel >= 3) {
-            supplement = "���������������������������������������������������������������������������";
-        }
-        if (condition.indexOf("���") != -1) {
-            supplement = "������������������������������������������������������������������������";
-        }else{
-            supplement ="";
-        }
-        winfowTextSource = "<p style='height: 22px;line-height: 22px'>���������������������������������������������������������������" + supplement + "</p>";
-    } else if (month == 6 || month == 7) {
-        if (windLevel >= 3) {
-            supplement = "������������������������������������";
-        }
-        if (condition.indexOf("���") != -1) {
-            supplement = "���������������������������������������������������������������������������";
-        }else{
-            supplement ="";
-        }
-        winfowTextSource = "<p style='height: 22px;line-height: 22px'>���������������������������������������,���������������������" + supplement + "</p>";
-    } else if (month == 8 || month == 9 || month == 10 || month == 11) {
-        if (windLevel >= 3) {
-            supplement = "������������������������������������������";
-        }
-        if (condition.indexOf("���") != -1) {
-            supplement = "������������������������������������������������������������������������";
-        }else{
-            supplement ="";
-        }
-        winfowTextSource = "<p style='height: 22px;line-height: 22px'>������������������������������������������������������������������������������������������������������" + supplement + "</p>";
+        winfowText += '<h3 style="background-color: #CD5C5C;color:white;margin-bottom: 1px">������������</h3>';
+        winfowText += winfowTextCause;
+        winfowText += '<h3 style="background-color: #66CD00;color:white;margin-bottom: 1px">������������</h3>';
+        winfowText += winfowTextSource;
+        winfowText += "</div>";
+        marker.addEventListener("click", function () {
+            var infoWindow = new BMap.InfoWindow(winfowText, opts);
+            this.openInfoWindow(infoWindow);
+        });
     }
 
-    var winfowText = '<div style="height:150px;" >';
-    var opts = {
-        width: 380,
-        title: '<h3>������������</h3>',
-        enableMessage: false //���������������������������������
-    }
-    winfowText += '<h3 style="background-color: #CD5C5C;color:white;margin-bottom: 1px">������������</h3>';
-    winfowText += winfowTextCause;
-    winfowText += '<h3 style="background-color: #66CD00;color:white;margin-bottom: 1px">������������</h3>';
-    winfowText += winfowTextSource;
-    winfowText += "</div>";
-    marker.addEventListener("click", function () {
-        var infoWindow = new BMap.InfoWindow(winfowText, opts);
-        this.openInfoWindow(infoWindow);
-    });
 
 
-    function addArrow(polyline, length, angleValue) {
+    function addArrow(polyline, length, angleValue,windSpeed) {
         var linePoint = polyline.getPath();// ���������������
         var arrowCount = linePoint.length;
         for (var i = 1; i < arrowCount; i++) { // ������������������������
@@ -267,32 +309,28 @@
             var pointArrow = map.pixelToPoint(new BMap.Pixel(pixelX, pixelY));
             var pointArrow1 = map.pixelToPoint(new BMap.Pixel(pixelX1, pixelY1));
             var pointMiddle = map.pixelToPoint(new BMap.Pixel(poMiddleX, poMiddleY));
+            lab = new BMap.Label("���������"+windSpeed+"m/s", {position: pointMiddle, offset: new BMap.Size(0, -30)});
+            lab.setStyle({
+                color: "red",
+                fontSize: "16px",
+                backgroundColor: "1",
+                border: "0",
+                fontWeight: "bold"
+            });
+            map.addOverlay(lab);
             var Arrow = new BMap.Polyline([pointArrow, pointMiddle, pointArrow1],
                 {strokeColor: "#5298FF", strokeWeight: 4, strokeOpacity: 1});
             map.addOverlay(Arrow);
         }
     };
 
-    function getWindDir(windDir, dirPoint) {
-        if (windDir == "������") {
-            dirPoint = n;
-        } else if (windDir == "������") {
-            dirPoint = s;
-        } else if (windDir == "������") {
-            dirPoint = w;
-        } else if (windDir == "������") {
-            dirPoint = e;
-        } else if (windDir == "���������") {
-            dirPoint = wn;
-        } else if (windDir == "���������") {
-            dirPoint = ne;
-        } else if (windDir == "���������") {
-            dirPoint = sw;
-        } else if (windDir == "���������") {
-            dirPoint = es;
-        } else {
-            dirPoint = n;
-        }
-        return dirPoint;
+    function showNoData() {
+        var longitude = 120.987287;
+        var latitude = 31.391562;
+        var point = new BMap.Point(longitude, latitude);
+        map.centerAndZoom(point, 17);
+        setTimeout(function () {
+            document.getElementById("cpm").style.display = 'block';
+        }, 250);
     };
 </script>

--
Gitblit v1.8.0