修改飞线高度
This commit is contained in:
@ -89,6 +89,7 @@ class FlowLine extends Base {
|
|||||||
const minLat = Math.min(...lats), maxLat = Math.max(...lats);
|
const minLat = Math.min(...lats), maxLat = Math.max(...lats);
|
||||||
|
|
||||||
const points = [];
|
const points = [];
|
||||||
|
let that = this
|
||||||
while (points.length < count) {
|
while (points.length < count) {
|
||||||
const lon = minLon + Math.random() * (maxLon - minLon);
|
const lon = minLon + Math.random() * (maxLon - minLon);
|
||||||
const lat = minLat + Math.random() * (maxLat - minLat);
|
const lat = minLat + Math.random() * (maxLat - minLat);
|
||||||
@ -100,9 +101,14 @@ class FlowLine extends Base {
|
|||||||
|
|
||||||
const isInside = turf.booleanPointInPolygon(point, polygon);
|
const isInside = turf.booleanPointInPolygon(point, polygon);
|
||||||
if (isInside) {
|
if (isInside) {
|
||||||
|
let posi = Cesium.Cartesian3.fromDegrees(lon, lat);
|
||||||
|
const cartographic = that.viewer.scene.globe.ellipsoid.cartesianToCartographic(posi);
|
||||||
|
const height = cartographic.height;
|
||||||
|
|
||||||
points.push([
|
points.push([
|
||||||
lon,
|
lon,
|
||||||
lat
|
lat,
|
||||||
|
height
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,9 +132,10 @@ class FlowLine extends Base {
|
|||||||
positions.forEach((item, index) => {
|
positions.forEach((item, index) => {
|
||||||
let point = item
|
let point = item
|
||||||
//根据点设置起始点位置
|
//根据点设置起始点位置
|
||||||
let start = Cesium.Cartesian3.fromDegrees(point[0], point[1], 0)
|
// let start = Cesium.Cartesian3.fromDegrees(point[0], point[1], 0)
|
||||||
|
let start = Cesium.Cartesian3.fromDegrees(point[0], point[1], point[2])
|
||||||
//根据点设置结束点位置
|
//根据点设置结束点位置
|
||||||
let end = Cesium.Cartesian3.fromDegrees(point[0], point[1], that.options.height + Math.random() * that.options.heightDifference)
|
let end = Cesium.Cartesian3.fromDegrees(point[0], point[1], point[2] + that.options.height + Math.random() * that.options.heightDifference)
|
||||||
//创建线
|
//创建线
|
||||||
that.viewer.entities.add({
|
that.viewer.entities.add({
|
||||||
parent: celiangEntity,
|
parent: celiangEntity,
|
||||||
@ -425,7 +432,7 @@ class FlowLine extends Base {
|
|||||||
let a = Cesium.Cartesian3.fromDegrees(
|
let a = Cesium.Cartesian3.fromDegrees(
|
||||||
this.positions[i][0],
|
this.positions[i][0],
|
||||||
this.positions[i][1],
|
this.positions[i][1],
|
||||||
this.options.height + this.options.heightDifference / 2
|
this.positions[i][2] + this.options.height + this.options.heightDifference / 2
|
||||||
)
|
)
|
||||||
positionArray.push(a.x, a.y, a.z)
|
positionArray.push(a.x, a.y, a.z)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user