>>> from ctypes import *
>>> nation = windll.kernel32.GetUserGeoID(16)
>>> buf = create_string_buffer(20)
>>> GEO_LATITUDE=0x0002
>>> GEO_LONGITUDE=0x0003
>>> windll.kernel32.GetGeoInfoA(nation, GEO_LATITUDE,
... byref(buf), sizeof(buf), 0)
6
>>> buf.value
'39.45'
>>> windll.kernel32.GetGeoInfoA(nation, GEO_LONGITUDE,
... byref(buf), sizeof(buf), 0)
8
>>> buf.value
'-98.908'
At first glance, this looks pretty cool. You can get geospacial coordinates on any Windows XP or Vista box. Except that the API only returns the latitude and longitude of the country selected in the "Regional and Language Options" control panel. That is: the coordinates returned are for the user's selected location (i.e. country).
Sure enough, plugging the returned latitude and longitude into Yahoo Maps, I find that the coordinates fall squarely in the middle of the country. A good thousand miles from where I sit in Palo Alto, California. Of course, being that I don't have a GPS receiver attached to my laptop, I didn't really expect the coordinates to be accurate.
For the life of me, I can't think of a single application of this information. But there it is: someone at Microsoft had to populate the database mapping countries to geospacial coordinates and some engineer had to code the API to retrieve them. For what purpose? What can you do with the latitude and longitude of a country (whatever that is supposed to mean)? Can anyone think of a use for this data?
4 comments:
To properly draw the animation of the earth with the little star over the selected geographical location in the 'Select Regional and Language Options' control panel.
That is the one and ONLY use I can think of :-)
Yours has got an animation? My XP test machine just has a simple drop-down list.
Actually I just confirmed that it is the image is part of the XP Pro install. There are two dropdown lists, and selecting the different location will move the red dot to a different spot on the map. Not sure if it uses the same API as it has the timezone information as well. The map is not animated, but is the standard image we have come to expect from movies like War Games, or anything dealing with NASA and space.
I was going to take a screen shot, but you cant do that as part of the install >.<
Ha ha. :) Thanks for the information! I sure am glad Microsoft was kind enough to expose that API for the rest of us to use too. :)
Post a Comment