osgEarth為開發osg應用提供了一個地理空間SDK和地形引擎.
osgEarth的目標:
l 提供基於osg開發3D地理空間應用的支持;
l 直接從數據源可視化地形模型和影像變得更加簡單;
l 提供對開放式繪圖標准,技術和數據的交互操作;
在很多情形下,osgEarth可以替代離線地形數據庫創建工具,你可以通過osgEarth完成如下工作:
獲取地形基礎地圖並快速而流暢的運行
訪問開放式標准的地圖數據服務,例如WMS和TMS
將基於web服務的影像數據和本地存儲的數據整合
在運行時嵌入新的地理空間數據層
超時處理可能改變的數據
集成商業數據源
社區資源
osgEarth是一個自由開源的SDK,任何人斗可以獲取源碼,同時歡迎和鼓勵參與社區的測試,新功能研發和bug修復.
工具
osgEarth自帶很多協助處理earth文件和地理空間數據的工具.
osgearth_viewer
從命令行加載並顯示一個地圖.osgEarth提供的地球操縱器用於控制相機,對地理空間數據的瀏覽進行了優化.
osgearth_version
顯示osgEarth的當前版本號.
osgearth_cache
管理osgEarth的緩存.osgearth_cache較常用的用法:通過非交互方式--seed參數生成緩存信息.
osgearth_cache --seed file.earth
osgearth_package
從earth文件創建一個基於TMS格式,可重復發布的包。
osgearth_package --tms file.earth --out package
osgearth_conv
將瓦片源中到內容拷貝到另一個文件。所有參數以鍵值對方式出現,需要為每個驅動選項查找頭文件。當然,輸出驅動必須支持寫(通過實現ReadWriteTileSource接口)。"in"屬性來自於GDALOptions getConfig方法。"out"屬性來自於MBTilesOptions getConfig方法。
osgearth_conv --in driver gdal --in url world.tif --out driver mbtiles --out filename world.db
osgearth_tfs
從特征源(例如shapefile)產生一個TFS數據集。通過將源預處理成網格結構(TFS),可極大提升大數據集的性能。同時,產生的TFS包可由web服務器提供服務。
osgearth_tfs filename
osgearth_backfill
用於后期處理TMS數據集的特殊工具。一些web地圖服務在不同縮放比例下會使用完全不同的數據集。例如,當縮放比例達到4級時,可能使用NASA 的BlueMarble,然后陡然切換到地球資源衛星數據。在2D場景下,對於較光滑的地圖有效,但是在3D場景下,整張圖看起來會很不均勻,因為在不同的LODs下,相鄰的瓦片看起來會完全不同。
Osgearth_backfill產生一個TMS數據集(使用osgearth_package或其他工具),然后從指定的查看高度填充較低縮放級別的細節。例如,你可以指定最大縮放級別10,0-9的lods就可以從10級的數據重新生成。
osgearth_boundarygen
產生邊界地理信息,可使用osgEarth<mask> 將外部模型數據嵌入地形信息中。
osgearth_boundarygen model_file [options]
osgearth_overlayviewer
調試疊加功能。運行時顯示兩個窗口,一個顯示普通的地圖視圖,一個顯示包含邊界的視錐體視圖(用於疊加計算)。
osgearth_graticule
加載經緯線
地圖
Osgearth提供了大量的地圖文件,每個文件都對應某類功能,可通過osgearth_viewer查看運行效果。
Feature_drapped_lines.earth: 顯示國界線
Feature_clip_plane.earth: 顯示透明地球+國界線
Feature_custom_filters.earth: 根據縮放級別動態顯示國名
Feature_drapped_polygons.earth: 相鄰國家使用不同顏色顯示
Feature_models.earth: 緊貼地表繪制的三維圖形
Graticule.earth: 顯示經緯線及經緯線位置(包含較清晰高層數據,未穿越雲層)
Ldb.earth: 在地球某一高度顯示一只靜態的飛機
實例
以下地圖文件基於osgearth提供的數據,包含一個地球、經緯線、國界線、各國名字。
-
<!--
-
osgEarth Sample
-
-
Demonstrates feature draping using projective texturing,
-
i.e. "altitude-clamping: terrain-drape".
-
-->
-
-
<map name="Geometry Rasterizer Demo" type="round" version="2">
-
-
<options>
-
<lighting>false</lighting>
-
<terrain min_lod="16"/>
-
</options>
-
-
<image name="world" driver="gdal">
-
<url>../data/world.tif</url>
-
<cache_policy usage="no_cache"/>
-
</image>
-
-
<model name="world_boundaries" driver="feature_geom">
-
-
<features name="earth" driver="ogr">
-
<url>../data/world.shp</url>
-
<build_spatial_index>true</build_spatial_index>
-
</features>
-
-
<styles>
-
<style type="text/css">
-
world {
-
stroke: #ffff00;
-
stroke-width: 5px;
-
altitude-clamping: terrain-drape;
-
}
-
</style>
-
</styles>
-
-
</model>
-
-
<extensions>
-
<graticule>
-
<!-- The approximate number of grid lines that you would like to see in your view extent.
-
This number, along with the resolutions list, will be used to select a resolution on each view.
-
-->
-
<grid_lines>10</grid_lines>
-
-
<!-- The grid resolutions, in degrees that you want to see, all separated by a space and sorted from lowest resolution to highest -->
-
<!--
-
<resolutions>10 5 2.5 1.25</resolutions>
-
-->
-
-
<!-- The grid line color -->
-
<color>#f7a73f70</color>
-
-
<!-- The label color -->
-
<label_color>#ffff00ff</label_color>
-
-
<!-- Specify the line width -->
-
<line_width>2</line_width>
-
</graticule>
-
</extensions>
-
-
<model name="cities" driver="feature_geom">
-
-
<features name="cities" driver="ogr">
-
<url>../data/world.shp</url>
-
-
<!--Define a ChangeAttributeFilter, which is defined in the osgearth_featurefilter example. This will change the cntry_name of all countries to osgEarthLand.-->
-
<change_attribute key="cntry_name" value="osgEarthLand"/>
-
</features>
-
-
<styles>
-
<style type="text/css">
-
cities {
-
text-provider: annotation;
-
text-content: [cntry_name];
-
text-priority: [pop_cntry];
-
text-halo: #3f3f7f;
-
text-align: center_center;
-
text-declutter: true;
-
}
-
</style>
-
</styles>
-
-
</model>
-
-
-
</map>
第15行加載地球模型,第20行加載國界,第39行加載經緯線,第62行加載國名。