How It Works

By popular demand, here's a brief description of how the search works.

Data

I collected a list of soaring sites, with their latitude & longitude. For the USA I started with a list published by the Soaring Society of America. I made some corrections for the sites I know of, and then started adding position information to each site. For the sites that are at airports that show up in AOPA's Airports USA guide, I used the position published there. This was done manually. For everything else I used a location based on the ZIP code, from this Geographic Name Server. Actually I used the service at the University of Michigan that the above provides a gateway to. There's also a service at the census bureau that the creators of the site above feel is better. They also have their entire database available right there for you to download. It didn't yet exist, or at least I didn't know about it, when I collected my data. The list for the UK, including positions, was contributed by another user; I understand it was compiled from information from the British Gliding Association. The names and locations of a few other sites have been contributed by people that fly there. Incidentally, if you contribute, or have contributed, any information for this database and you wouldn't mind being mentioned here, let me know so I can give due credit.

Searching

To simplify things, I assume the earth is a sphere. The list of sites is processed to build an index for rapid searching. That index contains the position of each site in Cartesian coordinates, in units of the earth's radius. So the north pole is at (0,0,1), and the south pole at (0,0,-1). The index is sorted by Z coordinate. It starts searching at the site with the closest Z coordinate to the desired location. It searches the list in both directions, keeping track of n (where n is the maximum number of matches requested) closest sites, until the distance due to latitude alone is greater than the nth closest site so far. Then it's done.

Here are a few of the gory details. To convert distances between the normalized coordinate system I used to numbers people understand, here are a few constants, as C defines:

#define PI 3.14159265358979323846264338327950288419716939937511 /* approx */
/* radius of the earth */
#define RADIUSNAUTICALMILES ((360.0*60.0)/(2.0*PI))
#define RADIUSSTATUTEMILES (RADIUSNAUTICALMILES*6000.0/5280.0)
#define RADIUSKILOMETERS (RADIUSNAUTICALMILES*6000.0*12.0*2.54/(100.0*1000.0))

Conversion from latitude/longitude to the normalized Cartesian coordinates (also in C notation, assuming latitude and longitude are in radians):

X=cos(longitude)*cos(latitude);
Y=sin(longitude)*cos(latitude);
Z=sin(latitude);

Great circle distance is:

acos(X1*X2+Y1*Y2+Z1*Z2);

More?

Here's how to get help.

allanh@kallisti.com

Allan's Home Page