osgearth介紹


 

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提供的數據,包含一個地球、經緯線、國界線、各國名字。

 

  1.  
    <!--
  2.  
    osgEarth Sample
  3.  
     
  4.  
    Demonstrates feature draping using projective texturing,
  5.  
    i.e. "altitude-clamping: terrain-drape".
  6.  
    -->
  7.  
     
  8.  
    <map name="Geometry Rasterizer Demo" type="round" version="2">
  9.  
     
  10.  
    <options>
  11.  
    <lighting>false</lighting>
  12.  
    <terrain min_lod="16"/>
  13.  
    </options>
  14.  
     
  15.  
    <image name="world" driver="gdal">
  16.  
    <url>../data/world.tif</url>
  17.  
    <cache_policy usage="no_cache"/>
  18.  
    </image>
  19.  
     
  20.  
    <model name="world_boundaries" driver="feature_geom">
  21.  
     
  22.  
    <features name="earth" driver="ogr">
  23.  
    <url>../data/world.shp</url>
  24.  
    <build_spatial_index>true</build_spatial_index>
  25.  
    </features>
  26.  
     
  27.  
    <styles>
  28.  
    <style type="text/css">
  29.  
    world {
  30.  
    stroke: #ffff00;
  31.  
    stroke-width: 5px;
  32.  
    altitude-clamping: terrain-drape;
  33.  
    }
  34.  
    </style>
  35.  
    </styles>
  36.  
     
  37.  
    </model>
  38.  
     
  39.  
    <extensions>
  40.  
    <graticule>
  41.  
    <!-- The approximate number of grid lines that you would like to see in your view extent.
  42.  
    This number, along with the resolutions list, will be used to select a resolution on each view.
  43.  
    -->
  44.  
    <grid_lines>10</grid_lines>
  45.  
     
  46.  
    <!-- The grid resolutions, in degrees that you want to see, all separated by a space and sorted from lowest resolution to highest -->
  47.  
    <!--
  48.  
    <resolutions>10 5 2.5 1.25</resolutions>
  49.  
    -->
  50.  
     
  51.  
    <!-- The grid line color -->
  52.  
    <color>#f7a73f70</color>
  53.  
     
  54.  
    <!-- The label color -->
  55.  
    <label_color>#ffff00ff</label_color>
  56.  
     
  57.  
    <!-- Specify the line width -->
  58.  
    <line_width>2</line_width>
  59.  
    </graticule>
  60.  
    </extensions>
  61.  
     
  62.  
    <model name="cities" driver="feature_geom">
  63.  
     
  64.  
    <features name="cities" driver="ogr">
  65.  
    <url>../data/world.shp</url>
  66.  
     
  67.  
    <!--Define a ChangeAttributeFilter, which is defined in the osgearth_featurefilter example. This will change the cntry_name of all countries to osgEarthLand.-->
  68.  
    <change_attribute key="cntry_name" value="osgEarthLand"/>
  69.  
    </features>
  70.  
     
  71.  
    <styles>
  72.  
    <style type="text/css">
  73.  
    cities {
  74.  
    text-provider: annotation;
  75.  
    text-content: [cntry_name];
  76.  
    text-priority: [pop_cntry];
  77.  
    text-halo: #3f3f7f;
  78.  
    text-align: center_center;
  79.  
    text-declutter: true;
  80.  
    }
  81.  
    </style>
  82.  
    </styles>
  83.  
     
  84.  
    </model>
  85.  
     
  86.  
     
  87.  
    </map>

第15行加載地球模型,第20行加載國界,第39行加載經緯線,第62行加載國名。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM