OGRGeometry *OGRCurvePolygon::clone() const { OGRCurvePolygon *poNewPolygon; poNewPolygon = (OGRCurvePolygon*) OGRGeometryFactory::createGeometry(getGeometryType()); poNewPolygon->assignSpatialReference( getSpatialReference() ); for( int i = 0; i < oCC.nCurveCount; i++ ) { poNewPolygon->addRing( oCC.papoCurves[i] ); } return poNewPolygon; }
OGRCurvePolygon* OGRPolygon::CastToCurvePolygon( OGRPolygon* poPoly ) { OGRCurvePolygon* poCP = new OGRCurvePolygon(); poCP->set3D(poPoly->Is3D()); poCP->setMeasured(poPoly->IsMeasured()); poCP->assignSpatialReference(poPoly->getSpatialReference()); poCP->oCC.nCurveCount = poPoly->oCC.nCurveCount; poCP->oCC.papoCurves = poPoly->oCC.papoCurves; poPoly->oCC.nCurveCount = 0; poPoly->oCC.papoCurves = nullptr; for( auto&& poRing: *poCP ) { poRing = OGRLinearRing::CastToLineString(poRing->toLinearRing()); } delete poPoly; return poCP; }
OGRGeometry* OGRPolygon::getCurveGeometry(const char* const* papszOptions) const { OGRCurvePolygon* poCC = new OGRCurvePolygon(); poCC->assignSpatialReference( getSpatialReference() ); bool bHasCurveGeometry = false; for( int iRing = 0; iRing < oCC.nCurveCount; iRing++ ) { OGRCurve* poSubGeom = (OGRCurve* )oCC.papoCurves[iRing]->getCurveGeometry(papszOptions); if( wkbFlatten(poSubGeom->getGeometryType()) != wkbLineString ) bHasCurveGeometry = true; poCC->addRingDirectly( poSubGeom ); } if( !bHasCurveGeometry ) { delete poCC; return clone(); } return poCC; }
OGRCurvePolygon* OGRPolygon::CastToCurvePolygon(OGRPolygon* poPoly) { OGRCurvePolygon* poCP = new OGRCurvePolygon(); poCP->set3D(poPoly->Is3D()); poCP->setMeasured(poPoly->IsMeasured()); poCP->assignSpatialReference(poPoly->getSpatialReference()); poCP->oCC.nCurveCount = poPoly->oCC.nCurveCount; poCP->oCC.papoCurves = poPoly->oCC.papoCurves; poPoly->oCC.nCurveCount = 0; poPoly->oCC.papoCurves = NULL; for( int iRing = 0; iRing < poCP->oCC.nCurveCount; iRing++ ) { poCP->oCC.papoCurves[iRing] = OGRLinearRing::CastToLineString( (OGRLinearRing*)poCP->oCC.papoCurves[iRing] ); } delete poPoly; return poCP; }
OGRGeometry * OGRPolygon::getCurveGeometry( const char* const* papszOptions ) const { OGRCurvePolygon* poCC = new OGRCurvePolygon(); poCC->assignSpatialReference( getSpatialReference() ); bool bHasCurveGeometry = false; for( auto&& poRing: *this ) { auto poSubGeom = poRing->getCurveGeometry(papszOptions); if( wkbFlatten(poSubGeom->getGeometryType()) != wkbLineString ) bHasCurveGeometry = true; poCC->addRingDirectly( poSubGeom->toCurve() ); } if( !bHasCurveGeometry ) { delete poCC; return clone(); } return poCC; }