Added a small program to post process RAW file and generate a RINEX file
[gps] / script-graph-kml
1 #!/bin/sh
2
3 GPS=mygps-maison.txt
4
5 create_kml() {
6     GPS="$1"
7     KML="$(basename "${GPS}" .txt).kml"
8
9 (
10     cat <<EOF
11 <?xml version="1.0" encoding="UTF-8"?>
12 <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
13 <Placemark>
14         <name>Path</name>
15         <LineString>
16                 <extrude>1</extrude>
17                 <tessellate>1</tessellate>
18                 <altitudeMode>relativeToGround</altitudeMode>
19                 <coordinates>
20 EOF
21
22     nb=0
23     lat_prev=0
24     lon_prev=0
25
26
27     grep "^Latitude:" "${GPS}" | awk '{print $2" "$5}' | while read lat lon;
28     do
29         if [ "${lat}" != "${lat_prev}" -o "${lon}" != "${lon_prev}" ]; then
30
31             nb=$(( $nb + 1 ))
32             lat_prev="${lat}"
33             lon_prev="${lon}"
34
35             cat <<EOF
36                         ${lon},${lat},10
37 EOF
38         fi
39     done
40
41     cat <<EOF
42                 </coordinates>
43         </LineString>
44 </Placemark>
45 </kml>
46 EOF
47 ) | tee "${KML}"
48 }
49
50 for file in $*; do
51     create_kml "${file}"
52 done
53