Search Postgresql Archives

Re: earthdistance compass bearing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06/18/2013 11:16 AM, Jeff Herrin wrote:
I don't need it to be too accurate. We're pushing hotel info into the GDS (sabre, expedia, orbitz, etc). They require airport info relative to the hotel. Example: DFW is 25 miles NW of the property. I thought about just faking it...comparing the hotel's lat/long from the airports. I can probably get N,S,E,W reliably enough, but i'm not sure at what point N becomes NW, etc. That just seems like a really crude bad way to do it, but the alternatives seem unnecessarily complex. I found some examples that use bearing but they all take headings in degrees (which im not seeing in earthdistance). I guess I'm going to have to either setup postGIS or brush up on my trig.

That's pretty easy to get "close enough" without burdensome calculations using some assumptions:

1. You are using true headings (no need to adjust for magnetic-variance).

2. You are using short (metro-area) distances.

3. You are limiting yourself to the eight principal positions on the compass rose (N, NW, W, SW, ...).

4. You are not operating at very high/low latitudes.

The eight points are at 45-degree intervals around the compass-rose so simple rounding is all that is needed. I.e. N is 0 +- 22.5 degrees, NW is 45+- 22.5 degrees, etc. A bit of basic math/trig will get close enough.

I wouldn't obsess on accuracy. A swath of 45-degrees at 25 (+- .5) miles is an area of nearly 20 square miles so it's not exactly turn-by-turn precision.

Cheers,
Steve




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux