wangzhibo
2021-11-02 40bdf8428336e29a77507cc8698f13a0b750a3b5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
"use script"; //开发环境建议开启严格模式
//系统 功能入口
 
 
function getDefaultDateTime() {
 
  // return "2021-07-01 12:00:00";
  var date = new Date;
  date.setHours(date.getHours() - 2);
  var year = date.getFullYear();//年
  var month = date.getMonth();//月
  var day = date.getDate();//日
  var hours = date.getHours();//时
  return year + "-" +
    ((month + 1) > 9 ? (month + 1) : "0" + (month + 1)) + "-" +
    (day > 9 ? day : ("0" + day)) + " " +
    (hours > 9 ? hours : ("0" + hours)) + ":00:00";
}
function getDefaultDateTimeEnd() {
 
  // return "2021-07-01 12:15:00";
  var date = new Date;
  date.setHours(date.getHours() - 2);
  var year = date.getFullYear();//年
  var month = date.getMonth();//月
  var day = date.getDate();//日
  var hours = date.getHours();//时
  return year + "-" +
    ((month + 1) > 9 ? (month + 1) : "0" + (month + 1)) + "-" +
    (day > 9 ? day : ("0" + day)) + " " +
    (hours > 9 ? hours : ("0" + hours)) + ":15:00";
}
 
function getDefaultDateTimeStart() {
  var date = new Date;
  date.setHours(date.getHours() - 10);
  var year = date.getFullYear();//年
  var month = date.getMonth();//月
  var day = date.getDate();//日
  var hours = date.getHours();//时
  return year + "-" +
    ((month + 1) > 9 ? (month + 1) : "0" + (month + 1)) + "-" +
    (day > 9 ? day : ("0" + day)) + " " +
    (hours > 9 ? hours : ("0" + hours)) + ":00:00";
}
 
function getDefaultDateTimeGeo() {
  var date = new Date;
  date.setHours(date.getHours() - 2);
  var year = date.getFullYear();//年
  var month = date.getMonth();//月
  var day = date.getDate();//日
  var hours = date.getHours();//时
  return year +
    ((month + 1) > 9 ? (month + 1) : "0" + (month + 1)) +
    (day > 9 ? day : ("0" + day)) +
    (hours > 9 ? hours : ("0" + hours)) + "0000";
}
mars3d.global_variables = default_system_params;
mars3d.global_variables.queryDataTStart = getDefaultDateTime();
mars3d.global_variables.queryDataTStartGeo = getDefaultDateTimeGeo();
mars3d.global_variables.queryDataTEnd = getDefaultDateTimeEnd();
mars3d.global_variables.DefaultDateTimeStart = getDefaultDateTimeStart();
// for tmp hight light graphic and 
//mars3d.global_variables.tmpHighlightGraphic;
//mars3d.global_variables.tmpHighlightGraphicLayer;
 
function initLayersByUserid() {
 
  //addMaskShanghai();
  addTDTAnnoLayer();
  addHighlightLayerClearButton();
  addTmpHighlightGraphicLayer();
 
  //TODO
  $.getJSON("data/getLayerListByUserid.json", { userid: mars3d.global_variables.userid }, (result) => {
    result.data.forEach((item) => {
      if ([item['type']] == 'wms') {
        addWMSLayer(item);
      } else if ([item['type']] == 'wind') {
        addWindLayer(item);
      } else if ([item['type']] == 'graphic') {
        //addGuokongLayer(item);
        addGuokongLayerDIV(item)
      } else if ([item['type']] == 'taxi') {
        addTaxiLayer(item);
      }
    });
  });
 
}
 
 
 
