Re: Miidpoint between two long/lat points? (earthdistance?) - Mailing list pgsql-general

From Rick Genter
Subject Re: Miidpoint between two long/lat points? (earthdistance?)
Date
Msg-id BANLkTik71UdWvZeiM786CjTPwK=LLU2hpg@mail.gmail.com
Whole thread Raw
In response to Miidpoint between two long/lat points? (earthdistance?)  (Carlo Stonebanks <stonec.register@sympatico.ca>)
List pgsql-general
On Wed, May 25, 2011 at 9:47 AM, Carlo Stonebanks <stonec.register@sympatico.ca> wrote:

I need to calculate the long/lat values between a line demarcated by two long/lat points.

 

The points will be very close, but there is the 180 degree problem to consider, so a simple average won’t work.

 

Does anyone know of a function or have a formula that will work using geo long/lat values? I don’t see anything obvious in the earthdistance module.


The simplest way to deal with "the 180 degree problem" is to remember that you can add 360 degrees to a long and get a value that should continue to work. So, assuming "West" is negative, -175 (175 degrees West) is the same as -175+360 = 185 (185 degrees East). Then you don't have to worry about wraparound. If the result is > 180, subtract 360.
--
Rick Genter
rick.genter@gmail.com

pgsql-general by date:

Previous
From: Carlo Stonebanks
Date:
Subject: Miidpoint between two long/lat points? (earthdistance?)
Next
From: Geoffrey Becker
Date:
Subject: Connecting to Postgres using Windows 7