]> granicus.if.org Git - postgis/commitdiff
Fixed bug in StartPoint and EndPoint functions.
authorSandro Santilli <strk@keybit.net>
Thu, 24 Feb 2005 08:32:08 +0000 (08:32 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 24 Feb 2005 08:32:08 +0000 (08:32 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@1437 b70326c6-7e19-0410-871a-916f4a2858ee

lwgeom/lwgeom_ogc.c

index 8357a959fdcd99d7468db5669779007e5d6f148b..1171da57602f07f4a4961409bc3d0bba683fb9c7 100644 (file)
@@ -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;