]> granicus.if.org Git - postgis/commitdiff
Added cleanup needed for GEOS > 1.0
authorSandro Santilli <strk@keybit.net>
Wed, 16 Jun 2004 19:37:54 +0000 (19:37 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 16 Jun 2004 19:37:54 +0000 (19:37 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@631 b70326c6-7e19-0410-871a-916f4a2858ee

postgis_geos.c
postgis_geos_wrapper.cpp

index 282784118f69fc9416cc260aae799f03e67251de..99f3a105bf4d3c1740ee0c87613b12c35ce5647e 100644 (file)
@@ -10,6 +10,9 @@
  *
  **********************************************************************
  * $Log$
+ * Revision 1.30  2004/06/16 19:37:54  strk
+ * Added cleanup needed for GEOS > 1.0
+ *
  * Revision 1.29  2004/06/16 18:47:59  strk
  * Added code to detect geos version.
  * Added appropriate includes in geos connectors.
 #include "access/rtree.h"
 
 #include "utils/builtins.h"
+
 #include "postgis_geos_version.h"
 
  /*
@@ -1382,7 +1386,8 @@ LINE3D *LineFromGeometry(Geometry *g,int *size)
 
 
 
-GEOMETRY *GEOS2POSTGIS(Geometry *g,char want3d)
+GEOMETRY *
+GEOS2POSTGIS(Geometry *g,char want3d)
 {
        int type = GEOSGeometryTypeId(g) ;
        GEOMETRY *result = NULL;
@@ -1591,7 +1596,8 @@ GEOMETRY *GEOS2POSTGIS(Geometry *g,char want3d)
 
 
 //BBOXONLYTYPE -> returns as a 2d polygon
-Geometry *POSTGIS2GEOS(GEOMETRY *g)
+Geometry *
+POSTGIS2GEOS(GEOMETRY *g)
 {
        POINT3D *pt;
        LINE3D *line;
@@ -1777,6 +1783,10 @@ Geometry *POSTGIS2GEOS(GEOMETRY *g)
                        elog(NOTICE, "POSTGIS2GEOS: COLLECTION has %d objs, srid %d and is %s 3d", g->nobjs, g->SRID, g->is3d ? "" : "not");
 #endif
                        geos = PostGIS2GEOS_collection(geoms,g->nobjs,g->SRID,g->is3d);
+#if GEOS_VERSION > 100
+                       for (t=0; t<g->nobjs; t++)
+                               GEOSdeleteGeometry(geoms[t]);
+#endif
                        if (geoms != NULL) pfree(geoms);
                        if (geos == NULL)
                        {
index 94c590467d3fbe9ed2b26353704bd743a0c368f2..87b0952f542e0c0d28d831f2370eae253cc202ad 100644 (file)
@@ -2,6 +2,9 @@
 
 /*
 * $Log$
+* Revision 1.20  2004/06/16 19:37:54  strk
+* Added cleanup needed for GEOS > 1.0
+*
 * Revision 1.19  2004/06/16 18:47:59  strk
 * Added code to detect geos version.
 * Added appropriate includes in geos connectors.
@@ -363,6 +366,10 @@ Geometry *PostGIS2GEOS_multipolygon(POLYGON3D **polygons,int npolys, int SRID, b
                                subPolys->push_back(PostGIS2GEOS_polygon(polygons[t], SRID,is3d ));
                        }
                        g = geomFactory->createMultiPolygon(subPolys);
+#if GEOS_VERSION > 100
+                       for (t=0; t<subPolys->size(); t++)
+                               delete (*subPolys)[t];
+#endif
                        delete subPolys;
 
                        if (g== NULL)
@@ -401,6 +408,9 @@ PostGIS2GEOS_multilinestring(const LINE3D **lines, int nlines, int SRID, bool is
                // geometries pointed to by subLines will be owned
                // by returned MultiLineString object
                g = geomFactory->createMultiLineString(subLines);
+#if GEOS_VERSION > 100
+               for (t=0; t<subLines->size(); t++) delete (*subLines)[t];
+#endif
                delete subLines;
                if (g==NULL) return NULL;
                g->setSRID(SRID);
@@ -431,6 +441,10 @@ Geometry *PostGIS2GEOS_multipoint(POINT3D **points,int npoints, int SRID, bool i
                                subPoints->push_back(PostGIS2GEOS_point(points[t], SRID,is3d ));
                        }
                        g = geomFactory->createMultiPoint(subPoints);
+#if GEOS_VERSION > 100
+                       for (t=0; t<subPoints->size(); t++)
+                               delete (*subPoints)[t];
+#endif
                        delete subPoints;
                        if (g==NULL)
                                return NULL;