From: Sandro Santilli Date: Tue, 27 Apr 2004 07:44:26 +0000 (+0000) Subject: Removed use of geometryFactory->toGeometry(), indicated by Martin Davis X-Git-Tag: pgis_0_8_2~47 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=354684cb48bdcfdc550f0e02ccdf306ee2df3b62;p=postgis Removed use of geometryFactory->toGeometry(), indicated by Martin Davis as being intended for internal use only. Created a linear ring instead (the function converts a box3d to a geos geometry). git-svn-id: http://svn.osgeo.org/postgis/trunk@512 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis_geos_wrapper.cpp b/postgis_geos_wrapper.cpp index 0ba606a3a..07369d643 100644 --- a/postgis_geos_wrapper.cpp +++ b/postgis_geos_wrapper.cpp @@ -2,6 +2,11 @@ /* * $Log$ +* Revision 1.18 2004/04/27 07:44:26 strk +* Removed use of geometryFactory->toGeometry(), indicated by Martin Davis +* as being intended for internal use only. Created a linear ring instead +* (the function converts a box3d to a geos geometry). +* * Revision 1.17 2003/12/12 13:34:20 strk * added missing 'const' in prototypes * @@ -189,24 +194,36 @@ void initGEOS (int maxalign) //note: you lose the 3d from this! Geometry *PostGIS2GEOS_box3d(BOX3D *box, int SRID) { + BasicCoordinateList *cl = new BasicCoordinateList(5); try { Geometry *g; - Envelope *envelope = new Envelope(box->LLB.x,box->URT.x ,box->LLB.y,box->URT.y); - g = geomFactory->toGeometry(envelope,geomFactory->getPrecisionModel(), SRID); - delete envelope; - if (g==NULL) - return NULL; + Coordinate c; + c.x = box->LLB.x; c.y = box->LLB.y; + cl->setAt(c, 0); + c.x = box->LLB.x; c.y = box->URT.y; + cl->setAt(c, 1); + c.x = box->URT.x; c.y = box->URT.y; + cl->setAt(c, 2); + c.x = box->URT.x; c.y = box->LLB.y; + cl->setAt(c, 3); + c.x = box->LLB.x; c.y = box->LLB.y; + cl->setAt(c, 4); + + g = geomFactory->createLinearRing(cl); + delete cl; + if (g==NULL) return NULL; g->setSRID(SRID); return g; } catch (GEOSException *ge) { NOTICE_MESSAGE((char *)ge->toString().c_str()); - delete ge; + delete cl; return NULL; } catch (...) { + delete cl; return NULL; } }