/*
* @Author: Wang jianLei
* @Date: 2022-04-07 17:40:38
* @Last Modified by: Wang JianLei
* @Last Modified time: 2022-04-07 17:41:40
*/
const Cesium = window.Cesium;
class CutFillAnalysis {
constructor(viewer, positions, height, precision) {
if (!viewer) throw new Error("no viewer object!");
this.viewer = viewer;
if (!positions) throw new Error("no positions object!");
this.positions = positions;
if (!height) throw new Error("no height object!");
this.height = height;
this.precision = precision || 256;
this.maxHeigh = -1000000;
this.createPolygonGeo(this.positions);
}
createPolygonGeo(points) {
//计算网格粒度-精度
let granularity = Math.PI / Math.pow(2, 11);
granularity = granularity / this.precision;
let polygonGeometry = new Cesium.PolygonGeometry.fromPositions({
positions: points,
vertexFormat: Cesium.PerInstanceColorAppearance.FLAT_VERTEX_FORMAT,
granularity: granularity,
});
//创建多边形平面几何体
this.geom = new Cesium.PolygonGeometry.createGeometry(polygonGeometry);
}
VolumeAnalysis() {
let cutArea = 0,
cutVolume = 0,
fillArea = 0,
fillVolume = 0,
noArea = 0;
const indices = this.geom.indices; //获取顶点索引数据
const positions = this.geom.attributes.position.values;
for (let index = 0; index < indices.length; index += 3) {
const pos0 = this.returnPosition(positions, indices[index]);
const pos1 = this.returnPosition(positions, indices[index + 1]);
const pos2 = this.returnPosition(positions, indices[index + 2]);
this.viewer.entities.add({
name: "三角面",
polygon: {
hierarchy: [pos0.heightPos, pos1.heightPos, pos2.heightPos],
perPositionHeight: true,
material: Cesium.Color.fromRandom(),
extrudedHeight: this.height,
outline: true,
outlineColor: Cesium.Color.BLACK,
},
});
//水平状态下三角形面积
const area = this.computeArea4Triangle(
pos0.noHeightPos,
pos1.noHeightPos,
pos2.noHeightPos
);
//计算三个点的均高
const height = (pos0.height + pos1.height + pos2.height) / 3;
if (height < this.height) {
// 需要填方的部分
fillArea += area;
const volume = area * (this.height - height);
fillVolume += volume;
} else if (height == this.height) {
noArea += area;
} else {
// 需要挖方的部分
cutArea += area;
const volume = area * (height - this.height);
cutVolume += volume;
}
}
const allArea = cutArea + fillArea + noArea;
this.result = {
allArea,
cutArea,
cutVolume,
fillArea,
fillVolume,
noArea,
};
return this.result;
}
computeCentroid4Polygon(positions) {
let x = [],
y = [];
let allX = 0,
allY = 0;
for (let i = 0; i < positions.length; i++) {
let cartographic = Cesium.Cartographic.fromCartesian(positions[i]);
allX += cartographic.longitude;
allY += cartographic.latitude;
x.push(cartographic.longitude);
y.push(cartographic.latitude);
}
let centroidx = allX / positions.length;
let centroidy = allY / positions.length;
const Cartographic = new Cesium.Cartographic(centroidx, centroidy);
return Cesium.Cartesian3.fromRadians(
Cartographic.longitude,
Cartographic.latitude,
this.maxHeigh + 30
);
}
/**
* 海伦公式求取三角形面积
* @param {*} pos1
* @param {*} pos2
* @param {*} pos3
* @returns 三角形面积㎡
*/
computeArea4Triangle(pos1, pos2, pos3) {
let a = Cesium.Cartesian3.distance(pos1, pos2);
let b = Cesium.Cartesian3.distance(pos2, pos3);
let c = Cesium.Cartesian3.distance(pos3, pos1);
let S = (a + b + c) / 2;
return Math.sqrt(S * (S - a) * (S - b) * (S - c));
}
returnPosition(positions, index) {
let cartesian = new Cesium.Cartesian3(
positions[index * 3],
positions[index * 3 + 1],
positions[index * 3 + 2]
);
let cartographic = Cesium.Cartographic.fromCartesian(cartesian);
let height = this.viewer.scene.globe.getHeight(cartographic);
if (height > this.maxHeigh) {
this.maxHeigh = height;
}
return {
heightPos: Cesium.Cartesian3.fromRadians(
cartographic.longitude,
cartographic.latitude,
height
),
noHeightPos: Cesium.Cartesian3.fromRadians(
cartographic.longitude,
cartographic.latitude,
0
),
height: height,
};
}
}
export default CutFillAnalysis;
没有合适的资源?快使用搜索试试~ 我知道了~
基于Cesium+VUE实现的填挖方分析功能,完整demo和源代码,代码未加密/未压缩,保证可直接调用运行

共4个文件
js:2个
vue:1个
md:1个

1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉

温馨提示
基于Cesium+VUE实现的填挖方分析功能,包括完整demo和源代码,代码未加密/未压缩,保证可直接运行 文章描述:https://blog.csdn.net/qq_34205305/article/details/124022368 代码不易,略收小费,使用过程中如果有任何问题欢迎在文章下进行评论,百分百回复哦
资源推荐
资源详情
资源评论

格式:zip 资源大小:10.8KB

格式:zip 资源大小:5.8KB



格式:zip 资源大小:359.1KB





格式:zip 资源大小:4.7KB

格式:zip 资源大小:3.2KB


格式:zip 资源大小:4.2KB

格式:zip 资源大小:2.6KB









格式:zip 资源大小:109.7MB



格式:zip 资源大小:72.4KB



格式:zip 资源大小:6.9KB

收起资源包目录






共 4 条
- 1


总要学点什么
- 粉丝: 982
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 基因工程一轮期末复习优秀.ppt
- 数字图像处理实验(MATLAB版).doc
- 人脸检测与目标点检测技术概述
- 操作系统课程实施方案报告【生产者消费者同步算法】.doc
- 移动通信电源部分考题.doc
- 【精品文档】项目管理学讲座.ppt
- 计算机软件开发中的JAVA编程语言分析.docx
- 巧用信息化平台优化小学英语听说课堂评价.docx
- 建设工程项目管理信息化发展问题分析.docx
- 大数据与国家形象战略传播.docx
- 大数据时代图书馆管理创新化策略探讨.docx
- 电气自动化专业基于PLC的全自动洗衣机控制系统.doc
- 单片机电子时钟课程设计方案报告.doc
- 基于互联网+的高校教务管理系统的分析与设计.docx
- NBU-Cluster-Server-Database-Agent-for-Oracle-配置指南.pdf
- C语言身份证管理.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制

- 1
- 2
- 3
- 4
- 5
- 6
前往页