GIS-3D:测量

前言

上节中,介绍了GIS地图中路线、图形的绘制。在路线绘制完成后,有事需要计算路线的长度或区域的面积,本章节介绍如何进行计算。

一、路径距离测量

  • 绘制路线
  • 根据路线中所有的点位,来计算路线的长度
   calculateTotalDistance(positions: any[]) {
    let total = 0;
    for (let i = 0; i < positions.length - 1; i++) {
      total += Cesium.Cartesian3.distance(positions[i], positions[i + 1]);
    }
    return total;
  }

二、 区域面积测量

  // 计算平面多边形面积(适用于小范围区域)
  calculatePlanarArea(positions: any) {
    let area = 0;
    const n = positions.length;

    for (let i = 0; i < n; i++) {
      const j = (i + 1) % n;
      area += positions[i].x * positions[j].y;
      area -= positions[j].x * positions[i].y;
    }

    return Math.abs(area) / 2;
  }
  • 根据已选择点的坐标,计算区域中心点的坐标
    // 中心点
    const center = Cesium.BoundingSphere.fromPoints(this.polygonPoints).center;
    const cartographic = Cesium.Cartographic.fromCartesian(
      center,
      viewer.scene.globe.ellipsoid,
      new Cesium.Cartographic(),
    );
    const lat = Cesium.Math.toDegrees(cartographic.latitude);
    const lng = Cesium.Math.toDegrees(cartographic.longitude);

    const position = Cesium.Cartesian3.fromDegrees(lng, lat, this.maxHeight);
    // 可以将面积的数据,显示在中心点上

三、源代码

demo

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 对于Smart3D使用的常见问题进行了汇总,看是否能够帮到大家。 【文中所附答案只是建议,只能作为参考不能作为标准...
    三维GIS那点事_王跃军阅读 118,304评论 108 76
  • 前言 在Cesium中,可使用Entity绘制一些图形,包括点、线、圆形、长方形、不规则图形等,从而满足我们在实际...
    fanren阅读 20评论 0 0
  • 实例数据:https://pan.baidu.com/s/1vHK31QQKwpLi8BBq7hcxcw 密码:...
    ZHOUZAIHUI阅读 10,471评论 0 5
  • GNSS:差分全球卫星导航系统 差分全球导航卫星系统是一种高度精确(厘米以内)的常规测量技术,它使用接收器已知的位...
    生活的探路者阅读 4,699评论 0 0
  • 前言 openlayers还提供了测量相关的api,可在地图上测量路线的长度,以及区域的面积。通过此api,可开发...
    fanren阅读 17评论 0 0

友情链接更多精彩内容