osgearth介紹

 

osgEarth爲開發osg應用提供了一個地理空間SDK和地形引擎.css

osgEarth的目標:html

l 提供基於osg開發3D地理空間應用的支持;web

l 直接從數據源可視化地形模型和影像變得更加簡單;數據庫

l 提供對開放式繪圖標準,技術和數據的交互操做;api

在不少情形下,osgEarth能夠替代離線地形數據庫建立工具,你能夠經過osgEarth完成以下工做:緩存

獲取地形基礎地圖並快速而流暢的運行服務器

訪問開放式標準的地圖數據服務,例如WMS和TMSapp

將基於web服務的影像數據和本地存儲的數據整合ide

在運行時嵌入新的地理空間數據層工具

超時處理可能改變的數據

集成商業數據源

社區資源

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行加載國名。

相關文章
相關標籤/搜索