Ejemplo n.º 1
0
QgsAbstractGeometryV2* QgsMultiPolygonV2::boundary() const
{
    QgsMultiLineStringV2* multiLine = new QgsMultiLineStringV2();
    for ( int i = 0; i < mGeometries.size(); ++i )
    {
        if ( QgsPolygonV2* polygon = dynamic_cast<QgsPolygonV2*>( mGeometries.at( i ) ) )
        {
            QgsAbstractGeometryV2* polygonBoundary = polygon->boundary();

            if ( QgsLineStringV2* lineStringBoundary = dynamic_cast< QgsLineStringV2* >( polygonBoundary ) )
            {
                multiLine->addGeometry( lineStringBoundary );
            }
            else if ( QgsMultiLineStringV2* multiLineStringBoundary = dynamic_cast< QgsMultiLineStringV2* >( polygonBoundary ) )
            {
                for ( int j = 0; j < multiLineStringBoundary->numGeometries(); ++j )
                {
                    multiLine->addGeometry( multiLineStringBoundary->geometryN( j )->clone() );
                }
                delete multiLineStringBoundary;
            }
            else
            {
                delete polygonBoundary;
            }
        }
    }
    if ( multiLine->numGeometries() == 0 )
    {
        delete multiLine;
        return nullptr;
    }
    return multiLine;
}
Ejemplo n.º 2
0
QgsAbstractGeometryV2* QgsGeometryImport::fromMultiPolyline( const QgsMultiPolyline& multiline )
{
  QgsMultiLineStringV2* mLine = new QgsMultiLineStringV2();
  for ( int i = 0; i < multiline.size(); ++i )
  {
    mLine->addGeometry( fromPolyline( multiline.at( i ) ) );
  }
  return mLine;
}