Usage:
./postcodetolonglat.sh ‘SK99 9LZ’
Creates a little temp file called z (I need to think about this as it could be overwritten if several calcs are going on at the same time. Think I will pipe the output of wget to a var instead..
Script:
#!/bin/bash
wget “http://maps.google.com/maps/geo?q=$1″ -O z
LONG=`cat z | awk -F “[” ‘{print $3}’ | awk -F “,” ‘{print $2}’`
LAT=`cat z | awk -F “[” ‘{print $3}’ | awk -F “,” ‘{print $1}’`
echo “longitude=” $LONG;
echo “latitude= “ “$LAT”;
#might be in reverse. I dont care.
Then in, say, google maps:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example: Simple Events</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=thekey"
type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(53.11110,-2.17884),17);
}
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 1300px; height: 900px"></div>
<div id="message"></div>
</body>
</html>
~