AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Latitude and Longitude [Solved]

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
SoggyDog



Joined: 02 May 2006
Posts: 621
Location: Greeley, CO

PostPosted: Thu Feb 05, 2009 6:58 pm    Post subject: Latitude and Longitude [Solved] Reply with quote

Anybody aware of a free CLI, DLL or other lite utility that will return your Latitude and Longitude based on address?
I am trying to avoid the many, many websites out there that will do this for you and work locally, but I don't mind if
the local utility has to go to the net to query a result.
_________________

SoggyDog
Dwarf Fortress:
"The most intriguing game I've ever played."


Last edited by SoggyDog on Fri Feb 06, 2009 12:56 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
BoBo³
Guest





PostPosted: Thu Feb 05, 2009 10:24 pm    Post subject: Reply with quote

Check out dRs httpQuery function, eg with this URL: http://www.netzwelt.de/geocoding/index.html
Back to top
BoBo³
Guest





PostPosted: Thu Feb 05, 2009 10:34 pm    Post subject: Reply with quote

Might be of interest too: [Google Reverse Geocoder]
Back to top
SoggyDog



Joined: 02 May 2006
Posts: 621
Location: Greeley, CO

PostPosted: Thu Feb 05, 2009 10:36 pm    Post subject: Reply with quote

Thanks BoBo...
I was afraid that was going to be the answer.

I will pursue this solution but, to the AHK community, please keep your eyes open for something that runs locally.

Thanks.
_________________

SoggyDog
Dwarf Fortress:
"The most intriguing game I've ever played."
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
BoBo³
Guest





PostPosted: Thu Feb 05, 2009 11:03 pm    Post subject: Reply with quote

AFAICS the main issue with a local solution would be to have a DB in place which holds the lat/long vs address info, right?

[GoogleMap Script Generator]
Back to top
BoBo³
Guest





PostPosted: Thu Feb 05, 2009 11:41 pm    Post subject: Reply with quote

Running a code like this ...
Code:
Key := <Your Key Here> ; as far as I know you've to register with Google to get it
Road := "Bahnhofstrasse"
Number := 18
ZipCode := 8330
City := "Pfäffikon"
Country := "CH"


ClipBoard = http://maps.google.com/maps/geo?q=%Road%+%Number%+%ZipCode%+%City%+%Country%&key=%Key%&output=csv;
Will be responded with something like that ...
Code:
{
  "name": "Bahnhofstrasse 18 8330 Pfäffikon CH",
  "Status": {
    "code": 200,
    "request": "geocode"
  },
  "Placemark": [ {
    "id": "p1",
    "address": "Bahnhofstrasse 18, 8330 Pfäffikon, Schweiz",
    "AddressDetails": {"Country": {"CountryNameCode": "CH","CountryName": "Schweiz","AdministrativeArea": {"AdministrativeAreaName": "Zürich","Locality": {"LocalityName": "Pfäffikon","Thoroughfare":{"ThoroughfareName": "Bahnhofstrasse 18"},"PostalCode": {"PostalCodeNumber": "8330"}}}},"Accuracy": 8},
    "ExtendedData": {
      "LatLonBox": {
        "north": 47.3699861,
        "south": 47.3636909,
        "east": 8.7874406,
        "west": 8.7811454
      }
    },
    "Point": {
      "coordinates": [ 8.7842930, 47.3668385, 0 ]
    }
  } ]
}
Good luck Cool
Back to top
SoggyDog



Joined: 02 May 2006
Posts: 621
Location: Greeley, CO

PostPosted: Fri Feb 06, 2009 12:04 am    Post subject: Reply with quote

Yes, the problem with a local solution is, in fact, a database, but if there was a local utility that queried the internet, that would be okay. Basically, I just wasn't in the mood to write such an application, but it looks like that's how it's gonna have to be.

That said, you sir, are a rock star;
This gives me very good direction.

Cheers.
_________________

SoggyDog
Dwarf Fortress:
"The most intriguing game I've ever played."
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
BoBo³
Guest





PostPosted: Fri Feb 06, 2009 12:27 am    Post subject: Reply with quote

Code:
http://maps.google.com/maps/geo?q=Bahnhofstrasse+18+8330+Pfäffikon+CH&key=<Your Key Here>&output=csv;
With eliminating the false semicolon at the end of the above URL you'd get an output/source like this ...
Code:
200,8,47.3668385,8.7842930

So a simple URLDownloadToFile should do it, right ?! Smile
Back to top
BoBo³
Guest





PostPosted: Fri Feb 06, 2009 12:31 am    Post subject: Reply with quote

