Re: earthdistance compass bearing - Mailing list pgsql-general

From Steve Crawford
Subject Re: earthdistance compass bearing
Date
Msg-id 51C0B786.308@pinpointresearch.com
Whole thread Raw
In response to Re: earthdistance compass bearing  (Jeff Herrin <jeff@openhotel.com>)
List pgsql-general
On 06/18/2013 11:16 AM, Jeff Herrin wrote:
p { margin: 0; }
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



pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: Index over only uncommon values in table
Next
From: Steven Schlansker
Date:
Subject: Re: Index over only uncommon values in table