OGRErr OGR_G_AddGeometryDirectly( OGRGeometryH hGeom, OGRGeometryH hNewSubGeom ) { switch( wkbFlatten(((OGRGeometry *) hGeom)->getGeometryType()) ) { case wkbPolygon: { OGRLinearRing *poRing = (OGRLinearRing *) hNewSubGeom; if( poRing->WkbSize() != 0 || poRing->getGeometryType() != wkbLineString ) return OGRERR_UNSUPPORTED_GEOMETRY_TYPE; else { ((OGRPolygon *)hGeom)->addRingDirectly( poRing ); return OGRERR_NONE; } } case wkbMultiPoint: case wkbMultiLineString: case wkbMultiPolygon: case wkbGeometryCollection: return ((OGRGeometryCollection *)hGeom)->addGeometryDirectly( (OGRGeometry *) hNewSubGeom ); default: return OGRERR_UNSUPPORTED_OPERATION; } }