One is decimal (looks like 83.5672 N 48.4532 W) This one is easy for computers to understand. The second is degree-minutes-seconds, which looks like 38° 53' 23" N, 77° 00' 32" W. The last is degree minutes (N 38° 23.5674' W 83° 43.5612') You may think that the GPS is outputting decimal, right? Wrong! It is actually degree-minutes with the punctuation omitted. If the GPS Says its at 4008.5398 N 08304.7582 W, then it is really N 40° 08.5398' W 83° 04.7582'. Just add a degree sign two digits before the decimal point.If you look at the raw output from your GPS device you can see something like that.
cat /dev/ttyACM3
latitude: 4253.0970 N
longitude: 01032.3917 E
To transform them into the right format first get the numbers before the point position minus 2.
(Not 100% sure if that's right?!)
4253.0970 = 42° ==> 53.0970 is left
01032.391 = 010° = 10° ==> 32.391 is left
Next, divide the rest by 60.
53.0970/60 = 0,88495
32.391/60 = 0,53985
Now just put them together do get the decimal degrees format
42,88495 10,53985
Last make sure if latitude is South, put and minus before that number. Same goes for longitude if it's West.
I wrote a bash script that reads from the device and does the job.
#!/bin/bash
device=$1
while read line;do
raw=$(echo $line | grep GPGGA | awk -F, '{printf "%f %f %s %s %s",$3,$5,$10,$4,$6}')
if [ -z "$raw" ];then
continue
fi
lat=$(echo $raw | awk '{printf $1}')
lon=$(echo $raw | awk '{printf $2}')
alt=$(echo $raw | awk '{printf $3}')
pointposlat=$(echo $lat | grep -b -o "\." | cut -d: -f1)
pointposlon=$(echo $lon | grep -b -o "\." | cut -d: -f1)
dpos1=$(($pointposlat-2))
dpos2=$(($pointposlon-2))
degree1=${lat:0:$dpos1}
degree2=${lon:0:$dpos2}
decmin1=$(echo "scale=6;${lat:2}/60" | bc)
decmin2=$(echo "scale=6;${lon:2}/60" | bc)
lat=$degree1$decmin1
lon=$degree2$decmin2
if [ $(echo $raw | awk '{printf $4}') = "S" ];then
lat="-$lat"
fi
if [ $(echo $raw | awk '{printf $5}') = "W" ];then
lon="-$lon"
fi
echo "Lat,Lon: $lat,$lon Alt: $alt"
done < $device
Usage: [sudo] ./gps.sh deviceNow you can feed it to maps
eg. http://www.gorissen.info/Pierre/maps/googleMapLocation.php
Please leave a comment if you see some mistakes or tips for optimization. Thank you.



.png)
.png)
.png)
.png)
.png)
.png)
.png)

