樹心幽徑

« 20180727makeUbuntuKernel4.17.0 | Main | 20180919程式xml2b.c:解讀gpx航跡檔並另存為xmlout.gpx »

20180910-13安裝xml程式庫libxml2-dev並設計測試程式xml2.c用來解讀gpx航跡檔
2018/09/10,12:58

(1)安裝xml2程式庫:sudo apt-get install libxml2-dev

(2) xml參考: http://xmlsoft.org/tutorial/index.html

(3-1) 程式碼 : xml2.c

(3-2) data : midlake.gpx

(3-3) map : http://oldwww.kmvs.km.edu.tw/lf/gallery/70/midlake.png

(4) complie: g++ `xml2-config --cflags` xml2.c `xml2-config --libs`

(5) excute:

treehrt@treehrt-BM6AE-BM1AE-BP1AE:~/lake$ ./a.out midlake.gpx

Root is <gpx> (1)
node type: Element, name: metadata

WPT 0
WPT attr name =lat value= 24.676764998584986
WPT attr name =lon value= 121.61000397987664
WPT ele: 109.23812100000001
WPT Time: 2018-03-16T23:13:35Z
WPT name: 001大同郵局
WPT sym: City (Small)
node type: Element, name: wpt

WPT 1
WPT attr name =lat value= 24.681043960154057
WPT attr name =lon value= 121.60281800664961
WPT ele: 148.16665599999999
WPT Time: 2018-03-16T23:20:19Z
WPT name: 002涼亭
WPT sym: City (Small)
node type: Element, name: wpt

WPT 2
WPT attr name =lat value= 24.687358969822526
WPT attr name =lon value= 121.59566899761558
WPT ele: 257.38415500000002
WPT Time: 2018-03-16T23:25:00Z
WPT name: 003斗嫩橋岔
WPT sym: City (Small)
node type: Element, name: wpt

WPT 3
WPT attr name =lat value= 24.69071701169014
WPT attr name =lon value= 121.59258001483977
WPT ele: 384.38803100000001
WPT Time: 2018-03-16T23:35:57Z
WPT name: 004柵欄
WPT sym: City (Small)
node type: Element, name: wpt

WPT 4
WPT attr name =lat value= 24.703876012936234
WPT attr name =lon value= 121.5848679933697
WPT ele: 736.84240699999998
WPT Time: 2018-03-17T01:07:14Z
WPT name: 008崙埤山岔
WPT sym: City (Small)
node type: Element, name: wpt

WPT 5
WPT attr name =lat value= 24.704700959846377
WPT attr name =lon value= 121.57880100421607
WPT ele: 827.36859100000004
WPT Time: 2018-03-17T01:36:26Z
WPT name: 011崙埤池岔
WPT sym: City (Small)
node type: Element, name: wpt

:

:

:

TrkPT 1676
TrkPT attr name =lat value= 24.690732602030039
TrkPT attr name =lon value= 121.59257649444044
TrkPT ele: 387.06999999999999
TrkPT time: 2018-03-17T09:41:26Z

TrkPT 1677
TrkPT attr name =lat value= 24.690732099115849
TrkPT attr name =lon value= 121.59257171675563
TrkPT ele: 385.63
TrkPT time: 2018-03-17T09:41:39Z

node type: Element, name: trk

 

迴響

 
Accessible and Valid XHTML 1.0 Strict and CSS Powered by LifeType