1#!/usr/local/bin/bash 2 3# This shell script copies Xastir snapshots from the directory in which 4# they are created ~/.xastir/temp to a directory where a web server can deliver 5# them as a kml feed to overlay the current snapshot from on the terrain in a kml 6# capable application that is subscribed to the feed. 7# 8# You will need to set two parameters for this script: 9# 1. set DIR= to the directory into which you wish to copy the snapshot files. 10# This can be a directory on a remote webserver mounted using sshfs. 11# 2. change www.example.com to the address of your webserver. You will also 12# need to change the link specified in kml_snapshot_feed.kml 13# 14# You can copy the kml_snapshot_feed.kml into the web folder, and load the 15# http://www.example.com/tracks/kml_snapshot_feed.kml file into your KML 16# application instead of http://www.example.com/tracks/snapshot.kml, and run 17# this shell script with cron to periodically update the snapshot.kml file. 18# This should enable your KML application to refresh the snapshots in sync 19# with their creation by Xastir. 20# 21# Note: GE will load jpg files but not png files, so ImageMagick's 22# convert is used here to convert the snapshot.png produced by Xastir to 23# a snapshot.jpg file. 24# 25DIR=/var/www/htdocs/tracks 26cd ~/.xastir/tmp 27convert ./snapshot.png $DIR/snapshot.jpg 28cat snapshot.kml | gawk -- ' { gsub(/<href>/,"&http://www.example.com/tracks/") } { gsub(/snapshot.png/,"snapshot.jpg") } { print } ' > $DIR/snapshot.kml 29