Re: earthdistance compass bearing
От | John R Pierce |
---|---|
Тема | Re: earthdistance compass bearing |
Дата | |
Msg-id | 51C0B087.3080006@hogranch.com обсуждение исходный текст |
Ответ на | Re: earthdistance compass bearing (Jeff Herrin <jeff@openhotel.com>) |
Список | pgsql-general |
On 6/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. half the difference. like, if NW is 45 degrees, then its anything +/- 22.5 degrees of that. if you're willing to accept the error in cartesian vs spherical, its fairly simple. theta is asin(X/R) where X is the delta longitude, and R is the radius, aka your earthdistance. asin returns radians, so multiply by 180/pi() to get degrees. divide the degrees by 16/360 and truncate to an integer, and you should get 0-15, index the string array ('N','NW','NW','W','W','SW','SW','S','S','SE','SE','E','E','NE','NE','N') to get compass direction points. verify you got the polarity right on the delta longitude such that 0 == North and 90 degrees == West. -- john r pierce 37N 122W somewhere on the middle of the left coast
В списке pgsql-general по дате отправления: