Changeset 2059

Show
Ignore:
Timestamp:
11/23/05 06:52:39 (6 years ago)
Author:
strk
Message:

Changed M() and Z() to return NULL when input doesn't have
the requested dimension. Updated regress tests with a few
of these cases.

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/CHANGES

    r2053 r2059  
    2424        - Initial support for topology modelling 
    2525        - Stricter mapping between DBF and SQL integer and string attributes 
     26        - Changed M() and Z() functions to return NULL if requested 
     27          dimension is not available 
    2628 
    2729PostGIS 1.0.5CVS 
  • trunk/lwgeom/lwgeom_ogc.c

    r1903 r2059  
    617617// Z(GEOMETRY) -- find the first POINT(..) in GEOMETRY, returns its Z value. 
    618618// Return NULL if there is no POINT(..) in GEOMETRY. 
    619 // Return 0 if there is no Z in this geometry. 
     619// Return NULL if there is no Z in this geometry. 
    620620PG_FUNCTION_INFO_V1(LWGEOM_z_point); 
    621621Datum LWGEOM_z_point(PG_FUNCTION_ARGS) 
     
    629629        geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); 
    630630 
    631         // if there's no Z return 0 
    632         if ( ! TYPE_HASZ(geom->type) ) PG_RETURN_FLOAT8(0.0); 
     631        // if there's no Z return NULL 
     632        if ( ! TYPE_HASZ(geom->type) ) PG_RETURN_NULL(); 
    633633 
    634634        inspected = lwgeom_inspect(SERIALIZED_FORM(geom)); 
     
    656656// M(GEOMETRY) -- find the first POINT(..) in GEOMETRY, returns its M value. 
    657657// Return NULL if there is no POINT(..) in GEOMETRY. 
    658 // Return 0 if there is no M in this geometry. 
     658// Return NULL if there is no M in this geometry. 
    659659PG_FUNCTION_INFO_V1(LWGEOM_m_point); 
    660660Datum LWGEOM_m_point(PG_FUNCTION_ARGS) 
     
    668668        geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); 
    669669 
    670         // if there's no M return 0 
    671         if ( ! TYPE_HASM(geom->type) ) PG_RETURN_FLOAT8(0.0); 
     670        // if there's no M return NULL 
     671        if ( ! TYPE_HASM(geom->type) ) PG_RETURN_NULL(); 
    672672 
    673673        inspected = lwgeom_inspect(SERIALIZED_FORM(geom)); 
  • trunk/regress/regress_expected

    r2057 r2059  
    133133131|1 
    134134132|2 
    135 133|0 
     135133| 
     136133a|3 
     137133b| 
     138133c| 
     139133d|4 
     140133e| 
    136141134|0 
    137142135|13 
  • trunk/regress/regress.sql

    r2057 r2059  
    224224select '132', Y('POINT(1 2)'); 
    225225select '133', Z('POINT(1 2)'); 
     226select '133a', Z('POINT(1 2 3)'); 
     227select '133b', Z('POINTM(1 2 3)'); 
     228select '133c', M('POINT(1 2)'); 
     229select '133d', M('POINTM(1 2 4)'); 
     230select '133e', M('POINT(1 2 4)'); 
    226231 
    227232select '134', distance('POINT(1 2)', 'POINT(1 2)');