[postgis-devel] [PostGIS] #1078: ST_Difference with NULL as second argument

PostGIS trac at osgeo.org
Wed Jun 29 14:41:50 PDT 2011


#1078: ST_Difference with NULL as second argument
---------------------+------------------------------------------------------
 Reporter:  nicklas  |       Owner:  nicklas      
     Type:  defect   |      Status:  new          
 Priority:  medium   |   Milestone:  PostGIS 2.0.0
Component:  postgis  |     Version:  trunk        
 Keywords:           |  
---------------------+------------------------------------------------------
 I think that ST_Difference should return the first argument if the second
 argument is NULL. Now it returns NULL or nothing.

 This is specially interesting in situation like the one described here,
 with a left or right join to catch the none intersecting ones:

 [http://gis.stackexchange.com/questions/11592/difference-between-two-
 layers-in-postgis]


 So I would like to commit this:


 {{{

 Index: postgis.sql.in.c
 ===================================================================
 --- postgis.sql.in.c    (revision 7521)
 +++ postgis.sql.in.c    (working copy)
 @@ -3199,7 +3199,7 @@
  CREATE OR REPLACE FUNCTION ST_Difference(geometry,geometry)
         RETURNS geometry
         AS 'MODULE_PATHNAME','difference'
 -       LANGUAGE 'C' IMMUTABLE STRICT;
 +       LANGUAGE 'C' IMMUTABLE;

  -- PostGIS equivalent function: boundary(geometry)
  CREATE OR REPLACE FUNCTION ST_Boundary(geometry)
 Index: lwgeom_geos.c
 ===================================================================
 --- lwgeom_geos.c       (revision 7521)
 +++ lwgeom_geos.c       (working copy)
 @@ -1493,8 +1493,12 @@
         int is3d;
         int srid;

 -       PROFSTART(PROF_QRUN);
 -
 +         /* Return the first geom if the second geom is null */
 +         if (PG_ARGISNULL(1))
 +                 PG_RETURN_DATUM(PG_GETARG_DATUM(0));
 +
 +        PROFSTART(PROF_QRUN);
 +
         geom1 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
         geom2 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(1));

 }}}



 Any objections?

 /Nicklas

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/1078>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-devel mailing list