orbisgis / h2gis

A spatial extension of the H2 database.
http://www.h2gis.org
GNU Lesser General Public License v3.0
208 stars 63 forks source link

Manage SRID on empty geometry #1385

Closed ebocher closed 5 months ago

ebocher commented 5 months ago

H2GIS checks the SRID of the geometries to allow some operations. This cause some troubles when a geometry is empty because the SRID is unhnown.

See : https://github.com/orbisgis/h2gis/blob/master/h2gis-functions/src/main/java/org/h2gis/functions/spatial/operators/ST_Intersection.java#L61

Select ST_SRID('POINT EMPTY'::GEOMETRY) as the_geom

returns a null value but it must return a 0 srid

Select st_intersects('POINT EMPTY'::GEOMETRY , 'POINT(0 0)'::geometry) as the_geom

throws an exception. It woud be more accurate to return POINT EMPTY

ebocher commented 5 months ago

@nicolas-f

nicolas-f commented 5 months ago
Select st_intersects('POINT EMPTY'::GEOMETRY , 'POINT(0 0)'::geometry) as the_geom

Maybe it should return false because it is not in the same projection system

ebocher commented 5 months ago

Sure PostGIS returns false. I will start to udpate all functions in H2GIS to fix this issue. It will be a big PR.

ebocher commented 5 months ago

Fixed