From 2759eea24b4d6cd5e0e8f8c88eae69a59b48d299 Mon Sep 17 00:00:00 2001
From: ZhuDongming <773644075@qq.com>
Date: Tue, 03 Sep 2019 13:43:57 +0800
Subject: [PATCH] update 污染传播接口
---
src/main/webapp/view/pollutionsource.jsp | 444 +++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 319 insertions(+), 125 deletions(-)
diff --git a/src/main/webapp/view/pollutionsource.jsp b/src/main/webapp/view/pollutionsource.jsp
index 31d1fd0..dbde898 100644
--- a/src/main/webapp/view/pollutionsource.jsp
+++ b/src/main/webapp/view/pollutionsource.jsp
@@ -34,10 +34,96 @@
padding: 0;
list-style: none;
}
+
+ .BMap_top {
+ display: none;
+ }
+
+ .BMap_center {
+ display: none;
+ }
+
+ .BMap_bubble_title {
+ color: white;
+ padding: 0 5px 0 5px;
+ background-color: #2DA0EB;
+ }
+
+ .BMap_bubble_content {
+ background-color: white;
+ padding: 5px;
+ }
+
+ .BMap_pop > img {
+ top: 42px !important;
+ margin-left: -10px;
+ }
+
+ .BMap_pop div:nth-child(1) div {
+ display: none;
+ }
+
+ .BMap_pop div:nth-child(3) {
+ display: none;
+ }
+
+ .BMap_pop div:nth-child(5) {
+ display: none;
+ }
+
+ .BMap_pop div:nth-child(7) {
+ display: none;
+ }
+
+ .BMap_pop div:nth-child(9) {
+ 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;
+ }
+
+ #show {
+ position: absolute;
+ z-index: 1;
+ top: 30px;
+ right: 50px;
+ display: inline-block;
+ width: 80px;
+ height: 40px;
+ border-width: 0px;
+ border-radius: 3px;
+ background: #6495ED;
+ cursor: pointer;
+ outline: none;
+ color: white;
+ font-size: 20px;
+ }
+
+ #show:hover {
+ background: #5CACEE;
+ }
</style>
<body>
<div class="main_body">
+ <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;">
@@ -54,16 +140,11 @@
style: "normal" // ������������������������������
};
var params = $.parseJSON($("#pollutionSourceParams").html());
- var weatherInfoToday = params["weatherInfoToday"];
- var weatherInfoForecast = params["weatherInfoForecast"];
- var isToday = params["isToday"];
- console.log(weatherInfoToday);
- console.log(weatherInfoForecast);
- console.log(isToday);
+ var month = params["month"];
var device = params["device"];
- var cityName = params["weatherInfoToday"]["cityName"];
+ var dirPoint = new BMap.Point(params["dirPoint"].lng, params["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({
@@ -78,125 +159,238 @@
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;
- if (Object.keys(weatherInfoForecast).length === 0) {
- var windDir = weatherInfoToday["windDir"];
- dirPoint = getWindDir(windDir, dirPoint);
- } else {
- if (isToday) {
- var windDir = weatherInfoToday["windDir"];
- dirPoint = getWindDir(windDir, dirPoint);
- } else {
- var windDir = weatherInfoForecast["windDirDay"];
- dirPoint = getWindDir(windDir, dirPoint);
- }
- }
- var polyline = new BMap.Polyline([
- dirPoint,
- point
- ],
- {strokeColor: "#5298FF", strokeWeight: 4, strokeOpacity: 1}
- );
- map.addOverlay(polyline);// ���������������
- addArrow(polyline, 50, Math.PI / 7);
+ map.centerAndZoom(point, 16);
- var winfowText =
- '<div style="min-height:20px;overflow:auto;max-height:330px;" >';
- var opts = {
- width: 220,
- height: 220,
- enableMessage: false //���������������������������������
- }
- winfowText += ("<p style='height: 22px;line-height: 22px'></p>");
- winfowText += "</div>";
- marker.addEventListener("click", function () {
- var infoWindow = new BMap.InfoWindow(winfowText, opts);
- this.openInfoWindow(infoWindow);
+ $("#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) {
+ showNoData();
+ } else {
+ var humidity = parseFloat(getPollutionSourceData["e6"]);
+ var 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 distance = windSpeed * 3600;
+ var winDirStart = 240 - windDir;
+ var winDirEnd = 300 - windDir;
+ setTimeout(function () {
+ var oval = new BMap.Polygon(Sector(dirPoint, distance, winDirStart, winDirEnd), {
+ strokeColor: "grey",
+ strokeWeight: 1,
+ strokeOpacity: 0.8,
+ fillColor: "grey"
+ });
+ map.addOverlay(oval);
+ }, 1500);
+ setTimeout(function () {
+ var oval = new BMap.Polygon(Sector(dirPoint, distance * 0.66, winDirStart, winDirEnd), {
+ strokeColor: "grey",
+ strokeWeight: 1,
+ strokeOpacity: 0.6,
+ fillColor: "grey"
+ });
+ map.addOverlay(oval);
+ var polyline = new BMap.Polyline([
+ dirPoint,
+ point
+ ],
+ {strokeColor: "#5298FF", strokeWeight: 4, strokeOpacity: 1}
+ );
+ addArrow(polyline, 0, Math.PI / 7, temperature, humidity, windSpeed, windDir);
+ }, 1000);
+ setTimeout(function () {
+ var oval = new BMap.Polygon(Sector(dirPoint, distance * 0.33, winDirStart, winDirEnd), {
+ strokeColor: "grey",
+ strokeWeight: 1,
+ strokeOpacity: 0.4,
+ fillColor: "grey"
+ });
+ map.addOverlay(markerDir);
+ map.addOverlay(oval);
+ }, 500);
+
+
+ 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>";
+ }
+
+ 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, 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);
});
-
- function addArrow(polyline, length, angleValue) {
- 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, pixelX1, pixelY1;// ���������������
- 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);
- pixelX1 = pixelTemX + r * Math.tan(angle);
- pixelY = pixelY1 = 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;
- pixelX1 = pixelTemX - Math.tan(angle) * r * delta / param;
- pixelY1 = pixelTemY + Math.tan(angle) * r / param;
- }
- 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));
- 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;
- };
</script>
--
Gitblit v1.8.0