1. 导出纹理
导出多张大图,大小为2的整数次幂,格式为tif,如:
x1.tif x2.tif x3.tif x4.tif
2. 生成中间文件
osgdem.exe -t x1.tif -t x2.tif -t x3.tif -t x4.tif --geocentric -l 1 -o output.ive
该命令执行过程中生成被重投影过的中间文件,如
temportaryfile_1.tif
temportaryfile_2.tif
temportaryfile_3.tif
temportaryfile_4.tif
该中间文件是我们需要的数据,原有的tif文件可以删除。
根据需要重命名中间文件,可借助工具,如下:
temportaryfile_1.tif -> 1.tif
temportaryfile_2.tif -> 2.tif
temportaryfile_3.tif -> 3.tif
temportaryfile_4.tif -> 4.tif
3. 编写earth文件
<map name="Geometry Rasterizer Demo" type="geocentric" version="2">
<image name="world" driver="gdal">
<url>world.tif</url>
</image>
<heightfield name = "dem" driver = "gdal">
<url>dem/sx_astergdemv2.tif</url>
</heightfield>
<image name="detial-image" driver="composite">
<image name="1" driver="gdal">
<url>maps/rp/1.tif</url>
</image>
<image name="11" driver="gdal">
<url>maps/rp/2.tif</url>
</image>
<image name="12" driver="gdal">
<url>maps/rp/3.tif</url>
</image>
<image name="13" driver="gdal">
<url>maps/rp/4.tif</url>
</image>
</image>
<image name="earth" driver="agglite">
<features name="earth" driver="ogr">
<url>world.shp</url>
<build_spatial_index>true</build_spatial_index>
</features>
<styles>
<style type="text/css">
earth {
stroke: #ffff00;
stroke-width: 2px;
altitude-clamping: terrain-drape;
}
</style>
</styles>
</image>
<options>
<cache type="filesystem">
<path>./FileCache</path>
</cache>
</options>
</map>
4. 生成cache
osgearth_cache.exe --seed china.earth --min-level 1 --max-level 3
osgearth_cache.exe --seed china.earth --bounds 103 30 115 35 --min-level 1 --max-level 5
osgearth_cache.exe --seed china.earth --bounds 108.5 34 109.5 35 --min-level 1 --max-level 6
逐步缩小范围,提高精度。
5. 运行测试
osgearth_viewer.exe china.earth