Added a first script to generate KML file (for google maps)
authorluceor <luceor@luceor-ePC4.(none)>
Mon, 13 Jun 2011 13:39:38 +0000 (15:39 +0200)
committerluceor <luceor@luceor-ePC4.(none)>
Mon, 13 Jun 2011 13:39:38 +0000 (15:39 +0200)
script-graph-kml [new file with mode: 0755]

diff --git a/script-graph-kml b/script-graph-kml
new file mode 100755 (executable)
index 0000000..3c19a27
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+GPS=mygps-boulot.txt
+
+KML="$(basename "${GPS}" .txt).kml"
+
+(
+    cat <<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+<Folder>
+EOF
+
+    nb=0
+    lat_prev=0
+    lon_prev=0
+
+
+    grep "^Latitude:" "${GPS}" | awk '{print $2" "$5}' | while read lat lon;
+    do
+       if [ "${lat}" != "${lat_prev}" -o "${lon}" != "${lon_prev}" ]; then
+
+           nb=$(( $nb + 1 ))
+           lat_prev="${lat}"
+           lon_prev="${lon}"
+
+           cat <<EOF
+  <Placemark>
+       <name>${nb}</name>
+       <description>GPS latitude: ${lat}, longitude: ${lon}</description>
+         <gx:balloonVisibility>1</gx:balloonVisibility>
+         <Point>
+               <altitudeMode>clampToGround</altitudeMode>
+               <coordinates>${lon},${lat}</coordinates>
+               </Point>
+  </Placemark>
+EOF
+       fi
+    done
+
+    cat <<EOF
+</Folder>
+</kml>
+EOF
+) | tee "${KML}"
+