[postgis-users] DISTANCE function doesn't work at 179,-179 degrees

Paul Ramsey pramsey at refractions.net
Wed Oct 22 09:20:23 PDT 2003


We do not handle lat/lon as if they are on a sphere, we do it as if they 
are on a plane. Doing things in spherical is a PITA. Basically we would 
need a whole separate mode for calculations which carefully dealt with 
the singularity points in lat/lon.

P.

Andrew Edmondson wrote:
> I have two points either side of the 180 degree line on a sphere. (example included)
> Calling DISTANCE on them, doesn't yield the result 2, but rather 357...
> Have I not actually got a sphere?
> Or does DISTANCE not do what I expect?
> 
> Thanks,
> 
> -Ed
> 
> <example>
> 
> test=# SELECT * FROM location;;
>  location_id | latlong          
> -------------+--------------------------
>            1 |  SRID=4278;POINT(0 0)
>            2 |  SRID=4278;POINT(0 90)
>            3 |  SRID=4278;POINT(0 179)
>            4 |  SRID=4278;POINT(0 -179)
> (4 rows)
> 
> test=# SELECT DISTANCE(latlong, GeometryFromText('POINT(0 178)',4278)) from location;
>      distance     
> ------------------
>               178
>                88
>                 1
>               357
> (4 rows)
> 
> </example>
> 


-- 
       __
      /
      | Paul Ramsey
      | Refractions Research
      | Email: pramsey at refractions.net
      | Phone: (250) 885-0632
      \_




More information about the postgis-users mailing list