Show
Ignore:
Timestamp:
11/06/09 17:31:07 (3 years ago)
Author:
pramsey
Message:

Make ~= be a bounding box only operator and upgrade ST_Equals() and ST_OrderingEquals() to match the new behavior. Update regression tests to match new behavior. (#282) See also #289 for an odd quirk discovered while updating regression tests.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/postgis/lwgeom_gist.c

    r4736 r4763  
    3838Datum LWGEOM_overabove(PG_FUNCTION_ARGS); 
    3939Datum LWGEOM_contained(PG_FUNCTION_ARGS); 
     40Datum LWGEOM_samebox(PG_FUNCTION_ARGS); 
    4041Datum LWGEOM_contain(PG_FUNCTION_ARGS); 
    4142Datum LWGEOM_gist_compress(PG_FUNCTION_ARGS); 
     
    375376} 
    376377 
     378PG_FUNCTION_INFO_V1(LWGEOM_samebox); 
     379Datum LWGEOM_samebox(PG_FUNCTION_ARGS) 
     380{ 
     381        PG_LWGEOM *lwgeom1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); 
     382        PG_LWGEOM *lwgeom2 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1)); 
     383        bool result; 
     384        BOX2DFLOAT4 box1; 
     385        BOX2DFLOAT4 box2; 
     386 
     387        POSTGIS_DEBUG(2, "GIST: LWGEOM_samebox --entry"); 
     388 
     389        errorIfSRIDMismatch(pglwgeom_getSRID(lwgeom1), pglwgeom_getSRID(lwgeom2)); 
     390 
     391        if ( ! (getbox2d_p(SERIALIZED_FORM(lwgeom1), &box1) && getbox2d_p(SERIALIZED_FORM(lwgeom2), &box2)) ) 
     392        { 
     393                PG_FREE_IF_COPY(lwgeom1, 0); 
     394                PG_FREE_IF_COPY(lwgeom2, 1); 
     395                PG_RETURN_BOOL(FALSE); 
     396        } 
     397 
     398        result = DatumGetBool(DirectFunctionCall2(BOX2D_same, 
     399                                                  PointerGetDatum(&box1), PointerGetDatum(&box2))); 
     400 
     401        PG_FREE_IF_COPY(lwgeom1, 0); 
     402        PG_FREE_IF_COPY(lwgeom2, 1); 
     403 
     404        PG_RETURN_BOOL(result); 
     405} 
    377406 
    378407PG_FUNCTION_INFO_V1(LWGEOM_contained); 
     
    564593        *recheck = false; 
    565594         
    566         /* Our ~= operator (strategy 6) requires a re-check in order to  
    567            function according to the documentation and past behavior.  
    568            We will temporarily enable that behavior here. */ 
    569         if ( strategy == 6 ) 
    570                 *recheck = true; 
    571595#endif 
    572596