From 76e3db6a828a8ad842bbcce38ae44ba589450197 Mon Sep 17 00:00:00 2001
From: master <master@163.com>
Date: 星期五, 15 四月 2022 17:49:43 +0800
Subject: [PATCH] 添加煤堆点云
---
public/hn3d/example/00_hn_new.html | 99 +++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 91 insertions(+), 8 deletions(-)
diff --git a/public/hn3d/example/00_hn_new.html b/public/hn3d/example/00_hn_new.html
index 10d315d..22b5707 100644
--- a/public/hn3d/example/00_hn_new.html
+++ b/public/hn3d/example/00_hn_new.html
@@ -60,17 +60,18 @@
<button type="button" id="meipeng_pati_madao" class="btn btn-primary" style="width: 100%;">鐖椹亾</button>
<button type="button" id="meipeng_tiejia" class="btn btn-primary" style="width: 100%;">閽㈢粨鏋勬灦</button>
<button type="button" id="meipeng_dimian" class="btn btn-primary" style="width: 100%;">鐓ゆ鍦伴潰</button>
- <button type="button" id="dou_move" class="btn btn-primary" style="width: 100%;">绉诲姩</button>
+ <!-- <button type="button" id="dou_move" class="btn btn-primary" style="width: 100%;">绉诲姩</button>
<button type="button" id="dou_rote" class="btn btn-primary" style="width: 100%;">鏃嬭浆</button>
- <button type="button" id="dou_work" class="btn btn-primary" style="width: 100%;">鎸栫叅</button>
+ <button type="button" id="dou_work" class="btn btn-primary" style="width: 100%;">鎸栫叅</button> -->
<button type="button" id="test_btn" class="btn btn-primary" style="width: 100%;">娴嬭瘯</button>
+ <button type="button" id="point_btn" class="btn btn-primary" style="width: 100%;">鐓ゅ爢</button>
</div>
- <div class="infoview handle" id="time_line">
+ <!-- <div class="infoview handle" id="time_line">
<button type="button" class="btn btn-primary" style="width: 100%;">time1</button>
<button type="button" class="btn btn-primary" style="width: 100%;">time2</button>
<button type="button" class="btn btn-primary" style="width: 100%;">time3</button>
<button type="button" class="btn btn-primary" style="width: 100%;">time4</button>
- </div>
+ </div> -->
<script src="./js/common.js"></script>
<script type="text/javascript">
@@ -92,7 +93,7 @@
var data_url = 'http://127.0.0.1:8001/admin/business/devicegroup/getdata?bid='
var time_btn = $("#time_line button")
var model_no = 0
-
+ var distance_half = 111319.5;
// 椤甸潰鍒濆鎵ц鐨勬柟娉�
$(document).ready(function () {
console.log(time_btn)
@@ -243,7 +244,7 @@
],
});
-
+ addCustomLayers()
//鍒涘缓涓夌淮鍦扮悆鍦烘櫙
@@ -294,7 +295,6 @@
parent: dou_parent
})
graphicLayer.addGraphic(dou3)
-
var dou4 = new mars3d.graphic.ModelEntity({
@@ -356,7 +356,6 @@
dimian_model.show = false;
}
});
-
@@ -478,6 +477,82 @@
$(this).addClass("active");
});
});
+
+
+
+ // group鏂规硶鍙互灏嗕竴涓暟缁勬寜鐓ф寚瀹氶暱搴﹁繘琛屽垎缁�
+ function group (array, subGroupLength) {
+ let index = 0;
+ let newArray = [];
+ while (index < array.length) {
+ newArray.push(array.slice(index, index += subGroupLength));
+ }
+ return newArray;
+ }
+
+
+ // 璇曞姞杞絋XT鐐逛簯鏂囦欢
+
+
+ // 璇诲彇TXT鏂囦欢骞跺皢TXT鍐呭杞崲涓烘暟缁�
+
+ // $.ajax({
+ // url: 'http://112.74.77.127:9100/hn/pointcloud/hn4.txt',
+ // dataType: 'text',
+ // success: function (data) {
+ // addPointCloud(data)
+ // }
+ // });
+
+
+ $("#point_btn").click(function () {
+ var data_path = 'http://112.74.77.127:9100/hn/pointcloud/hn4.txt'
+ console.log("鎴戠偣鍑讳簡")
+ $.ajax({
+ url: data_path,
+ dataType: 'text',
+ success: function (data) {
+ addPointCloud(data)
+ }
+ });
+ })
+
+ function addPointCloud (data) {
+ var pointPrimitives = null;// 鐢虫槑鐐规覆鏌撻泦鍚�
+ pointPrimitives = map.viewer.scene.primitives.add(new Cesium.PointPrimitiveCollection());
+ datas = data.split(/\s|[\r\n]/)//灏唗xt姣忚鍐呭鏍规嵁绌烘牸鍜屾崲琛岃繘琛屽垏鍓�
+ data_list = datas.map(Number)//灏嗗垏鍓插悗鐨剎yz宸﹁竟杞崲涓烘暟瀛楁牸寮�
+ list = group(data_list, 3)//灏嗚浆鎹㈠悗鐨勬暟鎹瘡鍏釜鍒嗕负涓�缁�
+ // 寰幆鏁扮粍锛屽姞杞界偣浜�
+ for (var i = 0; i < list.length; i++) {
+ var hn_lon = Number(list[i][0]) / distance_half + 121.398442;
+ var hn_lat = Number(list[i][1]) / distance_half + 31.460107;
+ var hn_h = 300 - Number(list[i][2]);
+ var color_b = Math.floor(hn_h)
+ if (hn_h <= 50) {
+ color = Cesium.Color.fromCssColorString(`rgba(0, ${color_b}, ${color_b}, 1)`)
+ } else if (hn_h <= 80) {
+ color = Cesium.Color.fromCssColorString(`rgba(${color_b}, 0, ${color_b}, 1)`)
+ } else {
+ color = Cesium.Color.fromCssColorString(`rgba(${color_b}, ${color_b}, 0, 1)`)
+ }
+ var position = Cesium.Cartesian3.fromDegrees(hn_lon, hn_lat, hn_h);
+ pointPrimitives.add({
+ pixelSize: 1,
+ color: color,
+ // 聽 聽 聽 聽 outlineColor: Cesium.Color.BLUE,
+ outlineWidth: 0,
+ position: position
+ });
+ }
+ }
+
+
+
+
+
+
+
//閿洏婕父
map.keyboardRoam.setOptions({
moveStep: 0.1, //骞崇Щ姝ラ暱 (绫�)銆�
@@ -502,6 +577,10 @@
+ // 璇曞姞杞絋XT鐐逛簯鏂囦欢
+ function addPrimitivesPointFromJSONTest () {
+ console.log(map, "map")
+ }
@@ -534,6 +613,10 @@
pitch: -18,
});
}
+
+ function addCustomLayers () {
+ addPrimitivesPointFromJSONTest()
+ }
</script>
</body>
--
Gitblit v1.9.1