Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Put yourself on the Map -- correction

by theorbtwo (Prior)
on Aug 20, 2002 at 02:37 UTC ( #191370=note: print w/replies, xml ) Need Help??


in reply to Put yourself on the Map -- correction

You're right, jens, it isn't there any more. The instructions were correct when I found the lat/long for my address some time ago, but it seems they changed their UI.

You can still get the data from mapblast, though. Fill in your address, and get the map, then zoom at least once so all the CGI parameters will get filled in. Then look for the CT parameter in the URL (it's a GET form, so it's easy to read). Mine reads &CT=40.0706471%3A-76.314855%3A20000, which makes my latutide 40.0706471 degrees N, by 76.314855 degrees W. longitude. However, this is decimal degrees, and we want dotted DMS. So, to convert, in each step I read off int() of the current value, then multiply the decimal part by 60. Thus, I'd put <!-- location:latitude=40.04.14,longitude=-76.18.53 -->. And thanks to you I just checked my homenode and noticed I didn't update it when I moved.

However, this, while easy, is hardly trivial. Another place to try, from a quick google search, is geocode.com's Eagle (US-centric)

One place I wouldn't try, BTW, is terraserver.com; not only are they MS, but they don't see to make any useful information without being a "pro user".


Confession: It does an Immortal Body good.

Replies are listed 'Best First'.
Re: Put yourself on the Map
by hacker (Priest) on Aug 20, 2002 at 12:48 UTC
    To convert a decimal number (dn) to degrees (d), minutes (m) and seconds (s):
    d = int(dn) mi = frac(dn)*60 m = int(mi) s = frac(mi)*60

    Note that int(n) denotes taking the integer part of a number (i.e. int(49.5125) = 49) and frac its fractional part (i.e. frac(49.5125) = 0.5125). mi is an intermediate result.

    Example: To convert 49.5125 decimal degrees to degrees, minutes and seconds:

    d = int(49.5125) = 49 mi = frac(49.5125)*60 = 0.5125*60 = 30.75 m = int(mi) = int(30.75) = 30 s = frac(mi)*60 = 0.75*60 = 45

    Many calculators have a built-in function to compute this - it is often called "dms" or "hms". Switch to scientific mode on your calculator. To convert from decimal to degrees, minutes and seconds, enter the number, then hit the dms button.

    To convert from degrees, minutes and seconds to decimal degrees, enter the degrees, a decimal point, then the minutes (2 digits) and seconds, then hit the [x]Inv (Inverse) button to get the inverse function and hit the dms button again.

Re: Re: Put yourself on the Map -- correction
by physgreg (Scribe) on Aug 20, 2002 at 16:02 UTC
    I found that for UK based monks www.streetmap.co.uk will give latitude/longitude for any given postcode or address.
Re: Re: Put yourself on the Map -- correction
by abitkin (Monk) on Aug 23, 2002 at 15:03 UTC
    Once you zoom in, the query string changes so that it includes the lat and long.
    http://www.mapblast.com/myblast/map.mb?CMD=LFILL&CT=45.3974961%3A-122.727504%3A20000&GAD1=... No need to show it all and expand the node. Anyways, here is some code for conversion, go ahead and optimize away:
    #!/usr/local/bin/perl -w use strict; sub convert { $_ = shift; my $a; my $b; /^([0-9-]+)\.([0-9]+)$/; ($a,$_) = ($1,("0." . $2)*60); /^([0-9-]+)\.([0-9]+)$/; ($b,$_) = ($1, ("0." . $2)*60); s/\..*$//; return "$a.$b.$_"; } while(<stdin>){ my $lat; my $lon; if(/.*&CT=([0-9.-]+)%3A([0-9.-]+).*/){ my $lat = $1; my $lon = $2; print "\n\n<!-- location:latitude=" . convert($lat) . ",longit +ude=" . convert($lon) . " -->\n"; } }

    Perhaps, this could be included on the site, somehow.

    Edited, added last idea.
    ==
    Kwyjibo. A big, dumb, balding North American ape. With no chin.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://191370]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2020-07-05 20:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?