From: Sandro Santilli Date: Thu, 24 Feb 2005 08:32:08 +0000 (+0000) Subject: Fixed bug in StartPoint and EndPoint functions. X-Git-Tag: pgis_1_0_0RC3~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=729090bd46005d1675b8fd905926c30bbb11860e;p=postgis Fixed bug in StartPoint and EndPoint functions. git-svn-id: http://svn.osgeo.org/postgis/trunk@1437 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/lwgeom/lwgeom_ogc.c b/lwgeom/lwgeom_ogc.c index 8357a959f..1171da576 100644 --- a/lwgeom/lwgeom_ogc.c +++ b/lwgeom/lwgeom_ogc.c @@ -672,7 +672,6 @@ Datum LWGEOM_startpoint_linestring(PG_FUNCTION_ARGS) LWLINE *line = NULL; POINTARRAY *pts; LWPOINT *point; - char *serializedpoint; PG_LWGEOM *result; int i; @@ -686,7 +685,7 @@ Datum LWGEOM_startpoint_linestring(PG_FUNCTION_ARGS) } pfree_inspected(inspected); - if ( point == NULL ) { + if ( line == NULL ) { PG_FREE_IF_COPY(geom, 0); PG_RETURN_NULL(); } @@ -701,17 +700,12 @@ Datum LWGEOM_startpoint_linestring(PG_FUNCTION_ARGS) // Construct an LWPOINT point = lwpoint_construct(pglwgeom_getSRID(geom), NULL, pts); - // Serialized the point - serializedpoint = lwpoint_serialize(point); - - // And we construct the line (copy again) - result = PG_LWGEOM_construct(serializedpoint, pglwgeom_getSRID(geom), - 0); + // Construct a PG_LWGEOM + result = pglwgeom_serialize((LWGEOM *)point); - pfree(point); - pfree(serializedpoint); - PG_FREE_IF_COPY(geom, 0); lwgeom_release((LWGEOM *)line); + lwgeom_release((LWGEOM *)point); + PG_FREE_IF_COPY(geom, 0); PG_RETURN_POINTER(result); } @@ -726,8 +720,7 @@ Datum LWGEOM_endpoint_linestring(PG_FUNCTION_ARGS) LWGEOM_INSPECTED *inspected; LWLINE *line = NULL; POINTARRAY *pts; - LWPOINT *point; - char *serializedpoint; + LWGEOM *point; PG_LWGEOM *result; int i; @@ -741,7 +734,7 @@ Datum LWGEOM_endpoint_linestring(PG_FUNCTION_ARGS) } pfree_inspected(inspected); - if ( point == NULL ) { + if ( line == NULL ) { PG_FREE_IF_COPY(geom, 0); PG_RETURN_NULL(); } @@ -756,19 +749,14 @@ Datum LWGEOM_endpoint_linestring(PG_FUNCTION_ARGS) TYPE_HASM(line->type), 1); // Construct an LWPOINT - point = lwpoint_construct(pglwgeom_getSRID(geom), NULL, pts); - - // Serialized the point - serializedpoint = lwpoint_serialize(point); + point = (LWGEOM *)lwpoint_construct(pglwgeom_getSRID(geom), NULL, pts); - // And we construct the line (copy again) - result = PG_LWGEOM_construct(serializedpoint, pglwgeom_getSRID(geom), - 0); + // Serialize an PG_LWGEOM + result = pglwgeom_serialize(point); - pfree(point); - pfree(serializedpoint); - PG_FREE_IF_COPY(geom, 0); + lwgeom_release(point); lwgeom_release((LWGEOM *)line); + PG_FREE_IF_COPY(geom, 0); PG_RETURN_POINTER(result); } @@ -780,7 +768,6 @@ Datum LWGEOM_from_text(PG_FUNCTION_ARGS) { text *wkttext = PG_GETARG_TEXT_P(0); char *wkt, fc; - int32 SRID; size_t size; PG_LWGEOM *geom; PG_LWGEOM *result = NULL;