[OpenLayers-Users] How to validate OpenLayers area calculation using PostGIS?

João Rodrigues joaorodr84 at gmail.com
Tue Sep 23 17:28:58 PDT 2014


Hi Phil.

Thank you for your answer. I've run this PostGIS code of yours:

*SELECT ST_Area(the_geog, true) As sqm_spheroid*
*FROM (SELECT*
* geography(*
* ST_GeomFromText('POLYGON((50 0,-60 -5, -30 -30,50 0))', 4236)*
* )*
*) As x(the_geog);*

And I get this error:

*ERROR:  ptarray_area_spheroid: cannot handle ptarray that crosses equator*

*********** Error ***********

*ERROR: ptarray_area_spheroid: cannot handle ptarray that crosses equator*
*SQL state: XX000*


In my 2nd attempt, I tried changing the flag to false and it ran
succesfully.

*SELECT ST_Area(the_geog, false) As sqm_spheroid*
*FROM (SELECT*
* geography(*
* ST_GeomFromText('POLYGON((50 0,-60 -5, -30 -30,50 0))', 4236)*
* )*
*) As x(the_geog);*

But I still got the value *19582793771831* square meters, in opposition to
the result *17050040174394.607* square meters obtained with getGeodesicArea.

In a 3rd attempt, to find a good result, I changed the flag back to true
and I tried new coordinates, in order to avoid crossing the equator, thus
avoiding the error shown in the 1st attempt.

*SELECT ST_Area(the_geog, true) As sqm_spheroid*
*FROM (SELECT*
* geography(*
* ST_GeomFromText('POLYGON((50 1, -60 1, -30 30, 50 1))', 4236)*
* )*
*) As x(the_geog);*

Here I get *22380590293551.1* square meters, but using the same
coordinates, I get *18843774494021.53* square meters using getGeodesicArea.

I'm sure OpenLayers works fine, but I have to do some unit tests, ans as
you may understand, I have to compare the OpenLayers result with something
else.

*Note*: I compares getLength with PostGIS and it worked just fine.

I'll try to reproduce my OpenLayers code, and respect the work secrecy at
the same time. I'll send you a JSFiddle as soon as I've reproduced it.

I hope you can help me with this.

Thanks a lot.

João Rodrigues
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20140924/20db43e4/attachment.html>


More information about the Users mailing list