A aviation & planes forum. AviationBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » AviationBanter forum » rec.aviation newsgroups » Simulators
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Lat/Lon to country codes/political boundaries



 
 
Thread Tools Display Modes
  #1  
Old February 13th 06, 02:18 AM posted to rec.aviation.simulators
external usenet poster
 
Posts: n/a
Default Lat/Lon to country codes/political boundaries

Can anybody help me out with taking an arbitrary (lat,lng) pair and
outputting a country code or name?. Ideally, I am looking for source
code that I can wrap into my own flight planner, but anything that
nudges me along in the right direction will be greatly appreciated.

Cheers.

  #2  
Old February 13th 06, 09:21 PM posted to rec.aviation.simulators
external usenet poster
 
Posts: n/a
Default Lat/Lon to country codes/political boundaries

You'd need a fairly large database of coordinates to determine that.
Basically what I'd do is generate a fairly dense grid of cells overlaid on a
world map which lists the countries for each cell and store that in a
database.
Then have a system to determine in which cell a particular spacial
coordinate is located.
If you store 2 coordinates of each grid cell (upper left and lower right for
example) you should be able to do that easily.

If there's only one country linked to the gridcell, you have your answer.
If there's more than one you can either subdivide the cell until you get a
clean answer (within restrictions of course, you'll have to break off
somewhere if the coordinates are almost on top of a border), or divide the
border into line segments and determine on which side of the line segment
your coordinate is located which will tell you the country code.
The latter is probably faster to do on the fly, but harder to implement.
The former could be done in advance by enabling the database to store cells
of different sizes.

For example you have a cell with coordinates N0W0-N3W3 which is in the UK.
Now you're looking for N1W1, which lies between N0 and N3 so that gives you
a range of cells.
W1 lies between W0 and W3 which gives you the exact cell and the answer.

Sounds like an interesting project come to think...

"rutledge" wrote in message
oups.com...
Can anybody help me out with taking an arbitrary (lat,lng) pair and
outputting a country code or name?. Ideally, I am looking for source
code that I can wrap into my own flight planner, but anything that
nudges me along in the right direction will be greatly appreciated.

Cheers.



  #3  
Old February 13th 06, 11:58 PM posted to rec.aviation.simulators
external usenet poster
 
Posts: n/a
Default Lat/Lon to country codes/political boundaries

"Jeroen Wenting" jwenting at hornet dot demon dot nl wrote in message
...
You'd need a fairly large database of coordinates to determine that.


Not really.

Basically what I'd do is generate a fairly dense grid of cells overlaid on
a world map which lists the countries for each cell and store that in a
database.


Typically, what a program would actually do is store the boundary data as
vectors. Some optimization might be done to narrow the initial search
(perhaps grouping them within each octant of the sphere, for example), but
ultimately all one needs to do is a "point in polygon" test on each country
in the database, using the boundary data.

