9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] geoloc - a crappy script I wrote.
@ 2009-06-06  2:01 J.R. Mauro
  2009-06-06  2:12 ` erik quanstrom
  2009-06-06  3:14 ` J.R. Mauro
  0 siblings, 2 replies; 4+ messages in thread
From: J.R. Mauro @ 2009-06-06  2:01 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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'



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-06-06  3:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-06  2:01 [9fans] geoloc - a crappy script I wrote J.R. Mauro
2009-06-06  2:12 ` erik quanstrom
2009-06-06  2:29   ` J.R. Mauro
2009-06-06  3:14 ` J.R. Mauro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).