function reLoadLayers() {
  var layers = map.getLayers({ layers: true });
  layers.forEach((layer) => {
    // console.log(layer.name + ":" + layer.type);
 
    if ([layer.type] == 'wms') {
      layer.options.layers = "konglu_58:" + layer.options.geoname_prefix + mars3d.global_variables.queryDataType;
      layer.options.parameters.viewparams = "userid:" + mars3d.global_variables.userid + ";regiontype:" + layer.options.regiontype + ";datetime:" + mars3d.global_variables.queryDataTStartGeo
      layer.options.getFeatureInfoParameters.viewparams = "userid:" + mars3d.global_variables.userid + ";regiontype:" + layer.options.regiontype + ";datetime:" + mars3d.global_variables.queryDataTStartGeo
      layer.reload();
    } else if ([layer.id] == 1001 && layer.options.show) {
      var tmpguokong = map.getLayerById(1001);
      tmpguokong.clear(true);
      getGuokongPointFromServer(tmpguokong);
      //graphiclayer.eachGraphic
    } else if ([layer.id] == 1004 && layer.options.show) {
      var tmpTaxi = map.getLayerById(1004);
      tmpTaxi.clear(true);
      setTaxiLayerMapClock();
      for (var i = 0, len = data_list_1004.length; i < len; i++) {
        getTaxiPathFromServerbySN(data_list_1004[i], tmpTaxi);
      }
    }
 
  });
 
}
 
function refreshWidgets() {
 
  refreshSingleWidget("widgetsTS/weather/widget.js", {});
  refreshSingleWidget("widgetsTS/widget_summary/widget.js", {});
 
}
 
function refreshSingleWidget(widget_path, params) {
 
  if (mars3d.widget.isActivate(widget_path)) {
    var tempWiget = mars3d.widget.getClass(widget_path);
    tempWiget.reloadData(params);
  }
 
}
function addGraphictoHighlightLayer() {
  mars3d.global_variables.tmpHighlightGraphicLayer.addGraphic(mars3d.global_variables.tmpHighlightGraphic);
 
}
 
function addHighlightLayerClearButton() {
  let clearButton = new mars3d.control.ToolButton({
    title: "clearHighlightLayer",
    icon: "fa fa-crop",
    insertIndex: 1, //插入的位置顺序, 1是home按钮后面
    click: (event) => {
      mars3d.global_variables.tmpHighlightGraphicLayer.clear(true);
    },
  });
  map.addControl(clearButton);
}
 
function showDetail(layerid, itemCode, qindex) {
  if (mars3d.widget.isActivate("widgetsTS/widget_detail/widget.js")) {
    var detailWiget = mars3d.widget.getClass("widgetsTS/widget_detail/widget.js");
    detailWiget.reloadData({ "nodejs_url_predix": mars3d.global_variables.nodejs_url_predix, "datatype": mars3d.global_variables.queryDataType, "selected_qindex": qindex, "datatime": mars3d.global_variables.queryDataTStart, "layerid": layerid, "siteid": itemCode });
  } else {
    mars3d.widget.activate({
      uri: "widgetsTS/widget_detail/widget.js",
      params: { "nodejs_url_predix": mars3d.global_variables.nodejs_url_predix, "datatype": mars3d.global_variables.queryDataType, "selected_qindex": qindex, "datatime": mars3d.global_variables.queryDataTStart, "layerid": layerid, "siteid": itemCode },
    });
  }
}
 
function showHistoryPathDetail(itemCode) {
 
  if (mars3d.widget.isActivate("widgetsTS/taxiRouteReplay/widget.js")) {
    var detailWiget = mars3d.widget.getClass("widgetsTS/taxiRouteReplay/widget.js");
    detailWiget.reloadData(itemCode);
  } else {
    mars3d.widget.activate({
      uri: "widgetsTS/taxiRouteReplay/widget.js",
      params: itemCode,
    });
  }
}
 
function changeNullAndundefinedToEmpty(json_in) {
  for (var key in json_in) {
    if (json_in[key] == null || json_in[key] == 'null' || json_in[key] == undefined || json_in[key] == 'undefined') {
      json_in[key] = "/";
    }
  }
  return json_in;
}