[postgis-commits] svn - r2708 - trunk/lwgeom

postgis-commits at postgis.refractions.net postgis-commits at postgis.refractions.net
Tue Sep 18 22:01:19 PDT 2007


Author: pramsey
Date: 2007-09-18 22:01:18 -0700 (Tue, 18 Sep 2007)
New Revision: 2708

Modified:
   trunk/lwgeom/lwgeom_functions_basic.c
Log:
Applied patch from Charlie Savage to make ST_Envelope return a POINT
when the input geometry is a POINT or a one-part MULTIPOINT.


Modified: trunk/lwgeom/lwgeom_functions_basic.c
===================================================================
--- trunk/lwgeom/lwgeom_functions_basic.c	2007-09-06 16:03:56 UTC (rev 2707)
+++ trunk/lwgeom/lwgeom_functions_basic.c	2007-09-19 05:01:18 UTC (rev 2708)
@@ -2501,6 +2501,17 @@
 	PG_LWGEOM *result;
 	uchar *ser;
 
+	if (lwgeom_getType(geom->type) == POINTTYPE ||
+            (lwgeom_getType(geom->type) == MULTIPOINTTYPE && lwgeom_getnumgeometries(SERIALIZED_FORM(geom)) == 1))
+	{
+		int srid = lwgeom_getsrid(SERIALIZED_FORM(geom));
+		LWPOINT* point = lwgeom_getpoint(SERIALIZED_FORM(geom), 0);
+		LWPOINT* envelope = lwpoint_construct(srid, NULL, point->point);
+		ser = lwpoint_serialize(envelope);
+		result = PG_LWGEOM_construct(ser, srid, 0);
+	PG_RETURN_POINTER(result);
+	}
+
 	/* get bounding box  */
 	if ( ! getbox2d_p(SERIALIZED_FORM(geom), &box) )
 	{



More information about the postgis-commits mailing list