From 621ff2f9473586aeacd92fbbee0360d0a9bc3242 Mon Sep 17 00:00:00 2001
From: wangzhibo <wangzhibo@shsening.com>
Date: 星期二, 05 十月 2021 17:57:44 +0800
Subject: [PATCH] 添加回放操作

---
 js/function_1004.js |  100 +++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 87 insertions(+), 13 deletions(-)

diff --git a/js/function_1004.js b/js/function_1004.js
index 46425e7..0322def 100644
--- a/js/function_1004.js
+++ b/js/function_1004.js
@@ -24,7 +24,7 @@
   taxi_layer.on(mars3d.EventType.click, function (event) {
     console.log("鐩戝惉layer锛屽崟鍑讳簡鐭㈤噺瀵硅薄", event);
     var item = event.graphic?.attr;
-    console.log(item);
+    //console.log(item);
   });
   taxi_layer.bindPopup(bindPopupFunction);
 
@@ -57,17 +57,23 @@
 
   map.on(mars3d.EventType.clockTick, function (event) {
 
-    var current_date = new Date(Cesium.JulianDate.toDate(event._currentTime));
-
-    if (current_date.getSeconds() != last_time_second) {
-      last_time_second = current_date.getSeconds();
-      changeTaxiLayerStyleAndAttr(getFormattedDateTime(current_date));
+    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(current_date) {
-
+function changeTaxiLayerStyleAndAttr_All(current_date) {
   var tmpattr;
   //current_date = "2021-07-01 00:00:32";
   taxi_layer.eachGraphic(function (item) {
@@ -75,11 +81,14 @@
     //console.log(tmpattr);
     if (tmpattr && tmpattr != null) {
       //item.options.attr = tmpattr;
+      let tmpTaxiColor = getLayerPointColorByQindexandValue(1004, item._layer.options.style_selected, tmpattr[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: getLayerPointColorByQindexandValue(1004, item._layer.options.style_selected, tmpattr[item._layer.options.style_selected]),
+            color: tmpTaxiColor,
           }
         }
       })
@@ -89,6 +98,71 @@
 
   });
 }
+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) {
+    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))
+    }
+
+    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: true,
+          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");
+    taxiReplayWiget.refreshDetailTable(tmpattr);
+  }
+
+
+
+}
 function getTaxiAttrFromTimeListData(datetime, datalist) {
   for (var i = 0; i < datalist.length; i++) {
     if (datalist[i]["datatime"] == datetime) {
@@ -97,9 +171,9 @@
   }
 }
 
-function getTaxiPathFromServerbySN(item, target_layer) {
+function getTaxiPathFromServerbySN(taxi_mn, target_layer) {
 
-  $.getJSON(mars3d.global_variables.nodejs_url_predix + "dataapi/Bdata?bid=get_1004_single_path&siteid=" + item["code"], {
+  $.getJSON(mars3d.global_variables.nodejs_url_predix + "dataapi/Bdata?bid=get_1004_single_path&siteid=" + taxi_mn["code"], {
     datatime1: mars3d.global_variables.queryDataTStart,
     datatime2: mars3d.global_variables.queryDataTEnd
   }, (result) => {
@@ -119,7 +193,7 @@
         attr: result.data.result[0],
         style: {
           url: "gltf/" + (result.data.result[0]["code"]).substring(0, 2) + ".gltf",
-          scale:5,
+          scale: 0.5,
           minimumPixelSize: 20,
           highlight: {
             type: mars3d.EventType.click,

--
Gitblit v1.9.1