osgEarth系列文章目录
文章目录
前言
osgearth源码工程中包含了osgearth_package工具,此工具用于切割DEM、DOM并形成金字塔。还可指定生成tms.xml。
处理图层
地图包含纹理层和高程层对象,这些层包含一些能够在运行时调整的属性
例如,你能够使用API打开,关闭,或者调整纹理层透明度等
在.earth文件中或者xml文件中添加下列代码,其中name可自己制定,url标签中添加dem模型所在的目录,可以写绝对路径或相对路径:
地球背景加载失败:
一、分析原因
在我们的资源配置文件中,地球的DEM数据没有找到,
二、修改配置文件
<document>
<dom>
<image driver="mbtiles" index="DOMT_None" max_level ="19" min_level = "0">
<filename>BaseData/dom.mbtiles</filename>
<cache_policy usage="none"/>
<format>jpeg</format>
<compute_levels>true</compute_levels>
</image>
<!-- <image driver="wms" index="DOMT_Local" max_level ="19" min_level = "0">
<cache_policy usage="none"/>
<url>http://demo.mapserver.org/cgi-bin/wms</url>
<srs>EPSG:4326</srs>
<tile_size>512</tile_size>
<layers>country_bounds,continents,bluemarble,cities</layers>
<styles>visual</styles>
<format>png</format>
</image> -->
<image driver="tms" index="DOMT_Local" max_level ="19" min_level = "0">
<cache_policy usage="none"/>
<!-- <url>http://Server:8888/DOM/tms.xml</url> -->
<!-- <url>http://nnu.geodata.cn:8009/DOM/tms.xml</url> -->
<url>../Media/DOM/tms.xml</url>
</image>
<image driver="xyz" index="DOMT_Google" max_level ="19" min_level = "0">
<cache_policy usage="read_write"/>
<url><![CDATA[http://khm[0123].google.com/kh/v=840&hl=zh&x={x}&y={y}&z={z}&s=]]></url>
<profile>global-mercator</profile>
<cache_id>google_dom</cache_id>
<nodata_image>Core/BaseData/img_nodata.jpg</nodata_image>
</image>
<!--<image driver="xyz" index="DOMT_Tianditu" max_level ="19" min_level = "0">
<cache_policy usage="read_write"/>
<url><![CDATA[http://t0.tianditu.gov.cn/img_w/wmts?tk=48d6f9ffb0a8d7e43c555f1b835b00b0&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={x}&TILECOL={y}]]></url>
<profile>global-mercator</profile>
<cache_id>tianditu_dom</cache_id>
<format>jpg</format>
</image>-->
<image driver="arcgis" index="DOMT_Arcgis_World_Transportation" max_level ="19" min_level = "0">
<cache_policy usage="read_write"/>
<url><![CDATA[ http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer]]></url>
<cache_id>arcgis_dom</cache_id>
</image>
<image driver="arcgis" index="DOMT_Arcgis" max_level ="19" min_level = "0">
<cache_policy usage="read_write"/>
<url><![CDATA[http://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/]]></url>
<cache_id>arcgis_dom</cache_id>
</image>
<image driver="arcgis" index="DOMT_ArcgisESRI" max_level ="19" min_level = "0">
<cache_policy usage="read_write"/>
<url><![CDATA[http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer]]></url>
<cache_id>arcgisesri_dom</cache_id>
</image>
<image driver="tms" index="DOMT_Readymap" max_level ="19" min_level = "0">
<cache_policy usage="read_write"/>
<url>http://readymap.org/readymap/tiles/1.0.0/7/</url>
<cache_id>readymap_dom</cache_id>
<nodata_image>Core/BaseData/img_nodata.jpg</nodata_image>
</image>
<image driver="xyz" index="DOMT_Mapbox" max_level ="19" min_level = "0">
<cache_policy usage="read_write"/>
<url><![CDATA[http://a.tiles.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.jpg?access_token=pk.eyJ1IjoiamFzb25iZXZlcmFnZSIsImEiOiJjaXV6dXViY2QwMDBxMm9wNnBpbDdreHU0In0.KcSEgP5z_w0mIWDYon29ng
]]></url>
<profile>global-mercator</profile>
<cache_id>mapbox_dom</cache_id>
<nodata_image>Core/BaseData/img_nodata.jpg</nodata_image>
</image>
</dom>
<dem>
<elevation driver="mbtiles" index = "DEMT_None" max_level ="19" min_level = "0">
<filename>BaseData/dem.mbtiles</filename>
<compute_levels>true</compute_levels>
<cache_policy usage="none"/>
</elevation>
<elevation driver="tms" index = "DEMT_Local" max_level ="10" min_level = "0">
<!-- <url>http://Server:8888/DEM/tms.xml</url> -->
<!-- <url>http://nnu.geodata.cn:8009/DEM/tms.xml</url> -->
<url>../Media/DEM/tms.xml</url>
<cache_policy usage="none"/>
</elevation>
<elevation driver="tms" index = "DEMT_Readymap" max_level ="10" min_level = "0">
<url>http://readymap.org/readymap/tiles/1.0.0/116/</url>
<cache_policy usage="read_write"/>
<cache_id>readymap_dem</cache_id>
</elevation>
<elevation driver="xyz" index = "DEMT_Mapbox" max_level ="19" min_level = "0">
<url><![CDATA[http://api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token=pk.eyJ1IjoiamFzb25iZXZlcmFnZSIsImEiOiJjaXV6dXViY2QwMDBxMm9wNnBpbDdreHU0In0.KcSEgP5z_w0mIWDYon29ng]]></url>
<profile>global-mercator</profile>
<elevation_encoding>mapbox</elevation_encoding>
<cache_policy usage="read_write"/>
<cache_id>mapbox_dem</cache_id>
</elevation>
</dem>
<map>
<image driver="mbtiles" index="MAPT_None" max_level ="19" min_level = "0">
<filename>Core/BaseData/map.mbtiles</filename>
<cache_policy usage="none"/>
<format>png</format>
<compute_levels>true</compute_levels>
</image>
<image driver="tms" index="MAPT_Local" max_level ="19" min_level = "0">
<cache_policy usage="none"/>
<url>http://Server:8888/MAP/tms.xml</url>
</image>
<image driver="xyz" index="MAPT_GoogleMap" max_level ="19" min_level = "0">
<cache_policy usage="read_write"/>
<url><![CDATA[http://khm[0123].google.com/kh/v=802&hl=zh&x={x}&y={y}&z={z}&s=]]></url>
<profile>global-mercator</profile>
<cache_id>googlemap_map</cache_id>
<nodata_image>Core/BaseData/img_nodata.jpg</nodata_image>
</image>
<image driver="xyz" index="MAPT_Autonavi" max_level ="19" min_level = "0">
<cache_policy usage="read_write"/>
<url><![CDATA[http://webst0[1234].is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}]]></url>
<profile>global-mercator</profile>
<cache_id>autonavi_map</cache_id>
<nodata_image>Core/BaseData/img_nodata.jpg</nodata_image>
</image>
<image driver="arcgis" index="MAPT_Arcgis" max_level ="19" min_level = "0">
<cache_policy usage="read_write"/>
<url><![CDATA[http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetColor/MapServer]]></url>
<profile>global-mercator</profile>
<format>PNG</format>
<cache_id>arcgis_map</cache_id>
<nodata_image>http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetColor/MapServer/tile/100/0/0.jpeg</nodata_image>
</image>
<image driver="xyz" index="MAPT_OpenStreetMap" max_level ="19" min_level = "0">
<cache_policy usage="read_write"/>
<url><![CDATA[http://[abc].tile.openstreetmap.org/{z}/{x}/{y}.png]]></url>
<profile>global-mercator</profile>
<cache_id>openstreetmap_map</cache_id>
<nodata_image>Core/BaseData/img_nodata.jpg</nodata_image>
</image>
</map>
<!-- 可编辑图片层 -->
<editable driver = "tms" max_level ="19" min_level = "0">
<cache_policy usage="none"/>
<url>CustomImage/Default/tms.xml</url>
<coverage>false</coverage>
<editable>true</editable>
<visible>false</visible>
<shared>true</shared>
<shared_sampler>DP_Edit_Image_Tex </shared_sampler>
<shared_matrix>DP_Edit_Image_Matrix</shared_matrix>
</editable>
<!-- 可编辑油彩层 -->
<editable driver = "tms" max_level ="19" min_level = "0">
<cache_policy usage="none"/>
<url>EditableLand/Default/tms.xml</url>
<coverage>true</coverage>
<editable>true</editable>
<visible>false</visible>
<shared>true</shared>
<shared_sampler>DP_Edit_Cover_Tex </shared_sampler>
<shared_matrix>DP_Edit_Cover_Matrix</shared_matrix>
</editable>
<fractal_elevation min_level="12" max_data_level="14" offset="true">
<cache_policy usage="no_cache"/>
<noise_image>data/seamless-noise-1.png</noise_image>
<amplitude>4</amplitude>
<base_lod>12</base_lod>
<frequency>64</frequency>
<persistence>0.65</persistence>
<lacunarity>4</lacunarity>
<octaves>24</octaves>
<gdal_image>GlobalLandCover</gdal_image>
<land_cover_mappings>
<mapping class= "water" amplitude="1"/>
<mapping class= "swamp" amplitude="0"/>
<mapping class= "tundra" amplitude = "6"/>
<mapping class= "cropland1" amplitude="4"/>
</land_cover_mappings>
</fractal_elevation>
</document>