Quote:
You may access the Google Maps API Geocoding Service directly over HTTP. To access the geocoder, send a request to http://maps.google.com/maps/geo? with the following parameters in the URL:

    q (required) — The address that you want to geocode.
    key (required) — Your API key.
    sensor (required) — Indicates whether or not the geocoding request comes from a device with a location sensor. This value must be either true or false. (Note that devices with sensors generally perform their own geocoding by definition; therefore, most geocoding requests to the Maps API Geocoding service should set sensor to false.)
    output (required) — The format in which the output should be generated. The options are xml, kml, csv, or (default) json. (For more information, see Geocoding Responses below.)
    oe (optional but strongly encouraged) — The output encoding format of the response. It is recommended that you set this output encoding explicitly to utf8 unless you have specific requirements to handle other encoding types.
    ll (optional) — The {latitude,longitude} of the viewport center expressed as a comma-separated string (e.g. "ll=40.479581,-117.773438" ). This parameter only has meaning if the spn parameter is also passed to the geocoder. (For more information see Viewport Biasing below.)
    spn (optional) — The "span" of the viewport expressed as a comma-separated string of {latitude,longitude} (e.g. "spn=11.1873,22.5" ). This parameter only has meaning if the ll parameter is also passed to the geocoder. (For more information see Viewport Biasing below.)
    gl (optional) — The country code, specified as a ccTLD ("top-level domain") two-character value. (For more information see Country Code Biasing below.)

Note: The gl and spn,ll viewport parameters will only influence, not fully restrict, results from the geocoder.

In this example, we request the geographic coordinates of Google's headquarters:

http://maps.google.com/maps/geo?q=1600+Amphitheatre+Parkway,+Mountain+View,+CA&output=json&oe=utf8&sensor=true_or_false&key=your_api_key

We've left the sensor parameter in this example as a variable true_or_false to emphasize that you must set this value to either true or false explicitly.

Geocoding Responses
The output parameter specifies the format of the response from the Geocoding Service. The following values are supported:

json (default) — The response is formatted as a JSON object. This format is preferred as it is generally more compact.
kml — The response is returned as KML with a kml MIME type.
xml — The response is returned as KML with an xml MIME type.
csv — The response is returned as a comma-seperated value, described below.


http://code.google.com/intl/de/apis/maps/documentation/geocoding/
Back to top
SoggyDog



Joined: 02 May 2006
Posts: 621
Location: Greeley, CO

PostPosted: Fri Feb 06, 2009 12:37 am    Post subject: Reply with quote

It's looking like this project might be getting easier and easier;
Thanks so much for having the interest and digging so deep on my behalf!
_________________

SoggyDog
Dwarf Fortress:
"The most intriguing game I've ever played."
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
garry



Joined: 19 Apr 2005
Posts: 1499
Location: switzerland

PostPosted: Fri Feb 06, 2009 11:17 am    Post subject: Reply with quote

just remember old GWBASIC program, get sunrise and sunset depending coordinate
must know longitude and latitude
http://en.wikipedia.org/wiki/Longitude

Code:

