From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 Date: Fri, 5 Jun 2009 22:01:26 -0400 Message-ID: <3aaafc130906051901i4950eefcje109d2aca5f8e1a2@mail.gmail.com> From: "J.R. Mauro" To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: [9fans] geoloc - a crappy script I wrote. Topicbox-Message-UUID: 05aacdb8-ead5-11e9-9d60-3106f5b1d025 Hi, Someone on contrib has a gmap (not the shell script one that was mentioned recently, the older(?) one done in C). I made the following stupid script to help start gmap at a user-specified address. Gmap only understands coordinates, which I can't memorize. But it's generally useful besides a gmap helper, I suppose. I'm trying to see if I can get something like google maps directions based on geoloc since the yahoo site it uses seems to not fail if you give it a very vague address, unlike most other services I've tried. I suppose I could try to see if I can get a barebones access to google maps directions. Like an XML page or something. If anyone knows how, I'd appreciate some pointers. The script outputs lat and lon (in that order) delimited with a '?' character, because that is what gmap uses. This is so that I can do something like: gmap -n`{geoloc 123 foo street anywhereville} Please note that the gmap on sources expects longitude to come before latitude for its -n option. I think that is backward from the normal convention, so I modified mine locally to swap them. It's a simple change. The script is really stupid and calls sed 87 times because it's parsing an ugly xml page and I don't know any better. Please feel free to tell me how bad it is. Without further ado: #!/bin/rc # geoloc - find coordinates of an address if (~ $#* 0) { echo Usage: geoloc address exit } addr = `{echo $* | sed -e 's/ /+/g'} hget http://api.local.yahoo.com/MapsService/V1/geocode?appid'='capelinks'&'location'='$addr'&'Geocode'='Geocode | \ awk -F'>' '{ print $4"X?"$6}' | sed -e 's/<.*eX//' | sed -e 's/<.*e//' | sed -e '/X/d'