I'm trying to write something agnostic to whichever database vendor is chosen between MySQL, SQL Server, Oracle, and PostgreSQL. However, I see inconsistent results in functions that return measures. In this instance, it's the Area/STArea/SDO_Area functions. I have a simple table with a geometry column, I've inserted the following Polygon in there:
POLYGON((20.0 20.0, 20.0 22.0, 22.0 22.0, 22.0 20.0, 20.0 20.0))
The SRID is 4326 and I've written 4 select statements, one for each database to retrieve the area.
MySQL
SELECT ST_AREA(spatial_column) FROM spatial_table
Returns: 46045765517.41474
Oracle
SELECT SDO_GEOM.SDO_AREA(spatial_column) FROM spatial_table
Returns: 46045755446.0611
SQL Server
SELECT spatial_column.STArea() FROM spatial_table
Returns: 4
PostgreSQL
SELECT ST_AREA(spatial_column) FROM spatial_table
Returns: 4
I have all the relevant spatial indexes for each database, the bounding boxes, etc. In this instance which is right? And how do I make the ones that aren't, behave the same way? I've read competing information on whether this should be square meters or just a Cartesian area and I'm struggling to understand which it should be.