最近要讀取kml檔案,具體就是把kml檔案當作乙個向量檔案來讀取。我發現gdal是支援整合kml庫的。不過整合這個kml庫的地方有點複雜。下面作乙個詳細的說明。
首先要libkml和expat這兩個庫,具體是修改gdal原始碼根目錄下的nmake.opt,將expat_dir放在libkml_dir的前面(為了確保expat_lib能被libkml_libs識別),具體修改如下:
# uncomment for expat support (required for kml, gpx and georss read support).
expat_dir = $(third_party)/expat_2_1_0_vc9
expat_include = -i$(expat_dir)/include
!ifdef debug
expat_lib = $(third_party)/expat_2_1_0_vc9/lib/libexpatd.lib
!else
expat_lib = $(third_party)/expat_2_1_0_vc9/lib/libexpat.lib
!endif
libkml_dir的設定修改如下:
# uncomment out the following lines to enable libkml support.
libkml_dir = $(third_party)/libkml_1_3_0_vc9
libkml_include = -i$(libkml_dir)/include -i$(third_party)/boost_1_42_vc9/include
libkml_library = $(libkml_dir)/lib
libkml_libs = $(libkml_library)/libkmlbase.lib \
$(libkml_library)/libkmlconvenience.lib \
$(libkml_library)/libkmldom.lib \
$(libkml_library)/libkmlengine.lib \
$(libkml_library)/libkmlregionator.lib \
$(libkml_library)/libkmlxsd.lib \
$(third_party)/minizip_vc9/lib/minizip_static.lib \
$(expat_lib) \
$(third_party)/uriparser_0_7_5_vc9/lib/uriparser.lib \
# $(libkml_dir)/third_party\zlib-1.2.3.win32/lib/minizip.lib \
$(third_party)/zlib_1_2_3_vc9/lib/libzlib_vc9_1_2_3.lib
可以除了kml本身的庫外,還要新增minizip庫、expat庫、boost庫和zip庫。
這樣就能將kml庫整合進來。還有一點需要注意的是,我發現kml並不支援傳統的shp檔案的向量型別,因此要過載kml圖層類的getgeomtype介面(將kml型別轉換為傳統的shp的向量型別),這個介面的實現**如下:
ogrwkbgeometrytype ogrlibkmllayer::getgeomtype()
} m_poogrfeaturedefn->setgeomtype(etype);
return etype;
}
GDAL庫的編譯
gdal庫的編譯相對簡單,這裡以在vs2005環境,應用到c 程式中為例進行編譯 gdal and mapserver build sdk packages provides to compile mapserver and gdal by yourself 使用vs2005提供的cmd工具,定位到...
gdal庫的學習和使用
1 windows下的編譯 1.1 解壓後開啟nmake.opt,設定gdal home 1.2 進入vs的command promot,進入正常的那個即可,64位的沒試過,可以參考gdal官網 1.3 nmake f makefile.vc 1.4 nmake f makefile.vc inst...
ROS的庫整合
結合opencv和moveit,可以讓你的機械人檢測並拾取乙個物件。ros為您提供了與這些專案和其他流行的開源專案的無縫整合,以及乙個訊息傳遞系統,該系統允許您輕鬆地交換不同的資料來源,這些資料來源可以是實時感測器 也可以是日誌檔案。gazebo是乙個3d多機械人模擬器,可以用於室內外的場景。gaz...