POINT3D *p;
//build coordinatelist & pre-allocate space
+#if GEOS_LAST_INTERFACE >= 2
+ vector<Coordinate> *vc = new vector<Coordinate>(pa->npoints);
+#else
DefaultCoordinateSequence *coords = new DefaultCoordinateSequence(pa->npoints);
+#endif
if (is3d)
{
for (t=0; t<pa->npoints; t++)
{
p = (POINT3D *)getPoint(pa, t);
+#if GEOS_LAST_INTERFACE >= 2
+ (*vc)[t].x = p->x;
+ (*vc)[t].y = p->y;
+ (*vc)[t].z = p->z;
+#else
c.x = p->x;
c.y = p->y;
c.z = p->z;
coords->setAt(c ,t);
+#endif
}
}
else //make 2d points
for (t=0; t<pa->npoints; t++)
{
p = (POINT3D *)getPoint(pa, t);
+#if GEOS_LAST_INTERFACE >= 2
+ (*vc)[t].x = p->x;
+ (*vc)[t].y = p->y;
+ (*vc)[t].z = DoubleNotANumber;
+#else
c.x = p->x;
c.y = p->y;
c.z = DoubleNotANumber;
coords->setAt(c ,t);
+#endif
}
}
+#if GEOS_LAST_INTERFACE >= 2
+ CoordinateSequence *coords = DefaultCoordinateSequenceFactory::instance()->create(vc);
+#endif
Geometry *g = geomFactory->createLineString(coords);
#if GEOS_LAST_INTERFACE < 2
delete coords;
Geometry *g;
LinearRing *outerRing;
LinearRing *innerRing;
- DefaultCoordinateSequence *cl;
+ CoordinateSequence *cl;
POINT3D *p;
- vector<Geometry *> *innerRings=new vector<Geometry *>;
+ vector<Geometry *> *innerRings;
+ vector<Coordinate> *vc;
// make outerRing
pa = lwpoly->rings[0];
+#if GEOS_LAST_INTERFACE >= 2
+ vc = new vector<Coordinate>(pa->npoints);
+#else
cl = new DefaultCoordinateSequence(pa->npoints);
+#endif
if (is3d)
{
for(t=0; t<pa->npoints; t++)
{
p = (POINT3D *)getPoint(pa, t);
+#if GEOS_LAST_INTERFACE >= 2
+ (*vc)[t].x = p->x;
+ (*vc)[t].y = p->y;
+ (*vc)[t].z = p->z;
+#else
c.x = p->x;
c.y = p->y;
c.z = p->z;
cl->setAt( c ,t);
+#endif
}
}
else
for(t=0; t<pa->npoints; t++)
{
p = (POINT3D *)getPoint(pa, t);
+#if GEOS_LAST_INTERFACE >= 2
+ (*vc)[t].x = p->x;
+ (*vc)[t].y = p->y;
+ (*vc)[t].z = DoubleNotANumber;
+#else
c.x = p->x;
c.y = p->y;
c.z = DoubleNotANumber;
cl->setAt(c ,t);
+#endif
}
}
+#if GEOS_LAST_INTERFACE >= 2
+ cl = DefaultCoordinateSequenceFactory::instance()->create(vc);
+#endif
outerRing = (LinearRing*) geomFactory->createLinearRing(cl);
#if GEOS_LAST_INTERFACE < 2
delete cl;
if (outerRing == NULL) return NULL;
outerRing->setSRID(SRID);
+ innerRings=new vector<Geometry *>(lwpoly->nrings-1);
for(ring=1; ring<lwpoly->nrings; ring++)
{
pa = lwpoly->rings[ring];
+#if GEOS_LAST_INTERFACE >= 2
+ vector<Coordinate> *vc = new vector<Coordinate>(pa->npoints);
+#else
cl = new DefaultCoordinateSequence(pa->npoints);
+#endif
if (is3d)
{
for(t=0; t<pa->npoints; t++)
{
p = (POINT3D *)getPoint(pa, t);
+#if GEOS_LAST_INTERFACE >= 2
+ (*vc)[t].x = p->x;
+ (*vc)[t].y = p->y;
+ (*vc)[t].z = p->z;
+#else
c.x = p->x;
c.y = p->y;
c.z = p->z;
cl->setAt(c ,t);
+#endif
}
}
else
for(t=0; t<pa->npoints; t++)
{
p = (POINT3D *)getPoint(pa, t);
+#if GEOS_LAST_INTERFACE >= 2
+ (*vc)[t].x = p->x;
+ (*vc)[t].y = p->y;
+ (*vc)[t].z = DoubleNotANumber;
+#else
c.x = p->x;
c.y = p->y;
c.z = DoubleNotANumber;
cl->setAt(c ,t);
+#endif
}
}
+#if GEOS_LAST_INTERFACE >= 2
+ CoordinateSequence *cl = DefaultCoordinateSequenceFactory::instance()->create(vc);
+#endif
innerRing = (LinearRing *) geomFactory->createLinearRing(cl);
#if GEOS_LAST_INTERFACE < 2
delete cl;
return NULL;
}
innerRing->setSRID(SRID);
- innerRings->push_back(innerRing);
+ (*innerRings)[ring-1] = innerRing;
}
g = geomFactory->createPolygon(outerRing, innerRings);
vector<Geometry *> *subGeoms=NULL;
Geometry *g;
- subGeoms=new vector<Geometry *>;
+ subGeoms=new vector<Geometry *>(ngeoms);
for (t=0; t<ngeoms; t++)
{
- subGeoms->push_back(PostGIS2GEOS_point(geoms[t]));
+ (*subGeoms)[t] = PostGIS2GEOS_point(geoms[t]);
}
g = geomFactory->createMultiPoint(subGeoms);
#if GEOS_LAST_INTERFACE < 2
vector<Geometry *> *subGeoms=NULL;
Geometry *g;
- subGeoms=new vector<Geometry *>;
+ subGeoms=new vector<Geometry *>(ngeoms);
for (t=0; t<ngeoms; t++)
{
- subGeoms->push_back(PostGIS2GEOS_linestring(geoms[t]));
+ (*subGeoms)[t] = PostGIS2GEOS_linestring(geoms[t]);
}
g = geomFactory->createMultiLineString(subGeoms);
#if GEOS_LAST_INTERFACE < 2
vector<Geometry *> *subPolys=NULL;
Geometry *g;
- subPolys=new vector<Geometry *>;
+ subPolys=new vector<Geometry *>(npolys);
for (t =0; t< npolys; t++)
{
- subPolys->push_back(PostGIS2GEOS_polygon(polygons[t]));
+ (*subPolys)[t] = PostGIS2GEOS_polygon(polygons[t]);
}
g = geomFactory->createMultiPolygon(subPolys);
#if GEOS_LAST_INTERFACE < 2
{
Geometry *g;
int t;
- vector<Geometry *> *subGeos=new vector<Geometry *>;
+ vector<Geometry *> *subGeos=new vector<Geometry *>(ngeoms);
- for (t =0; t< ngeoms; t++)
+ for (t =0; t<ngeoms; t++)
{
- subGeos->push_back(geoms[t]);
+ (*subGeos)[t] = geoms[t];
}
g = geomFactory->buildGeometry(subGeos);
#if GEOS_LAST_INTERFACE < 2