Re: earthdistance compass bearing

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Jeff Herrin <jeff(at)openhotel(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: earthdistance compass bearing
Date: 2013-06-18 19:39:50
Message-ID: 51C0B786.308@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Steven Schlansker 2013-06-18 20:08:45 Re: Index over only uncommon values in table
Previous Message John R Pierce 2013-06-18 19:23:26 Re: Index over only uncommon values in table