osgearth訪問幾種資料的幾種方式

2021-07-09 13:16:26 字數 3572 閱讀 2814

原文章:

osgearth訪問資料分類方式可以分為使用earth檔案載入和通過程式載入。

1.earth檔案方式比較簡單方便

只要掌握一定的格式就能訪問各種資料,下面就給出乙個例子:訪問網上的arcgis server 資料的例子

/tile/100/0/0.jpegata_image>

false

9非常感謝這個部落格 我就是從這篇部落格開始學習,大家如果對通過earth檔案載入資料可以看一下這部落格,主要是介紹一下通過程式載入資料的方法。

2.通過程式載入資料

趕緊進入正題,程式載入各種資料,首先介紹一下總體的方式

/*這裡***options 是根據不同的資料型別選擇不同驅動,比如載入本地資料可以使用gdaloptions ,加 載tms資料可以使

用tmsoptions(注意

tmsoptions可以載入

本地也可以載入網上資料),

wmsoptions可以載入網上資料(注意這個opti

ons主要載入影像和資料),arcgisopti

ons載入arcgis server發布資料。*/

osgearth::drivers::***options ***layer;

/*這裡就是載入的資料路徑,如果載入的本地資料就是本地資料的路徑,如果載入是網 上資料就是相應的***/

***layer.url()=osgearth::uri(".................................");

/*載入的資料是分層管理,每載入進來乙個資料在earth上就是乙個資料層,這裡給資料層付個名字。*/

std::string layername="earth";

/*osgearth裡layer主要有三種型別 imagelayer、elevationlayer和modlelayer ,前兩個大家從字面就可以知道第乙個是載入影像和第二個是載入高程資料的,第三個是主要用來載入shp資料,至少我是這樣用的,不知道還能否載入其他資料型別。確定載入用的驅動、資料來源位置(路徑)、資料層名和初始化了資料層,接下來就是把資料層加到地球中如下所示。*/

osg::ref_ptrlayer =new   osgearth::***layer(osgearth::***layeroptions(layername,***layer));

m_pmap->addimagelayer(layer.get());

(1)載入本地資料

a  本地影像資料,資料型別為tif

osgearth::drivers::gdaloptions imagelayeropt;//選擇gdaloptions

imagelayeropt.url() = osgearth::uri("e:\\vs2010progam files\\osgvr74\\osgvr74\\world.tif");//影像資料路徑

std::string imagelayername = "worldimage"; //影像資料層名

osg::ref_ptrimagelayer = new  

osgearth::imagelayer(osgearth::imagelayeroptions(imagelayername ,imagelayeropt));

//初始資料層

m_pmap->addimagelayer(

imagelayer .get());

b 本地高程資料,資料型別為tif

osgearth::drivers::gdaloptions demlayeropt; //使用還是gdaloptions

demlayeropt.url() = osgearth::uri("e:\\vs2010progam files\\osgvr74\\osgvr74\\worlddem.tif");//高程資料路徑

std::string demlayername = "worlddem";//高程資料層名

osg::ref_ptrdemlayer = new osgearth::imagelayer(osgearth::imagelayeroptions(demlayername,demlayeropt));//初始資料層

m_pmap->addimagelayer(

demlayer.get());

載入本地經過package 切片的資料還可以用tmsoptions,

osgearth::drivers::tmsoptions tmsopt;////選擇tmsoptions 驅動

tmsopt.url()=osgearth::uri("//edvis_-1/layer_0/tms.xml");

//package 切片生成金字塔檔案下的 xml

std::stringdemtmslayername="tmsdem";//圖層名

osgearth::elevationlayeroptionstmslayeropt(demtmslayername,tmsopt);

osg::ref_ptrtmsdemlayer = new osgearth::elevationlayer(tmslayeropt);

m_pmap->addelevationlayer(tmsdemlayer.get());

//初始化圖層並加入到地球中

(2)載入網上資料

a 載入arcgis server 發布的資料 載入方式與上面提到的類似

//這裡注意,當osgearth訪問arcgis server 發布資料的時候有些問題很奇怪,用上面的方式訪問arcgis server 國外發布的資料沒問題,但是訪問自己發布的資料就會有問題,經過試驗投影要設成3857才能正常訪問。

b 載入網上資料還可以用wmsoptions 載入方式同上。

java幾種資料轉換

將兩個位元組轉換成整型 param input the input return the int from the array public static intgetintfrom2bytearray final byte input 將乙個位元組轉換成整型 for example,ff will...

Android的幾種資料儲存方式

在android,可供選擇的儲存方式包括了sharedpreferences 檔案儲存 sqlite資料庫儲存方式 內容提供器方式 content provider 以及網路方式 5種,具體如下 1 sharedpreferences是android提供的一種配置檔案讀寫方式,預設存在應用的data...

python的幾種資料結構

python 包含6種內建的序列 一種資料型別,所有元素都進行了編號 元組 不可變序列 函式 tuple 將乙個序列轉換為元組 索引和分片 字串 不可變序列 函式 find 查詢子字串,返回第乙個值索引未找到返回 1,還可指定起始點和結束點 join split逆方法,連線字串列表 lower 返回...