上一篇《Navit學習筆記(一)》主要簡要闡述了Navit的一些特徵,怎樣下載源代碼、怎樣在Unbuntu 10.04下進行安裝的準備並進行默認安裝。因爲Navit是模塊化設計的,根據安裝平臺的不同需求對其進行配置。本文的主要目的是講述Navit的配置問題。
Navit的設置是通過編輯navit.xml文件實現的。當登入Navit是,程序會加載navit.xml文件設置程序。如果是SVN獲取的源代碼navit.xml文件在主目錄下,如果是安裝程序,配置文件在/usr/shared/navit 或者 /etc/navit文件夾下。
1、用戶圖形接口
Navit通過插件形式提供多種用戶圖形接口。下面簡要的介紹一下兩種已經成功地嵌入於Navit的GUI。
Internal GUI:它是當前最新的GUI主要是用於觸摸屏設備的,這個GUI現在還在不同的開發完善中。由於本學習筆記針對Navit的核心模塊和功能,對於觸摸屏設置這部分還請大家參考《Internal GUI》,那裏有這部分的具體實現新式和最新進展。
GTK GUI:在本文中,我們將簡要介紹GTK,更詳細的介紹請查閱《Custom GTK Tutorial》 GTK是Navit默認的GUI,其一般設置如下:
* toolbar="0" will disable the tool bar. Useful on devices with small screens
* statusbar="0" will disable the status bar. Useful on devices with small screens
2、一些可以更改的設置
加載起始點(起始經緯值)
GSP 模塊可以爲 Navit 提供當地的經緯度值,也就是說可以爲Navit提供起始位置。但我們也可以手動設置,特別是沒有GPS模塊時。當地的經緯度信息可以從http://maps.google.com/上獲取,也可以從http://itouchmap.com/latlong.html 獲取,在navit.xml 文件中設置如下:
注:設置中的經緯度的值是實際經緯度值 x 100,並取整。
地圖設置
在使用Navit前,要在navit.xml 添加我們的地圖。Navit 能夠使用多種地圖格式。以下是一些能在Navit上使用的地圖格式設置嚮導鏈接,大家可以根據自己的關注點查看詳細信息,本文將以Open Street Maps 地圖格式爲例闡述Navit的地圖設置。
*For a guide on using European maps please go to the European Maps Guide
*For a guide on using Garmin aps please go to the Garmin Maps Guide
*For information regarding US/Tiger Data aps please go to Tiger Maps Guide
*For other maps not included please refer to the Other Maps Guide
我們可以從“Navit Planet Extractor”上獲取你想要的OSM地圖(這裏是北京市區的地圖)。然後在navit.xml文件添加
車輛導航
這一節設置Navit的GPS數據源,Navit支持三種數據源獲取方式:網絡、文件和GPS設備。
* source="file:/dev/ttyS0" - /dev/ttyS0 for serial GPS connected to the first serial port
* source="file:/dev/rfcomm0" - BlueTooth GPS, /dev/rfcomm0 must be configured in /etc/bluetooth/rfcomm.conf
* source="pipe:/usr/bin/gpspipe -r" - any executable that produces NMEA output - gpsbabel, gpspipe, ...
調試
當Navit程序崩潰時,它能夠自動的啓動gdb進行調式。但需要對navit.xml進行設置。
如果想要得到更多的關於系統錯誤的信息
<debug name=osd_core:osd_nav_next_turn_draw level="1" />
其中level的設置值如下:
* level="1" : let navit display a backtrace with gdb. This is the default setting.
* level="2" : let navit enter an interactive gdb session
3、深入學習配置文件
配置文件構造
配置的文件的構造可以通過主目錄下的navit.dtd文件查看。查看配置文件,最先出現的是<plugins>節,這一節的說明我們稍候闡述。接下來,我們可以看到Navit的初始化設置。
*gui 默認設置
*一輛或者多輛車輛的跟蹤(GPS數據)
*地圖設置,使用一個或者多個地圖數據
<map type="mg" enabled="yes" data="/opt/reiseplaner/travel/DE.map" />
<map type="mg" enabled="yes" data="/opt/reiseplaner/travel/DE.map/smp2.smp" />
</mapset>
*最後添加顯示的層數。