From ddea16e8e0253ee6fbfedc3ab84d148d4fe9e789 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Wed, 16 Jun 2004 19:37:54 +0000 Subject: [PATCH] Added cleanup needed for GEOS > 1.0 git-svn-id: http://svn.osgeo.org/postgis/trunk@631 b70326c6-7e19-0410-871a-916f4a2858ee --- postgis_geos.c | 14 ++++++++++++-- postgis_geos_wrapper.cpp | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/postgis_geos.c b/postgis_geos.c index 282784118..99f3a105b 100644 --- a/postgis_geos.c +++ b/postgis_geos.c @@ -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. @@ -139,6 +142,7 @@ #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; tnobjs; t++) + GEOSdeleteGeometry(geoms[t]); +#endif if (geoms != NULL) pfree(geoms); if (geos == NULL) { diff --git a/postgis_geos_wrapper.cpp b/postgis_geos_wrapper.cpp index 94c590467..87b0952f5 100644 --- a/postgis_geos_wrapper.cpp +++ b/postgis_geos_wrapper.cpp @@ -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; tsize(); 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; tsize(); 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; tsize(); t++) + delete (*subPoints)[t]; +#endif delete subPoints; if (g==NULL) return NULL; -- 2.40.0