12900 '----SUNRISE / SUNSET ---------------------------------------------------
12901 'http://en.wikipedia.org/wiki/Longitude
12950 'Basel 47.33 -07.35, south and east negative
13000 'Zurich 47.22 -08.32
13050 'Bern 46.56 -07.26
13060 'VALLETTA 35.7 -14.3
13090 CLS
13100 '
13150 DIM N(12)
13200 D1=46.56:D2=-7.26 'BERN
13210 '
13250 PL=3.141592654#/26:J=57.29577951#
13300 GOSUB 16750
13350 LA = D1
13400 IF LA < 0 THEN LA = LA + 180
13450 IF D2 < 0 THEN D2 = D2 + 360
13500 LO = FIX(D2/15)*15 :REM finds time zone beginning
13550 TD=(D2-LO)/15
13600 '
13650 M$=MID$(DATE$,1,2):M=VAL(M$)
13700 DA$=MID$(DATE$,4,2):DA=VAL(DA$)
13750 '
13800 FOR I=1 TO 12: READ N(I):NEXT I
13850 DATA 0,31,59,90,120,151
13900 DATA 181,212,243,273,304,334
13950 X=(N(M)+DA)/7
14000 '
14050 D=.4560001-22.195*COS(PL*X)-.43*COS(2*PL*X)-.156*COS(3*PL*X)+3.83*SIN(PL*X)+.06*SIN(2*PL*X)-.082*SIN(3*PL*X)
14100 '
14150 'LOCATE 3,2
14200 PRINT"DECLINATION OF SUN:";
14250 PRINT USING"###.#";D;
14300 PRINT" DEGREES"
14350 E=8.000001E-03+.51*COS(PL*X)-3.197*COS(2*PL*X)-.106*COS(3*PL*X)-.15*COS(4*PL*X)-7.317001*SIN(PL*X)-9.471001*SIN(2*PL*X)- .391*SIN(3*PL*X)-.242*SIN(4*PL*X)
14400 '
14450 PRINT"EQUATION OF TIME:";
14500 PRINT USING"###.#";E;
14550 PRINT" MINUTES"
14600 CL=COS(LA/J):SD=SIN(D/J):CD=COS(D/J):Y=SD/CL
14650 IF ABS(Y)=>1 THEN PRINT"NO SUNRISE OR SUNSET":GOTO 17150
14700 Z = 90 - J*ATN(Y/SQR(1-Y*Y))
14750 PRINT"AZIMUTH OF SUNRISE:";
14800 PRINT USING"####.#";ABS(Z);
14850 PRINT" DEGREES"
14900 PRINT"AZIMUTH OF SUNSET: ";
14950 PRINT USING"####.#";360-ABS(Z);
15000 PRINT" DEGREES"
15050 ST=SIN(Z/J)/CD
15100 IF ABS(ST)>=1 THEN T=6:TT=6:GOTO 15300
15150 CT=SQR(1-ST*ST)
15200 T=J/15*ATN(ST/CT)
15250 TT=T
15300 'x
15350 IF D<0 AND LA<90 THEN T=12-T:TT=T
15400 IF D>0 AND LA>90 THEN T=12-T:TT=T
15450 T=T+TD-E/60-.04
15500 GOSUB 16050
15550 'LOCATE 3,2
15600 'PRINT "TIME OF SUNRISE BERN:";T1$;":";T2$;" ";T$;"L.T. ";GM$;":";T2$;" GM";
15650 PRINT "SWITZERLAND BERN SUNRISE= ";T1$;":";T2$;" ";
15700 T=12-TT:T=T+TD-E/60+.04
15750 CNT=1
15800 T12=12
15850 GOSUB 16050
15900 'PRINT "TIME OF SUNSET= ";T1$;":";T2$;" ";T$;"L.T. ";GM$;":";T2$;" GM";" ";SD$
15950 PRINT " SUNSET= ";T1$;":";T2$;" ";SD$
16000 GOTO 17150
16050 'x
16100 T1=INT(T):T2=T-T1
16150 IF SD$="ST" THEN LET T1=T1+1
16200 T1$=STR$(T1+T12):T2=INT((T2*600+5)/10):IF T2=60 THEN 16250 ELSE 16300
16250 T2=0:T1=T1+1:T1$=STR$(T1+T12)
16300 T2$=STR$(T2):T2$=RIGHT$(T2$,LEN(T2$)-1)
16350 IF INT(T2)<10 THEN T2$="0"+T2$
16400 GM = FIX(D2/15) :REM calculate difference between GM and local time
16450 IF CNT = 0 THEN GM = VAL(T1$)+GM :REM GMT for sunrise
16500 IF CNT > 0 THEN GM = VAL(T1$)+12+GM :REM GMT for sunset
16550 IF GM +(VAL(T2$)/60)> 24 THEN GM = GM - 24
16600 GM$ = STR$(GM) :GM$ = RIGHT$("0"+GM$,2)
16650 RETURN
16700 '
16750 'x This subroutine converts DD.MM input to DD.DD
16800 DEGTMP = (ABS(D1)-ABS(FIX(D1))) *100/60
16850 D1 = (FIX(ABS(D1))+DEGTMP)*SGN(D1)
16900 DEGTMP = (ABS(D2)-ABS(FIX(D2))) *100/60
16950 D2 = (FIX(ABS(D2))+DEGTMP)*SGN(D2)
17000 RETURN
17050 '
17100 '
17150 'END
30030 PRINT "PUSH any KEY"
30080 A$=INKEY$:IF A$="" THEN 30080
31030 SHELL "CD\":SYSTEM
31040 '=============================================
Back to top
View user's profile Send private message
SoggyDog



Joined: 02 May 2006
Posts: 621
Location: Greeley, CO

PostPosted: Fri Feb 06, 2009 3:07 pm    Post subject: Reply with quote

garry wrote:
just remember old GWBASIC program, get sunrise and sunset depending coordinate

How utterly coincidental that you would bring this up...
Sunrise/Sunset is exactly the purpose for which I need Latitude and Longitude.
_________________

SoggyDog
Dwarf Fortress:
"The most intriguing game I've ever played."
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
garry



Joined: 19 Apr 2005
Posts: 1499
Location: switzerland

PostPosted: Fri Feb 06, 2009 8:12 pm    Post subject: Reply with quote

maybe can use the same mathematic calculations ( mid$=stringmid )
it's possible to run gwbasic hidden and write calculated variables to a csv file
then read variables with autohotkey and continue with a gui
(not so nice , used when was unable/lazy to rewrite the program)
Back to top
View user's profile Send private message
SoggyDog



Joined: 02 May 2006
Posts: 621
Location: Greeley, CO

PostPosted: Fri Feb 06, 2009 9:03 pm    Post subject: Reply with quote

garry wrote:
maybe can use the same mathematic calculations ( mid$=stringmid )
it's possible to run gwbasic hidden and write calculated variables to a csv file
then read variables with autohotkey and continue with a gui
(not so nice , used when was unable/lazy to rewrite the program)

I already have the calculations, though I need to optimize the code that performs those calculations;
I really just needed a tidy way of getting the Lat/Long.

I haven't had a chance yet, but intend to compare my calculations to these...
I may have taken the long way to a shorter point.
_________________

SoggyDog
Dwarf Fortress:
"The most intriguing game I've ever played."
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group