Opened 14 years ago

Closed 14 years ago

#450 closed defect (fixed)

ST_Area(geography) returns wrong result for objects crossing dateline

Reported by: pramsey Owned by: pramsey
Priority: high Milestone: PostGIS 1.5.1
Component: postgis Version: 1.5.X
Keywords: Cc: noss@…

Description (last modified by pramsey)

http://postgis.refractions.net/pipermail/postgis-users/2010-February/025984.html

A box that doesn't cross the dateline returns a good result:

g4wd=# select st_area(g)/1000000, st_area(transform(geometry(g), 4326)),
astext(geometry(g)) from (select 'POLYGON((178.5 2, 178.5 1, 179.5 1, 179.5
2, 178.5 2))'::geography) as foo(g); 
    ?column?     | st_area |                       astext                       
-----------------+---------+---------------------------------------------------- 
 12304.814950073 |       1 | POLYGON((178.5 2,178.5 1,179.5 1,179.5 2,178.5
2)) 
(1 row)

But the same box s hifted over the dateline returns a bad result.

g4wd=# select st_area(g)/1000000, st_area(transform(geometry(g), 4326)),
astext(geometry(g)) from (select 'POLYGON((179.5 2, 179.5 1, -179.5 1,
-179.5 2, 179.5 2))'::geography) as foo(g); 
     ?column?     | st_area |                        astext                         
------------------+---------+------------------------------------------------------ 
 55910.8880691158 |     359 | POLYGON((179.5 2,179.5 1,-179.5 1,-179.5
2,179.5 2)) 
(1 row)

Attachments (1)

450-1.patch (3.5 KB ) - added by pramsey 14 years ago.
Fix for spheroid area

Download all attachments as: .zip

Change History (5)

comment:1 by pramsey, 14 years ago

Description: modified (diff)

by pramsey, 14 years ago

Attachment: 450-1.patch added

Fix for spheroid area

comment:2 by pramsey, 14 years ago

Cc: noss@… added

The attached patch fixes the spheroid case. I have found the sphere case ( st_area(geography, false) )also has slightly different results on shifted polygons, even with this fix.

comment:3 by pramsey, 14 years ago

Spheroid problem patched in trunk at r5339 and in 1.5 branch at r5340

comment:4 by pramsey, 14 years ago

Resolution: fixed
Status: newclosed

Working the sphere area problem in a new ticket (#451) and closing this one out.

Note: See TracTickets for help on using tickets.