/*protected*/ Polygon::Polygon(LinearRing *newShell, vector<Geometry *> *newHoles, const GeometryFactory *newFactory): Geometry(newFactory) { if (newShell==nullptr) { shell=getFactory()->createLinearRing(nullptr); } else { if (newHoles != nullptr && newShell->isEmpty() && hasNonEmptyElements(newHoles)) { throw util::IllegalArgumentException("shell is empty but holes are not"); } shell=newShell; } if (newHoles==nullptr) { holes=new vector<Geometry *>(); } else { if (hasNullElements(newHoles)) { throw util::IllegalArgumentException("holes must not contain null elements"); } for (size_t i=0; i<newHoles->size(); i++) if ( (*newHoles)[i]->getGeometryTypeId() != GEOS_LINEARRING) throw util::IllegalArgumentException("holes must be LinearRings"); holes=newHoles; } }
/*protected*/ GeometryCollection::GeometryCollection(vector<Geometry *> *newGeoms, const GeometryFactory *factory): Geometry(factory) { if (newGeoms==NULL) { geometries=new vector<Geometry *>(); return; } if (hasNullElements(newGeoms)) { throw util::IllegalArgumentException("geometries must not contain null elements\n"); return; } geometries=newGeoms; }
/*protected*/ GeometryCollection::GeometryCollection(vector<Geometry *> *newGeoms, const GeometryFactory *factory): Geometry(factory) { if (newGeoms==NULL) { geometries=new vector<Geometry *>(); return; } if (hasNullElements(newGeoms)) { throw util::IllegalArgumentException("geometries must not contain null elements\n"); return; } geometries=newGeoms; // Drop SRID from inner geoms size_t ngeoms=geometries->size(); for(size_t i=0; i<ngeoms; ++i) { (*geometries)[i]->setSRID(0); } }