]> granicus.if.org Git - postgis/commitdiff
minor clean and trying to figure out a memory bug. valgrind wasnt helping, but
authorDavid Blasby <dblasby@gmail.com>
Thu, 11 Mar 2004 01:27:43 +0000 (01:27 +0000)
committerDavid Blasby <dblasby@gmail.com>
Thu, 11 Mar 2004 01:27:43 +0000 (01:27 +0000)
it went away.

git-svn-id: http://svn.osgeo.org/postgis/trunk@487 b70326c6-7e19-0410-871a-916f4a2858ee

lwgeom/lwgeom.sql.in
lwgeom/lwgeom_api.c
lwgeom/lwgeom_inout.c

index 43f68c74ba67dade4a86b493b791c978cdcc1eb9..9748a1a613a491d7b70ebdb208d378c50c852a9d 100644 (file)
@@ -45,3 +45,5 @@ select geometry(wkb(lwgeom(asbinary('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))'::ge
 select geometry(wkb(lwgeom(asbinary('POLYGON((0 0 -99, 10 0 -99, 10 10 -99, 0 10 -99, 0 0 -99))'::geometry))));
 
 
+select geometry(wkb(lwgeom(asbinary('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 5,7 5, 7 7, 5 7, 5 5))'::geometry))));
+select geometry(wkb(lwgeom(asbinary('POLYGON((0 0 -99, 10 0 -99, 10 10 -99, 0 10 -99, 0 0 -99),(5 5 -99,7 5 -99, 7 7 -99, 5 7 -99, 5 5 -99))'::geometry))));
index 1afc661220a9834a960cef24ab04ff15705cb448..d04cbb5ef8f7b99489fd83127d01f66c5e917b9b 100644 (file)
@@ -492,7 +492,6 @@ LWLINE *lwline_deserialize(char *serialized_form)
        result->points = pa;
        result->is3d = lwgeom_is3d(type);
 
-//elog(NOTICE,"npoints in deserialize line = %i",npoints);
        return result;
 }
 
@@ -506,7 +505,9 @@ char  *lwline_serialize(LWLINE *line)
        int t;
        char *loc;
 
-elog(NOTICE,"lwline_serialize::entry");
+if (line == NULL)
+       elog(ERROR,"lwline_serialize:: given null line");
+
        hasSRID = (line->SRID != -1);
 
        if (hasSRID)
@@ -521,9 +522,8 @@ elog(NOTICE,"lwline_serialize::entry");
                size += 16 * line->points->npoints; //x,y
        }
 
-       size+=4; // npoints
 
-elog(NOTICE,"lwline_serialize:: size = %i",size);
+       size+=4; // npoints
 
        result = palloc(size);
 
@@ -540,6 +540,8 @@ elog(NOTICE,"lwline_serialize:: size = %i",size);
        loc +=4;
        //copy in points
 
+elog(NOTICE," line serialize - size = %i", size);
+
        if (line->is3d)
        {
                for (t=0; t< line->points->npoints;t++)
@@ -556,7 +558,7 @@ elog(NOTICE,"lwline_serialize:: size = %i",size);
                        loc += 16; // size of a 2d point
                }
        }
-       printBYTES((unsigned char *)result, size);
+       //printBYTES((unsigned char *)result, size);
        return result;
 }
 
@@ -593,7 +595,6 @@ uint32 lwline_findlength(char *serialized_line)
                // we've read the type (1 byte) and SRID (4 bytes, if present)
 
                npoints = get_uint32(loc);
-elog(NOTICE,"npoint in lwline_findlength= %i",npoints);
                result += 4; //npoints
 
                if (lwgeom_is3d(type) )
@@ -843,7 +844,6 @@ LWPOLY *lwpoly_deserialize(char *serialized_form)
        nrings = get_uint32(loc);
        result->nrings = nrings;
        loc +=4;
