ogr/ogrgeometryfactory.cpp
OGRGeometry *OGRGeometryFactory::forceToMultiLineString( OGRGeometry *poGeom )

{
    if( poGeom == NULL )
        return NULL;

/* -------------------------------------------------------------------- */
/*      Check for the case of a geometrycollection that can be          */
/*      promoted to MultiLineString.                                    */
/* -------------------------------------------------------------------- */
    if( wkbFlatten(poGeom->getGeometryType()) == wkbGeometryCollection )
    {
        int iGeom;
        int bAllLines = TRUE;
        OGRGeometryCollection *poGC = (OGRGeometryCollection *) poGeom;

        for( iGeom = 0; iGeom < poGC->getNumGeometries(); iGeom++ )
        {
            if( wkbFlatten(poGC->getGeometryRef(iGeom)->getGeometryType())
                != wkbLineString )
                bAllLines = FALSE;
        }

        if( !bAllLines )
            return poGeom;
        
        OGRMultiLineString *poMP = new OGRMultiLineString();

        while( poGC->getNumGeometries() > 0 )
        {
            poMP->addGeometryDirectly( poGC->getGeometryRef(0) );
            poGC->removeGeometry( 0, FALSE );
        }

        delete poGC;

        return poMP;
    }

    if( wkbFlatten(poGeom->getGeometryType()) != wkbLineString )
        return poGeom;

    OGRMultiLineString *poMP = new OGRMultiLineString();
    poMP->addGeometryDirectly( poGeom );

    return poMP;
}
/**
 * Convert to multilinestring.
 *
 * Tries to force the provided geometry to be a multilinestring.  Currently
 * this just effects a change on linestrings.  The passed in geometry is
 * consumed and a new one returned (or potentially the same one). 
 * 
 * @return new geometry.
 */
Convert to multilinestring.
Tries to force the provided geometry to be a multilinestring.  Currently
this just effects a change on linestrings.  The passed in geometry is
consumed and a new one returned (or potentially the same one).

@return new geometry.
Convert to multilinestring . Tries to force the provided geometry to be a multilinestring . Currently this just effects a change on linestrings . The passed in geometry is consumed and a new one returned ( or potentially the same one ) . @return new geometry .
OGRGeometry *OGRGeometryFactory::forceToMultiLineString( OGRGeometry *poGeom )
{
    if( poGeom == NULL )
        return NULL;
    if( wkbFlatten(poGeom->getGeometryType()) == wkbGeometryCollection )
    {
        int iGeom;
        int bAllLines = TRUE;
        OGRGeometryCollection *poGC = (OGRGeometryCollection *) poGeom;
        for( iGeom = 0; iGeom < poGC->getNumGeometries(); iGeom++ )
        {
            if( wkbFlatten(poGC->getGeometryRef(iGeom)->getGeometryType())
                != wkbLineString )
                bAllLines = FALSE;
        }
        if( !bAllLines )
            return poGeom;
        OGRMultiLineString *poMP = new OGRMultiLineString();
        while( poGC->getNumGeometries() > 0 )
        {
            poMP->addGeometryDirectly( poGC->getGeometryRef(0) );
            poGC->removeGeometry( 0, FALSE );
        }
        delete poGC;
        return poMP;
    }
    if( wkbFlatten(poGeom->getGeometryType()) != wkbLineString )
        return poGeom;
    OGRMultiLineString *poMP = new OGRMultiLineString();
    poMP->addGeometryDirectly( poGeom );
    return poMP;
}
OGRGeometry * OGRGeometryFactory :: forceToMultiLineString ( OGRGeometry * poGeom ) { if ( poGeom == NULL ) return NULL ; if ( wkbFlatten ( poGeom -> getGeometryType ( ) ) == wkbGeometryCollection ) { int iGeom ; int bAllLines = TRUE ; OGRGeometryCollection * poGC = ( OGRGeometryCollection * ) poGeom ; for ( iGeom = 0 ; iGeom < poGC -> getNumGeometries ( ) ; iGeom ++ ) { if ( wkbFlatten ( poGC -> getGeometryRef ( iGeom ) -> getGeometryType ( ) ) != wkbLineString ) bAllLines = FALSE ; } if ( ! bAllLines ) return poGeom ; OGRMultiLineString * poMP = new OGRMultiLineString ( ) ; while ( poGC -> getNumGeometries ( ) > 0 ) { poMP -> addGeometryDirectly ( poGC -> getGeometryRef ( 0 ) ) ; poGC -> removeGeometry ( 0 , FALSE ) ; } delete poGC ; return poMP ; } if ( wkbFlatten ( poGeom -> getGeometryType ( ) ) != wkbLineString ) return poGeom ; OGRMultiLineString * poMP = new OGRMultiLineString ( ) ; poMP -> addGeometryDirectly ( poGeom ) ; return poMP ; }
Convert to multilinestring.
Convert to multilinestring .
/* -------------------------------------------------------------------- */ /*      Check for the case of a geometrycollection that can be          */ /*      promoted to MultiLineString.                                    */ /* -------------------------------------------------------------------- */