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'

Reply via email to