【IT168 技術文檔】在Android平台上開發可能沒有真機的時候,我們通過DDMS中載入KML或NMEA檔案來模拟生産資料,使用方法參考新版ADT插件讓Android開發更人性化一文,最終這兩個檔案加載到/data/misc/location/gps/nmea或/data/misc/location/gps/kml/
一、KML檔案其實是一個XML檔案,我們看下KML檔案結構
1065 Brea Mall, Brea, CA 92821.kml
normal
#default_copy0+icon=http://maps.google.com/mapfiles/kml/pal3/icon60.png
highlight
#default_copy0+icon=http://maps.google.com/mapfiles/kml/pal3/icon52.png
1.1
http://maps.google.com/mapfiles/kml/pal3/icon52.png
1.1
http://maps.google.com/mapfiles/kml/pal3/icon60.png
1065 Brea Mall, Brea, CA 92821
1065 Brea Mall, Brea, CA 92821
-117.883593
33.916991
1000
#default_copy0+nicon=http://maps.google.com/mapfiles/kml/pal3/icon60.png+hicon=http://maps.google.com/mapfiles/kml/pal3/icon52.png
-117.883593,33.916991,0
二、NMEA協定就是正常的GPS資料,通過序列槽直接擷取到的,如下
$GPRMC,003347.000,A,3725.3433,N,12205.7920,W,0.08,149.46,061007,,,D*70
$GPRMC,003348.000,A,3725.3433,N,12205.7921,W,0.05,142.51,061007,,,D*7E
$GPRMC,003349.000,A,3725.3432,N,12205.7921,W,0.08,159.56,061007,,,D*7E
$GPRMC,003350.000,A,3725.3432,N,12205.7921,W,0.06,151.59,061007,,,D*7F
$GPRMC,003351.000,A,3725.3432,N,12205.7921,W,0.20,120.57,061007,,,D*72
執行個體:
解析方法:
RMC = Recommended Minimum Specific GPS/TRANSIT Data
$GPRMC,hhmmss.ss,A,llll.ll,a,yyyyy.yy,a,x.x,x.x,ddmmyy,x.x,a*hh
1 = UTC(universal time, coordinated) of position fix
2 = Data status (A=good, V=navigation receiver warning)
3 = Current Latitude
4 = North/South in Latitude Hemisphere
5 = Current Longitude
6 = East/West in Longitude Hemisphere
7 = Speed over ground in knots
8 = (Direction of travel N:0°, E:90°, S:180°, W:270°)
9 = UT DateStamp
10 = Magnetic variation degrees (Easterly var. subtracts from true course)
11 = East/West
12 = Checksum
$GPRMC,003347.000,A,3725.3433,N,12205.7920,W,0.08,149.46,061007,,,D*70
Parts:
1: 003347.000 --> 0:33 am 47 seconds 0 milliseconds (UTC(universal time, coordinated) of position fix)
2: A --> Status is ok (Data status (A=good, V=navigation receiver warning))
3: 3725.3433 (North/South in Latitude Hemisphere)
4: N --> North (North/South)
5: 12205.7920 (Current Longitude)
6: W --> West (East/West in Longitude Hemisphere)
7: 0.08 --> 0.08 knots/second (Direction: North/West) (Speed over ground in knots)
8: 149.46 --> sth. like SouthEast (Direction of travel N:0°, E:90°, S:180°, W:270°)
9: 061007 --> 6th October, 2007 (UT(universal time) DateStamp)
10: (Magnetic variation degrees (Easterly var. subtracts from true course))