AddGeometryColumns() and update_geometry_stats()
- Initial support for topology modelling
- Stricter mapping between DBF and SQL integer and string attributes
+ - Changed M() and Z() functions to return NULL if requested
+ dimension is not available
PostGIS 1.0.5CVS
2005/11/25
// Z(GEOMETRY) -- find the first POINT(..) in GEOMETRY, returns its Z value.
// Return NULL if there is no POINT(..) in GEOMETRY.
-// Return 0 if there is no Z in this geometry.
+// Return NULL if there is no Z in this geometry.
PG_FUNCTION_INFO_V1(LWGEOM_z_point);
Datum LWGEOM_z_point(PG_FUNCTION_ARGS)
{
geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
- // if there's no Z return 0
- if ( ! TYPE_HASZ(geom->type) ) PG_RETURN_FLOAT8(0.0);
+ // if there's no Z return NULL
+ if ( ! TYPE_HASZ(geom->type) ) PG_RETURN_NULL();
inspected = lwgeom_inspect(SERIALIZED_FORM(geom));
// M(GEOMETRY) -- find the first POINT(..) in GEOMETRY, returns its M value.
// Return NULL if there is no POINT(..) in GEOMETRY.
-// Return 0 if there is no M in this geometry.
+// Return NULL if there is no M in this geometry.
PG_FUNCTION_INFO_V1(LWGEOM_m_point);
Datum LWGEOM_m_point(PG_FUNCTION_ARGS)
{
geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
- // if there's no M return 0
- if ( ! TYPE_HASM(geom->type) ) PG_RETURN_FLOAT8(0.0);
+ // if there's no M return NULL
+ if ( ! TYPE_HASM(geom->type) ) PG_RETURN_NULL();
inspected = lwgeom_inspect(SERIALIZED_FORM(geom));
select '131', X('POINT(1 2)');
select '132', Y('POINT(1 2)');
select '133', Z('POINT(1 2)');
+select '133a', Z('POINT(1 2 3)');
+select '133b', Z('POINTM(1 2 3)');
+select '133c', M('POINT(1 2)');
+select '133d', M('POINTM(1 2 4)');
+select '133e', M('POINT(1 2 4)');
select '134', distance('POINT(1 2)', 'POINT(1 2)');
select '135', distance('POINT(5 0)', 'POINT(10 12)');