From 4725705ad2cca332b2fe88979b0875826df8016b Mon Sep 17 00:00:00 2001
From: zhaoxing <zhaoxing@shsening.com>
Date: 星期四, 20 十月 2022 16:28:51 +0800
Subject: [PATCH] 增加排除整个上海范围外的汽车&撒点颜色和轨迹颜色不同问题

---
 js/function_1004.js                 |   18 +++++++--
 widgetsTS/taxiRouteReplay/widget.js |   56 ++++++++++++++++++----------
 2 files changed, 50 insertions(+), 24 deletions(-)

diff --git a/js/function_1004.js b/js/function_1004.js
index 8bbace7..8ef63ca 100644
--- a/js/function_1004.js
+++ b/js/function_1004.js
@@ -227,10 +227,20 @@
       var tmpPositionProperty = new Cesium.SampledPositionProperty();
 
       if(regionCode == 0){
-        for (var i = 0, len = result.data.result.length; i < len; i++) {
-          let item = result.data.result[i];
-          tmpPositionProperty.addSample(Cesium.JulianDate.fromDate(new Date(item["datatime"])), Cesium.Cartesian3.fromDegrees(item["lon"], item["lat"], 0.2))
-        }
+        $.getJSON("./data/shanghai.json", (result2) => {
+          polygon_Points = result2.features[0].geometry.coordinates[0][0]
+          console.log(polygon_Points,"涓婃捣杈圭晫")
+          for (var i = 0, len = result.data.result.length; i < len; i++) {
+            let item = result.data.result[i];
+            console.log(item.lon,item.lat,polygon_Points)
+            let isIn = isInPolygon([item.lon,item.lat],polygon_Points)
+            if(isIn){
+              console.log("杩涙潵浜�")
+                tmpPositionProperty.addSample(Cesium.JulianDate.fromDate(new Date(item["datatime"])), Cesium.Cartesian3.fromDegrees(item["lon"], item["lat"], 0.2))
+              }
+          }
+          
+        })
       }else{
         $.getJSON("./data/"+regionCode+".geojson", (result2) => {
           polygon_Points = result2.features[0].geometry.coordinates[0][0]
diff --git a/widgetsTS/taxiRouteReplay/widget.js b/widgetsTS/taxiRouteReplay/widget.js
index e7661f3..2784a61 100644
--- a/widgetsTS/taxiRouteReplay/widget.js
+++ b/widgetsTS/taxiRouteReplay/widget.js
@@ -75,6 +75,7 @@
           position2 = Cesium.Cartesian3.fromDegrees(lng2, lat2);
         }
         item = changeNullAndundefinedToEmpty(item)
+        console.log(item,"璺嚎item",item[this.qindex])
       let graphic = new mars3d.graphic.PolylineEntity({
         positions: [position,position2],
         style: {
@@ -108,27 +109,42 @@
  
     addTaxiPointInfoGraphic() {
         var Pointsdata = mars3d.global_variables.singleTaxiReplayData;
-        for (var i = 0, len = Pointsdata.length; i < len; i++) {
+        for (var i = 0, len = Pointsdata.length; i < len-1; i++) {
+          // var item = Pointsdata[i];
+          // // var lng = Number(item["lon"]); //缁忓害
+          // // var lat = Number(item["lat"]); //绾害
+          // // var position = null;
+          // // if (lng && lat) {
+          // //   position = Cesium.Cartesian3.fromDegrees(lng, lat);
+          // // }
+          // let keys = ["lon","lat"]
+          // let array = []
+          // Pointsdata.map(item => {
+          //   array.push(keys.reduce((result, key) => ({ ...result, [key]: item[key] }), {}))
+          // })
+          // let points = []
+          // array.map(item => {
+          //   points.push(Object.values(item))
+          // })
+          // item = changeNullAndundefinedToEmpty(item)
           var item = Pointsdata[i];
-          // var lng = Number(item["lon"]); //缁忓害
-          // var lat = Number(item["lat"]); //绾害
-          // var position = null;
-          // if (lng && lat) {
-          //   position = Cesium.Cartesian3.fromDegrees(lng, lat);
-          // }
-          let keys = ["lon","lat"]
-          let array = []
-          Pointsdata.map(item => {
-            array.push(keys.reduce((result, key) => ({ ...result, [key]: item[key] }), {}))
-          })
-          let points = []
-          array.map(item => {
-            points.push(Object.values(item))
-          })
+          var item2 = Pointsdata[i+1];
+          var lng = Number(item["lon"]); //缁忓害
+          var lat = Number(item["lat"]); //绾害
+          var lng2 = Number(item2["lon"]); //缁忓害
+          var lat2 = Number(item2["lat"]); //绾害
+          var position = null;
+          var position2 = null;
+          if (lng && lat&&lng2&&lat2) {
+            position = Cesium.Cartesian3.fromDegrees(lng, lat);
+            position2 = Cesium.Cartesian3.fromDegrees(lng2, lat2);
+          }
           item = changeNullAndundefinedToEmpty(item)
+          let color_value = this.viewWindow.getLayerPointColorByQindexandValue(1004,this.qindex, item[this.qindex]);
+          console.log(item,"璺嚎item",item[this.qindex],this.viewWindow.getLayerPointColorByQindexandValue(1004,this.qindex, item[this.qindex]))
           //points[Pointsdata.length] = [lon,lat]
-          var CorridorPrimitive = new mars3d.graphic.CorridorPrimitive({
-            positions: points,
+          var CorridorPrimitive = new mars3d.graphic.CorridorEntity({
+            positions: [position,position2],
             style: {
               // length: 60.0,
 		      width: 10.0,
@@ -136,8 +152,8 @@
 		      cornerType: Cesium.CornerType.BEVELED,
               // radius: 8.0,
               diffHeight: this.qindex == "co" ? 300 * item[this.qindex] :  item[this.qindex]  || item[this.qindex] == "/" ? 500 : item[this.qindex], //楂樺害
-              color:this.viewWindow.getLayerPointColorByQindexandValue(1004,this.qindex, item[this.qindex]),
-              opacity: 0.6,
+              color:color_value,
+              opacity: 1,
               // rotationDegree: 45,
               highlight: {
                opacity: 1

--
Gitblit v1.9.1