The boundary data can be as detailed as one wants. Searches go faster with
less detail, but of course that opens the possibility for boundary cases
returning the wrong country. IMHO, there's no practical way to solve that
though, given the inherent errors in the basic data anyway. Except for
boundaries defined by straight lines, no matter how much resolution you
have, there's the possibility for a wrong answer. The main thing is to make
sure the user is aware of the possibility (and to reduce the error enough
that a wrong answer isn't a big deal).

Using vector data is MUCH more efficient than turning the entire world into
a bitmap. Even though the algorithm is more complex, the sheer data
bandwidth issues for a world-sized bitmap more than offsets that.

Pete


  #4  
Old February 19th 06, 07:27 PM posted to rec.aviation.simulators
external usenet poster
 
Posts: n/a
Default Lat/Lon to country codes/political boundaries

I considered a quad-tree representation, but the vector based approach
is easier which makes up for any loss in speed. Speed isnt even a real
issue for me anyways. The problem was finding the data though and I
did actually find it. It is called the Digital Chart of the World and
Penn State offers political boundaries in ASCII text files derived from
it. It is a little dated (e.g. Yugoslavia handt broken up yet), but
good enough. So I'm set. Thanks.

  #5  
Old March 3rd 06, 09:23 PM posted to rec.aviation.simulators
external usenet poster
 
Posts: n/a
Default Lat/Lon to country codes/political boundaries



Peter Duniho wrote:
"Jeroen Wenting" jwenting at hornet dot demon dot nl wrote in message
...

You'd need a fairly large database of coordinates to determine that.



Not really.


Basically what I'd do is generate a fairly dense grid of cells overlaid on
a world map which lists the countries for each cell and store that in a
database.



Typically, what a program would actually do is store the boundary data as
vectors. Some optimization might be done to narrow the initial search
(perhaps grouping them within each octant of the sphere, for example), but
ultimately all one needs to do is a "point in polygon" test on each country
in the database, using the boundary data.

The boundary data can be as detailed as one wants. Searches go faster with
less detail, but of course that opens the possibility for boundary cases
returning the wrong country. IMHO, there's no practical way to solve that
though, given the inherent errors in the basic data anyway. Except for
boundaries defined by straight lines, no matter how much resolution you
have, there's the possibility for a wrong answer. The main thing is to make
sure the user is aware of the possibility (and to reduce the error enough
that a wrong answer isn't a big deal).

Using vector data is MUCH more efficient than turning the entire world into
a bitmap. Even though the algorithm is more complex, the sheer data
bandwidth issues for a world-sized bitmap more than offsets that.

Pete



Now there is a familiar name! Ditto from the rec.av.piloting newsgroup!
It's been some moons, Peter, although I see that you continue to do
favorable nod justice to the 'scribbler' dictums of Messrs. Strunk and
White! Relax, Peter, that's an on-going compliment!

Anyway, after some time away from both the real McCoy and flight simming
for reasons I won't bore you with, I've returned to the flight deck, so
to speak. Peter, and recalling some of the more humorous times in
rec.av.piloting [RAP], do you recall a poster named Al Smith? Not a nym,
mind you, but if you should see his moniker, please tell him that Doc
was asking for him and says hello! Like yourself, real McCoy stuff [SEL
and helo too] ... and the sims. So too, and while you're here, I added
the CH USB throttle quadrant to the CH USB yoke [I like those
'instructions' [!?] that came with it ... essentially .... 'you', the
user, figure it out and give us a call if there is a problem!] ---
anyway --- more than once, literally, I program the thing for FS2K2 and
FS9 only to come back to it upon machine restart .... and the
programming is gone! Am I missing something? Further, and perhaps this
is unique only to myself [translation: op error in re not knowing how to
use it properly!], I find the quadrant is 'very', how shall I say,
sensitive to sensitivity settings, so what's your take, if you use the
quadrant yourself of course, on a sort of compromise quadrant
sensitivity and null area setting(s)? And do you advise the simple or
advanced settings for best results?

Thanks, Peter.


Doc Tony

  #6  
Old March 4th 06, 01:18 AM posted to rec.aviation.simulators
external usenet poster
 
Posts: n/a
Default CH flight yoke/quadrant (was "Lat/Lon to country codes/political boundaries")

"Dr. Anthony J. Lomenzo" wrote in message
...
[...]
anyway --- more than once, literally, I program the thing for FS2K2 and
FS9 only to come back to it upon machine restart .... and the programming
is gone! Am I missing something? Further, and perhaps this is unique only
to myself [translation: op error in re not knowing how to use it
properly!], I find the quadrant is 'very', how shall I say, sensitive to
sensitivity settings, so what's your take, if you use the quadrant
yourself of course, on a sort of compromise quadrant sensitivity and null
area setting(s)? And do you advise the simple or advanced settings for
best results?


Hi Doc...nice to see you on Usenet again.

As far as your problem goes, I'm afraid I have no personal experience with
the flight controls you're using. I'll offer comments, but they'll have to
be very general, and you should take anything I write with a grain of salt
(good advice anyway ).

With respect to control sensitivity, it seems to me that you want no null
area at all for engine and prop controls. A null area implies a region of
control movement through which nothing happens, which is appropriate for a
flight control (especially one simulating tension-cable operated control
surfaces found in many real airplanes), but would not be for power controls
(which usually have a fairly immediate response, and in any case don't
really have an idea of a "centered" position, which is where the null area
is).

For the sensitivity itself, you want the power controls to map their full
range of motion to the full range of power settings available. I don't
really know how this translates to the settings for the power quadrant
you're using, but I suspect you want whatever is the "normal" sensitivity.
That is, something that is basically a 1-to-1 mapping.

Generally speaking, increasing sensitivity means that smaller movements of
the control result in a given change in the actual parameter (throttle,
prop, etc), while decreasing sensitivity means that larger movements of the
control result in a given change. Put another way, this means that at
higher sensitivities than the default, the maximum change in the parameter
occurs before the control reaches the end of its throw, while at lower
sensitivities, you may not be able to obtain the full range of parameter
values even with full-stop movement of the control. IMHO, neither extreme
is desirable, so for power controls, you just want the normal sensitivity.

Finally, the first question: why don't your settings get saved? What might
cause that depends on a variety of things, and I can't say for sure why it
might be happening. But the first thing that comes to mind is that you may
be running MSFS without administrator privileges (which is actually a good
thing thing to do, except that it can cause headaches like this "can't save
control settings" problem), except that you haven't given non-admin accounts
on your computer access to the install directory for MSFS (where user
settings are stored). Of course, if this were the problem, then other
changes to user settings (like default flights, flight plans, etc.) would
probably not work either.

If you otherwise have no problems with settings being saved, and only the
control settings are causing problems, then I'm not sure what to suggest.
You may still want to verify that you have write-access privileges to the
configuration file where the user settings are stored, just in case. If
it's a file privileges issue, then the fix is simple: just look at the
security settings for the install directory for MSFS (under the "Program
Files" directory), and give "Full Control" access to the "Users" group. You
can get to the security settings by right-clicking on the install folder,
choosing the "Properties" menu item, and then clicking on the "Security" tab
of that dialog.

If that doesn't help, I'm afraid I am out of ideas at the moment. I do hope
that there's something helpful in all of the above.

Pete


  #7  
Old March 4th 06, 02:06 AM posted to rec.aviation.simulators
external usenet poster
 
Posts: n/a
Default CH flight yoke/quadrant (was "Lat/Lon to country codes/politicalboundaries")



Peter Duniho wrote:
"Dr. Anthony J. Lomenzo" wrote in message
...

[...]
anyway --- more than once, literally, I program the thing for FS2K2 and
FS9 only to come back to it upon machine restart .... and the programming
is gone! Am I missing something? Further, and perhaps this is unique only
to myself [translation: op error in re not knowing how to use it
properly!], I find the quadrant is 'very', how shall I say, sensitive to
sensitivity settings, so what's your take, if you use the quadrant
yourself of course, on a sort of compromise quadrant sensitivity and null
area setting(s)? And do you advise the simple or advanced settings for
best results?



Hi Doc...nice to see you on Usenet again.

As far as your problem goes, I'm afraid I have no personal experience with
the flight controls you're using. I'll offer comments, but they'll have to
be very general, and you should take anything I write with a grain of salt
(good advice anyway ).

With respect to control sensitivity, it seems to me that you want no null
area at all for engine and prop controls. A null area implies a region of
control movement through which nothing happens, which is appropriate for a
flight control (especially one simulating tension-cable operated control
surfaces found in many real airplanes), but would not be for power controls
(which usually have a fairly immediate response, and in any case don't
really have an idea of a "centered" position, which is where the null area
is).

For the sensitivity itself, you want the power controls to map their full
range of motion to the full range of power settings available. I don't
really know how this translates to the settings for the power quadrant
you're using, but I suspect you want whatever is the "normal" sensitivity.
That is, something that is basically a 1-to-1 mapping.

Generally speaking, increasing sensitivity means that smaller movements of
the control result in a given change in the actual parameter (throttle,
prop, etc), while decreasing sensitivity means that larger movements of the
control result in a given change. Put another way, this means that at
higher sensitivities than the default, the maximum change in the parameter
occurs before the control reaches the end of its throw, while at lower
sensitivities, you may not be able to obtain the full range of parameter
values even with full-stop movement of the control. IMHO, neither extreme
is desirable, so for power controls, you just want the normal sensitivity.

Finally, the first question: why don't your settings get saved? What might
cause that depends on a variety of things, and I can't say for sure why it
might be happening. But the first thing that comes to mind is that you may
be running MSFS without administrator privileges (which is actually a good
thing thing to do, except that it can cause headaches like this "can't save
control settings" problem), except that you haven't given non-admin accounts
on your computer access to the install directory for MSFS (where user
settings are stored). Of course, if this were the problem, then other
changes to user settings (like default flights, flight plans, etc.) would
probably not work either.

If you otherwise have no problems with settings being saved, and only the
control settings are causing problems, then I'm not sure what to suggest.
You may still want to verify that you have write-access privileges to the
configuration file where the user settings are stored, just in case. If
it's a file privileges issue, then the fix is simple: just look at the
security settings for the install directory for MSFS (under the "Program
Files" directory), and give "Full Control" access to the "Users" group. You
can get to the security settings by right-clicking on the install folder,
choosing the "Properties" menu item, and then clicking on the "Security" tab
of that dialog.

If that doesn't help, I'm afraid I am out of ideas at the moment. I do hope
that there's something helpful in all of the above.

Pete



Peter ... I owe you! As luck would have it, my son was over the house
when your message came in, he read it, applied the recommendations, and
the quadrant works like a charm! Ditto the yoke and some finer [read:
now understood] sensitivity/null zone adjustments.

I must say that when I first got it [CH throttle quadrant] and tried it
and this without even touching [and to fully confess, only half
understanding the whole business of null zones and sensitivity issues
which you have now very non technically explained!] the sensitivities
box in 'either' 2K or 2K2, the DC-3 [*I'm still a great fan ever since
FS98 of the Roy Chaffin, et al, DC-3, a magnificent creation that series
for '98, 2K and 2K2!]-- anyway, with my own tinkerings and again not
even bothering with the sensitivity/null zone boxes, the DC-3 acted as
if the thing was suddenly possessed and went into high RPM while
literally doing a 180 and dancing off the runway at KCGX Meigs and into
the drink forthwith! Whew! Then, I 'tinkered' with the settings, well,
when I say 'tinkering' of the wholly uninformed variety, hey, I might as
well have tried taking off from Meigs [!] in that classic monster
Convair B-36 'Peacekeeper' bomber ... fully loaded. With the same result
therein! 'Drink city' once again and quite similar to my virtual 'helo'
experiences ... as Al Smith would duly attest!

Thank you , Peter. Much appreciated the helping-hand. I think it's one
of the things that makes the sim community, indeed, even the real McCoy
flight community itself, what it is! I don't think there is any such
thing as going it totally alone ... real or virtual ... and one always
benefits from another and they, in turn, from someone else who has been
there, done that type of thing and even those types no doubt got their
savvy from someone and/or have to seek the helping hand when necessary
as new [or baffling!] technology comes up! Thanks again!

Doc Tony

  #8  
Old March 4th 06, 03:11 AM posted to rec.aviation.simulators
external usenet poster
 
Posts: n/a
Default CH flight yoke/quadrant (was "Lat/Lon to country codes/political boundaries")

"Dr. Anthony J. Lomenzo" wrote in message
...
[...]
Thank you , Peter. Much appreciated the helping-hand. I think it's one of
the things that makes the sim community, indeed, even the real McCoy
flight community itself, what it is! I don't think there is any such thing
as going it totally alone ... real or virtual ... and one always benefits
from another and they, in turn, from someone else who has been there, done
that type of thing and even those types no doubt got their savvy from
someone and/or have to seek the helping hand when necessary as new [or
baffling!] technology comes up! Thanks again!


Glad I could help. I think your comments apply to any human endeavor. It's
a shame when any individual slows down forward progress by the human race by
engaging in conflict rather than cooperation (I admit to being just as
guilty of this on occasion as anyone else ), but it is also remarkable
how quickly things can get done when people share what they already know.

I sometimes think that the fictional Borg from Star Trek have the right
idea. I look at the conflict that exists in the world, and think that it
might be impossible to go to war with someone if you know, through some kind
of mental link, everything that they know and feel. And imagine how much
even more quickly you would have gotten your flight control issues fixed if
you had instant access to the collective memories of every other flight sim
user out there.

Pete


  #9  
Old March 4th 06, 04:43 AM posted to rec.aviation.simulators
external usenet poster
 
Posts: n/a
Default CH flight yoke/quadrant (was "Lat/Lon to country codes/politicalboundaries")



Peter Duniho wrote:
"Dr. Anthony J. Lomenzo" wrote in message
...

[...]
Thank you , Peter. Much appreciated the helping-hand. I think it's one of
the things that makes the sim community, indeed, even the real McCoy
flight community itself, what it is! I don't think there is any such thing
as going it totally alone ... real or virtual ... and one always benefits
from another and they, in turn, from someone else who has been there, done
that type of thing and even those types no doubt got their savvy from
someone and/or have to seek the helping hand when necessary as new [or
baffling!] technology comes up! Thanks again!



Glad I could help. I think your comments apply to any human endeavor. It's
a shame when any individual slows down forward progress by the human race by
engaging in conflict rather than cooperation (I admit to being just as
guilty of this on occasion as anyone else ), but it is also remarkable
how quickly things can get done when people share what they already know.

I sometimes think that the fictional Borg from Star Trek have the right
idea. I look at the conflict that exists in the world, and think that it
might be impossible to go to war with someone if you know, through some kind
of mental link, everything that they know and feel. And imagine how much
even more quickly you would have gotten your flight control issues fixed if
you had instant access to the collective memories of every other flight sim
user out there.

Pete



Indeed! And not to start any sort of off topic 'Jihad' here but [and I
say this still wearing around my neck to this day and dipped in silver
along the way the surviving [1 of the 2 originally issued] dog-tag from
my US Army active duty days [1968-70]... I don't know what the hell
we're doing in Iraq! I see deja-vu all over again and I don't want to
see what happened to us during the RVN years happen to this generation
where the view was during the RVN [Republic of Vietnam] years that of
the returning soldier as a veritable leper and no collective 'welcome
home' where those who served [and no matter branch nor duty station BTW]
became the brunt of the nation's frustration with Vietnam as if the
individual soldier was 'personally' to blame! I have very bitter
memories of that time and era where the Class A uniform became the hit
and run target for shouted insults or eggs with Army CIB's or RVN
ribbons in the other services as the target!

Mercifully, the clock and the Constitution will serve to bring in a
hopefully more intelligent and much cooler head, as it were, at 1600
Pennsylvania Avenue and those of the collective political retinue. I've
personally been through one farce already with dubious 'cures' and to
witness yet another military venture for reasons even more dubious and
higher questionable not to mention the WMD fiasco or Mr. Bush publicly
telling the UN to essentially engage in self-fornication, well, now I
see us mired there for who knows how long. On the other hand, Peter, I
sometimes muse that any sort of universal peace or collective sharing on
a 'sustained' basis is a pipe dream ... human nature itself often works
against it and the history of the species in re chronic wars based on
greed, economics, religious fanaticism, ideological differences, et al
make the olive branch a difficult one to grasp .... and hold on to
firmly. Ahhh, enough about that. Thanks again.

Doc Tony

  #10  
Old March 4th 06, 04:59 AM posted to rec.aviation.simulators
external usenet poster
 
Posts: n/a
Default CH flight yoke/quadrant (was "Lat/Lon to country codes/political boundaries")

"Dr. Anthony J. Lomenzo" wrote in message
...
[...] the view was during the RVN [Republic of Vietnam] years that of the
returning soldier as a veritable leper and no collective 'welcome home'
where those who served [and no matter branch nor duty station BTW] became
the brunt of the nation's frustration with Vietnam as if the individual
soldier was 'personally' to blame!


I hope that, even if our President (and others) did not learn their lesson
from previous history, the country as a whole will have learned some
manners, and that our Iraq veterans will be honored as those in the service
should. Perhaps even more, for doing their jobs -- jobs they promised to
do -- even as no one should blame them for objecting to the job (as many of
us do).

It's relatively easy to do a job everyone feels is a necessary and important
one. It's much harder to do the same job if half the people think you
shouldn't be there in the first place.

[...] On the other hand, Peter, I sometimes muse that any sort of
universal peace or collective sharing on a 'sustained' basis is a pipe
dream


I'm sure it is. But a worthwhile one, nonetheless.

[...] Ahhh, enough about that. Thanks again.


You're very welcome. Glad to be of help.

Pete


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
UK planning to evict N-registered aircraft George Patterson Instrument Flight Rules 67 September 1st 05 08:04 AM
UK planning to evict N-registered aircraft Juan Jimenez Owning 37 September 1st 05 08:04 AM
Cross Country the main focus of soaring? mat Redsell Soaring 77 October 18th 04 10:40 PM
US cross country flight S Narayan Instrument Flight Rules 0 January 7th 04 03:58 PM
US cross country flight S Narayan Piloting 0 January 7th 04 03:58 PM


All times are GMT +1. The time now is 10:22 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 AviationBanter.
The comments are property of their posters.