From 39856a8269d248a3ea2730ef314868ed3121c308 Mon Sep 17 00:00:00 2001
From: zhaoxing <zhaoxing@shsening.com>
Date: 星期四, 03 八月 2023 10:05:43 +0800
Subject: [PATCH] 取消移动端车模型点击弹窗

---
 cars.html            |    2 
 js/function_1004M.js |  307 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 308 insertions(+), 1 deletions(-)

diff --git a/cars.html b/cars.html
index 8f425cf..bb70cb2 100644
--- a/cars.html
+++ b/cars.html
@@ -49,7 +49,7 @@
     <script src="js/enc-base64-min.js"></script>    
     <script src="js/changable_params.js"></script>
     <script src="js/function_1001.js"></script>
-    <script src="js/function_1004.js"></script>
+    <script src="js/function_1004M.js"></script>
     <script src="js/function_wind.js"></script>
     <script src="js/function.js"></script>
     <script src="js/server.js"></script>
diff --git a/js/function_1004M.js b/js/function_1004M.js
new file mode 100644
index 0000000..59fad92
--- /dev/null
+++ b/js/function_1004M.js
@@ -0,0 +1,307 @@
+"use script"; //寮�鍙戠幆澧冨缓璁紑鍚弗鏍兼ā寮�
+//绯荤粺 鍔熻兘鍏ュ彛
+
+var data_list_1004;
+var data_list_1004_paths = new Map();
+var taxi_layer;
+
+
+var polygon_Points;
+
+  
+  
+
+function addTaxiLayer(item) {
+  
+  taxi_layer = new mars3d.layer.GraphicLayer({
+    id: item.id,
+    name: item.name,
+    pid: item.pid, //鍥惧眰绠$悊 涓娇鐢紝鐖惰妭鐐筰d
+    center: { "lat": 30.62156, "lng": 121.44918, "alt": 48716, "heading": 359, "pitch": -40 },
+    noCenter: true,
+    style_selected: item.style_selected,
+    style_options: item.styleoptions,
+    show: item.show,
+    onWidget: "widgetsTS/taxi_layer_setting/widget.js",
+  });
+  map.addLayer(taxi_layer);
+
+  taxi_layer.on(mars3d.EventType.click, function (event) {
+    console.log("鐩戝惉layer锛屽崟鍑讳簡鐭㈤噺瀵硅薄", event);
+    var item = event.graphic?.attr;
+  });
+  //taxi_layer.bindPopup(bindPopupFunction);
+
+  getTaxiListFromServerByUserId(taxi_layer);
+}
+
+function getTaxiListFromServerByUserId(tmpLayer) {
+  setTaxiLayerMapClock();
+  $.getJSON(mars3d.global_variables.nodejs_url_predix + "dataapi/Bdata?bid=get_1004_list_by_userid&regionCode="+mars3d.global_variables.regionCode+"&userid=" + mars3d.global_variables.userid, (result) => {
+    data_list_1004 = result.data.result;
+    for (var i = 0, len = result.data.result.length; i < len; i++) {
+      let item = result.data.result[i];
+      getTaxiPathFromServerbySN(item, tmpLayer);
+    }
+  });
+
+}
+
+function setTaxiLayerMapClock() {
+  
+  map.clock.shouldAnimate = true;
+  map.clock.startTime = Cesium.JulianDate.fromDate(new Date(mars3d.global_variables.queryDataTStartTaxi));
+  map.clock.currentTime = Cesium.JulianDate.fromDate(new Date(mars3d.global_variables.queryDataTStartTaxi));
+  map.clock.stopTime = Cesium.JulianDate.fromDate(new Date(mars3d.global_variables.queryDataTEnd));
+  map.clock.multiplier = 2.0;
+  map.clock.clockRange = Cesium.ClockRange.LOOP_STOP;
+  var last_time_second = 0;
+
+
+  map.on(mars3d.EventType.clockTick, function (event) {
+
+    if (mars3d.global_variables.is_single_taxi_replaying) {
+      mars3d.global_variables.singleTaxiReplayData
+      var current_date = new Date(Cesium.JulianDate.toDate(event._currentTime));
+      if (current_date.getSeconds() != last_time_second) {
+        last_time_second = current_date.getSeconds();
+        changeTaxiLayerStyleAndAttr_Single(getFormattedDateTime(current_date));
+      }
+    } else if (map.getLayerById(1004).options.show) {
+      var current_date = new Date(Cesium.JulianDate.toDate(event._currentTime));
+      if (current_date.getSeconds() != last_time_second) {
+        last_time_second = current_date.getSeconds();
+        changeTaxiLayerStyleAndAttr_All(getFormattedDateTime(current_date));
+      }
+    }
+  });
+}
+function changeTaxiLayerStyleAndAttr_All(current_date) {
+  var tmpattr;
+  //current_date = "2021-07-01 00:00:32";
+  taxi_layer.eachGraphic(function (item) {
+    tmpattr = getTaxiAttrFromTimeListData(current_date, data_list_1004_paths.get(item.options.id));
+    if (tmpattr && tmpattr != null) {
+      //item.options.attr = tmpattr;
+      let tmpTaxiColor = getLayerPointColorByQindexandValue(1004, item._layer.options.style_selected, tmpattr[item._layer.options.style_selected]);
+      mars3d.global_variables.style_selected = item._layer.options.style_selected;
+      let tmpTaxigltfurl = "gltf/" + (tmpattr["code"]).substring(0, 2) + tmpTaxiColor.substring(1) + ".gltf";
+      item.setOptions({
+        attr: tmpattr,
+        style: {
+          url: tmpTaxigltfurl,
+          label: {
+            color: tmpTaxiColor,
+          }
+        }
+      })
+      //item.options.style.label.color = getLayerPointColorByQindexandValue(1004, item._layer.options.style_selected, tmpattr[item._layer.options.style_selected]);
+      //console.log('color has been changed.' + item.options.id);
+    }
+
+  });
+}
+function changeTaxiLayerStyleAndAttr_Single(current_date) {
+  var tmpattr;
+  var taxi_qindex = map.getLayerById(1004).options.style_selected;
+  let single_taxi = taxi_layer.getGraphicById(mars3d.global_variables.singleTaxiReplayData[0]["code"]);
+  if (!single_taxi) {
+    console.log("杩涘叆绗竴涓猧f")
+    var tmpPositionProperty = new Cesium.SampledPositionProperty();
+    for (var i = 0, len = mars3d.global_variables.singleTaxiReplayData.length; i < len; i++) {
+      let item = mars3d.global_variables.singleTaxiReplayData[i];
+      tmpPositionProperty.addSample(Cesium.JulianDate.fromDate(new Date(item["datatime"])), Cesium.Cartesian3.fromDegrees(item["lon"], item["lat"], 0.2))
+      console.log(tmpPositionProperty,"姹借溅璺嚎缁忕含搴�")
+    }
+
+    single_taxi = new mars3d.graphic.ModelEntity({
+      id: mars3d.global_variables.singleTaxiReplayData[0].code,
+      attr: mars3d.global_variables.singleTaxiReplayData[0],
+      style: {
+        url: "gltf/" + (mars3d.global_variables.singleTaxiReplayData[0]["code"]).substring(0, 2) + ".gltf",
+        scale: 0.5,
+        minimumPixelSize: 20,
+        highlight: {
+          type: mars3d.EventType.click,
+          silhouette: false,
+          silhouetteColor: "#ff0000",
+          silhouetteSize: 4,
+        },
+        label: {
+          //涓嶉渶瑕佹枃瀛楁椂锛屽幓鎺塴abel閰嶇疆鍗冲彲
+          text: mars3d.global_variables.singleTaxiReplayData[0]["code"],
+          font_size: 16,
+          // TODO need to be changed according to qindex color.
+          color: "#ff00ff",
+          outline: true,
+          outlineColor: "#000000",
+          pixelOffsetY: -20,
+          distanceDisplayCondition: true,
+          distanceDisplayCondition_far: 50000,
+          distanceDisplayCondition_near: 100,
+        },
+      },
+    });
+    single_taxi.position = tmpPositionProperty;
+    map.getLayerById(1004).addGraphic(single_taxi);
+
+  }
+  tmpattr = getTaxiAttrFromTimeListData(current_date, mars3d.global_variables.singleTaxiReplayData);
+  if (tmpattr && tmpattr != null) {
+    let tmpTaxiColor = getLayerPointColorByQindexandValue(1004, taxi_qindex, tmpattr[taxi_qindex]);
+    let tmpTaxigltfurl = "gltf/" + (tmpattr["code"]).substring(0, 2) + tmpTaxiColor.substring(1) + ".gltf";
+    single_taxi.setOptions({
+      attr: tmpattr,
+      style: {
+        url: tmpTaxigltfurl,
+        label: {
+          color: tmpTaxiColor,
+        }
+      }
+    })
+    // refresh Taxi Replay Detail table:
+    // assum that detailed widget is active;
+    let taxiReplayWiget = mars3d.widget.getClass("widgetsTS/taxiRouteReplay/widget.js");
+    let taxiReplayWiget2 = mars3d.widget.getClass("widgetsTS/taxiRouteReplay2/widget.js");
+    let taxiReplayWiget_end = taxiReplayWiget2 == undefined?taxiReplayWiget:taxiReplayWiget2;
+    taxiReplayWiget_end.refreshDetailTable(tmpattr);
+  }
+
+
+
+}
+function getTaxiAttrFromTimeListData(datetime, datalist) {
+  for (var i = 0; i < datalist.length; i++) {
+    if (datalist[i]["datatime"] == datetime) {
+      return datalist[i];
+    }
+  }
+}
+
+
+
+// 鍒ゆ柇涓�涓偣鏄惁鍦ㄤ竴涓尯鍩熷唴鏂规硶
+function isInPolygon(checkPoint, polygonPoints) {
+  var counter = 0;
+  var i;
+  var xinters;
+  var p1, p2;
+  var pointCount = polygonPoints.length;
+  p1 = polygonPoints[0];
+
+  for (i = 1; i <= pointCount; i++) {
+      p2 = polygonPoints[i % pointCount];
+      if (
+          checkPoint[0] > Math.min(p1[0], p2[0]) &&
+          checkPoint[0] <= Math.max(p1[0], p2[0])
+      ) {
+          if (checkPoint[1] <= Math.max(p1[1], p2[1])) {
+              if (p1[0] != p2[0]) {
+                  xinters =
+                      (checkPoint[0] - p1[0]) *
+                          (p2[1] - p1[1]) /
+                          (p2[0] - p1[0]) +
+                      p1[1];
+                  if (p1[1] == p2[1] || checkPoint[1] <= xinters) {
+                      counter++;
+                  }
+              }
+          }
+      }
+      p1 = p2;
+  }
+  if (counter % 2 == 0) {
+      return false;
+  } else {
+      return true;
+  }
+}
+
+function getTaxiPathFromServerbySN(taxi_mn, target_layer) {
+  $.getJSON(mars3d.global_variables.nodejs_url_predix + "dataapi/Bdata?bid=get_1004_real&siteid=" + taxi_mn["code"], {
+    datatime1: mars3d.global_variables.queryDataTStartTaxi,
+    datatime2: mars3d.global_variables.queryDataTEnd
+  }, (result) => {
+
+    if (result.data.result.length > 0) {
+      // 淇濆瓨涓存椂鏁版嵁锛屼负鍚庣画鏇挎崲棰滆壊鍋氬噯澶囥��
+      data_list_1004_paths.set(result.data.result[0].code, result.data.result);
+      var tmpPositionProperty = new Cesium.SampledPositionProperty();
+
+      if(regionCode == 0){
+        $.getJSON("./data/shanghai.json", (result2) => {
+          polygon_Points = result2.features[0].geometry.coordinates[0][0]
+          for (var i = 0, len = result.data.result.length; i < len; i++) {
+            let item = result.data.result[i];
+            let isIn = isInPolygon([item.lon,item.lat],polygon_Points)
+            if(isIn){
+                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]
+          for (var i = 0, len = result.data.result.length; i < len; i++) {
+            let item = result.data.result[i];
+            let isIn = isInPolygon([item.lon,item.lat],polygon_Points)
+            if(isIn){
+                tmpPositionProperty.addSample(Cesium.JulianDate.fromDate(new Date(item["datatime"])), Cesium.Cartesian3.fromDegrees(item["lon"], item["lat"], 0.2))
+              }
+            // mpPositionProperty.addSample(Cesium.JulianDate.fromDate(new Date(item["datatime"])), Cesium.Cartesian3.fromDegrees(item["lon"], item["lat"], 0.2))
+          }
+          
+        })
+      }
+
+      let graphic = new mars3d.graphic.ModelEntity({
+        id: result.data.result[0].code,
+        attr: result.data.result[0],
+        style: {
+          url: "gltf/" + (result.data.result[0]["code"]).substring(0, 2) + ".gltf",
+          scale: 0.5,
+          minimumPixelSize: 40,
+          highlight: {
+            type: mars3d.EventType.click,
+            silhouette: false,
+            silhouetteColor: "#ff0000",
+            silhouetteSize: 4,
+          },
+          label: {
+            //涓嶉渶瑕佹枃瀛楁椂锛屽幓鎺塴abel閰嶇疆鍗冲彲
+            text: result.data.result[0]["code"],
+            font_size: 16,
+            // TODO need to be changed according to qindex color.
+            color: "#ff00ff",
+            outline: true,
+            outlineColor: "#000000",
+            pixelOffsetY: -20,
+            distanceDisplayCondition: true,
+            distanceDisplayCondition_far: 50000,
+            distanceDisplayCondition_near: 100,
+          },
+        },
+      });
+      graphic.position = tmpPositionProperty;
+      target_layer.addGraphic(graphic);
+    }
+  });
+}
+
+function getFormattedDateTime(date) {
+
+  var year = date.getFullYear();//骞�
+  var month = date.getMonth();//鏈�
+  var day = date.getDate();//鏃�
+  var hours = date.getHours();//鏃�
+  var mins = date.getMinutes();//鍒�
+  var seconds = date.getSeconds();//绉�
+
+  return date.getFullYear() + "-" +
+    ((month + 1) > 9 ? (month + 1) : "0" + (month + 1)) + "-" +
+    (day > 9 ? day : ("0" + day)) + " " +
+    (hours > 9 ? hours : ("0" + hours)) + ":" +
+    (mins > 9 ? mins : ("0" + mins)) + ":" +
+    (seconds > 9 ? seconds : ("0" + seconds));
+}
\ No newline at end of file

--
Gitblit v1.9.1