-elog(NOTICE,"lwpoly_deserialize:: polygon with %i rings",nrings);
        result->rings = (POINTARRAY**) palloc(nrings* sizeof(POINTARRAY*));
 
        for (t =0;t<nrings;t++)
@@ -895,7 +895,6 @@ char *lwpoly_serialize(LWPOLY *poly)
                        size += 16*total_points;
 
                result = palloc(size);
-       elog(NOTICE,"lwpoly_serialize size = %i", size);
 
                result[0] = lwgeom_makeType(poly->is3d,hasSRID, POLYGONTYPE);
                loc = result+1;
@@ -915,7 +914,6 @@ char *lwpoly_serialize(LWPOLY *poly)
                {
                        POINTARRAY *pa = poly->rings[t];
                        npoints = poly->rings[t]->npoints;
-elog(NOTICE,"doing ring #%i with %i points",t,npoints);
                        memcpy(loc, &npoints, sizeof(int32)); //npoints this ring
                        loc+=4;
                        if (poly->is3d)
@@ -930,7 +928,6 @@ elog(NOTICE,"doing ring #%i with %i points",t,npoints);
                        {
                                for (u=0;u<npoints;u++)
                                {
-elog(NOTICE,"pt %i",u);
                                        getPoint2d_p(pa, u, loc);
                                        loc+= 16;
                                }
index 11977db66f48626c8ad065f6ed2f137b18abf903..a19d5a4facdc520ea0790b9c8bf0505ec9d9fe8b 100644 (file)
@@ -164,7 +164,7 @@ Datum LWGEOMFromWKB(PG_FUNCTION_ARGS)
                                        SRID = -1;
 
 #ifdef DEBUG
-        elog(NOTICE,"LWGEOMFromWKB: entry with SRID=%i\n",SRID);
+        elog(NOTICE,"LWGEOMFromWKB: entry with SRID=%i",SRID);
 #endif
 
                                        // need to do this because there might be a bunch of endian flips!
@@ -240,7 +240,7 @@ char *wkb_to_lwgeom(char *wkb, int SRID,int *size)
        simpletype = wkb_simpletype(wkbtype);
 
 #ifdef DEBUG
-        elog(NOTICE,"wkb_to_lwgeom: entry with SRID=%i, dims=%i, simpletype=%i\n",SRID,(int) dims, (int) simpletype);
+        elog(NOTICE,"wkb_to_lwgeom: entry with SRID=%i, dims=%i, simpletype=%i",SRID,(int) dims, (int) simpletype);
 #endif
 
 
@@ -254,21 +254,17 @@ char *wkb_to_lwgeom(char *wkb, int SRID,int *size)
                                                break;
                case LINETYPE:
                                                line = wkb_line_to_lwline(wkb, SRID);
-       printLWLINE(line);
-       elog(NOTICE,"have line with %i points",line->points->npoints);
+       //printLWLINE(line);
                                                result  = lwline_serialize(line);
-       elog(NOTICE,"serialized it");
+//     elog(NOTICE,"line serialized");
                                                *size = lwline_findlength(result);
-       elog(NOTICE,"serialized length=%i",*size);
                                                pfree_line(line);
                                                break;
                case POLYGONTYPE:
                                                poly = wkb_poly_to_lwpoly(wkb, SRID);
-       printLWPOLY(poly);
+//     printLWPOLY(poly);
                                                result  = lwpoly_serialize(poly);
-       elog(NOTICE,"serialized polygon");
                                                *size = lwpoly_findlength(result);
-       elog(NOTICE,"serialized polygon has length = %i",*size);
                                                pfree_polygon(poly);
                                                break;
                case MULTIPOINTTYPE:
@@ -308,7 +304,7 @@ LWPOINT *wkb_point_to_lwpoint(char *wkb,int SRID)
        simpletype = wkb_simpletype(wkbtype);
 
 #ifdef DEBUG
-        elog(NOTICE,"wkb_point_to_lwpoint: entry with SRID=%i, dims=%i, simpletype=%i\n",SRID,(int) dims, (int) simpletype);
+        elog(NOTICE,"wkb_point_to_lwpoint: entry with SRID=%i, dims=%i, simpletype=%i",SRID,(int) dims, (int) simpletype);
 #endif
 
 
@@ -352,7 +348,6 @@ LWLINE *wkb_line_to_lwline(char *wkb,int SRID)
                flipPoints(wkb+9,npoints,dims);
 
        pa = pointArray_construct(wkb+9, dims, npoints);
-printPA(pa);
        return lwline_construct(dims, SRID, pa);
 }
 
@@ -413,7 +408,6 @@ LWPOLY *wkb_poly_to_lwpoly(char *wkb,int SRID)
                                        // read a ring
                        if (need_flip)
                                flipPoints(loc+4,npoints,dims);
-elog(NOTICE,"wkb_poly_to_lwpoly:: doing ring %i with %i points", t, npoints);
                        pa = pointArray_construct(loc+4, dims, npoints);
 
                        loc += 4;
@@ -439,7 +433,7 @@ char *lwgeom_to_wkb(char *serialized_form,int *wkblength,char desiredWKBEndian)
        char   *multigeom = NULL;
 
 #ifdef DEBUG
-        elog(NOTICE,"lwgeom_to_wkb: entry with  simpletype=%i, dims=%i\n",(int) simple_type,(int)  lwgeom_is3d( serialized_form[0]) );
+        elog(NOTICE,"lwgeom_to_wkb: entry with  simpletype=%i, dims=%i",(int) simple_type,(int)  lwgeom_is3d( serialized_form[0]) );
 #endif
 
 
@@ -456,9 +450,8 @@ char *lwgeom_to_wkb(char *serialized_form,int *wkblength,char desiredWKBEndian)
                                                pfree_line(line);
                                                break;
                case POLYGONTYPE:
-       elog(NOTICE,"lwgeom_to_wkb :: deserializing polygon");
                                                poly = lwpoly_deserialize(serialized_form);
-       printLWPOLY(poly);
+//     printLWPOLY(poly);
                                                result = lwpoly_to_wkb(poly, desiredWKBEndian, wkblength);
                                                pfree_polygon(poly );
                                                break;
@@ -483,7 +476,7 @@ char *lwpoint_to_wkb(LWPOINT *pt, char desiredWKBEndian, int *wkbsize)
        bool need_flip =  requiresflip( desiredWKBEndian );
 
 #ifdef DEBUG
-        elog(NOTICE,"lwpoint_to_wkb:  pa dims = %i\n", (int)pt->point->is3d );
+        elog(NOTICE,"lwpoint_to_wkb:  pa dims = %i", (int)pt->point->is3d );
 #endif
 
 
@@ -496,7 +489,7 @@ char *lwpoint_to_wkb(LWPOINT *pt, char desiredWKBEndian, int *wkbsize)
        wkbtype = constructWKBType(POINTTYPE, pt->point->is3d);
 
 #ifdef DEBUG
-        elog(NOTICE,"lwpoint_to_wkb: entry with wkbtype=%i, pa dims = %i\n",wkbtype, (int)pt->point->is3d );
+        elog(NOTICE,"lwpoint_to_wkb: entry with wkbtype=%i, pa dims = %i",wkbtype, (int)pt->point->is3d );
 #endif
 
 
@@ -519,9 +512,6 @@ char *lwline_to_wkb(LWLINE *line, char desiredWKBEndian, int *wkbsize)
                uint32 wkbtype ;
                bool need_flip =  requiresflip( desiredWKBEndian );
 
-
-printLWLINE(line);
-
                *wkbsize = 1+ 4+4+ line->points->npoints * ptsize; //endian, type, npoints, points
 
                result = palloc(*wkbsize);