View Single Post
  #3  
Old February 13th 06, 10: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