zoukankan      html  css  js  c++  java
  • cesium 之加载地形图 Terrain 篇(附源码下载)

    前言

    cesium 官网的api文档介绍地址cesium官网api,里面详细的介绍 cesium 各个类的介绍,还有就是在线例子:cesium 官网在线例子,这个也是学习 cesium 的好素材。

    内容概览

    1.基于cesium 实现地形图 Terrain 效果
    2.源代码 demo 下载

    本篇实现 cesium 加载地形图 Terrain 功能,效果图如下:

    • cesium 支持地形图数据格式
      Quantized-mesh ,Cesium团队提供的开发的格式
      Heightmap,Google Earth Enterprise
    • cesium 加载地形图类 CesiumTerrainProvider
      cesium 中添加地形数据,我们创建一个 CesiumTerrainProvider, 指定一个 URL 地址和一些配置的选项,然后讲它分配给一个 viewer.terrainProvider。在这个实例中,我们可以使用 createWorldTerrain 辅助功能创建一个 Cesium 世界地形。
      核心代码:
    //Cesium动态叠加地形图
    MapConfig.terrainObj = {url:"//assets.agi.com/stk-terrain/world",requestWaterMask:false,requestVertexNormals:false,proxyUrl:""};
    MapConfig.terrainObj = {url:"http://localhost:8180/cesium/worldTerrain",requestWaterMask:false,requestVertexNormals:false,proxyUrl:""};
     
    /**
    * 添加地形图图层
    * @method addTerrainLayer
    * @param url 地形图url proxyUrl 代理请求url
    * @return
    */
    addTerrainLayer: function (terrainObj) {
    if (terrainObj.url && terrainObj.url.replace(/(^s*)|(s*$)/g, "").length >0)
    {
    var provider ={};
    if(terrainObj.proxyUrl && terrainObj.proxyUrl.length>0)
    provider = {proxy:new Cesium.DefaultProxy(terrainObj.proxyUrl),url:terrainObj.url,requestWaterMask:terrainObj.requestWaterMask,requestVertexNormals:terrainObj.requestVertexNormals};
    else
    provider = {url:terrainObj.url,requestWaterMask:terrainObj.requestWaterMask,requestVertexNormals:terrainObj.requestVertexNormals};
     
    var terrainProvider = new Cesium.CesiumTerrainProvider(provider);
    this.cesiumViewer.terrainProvider = terrainProvider;
    }
    }

    RequestWaterMask 和 requestVertexNormals 的配置选项,是告诉 Cesium 需要额外的获取水和照明效果。默认情况下他们设置是 false。

    更多的详情见GIS之家小专栏

    文章尾部提供源代码下载,对本专栏感兴趣的话,可以关注一波

  • 相关阅读:
    21.Merge Two Sorted Lists 、23. Merge k Sorted Lists
    34. Find First and Last Position of Element in Sorted Array
    leetcode 20. Valid Parentheses 、32. Longest Valid Parentheses 、301. Remove Invalid Parentheses
    31. Next Permutation
    17. Letter Combinations of a Phone Number
    android 常见分辨率(mdpi、hdpi 、xhdpi、xxhdpi )及屏幕适配注意事项
    oc 异常处理
    oc 类型判断
    oc Delegate
    oc 协议
  • 原文地址:https://www.cnblogs.com/giserhome/p/9393952.html
Copyright © 2011-2022 走看看