Symbology::Geometry* OgrUtils::createGeometry( OGRGeometryH geomHandle ) { Symbology::Geometry* output = 0L; OGRwkbGeometryType wkbType = OGR_G_GetGeometryType( geomHandle ); if ( wkbType == wkbPolygon || wkbType == wkbPolygon25D ) { output = createPolygon( geomHandle ); } else if ( wkbType == wkbLineString || wkbType == wkbLineString25D ) { int numPoints = OGR_G_GetPointCount( geomHandle ); output = new Symbology::LineString( numPoints ); populate( geomHandle, output, numPoints ); } else if ( wkbType == wkbLinearRing ) { int numPoints = OGR_G_GetPointCount( geomHandle ); output = new Symbology::Ring( numPoints ); populate( geomHandle, output, numPoints ); } else if ( wkbType == wkbPoint || wkbType == wkbPoint25D ) { int numPoints = OGR_G_GetPointCount( geomHandle ); output = new Symbology::PointSet( numPoints ); populate( geomHandle, output, numPoints ); } else if ( wkbType == wkbGeometryCollection || wkbType == wkbGeometryCollection25D || wkbType == wkbMultiPoint || wkbType == wkbMultiPoint25D || wkbType == wkbMultiLineString || wkbType == wkbMultiLineString25D || wkbType == wkbMultiPolygon || wkbType == wkbMultiPolygon25D ) { Symbology::MultiGeometry* multi = new Symbology::MultiGeometry(); int numGeoms = OGR_G_GetGeometryCount( geomHandle ); for( int n=0; n<numGeoms; n++ ) { OGRGeometryH subGeomRef = OGR_G_GetGeometryRef( geomHandle, n ); if ( subGeomRef ) { Symbology::Geometry* geom = createGeometry( subGeomRef ); if ( geom ) multi->getComponents().push_back( geom ); } } output = multi; } return output; }
Symbology::Geometry* OgrUtils::createGeometry( OGRGeometryH geomHandle ) { Symbology::Geometry* output = 0L; OGRwkbGeometryType wkbType = OGR_G_GetGeometryType( geomHandle ); int numPoints, numGeoms; switch (wkbType) { case wkbPolygon: case wkbPolygon25D: #ifdef GDAL_HAS_M_TYPES case wkbPolygonM: case wkbPolygonZM: #endif output = createPolygon(geomHandle); break; case wkbLineString: case wkbLineString25D: #ifdef GDAL_HAS_M_TYPES case wkbLineStringM: case wkbLineStringZM: #endif numPoints = OGR_G_GetPointCount( geomHandle ); output = new Symbology::LineString( numPoints ); populate( geomHandle, output, numPoints ); break; case wkbLinearRing: numPoints = OGR_G_GetPointCount( geomHandle ); output = new Symbology::Ring( numPoints ); populate( geomHandle, output, numPoints ); break; case wkbPoint: case wkbPoint25D: #ifdef GDAL_HAS_M_TYPES case wkbPointM: case wkbPointZM: #endif numPoints = OGR_G_GetPointCount( geomHandle ); output = new Symbology::PointSet( numPoints ); populate( geomHandle, output, numPoints ); break; case wkbGeometryCollection: case wkbGeometryCollection25D: case wkbMultiPoint: case wkbMultiPoint25D: case wkbMultiLineString: case wkbMultiLineString25D: case wkbMultiPolygon: case wkbMultiPolygon25D: #ifdef GDAL_HAS_M_TYPES case wkbGeometryCollectionM: case wkbGeometryCollectionZM: case wkbMultiPointM: case wkbMultiPointZM: case wkbMultiLineStringM: case wkbMultiLineStringZM: case wkbMultiPolygonM: case wkbMultiPolygonZM: #endif Symbology::MultiGeometry* multi = new Symbology::MultiGeometry(); numGeoms = OGR_G_GetGeometryCount( geomHandle ); for( int n=0; n<numGeoms; n++ ) { OGRGeometryH subGeomRef = OGR_G_GetGeometryRef( geomHandle, n ); if ( subGeomRef ) { Symbology::Geometry* geom = createGeometry( subGeomRef ); if ( geom ) multi->getComponents().push_back( geom ); } } output = multi; break; } return output; }