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

* Re: [9fans] geoloc - a crappy script I wrote.
  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
  1 sibling, 1 reply; 4+ messages in thread
From: erik quanstrom @ 2009-06-06  2:12 UTC (permalink / raw)
  To: 9fans

On Fri Jun  5 22:03:29 EDT 2009, jrm8005@gmail.com wrote:
> 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

steve's gmap script does a great job with arbitrary addresses.  for example

	; gmap 220 college ave athens ga

- erik



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

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

On Fri, Jun 5, 2009 at 10:12 PM, erik quanstrom<quanstro@quanstro.net> wrote:
> On Fri Jun  5 22:03:29 EDT 2009, jrm8005@gmail.com wrote:
>> 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
>
> steve's gmap script does a great job with arbitrary addresses.  for example
>
>        ; gmap 220 college ave athens ga
>
> - erik
>
>

The gmap script is pretty cool, but I have problems with it on p9p and
it's not interactive. The other gmap has some nifty features I like.

I hope even if you don't use the other gmap you might like geoloc
since it is still useful in and of itself. Even though it's a hack.



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

* Re: [9fans] geoloc - a crappy script I wrote.
  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  3:14 ` J.R. Mauro
  1 sibling, 0 replies; 4+ messages in thread
From: J.R. Mauro @ 2009-06-06  3:14 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Fri, Jun 5, 2009 at 10:01 PM, J.R. Mauro<jrm8005@gmail.com> wrote:

> 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.

Here's a hack on top of my hack. The real suckage comes from me making
geoloc separate lat and lon with '?' to appease gmap. It's a small
change if you don't like it. I really want subway directions, but
apparently Yahoo can't do that. I'll keep digging.


#!/bin/rc
# directions -- print directions from a coordinate pair to another.

if (! ~ $#* 2) {
	echo Usage: directions lat1?lon1 lat2?lon2
	exit
}

SLA = `{echo $1 | sed -e 's/\?.*//'}
SLO = `{echo $1 | sed -e 's/.*\?//'}
DLA = `{echo $2 | sed -e 's/\?.*//'}
DLO = `{echo $2 | sed -e 's/.*\?//'}

#echo I got: $SLA $SLO $DLA $DLO

hget 'http://maps.yahoo.com/print?mvt=m&tp=1&stx=&fcat=&frat=&clat='^$DLA^'&clon='^$DLO^'&mag=10&zoom=9&trf=0&radius=134.16445&&q1='$SLA'%20'^$SLO^'&q2='^$DLA^'%20'^$DLO^'&v3=0'
| htmlfmt



^ 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).