9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "J.R. Mauro" <jrm8005@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: [9fans] geoloc - a crappy script I wrote.
Date: Fri,  5 Jun 2009 22:01:26 -0400	[thread overview]
Message-ID: <3aaafc130906051901i4950eefcje109d2aca5f8e1a2@mail.gmail.com> (raw)

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	other threads:[~2009-06-06  2:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-06  2:01 J.R. Mauro [this message]
2009-06-06  2:12 ` erik quanstrom
2009-06-06  2:29   ` J.R. Mauro
2009-06-06  3:14 ` J.R. Mauro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3aaafc130906051901i4950eefcje109d2aca5f8e1a2@mail.gmail.com \
    --to=jrm8005@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).