diff --git a/python/core/qgsproviderregistry.sip b/python/core/qgsproviderregistry.sip index 4c0d9214888..78e7b246447 100644 --- a/python/core/qgsproviderregistry.sip +++ b/python/core/qgsproviderregistry.sip @@ -26,7 +26,7 @@ class QgsProviderRegistry void setLibraryDirectory(const QDir & path); - QgsDataProvider * getProvider( const QString & providerKey, + QgsDataProvider *provider( const QString & providerKey, const QString & dataSource ); /** Return list of available providers by their keys */ diff --git a/scripts/astyle-all.sh b/scripts/astyle-all.sh index e78c9b61fd4..24a1540a5c9 100755 --- a/scripts/astyle-all.sh +++ b/scripts/astyle-all.sh @@ -8,21 +8,21 @@ export elcr="$(tput el)$(tput cr)" find src -type f -print | while read f; do case "$f" in - src/core/spatialite/*) - continue - ;; + src/core/spatialite/*|src/core/gps/qextserialport/*|src/plugins/grass/qtermwidget/*|src/astyle/*|python/pyspatialite/*|src/providers/sqlanywhere/sqlanyconnection/*) + echo $f skipped + continue + ;; - - *.cpp|*.h|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H) + *.cpp|*.h|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.hpp) cmd=astyle.sh ;; - *.ui|*.qgm|*.txt|*.t2t|*.py|*.sip|resources/context_help/*) - cmd="flip -ub" - ;; - + *.ui|*.qgm|*.txt|*.t2t|*.py|*.sip|resources/context_help/*) + cmd="flip -ub" + ;; *) + echo $f skipped continue ;; esac diff --git a/src/analysis/interpolation/DualEdgeTriangulation.cc b/src/analysis/interpolation/DualEdgeTriangulation.cc index dd94cbeadb7..b9a38dfe456 100644 --- a/src/analysis/interpolation/DualEdgeTriangulation.cc +++ b/src/analysis/interpolation/DualEdgeTriangulation.cc @@ -1979,7 +1979,6 @@ void DualEdgeTriangulation::ruppertRefinement() } while ( actedge != pointingedge ); - } } } @@ -2190,9 +2189,6 @@ void DualEdgeTriangulation::ruppertRefinement() } while ( actedge != pointingedge ); - - - } } //end fast method @@ -2407,7 +2403,6 @@ void DualEdgeTriangulation::ruppertRefinement() } while ( actedge != pointingedge ); - } } diff --git a/src/analysis/interpolation/ParametricLine.h b/src/analysis/interpolation/ParametricLine.h index eb0897fdc71..62b8721a2fa 100644 --- a/src/analysis/interpolation/ParametricLine.h +++ b/src/analysis/interpolation/ParametricLine.h @@ -22,7 +22,7 @@ #include class ANALYSIS_EXPORT ParametricLine - /**ParametricLine is an Interface for parametric lines. It is possible, that a parametric line is composed of several parametric lines (see the composite pattern in Gamma et al. 'Design Patterns'). Do not build instances of it since it is an abstract class.*/ + /**ParametricLine is an Interface for parametric lines. It is possible, that a parametric line is composed of several parametric lines (see the composite pattern in Gamma et al. 'Design Patterns'). Do not build instances of it since it is an abstract class.*/ { protected: /**Degree of the parametric Line*/ diff --git a/src/app/attributetable/qgsattributetabledialog.cpp b/src/app/attributetable/qgsattributetabledialog.cpp index 3eb7610b69a..c7d3a062c2a 100644 --- a/src/app/attributetable/qgsattributetabledialog.cpp +++ b/src/app/attributetable/qgsattributetabledialog.cpp @@ -137,7 +137,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid connect( mView->verticalHeader(), SIGNAL( sectionPressed( int ) ), this, SLOT( updateRowPressed( int ) ) ); connect( mModel, SIGNAL( modelChanged() ), this, SLOT( updateSelection() ) ); - connect( mView, SIGNAL(willShowContextMenu( QMenu*, QModelIndex ) ), this, SLOT(viewWillShowContextMenu(QMenu*, QModelIndex ) ) ); + connect( mView, SIGNAL( willShowContextMenu( QMenu*, QModelIndex ) ), this, SLOT( viewWillShowContextMenu( QMenu*, QModelIndex ) ) ); mLastClickedHeaderIndex = 0; mSelectionModel = new QItemSelectionModel( mFilterModel ); diff --git a/src/app/composer/qgscomposer.cpp b/src/app/composer/qgscomposer.cpp index 173b55e49fb..34c68a85fb5 100644 --- a/src/app/composer/qgscomposer.cpp +++ b/src/app/composer/qgscomposer.cpp @@ -499,7 +499,8 @@ void QgsComposer::on_mActionExportAsPDF_triggered() int result = myQFileDialog->exec(); raise(); - if ( result != QDialog::Accepted ) return; + if ( result != QDialog::Accepted ) + return; QString myOutputFileNameQString = myQFileDialog->selectedFiles().first(); if ( myOutputFileNameQString == "" ) @@ -666,7 +667,8 @@ void QgsComposer::on_mActionExportAsImage_triggered() QString myFilter = tr( "%1 format (*.%2 *.%3)" ) .arg( myFormat ).arg( myFormat.toLower() ).arg( myFormat.toUpper() ); - if ( myCounterInt > 0 ) myFilters += ";;"; + if ( myCounterInt > 0 ) + myFilters += ";;"; myFilters += myFilter; myFilterMap[myFilter] = myFormat; if ( myFormat == myLastUsedFormat ) @@ -799,7 +801,8 @@ void QgsComposer::on_mActionExportAsSVG_triggered() int result = myQFileDialog->exec(); raise(); - if ( result != QDialog::Accepted ) return; + if ( result != QDialog::Accepted ) + return; QString myOutputFileNameQString = myQFileDialog->selectedFiles().first(); if ( myOutputFileNameQString == "" ) diff --git a/src/app/composer/qgscomposermapwidget.cpp b/src/app/composer/qgscomposermapwidget.cpp index 139149d1ab1..cd47c59a3ec 100644 --- a/src/app/composer/qgscomposermapwidget.cpp +++ b/src/app/composer/qgscomposermapwidget.cpp @@ -402,13 +402,17 @@ void QgsComposerMapWidget::updateComposerExtentFromGui() bool conversionSuccess; xmin = mXMinLineEdit->text().toDouble( &conversionSuccess ); - if ( !conversionSuccess ) {return;} + if ( !conversionSuccess ) + return; xmax = mXMaxLineEdit->text().toDouble( &conversionSuccess ); - if ( !conversionSuccess ) {return;} + if ( !conversionSuccess ) + return; ymin = mYMinLineEdit->text().toDouble( &conversionSuccess ); - if ( !conversionSuccess ) {return;} + if ( !conversionSuccess ) + return; ymax = mYMaxLineEdit->text().toDouble( &conversionSuccess ); - if ( !conversionSuccess ) {return;} + if ( !conversionSuccess ) + return; QgsRectangle newExtent( xmin, ymin, xmax, ymax ); mComposerMap->beginCommand( tr( "Map extent changed" ) ); diff --git a/src/app/legend/qgslegend.cpp b/src/app/legend/qgslegend.cpp index be2bb04c437..a81ea786bfd 100644 --- a/src/app/legend/qgslegend.cpp +++ b/src/app/legend/qgslegend.cpp @@ -870,7 +870,8 @@ void QgsLegend::legendLayerShowInOverview() return; QgsLegendLayer* ll = qobject_cast( li ); - if ( !ll ) return; + if ( !ll ) + return; ll->showInOverview(); } @@ -1805,7 +1806,7 @@ void QgsLegend::legendLayerZoom() } } - if( extent.isEmpty() ) + if ( extent.isEmpty() ) { return; } diff --git a/src/app/main.cpp b/src/app/main.cpp index 53ec83f9c89..f674b05f684 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -448,7 +448,7 @@ int main( int argc, char *argv[] ) } // GUI customization is enabled by default unless --nocustomization argument is used - QgsCustomization::instance()->setEnabled(myCustomization); + QgsCustomization::instance()->setEnabled( myCustomization ); QgsApplication myApp( argc, argv, myUseGuiFlag, configpath ); @@ -624,10 +624,10 @@ int main( int argc, char *argv[] ) QgisApp *qgis = new QgisApp( mypSplash, myRestorePlugins ); // "QgisApp" used to find canonical instance qgis->setObjectName( "QgisApp" ); - myApp.connect ( - &myApp, SIGNAL( preNotify( QObject *, QEvent *, bool *)), + myApp.connect( + &myApp, SIGNAL( preNotify( QObject *, QEvent *, bool * ) ), //qgis, SLOT( preNotify( QObject *, QEvent *)) - QgsCustomization::instance(), SLOT( preNotify( QObject *, QEvent *, bool *)) + QgsCustomization::instance(), SLOT( preNotify( QObject *, QEvent *, bool * ) ) ); ///////////////////////////////////////////////////////////////////// diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index c2c5f0a48f0..7742310b899 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -983,9 +983,9 @@ void QgisApp::createMenus() // Panel and Toolbar Submenus mPanelMenu = new QMenu( tr( "Panels" ) ); - mPanelMenu->setObjectName("mPanelMenu"); + mPanelMenu->setObjectName( "mPanelMenu" ); mToolbarMenu = new QMenu( tr( "Toolbars" ) ); - mToolbarMenu->setObjectName("mToolbarMenu"); + mToolbarMenu->setObjectName( "mToolbarMenu" ); // Get platform for menu layout customization (Gnome, Kde, Mac, Win) QDialogButtonBox::ButtonLayout layout = @@ -1079,9 +1079,9 @@ void QgisApp::createToolBars() QList toolbarMenuActions; // Set action names so that they can be used in customization - foreach ( QToolBar *toolBar, toolbarMenuToolBars ) + foreach( QToolBar *toolBar, toolbarMenuToolBars ) { - toolBar->toggleViewAction()->setObjectName ( "mActionToggle" + toolBar->objectName().mid(1) ); + toolBar->toggleViewAction()->setObjectName( "mActionToggle" + toolBar->objectName().mid( 1 ) ); toolbarMenuActions << toolBar->toggleViewAction(); } @@ -2448,16 +2448,16 @@ void QgisApp::addWmsLayer() QgsDebugMsg( "about to addRasterLayer" ); // TODO: QDialog for now, switch to QWidget in future - QDialog *wmss = dynamic_cast ( QgsProviderRegistry::instance()->getSelectWidget( QString("wms"), this ) ); - if ( !wmss ) + QDialog *wmss = dynamic_cast( QgsProviderRegistry::instance()->selectWidget( QString( "wms" ), this ) ); + if ( !wmss ) { QMessageBox::warning( this, tr( "WMS" ), tr( "Cannot get WMS select dialog from provider." ) ); - return; + return; } - connect ( wmss , SIGNAL ( addRasterLayer( QString const &, QString const &, QString const &,QStringList const &,QStringList const &,QString const &, -QString const &) ), - this , SLOT ( addRasterLayer( QString const &, QString const &, QString const &,QStringList const &,QStringList const &,QString const &, -QString const &) ) ); + connect( wmss , SIGNAL( addRasterLayer( QString const &, QString const &, QString const &, QStringList const &, QStringList const &, QString const &, + QString const & ) ), + this , SLOT( addRasterLayer( QString const &, QString const &, QString const &, QStringList const &, QStringList const &, QString const &, + QString const & ) ) ); wmss->exec(); delete wmss; } @@ -3103,8 +3103,10 @@ void QgisApp::toggleActiveWindowMaximized() QWidget *window = QApplication::activeWindow(); if ( window ) { - if ( window->isMaximized() ) window->showNormal(); - else window->showMaximized(); + if ( window->isMaximized() ) + window->showNormal(); + else + window->showMaximized(); } } @@ -4554,8 +4556,8 @@ void QgisApp::showPluginManager() // implementation of the python runner class QgsPythonRunnerImpl : public QgsPythonRunner { -public: - QgsPythonRunnerImpl(QgsPythonUtils* pythonUtils) : mPythonUtils(pythonUtils) {} + public: + QgsPythonRunnerImpl( QgsPythonUtils* pythonUtils ) : mPythonUtils( pythonUtils ) {} virtual bool runCommand( QString command, QString messageOnError = QString() ) { if ( mPythonUtils && mPythonUtils->isEnabled() ) @@ -4565,7 +4567,7 @@ public: return false; } -protected: + protected: QgsPythonUtils* mPythonUtils; }; @@ -4615,7 +4617,7 @@ void QgisApp::loadPythonSupport() QgsPluginRegistry::instance()->setPythonUtils( mPythonUtils ); // init python runner - QgsPythonRunner::setInstance( new QgsPythonRunnerImpl(mPythonUtils) ); + QgsPythonRunner::setInstance( new QgsPythonRunnerImpl( mPythonUtils ) ); std::cout << "Python support ENABLED :-) " << std::endl; // OK } @@ -5477,7 +5479,8 @@ void QgisApp::updateMouseCoordinatePrecision() dp = QgsProject::instance()->readNumEntry( "PositionPrecision", "/DecimalPlaces" ); // Keep dp sensible - if ( dp < 0 ) dp = 0; + if ( dp < 0 ) + dp = 0; mMousePrecisionDecimalPlaces = dp; } diff --git a/src/app/qgsabout.cpp b/src/app/qgsabout.cpp index b2c322c5d1e..eec83bf25f8 100644 --- a/src/app/qgsabout.cpp +++ b/src/app/qgsabout.cpp @@ -71,7 +71,8 @@ void QgsAbout::init() { line = stream.readLine(); // line of text excluding '\n' //ignore the line if it starts with a hash.... - if ( line.left( 1 ) == "#" ) continue; + if ( line.left( 1 ) == "#" ) + continue; QStringList myTokens = line.split( "\t", QString::SkipEmptyParts ); lines << myTokens[0]; } @@ -102,7 +103,8 @@ void QgsAbout::init() { line = stream.readLine(); // line of text excluding '\n' //ignore the line if it starts with a hash.... - if ( line.left( 1 ) == "#" ) continue; + if ( line.left( 1 ) == "#" ) + continue; lines += line; } file2.close(); @@ -129,7 +131,8 @@ void QgsAbout::init() "money to fund QGIS development and other project costs see " "" "http://qgis.org/en/sponsorship/donors.html

" ); - /*QString website; +#if 0 + QString website; QTextStream donorsStream( &donorsFile ); // Always use UTF-8 donorsStream.setCodec( "UTF-8" ); @@ -138,7 +141,8 @@ void QgsAbout::init() { sline = donorsStream.readLine(); // line of text excluding '\n' //ignore the line if it starts with a hash.... - if ( sline.left( 1 ) == "#" ) continue; + if ( sline.left( 1 ) == "#" ) + continue; QStringList myTokens = sline.split( "|", QString::SkipEmptyParts ); if ( myTokens.size() > 1 ) { @@ -153,7 +157,8 @@ void QgsAbout::init() // close the row donorsHTML += ""; } - donorsHTML += "";*/ + donorsHTML += ""; +#endif QString myStyle = QgsApplication::reportStyleSheet(); txtDonors->clear(); @@ -187,7 +192,8 @@ void QgsAbout::init() { sline = translatorStream.readLine(); // line of text excluding '\n' //ignore the line if it starts with a hash.... - if ( sline.left( 1 ) == "#" ) continue; + if ( sline.left( 1 ) == "#" ) + continue; QStringList myTokens = sline.split( "|", QString::SkipEmptyParts ); if ( myTokens.size() > 1 ) { diff --git a/src/app/qgsattributeactiondialog.cpp b/src/app/qgsattributeactiondialog.cpp index daddcdc1edf..36d6a7a3da7 100644 --- a/src/app/qgsattributeactiondialog.cpp +++ b/src/app/qgsattributeactiondialog.cpp @@ -164,7 +164,8 @@ void QgsAttributeActionDialog::remove() attributeActionTable->removeRow( row ); // And select the row below the one that was selected or the last one. - if ( row >= attributeActionTable->rowCount() ) row = attributeActionTable->rowCount() - 1; + if ( row >= attributeActionTable->rowCount() ) + row = attributeActionTable->rowCount() - 1; attributeActionTable->selectRow( row ); } } @@ -172,7 +173,6 @@ void QgsAttributeActionDialog::remove() void QgsAttributeActionDialog::insert() { // Add the action details as a new row in the table. - int pos = attributeActionTable->rowCount(); insert( pos ); } diff --git a/src/app/qgsconfigureshortcutsdialog.cpp b/src/app/qgsconfigureshortcutsdialog.cpp index 00a31ba5b04..f168719705e 100644 --- a/src/app/qgsconfigureshortcutsdialog.cpp +++ b/src/app/qgsconfigureshortcutsdialog.cpp @@ -212,7 +212,8 @@ void QgsConfigureShortcutsDialog::changeShortcut() void QgsConfigureShortcutsDialog::resetShortcut() { QAction* action = currentAction(); - if ( !action ) return; + if ( !action ) + return; // set default shortcut QString shortcut = QgsShortcutsManager::instance()->actionDefaultShortcut( action ); @@ -361,7 +362,8 @@ void QgsConfigureShortcutsDialog::setGettingShortcut( bool getting ) void QgsConfigureShortcutsDialog::setCurrentActionShortcut( QKeySequence s ) { QAction* action = currentAction(); - if ( !action ) return; + if ( !action ) + return; // first check whether this action is not taken already QAction* otherAction = QgsShortcutsManager::instance()->actionForShortcut( s ); diff --git a/src/app/qgscustomization.cpp b/src/app/qgscustomization.cpp index db70fe00960..59839860fef 100644 --- a/src/app/qgscustomization.cpp +++ b/src/app/qgscustomization.cpp @@ -35,28 +35,25 @@ #include #include #include - -//standard includes -#include -#include -#include +#include #ifdef Q_OS_MACX QgsCustomizationDialog::QgsCustomizationDialog() - : QMainWindow( NULL, Qt::WindowSystemMenuHint ), // Modeless dialog with close button only - mSettings ( "QuantumGIS", "QGISCUSTOMIZATION" ) + : QMainWindow( NULL, Qt::WindowSystemMenuHint ) // Modeless dialog with close button only + , mSettings( "QuantumGIS", "QGISCUSTOMIZATION" ) #else QgsCustomizationDialog::QgsCustomizationDialog() - : QMainWindow( NULL ), mSettings ( "QuantumGIS", "QGISCUSTOMIZATION" ) + : QMainWindow( NULL ) + , mSettings( "QuantumGIS", "QGISCUSTOMIZATION" ) #endif { setupUi( this ); init(); QStringList myHeaders; - myHeaders << tr("Object name") << tr("Label") << tr("Description"); - treeWidget->setHeaderLabels ( myHeaders ); - - mLastDirSettingsName = QString("/UI/lastCustomizationDir" ); + myHeaders << tr( "Object name" ) << tr( "Label" ) << tr( "Description" ); + treeWidget->setHeaderLabels( myHeaders ); + + mLastDirSettingsName = QString( "/UI/lastCustomizationDir" ); //treeWidget->hideColumn(0) connect( buttonBox->button( QDialogButtonBox::Ok ), SIGNAL( clicked() ), this, SLOT( ok() ) ); connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) ); @@ -69,76 +66,81 @@ QgsCustomizationDialog::~QgsCustomizationDialog() { } -QTreeWidgetItem * QgsCustomizationDialog::item ( QString thePath, QTreeWidgetItem *theItem ) +QTreeWidgetItem * QgsCustomizationDialog::item( QString thePath, QTreeWidgetItem *theItem ) { QString path = thePath; - if ( path.startsWith("/") ) path = path.mid(1); // remove '/' - QStringList names = path.split('/'); - path = QStringList(names.mid(1)).join ("/" ); + if ( path.startsWith( "/" ) ) + path = path.mid( 1 ); // remove '/' + QStringList names = path.split( '/' ); + path = QStringList( names.mid( 1 ) ).join( "/" ); - if ( ! theItem ) + if ( ! theItem ) { - for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) + for ( int i = 0; i < treeWidget->topLevelItemCount(); ++i ) { - QTreeWidgetItem *myItem = treeWidget->topLevelItem(i); - QString objectName = myItem->text(0); - if ( objectName == names[0] ) + QTreeWidgetItem *myItem = treeWidget->topLevelItem( i ); + QString objectName = myItem->text( 0 ); + if ( objectName == names[0] ) { - return item ( path, myItem ); + return item( path, myItem ); } } } else { - for (int i = 0; i < theItem->childCount(); ++i) { - QTreeWidgetItem *myItem = theItem->child(i); - QString objectName = myItem->text(0); - if ( objectName == names[0] ) + for ( int i = 0; i < theItem->childCount(); ++i ) + { + QTreeWidgetItem *myItem = theItem->child( i ); + QString objectName = myItem->text( 0 ); + if ( objectName == names[0] ) { - if ( names.size () == 1 ) + if ( names.size() == 1 ) { - return myItem; + return myItem; } else { - return item ( path, myItem ); + return item( path, myItem ); } } } } - QgsDebugMsg( "not found") ; + QgsDebugMsg( "not found" ) ; return 0; } -bool QgsCustomizationDialog::itemChecked ( QString thePath ) +bool QgsCustomizationDialog::itemChecked( QString thePath ) { - QgsDebugMsg( QString("thePath = %1").arg(thePath)); - QTreeWidgetItem *myItem = item ( thePath ); - if ( !myItem ) return true; - return myItem->checkState(0) == Qt::Checked ? true : false; + QgsDebugMsg( QString( "thePath = %1" ).arg( thePath ) ); + QTreeWidgetItem *myItem = item( thePath ); + if ( !myItem ) + return true; + return myItem->checkState( 0 ) == Qt::Checked ? true : false; } -void QgsCustomizationDialog::setItemChecked ( QString thePath, bool on ) +void QgsCustomizationDialog::setItemChecked( QString thePath, bool on ) { - QgsDebugMsg( QString("thePath = %1 on = %2").arg(thePath).arg(on)); - QTreeWidgetItem *myItem = item ( thePath ); - if ( !myItem ) return; - myItem->setCheckState(0, on ? Qt::Checked : Qt::Unchecked); + QgsDebugMsg( QString( "thePath = %1 on = %2" ).arg( thePath ).arg( on ) ); + QTreeWidgetItem *myItem = item( thePath ); + if ( !myItem ) + return; + myItem->setCheckState( 0, on ? Qt::Checked : Qt::Unchecked ); } void QgsCustomizationDialog::settingsToItem( QString thePath, QTreeWidgetItem *theItem, QSettings *theSettings ) { - QString objectName = theItem->text(0); - if (objectName.isEmpty()) + QString objectName = theItem->text( 0 ); + if ( objectName.isEmpty() ) return; // object is not identifiable QString myPath = thePath + "/" + objectName; - bool on = theSettings->value(myPath, true).toBool(); - theItem->setCheckState(0, on ? Qt::Checked : Qt::Unchecked ); + bool on = theSettings->value( myPath, true ).toBool(); + theItem->setCheckState( 0, on ? Qt::Checked : Qt::Unchecked ); - for (int i = 0; i < theItem->childCount(); ++i) { - QTreeWidgetItem *myItem = theItem->child(i); + for ( int i = 0; i < theItem->childCount(); ++i ) + { + QTreeWidgetItem *myItem = theItem->child( i ); settingsToItem( myPath, myItem, theSettings ); } } @@ -146,39 +148,41 @@ void QgsCustomizationDialog::settingsToItem( QString thePath, QTreeWidgetItem *t void QgsCustomizationDialog::itemToSettings( QString thePath, QTreeWidgetItem *theItem, QSettings *theSettings ) { - QString objectName = theItem->text(0); - if (objectName.isEmpty()) + QString objectName = theItem->text( 0 ); + if ( objectName.isEmpty() ) return; // object is not identifiable QString myPath = thePath + "/" + objectName; - bool on = theItem->checkState(0) == Qt::Checked ? true : false; + bool on = theItem->checkState( 0 ) == Qt::Checked ? true : false; theSettings->setValue( myPath, on ); - for (int i = 0; i < theItem->childCount(); ++i) { - QTreeWidgetItem *myItem = theItem->child(i); + for ( int i = 0; i < theItem->childCount(); ++i ) + { + QTreeWidgetItem *myItem = theItem->child( i ); itemToSettings( myPath, myItem, theSettings ); } } -void QgsCustomizationDialog::treeToSettings ( QSettings *theSettings ) +void QgsCustomizationDialog::treeToSettings( QSettings *theSettings ) { - for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) { - itemToSettings( QString("/Customization"), treeWidget->topLevelItem(i), theSettings ); + for ( int i = 0; i < treeWidget->topLevelItemCount(); ++i ) + { + itemToSettings( QString( "/Customization" ), treeWidget->topLevelItem( i ), theSettings ); } } -void QgsCustomizationDialog::settingsToTree ( QSettings *theSettings ) +void QgsCustomizationDialog::settingsToTree( QSettings *theSettings ) { - for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) + for ( int i = 0; i < treeWidget->topLevelItemCount(); ++i ) { - settingsToItem( QString("/Customization"), treeWidget->topLevelItem(i), theSettings ); + settingsToItem( QString( "/Customization" ), treeWidget->topLevelItem( i ), theSettings ); } } void QgsCustomizationDialog::reset() { mSettings.sync(); - settingsToTree ( &mSettings ); + settingsToTree( &mSettings ); } void QgsCustomizationDialog::ok() @@ -188,9 +192,9 @@ void QgsCustomizationDialog::ok() } void QgsCustomizationDialog::apply() { - QgsDebugMsg( QString("columnCount = %1").arg( treeWidget->columnCount() ) ); - treeToSettings ( &mSettings ); - mSettings.setValue( QgsCustomization::instance()->statusPath(), QgsCustomization::User); + QgsDebugMsg( QString( "columnCount = %1" ).arg( treeWidget->columnCount() ) ); + treeToSettings( &mSettings ); + mSettings.setValue( QgsCustomization::instance()->statusPath(), QgsCustomization::User ); mSettings.sync(); } @@ -204,16 +208,17 @@ void QgsCustomizationDialog::on_actionSave_triggered( bool checked ) QSettings mySettings; QString lastDir = mySettings.value( mLastDirSettingsName, "." ).toString(); - QString fileName = QFileDialog::getSaveFileName(this, - tr( "Choose a customization INI file" ), - lastDir, tr( "Customization files (*.ini)" ) ); + QString fileName = QFileDialog::getSaveFileName( this, + tr( "Choose a customization INI file" ), + lastDir, tr( "Customization files (*.ini)" ) ); - if ( fileName.isEmpty() ) return; + if ( fileName.isEmpty() ) + return; QFileInfo fileInfo( fileName ); - mySettings.setValue ( mLastDirSettingsName, fileInfo.absoluteDir().absolutePath () ); + mySettings.setValue( mLastDirSettingsName, fileInfo.absoluteDir().absolutePath() ); - QSettings fileSettings( fileName, QSettings::IniFormat); - treeToSettings ( &fileSettings ); + QSettings fileSettings( fileName, QSettings::IniFormat ); + treeToSettings( &fileSettings ); } void QgsCustomizationDialog::on_actionLoad_triggered( bool checked ) @@ -221,16 +226,17 @@ void QgsCustomizationDialog::on_actionLoad_triggered( bool checked ) QSettings mySettings; QString lastDir = mySettings.value( mLastDirSettingsName, "." ).toString(); - QString fileName = QFileDialog::getOpenFileName(this, - tr( "Choose a customization INI file" ), - lastDir, tr( "Customization files (*.ini)" ) ); + QString fileName = QFileDialog::getOpenFileName( this, + tr( "Choose a customization INI file" ), + lastDir, tr( "Customization files (*.ini)" ) ); - if ( fileName.isEmpty() ) return; + if ( fileName.isEmpty() ) + return; QFileInfo fileInfo( fileName ); - mySettings.setValue ( mLastDirSettingsName, fileInfo.absoluteDir().absolutePath () ); - - QSettings fileSettings( fileName, QSettings::IniFormat); - settingsToTree ( &fileSettings ); + mySettings.setValue( mLastDirSettingsName, fileInfo.absoluteDir().absolutePath() ); + + QSettings fileSettings( fileName, QSettings::IniFormat ); + settingsToTree( &fileSettings ); } void QgsCustomizationDialog::on_actionExpandAll_triggered( bool checked ) @@ -245,12 +251,12 @@ void QgsCustomizationDialog::on_actionCollapseAll_triggered( bool checked ) void QgsCustomizationDialog::on_actionSelectAll_triggered( bool checked ) { - QList items = treeWidget->findItems("*",Qt::MatchWildcard|Qt::MatchRecursive, 0); - + QList items = treeWidget->findItems( "*", Qt::MatchWildcard | Qt::MatchRecursive, 0 ); + QList::iterator i; - for ( i = items.begin(); i != items.end(); ++i) + for ( i = items.begin(); i != items.end(); ++i ) { - (*i)->setCheckState(0, Qt::Checked); + ( *i )->setCheckState( 0, Qt::Checked ); } } @@ -258,21 +264,22 @@ void QgsCustomizationDialog::init() { QgsDebugMsg( "Entered" ); QTreeWidgetItem * wi = createTreeItemWidgets(); - if ( wi ) { - treeWidget->insertTopLevelItem(0, wi ); + if ( wi ) + { + treeWidget->insertTopLevelItem( 0, wi ); treeWidget->expandItem( wi ); } treeWidget->insertTopLevelItems( 0, QgsCustomization::instance()->mMainWindowItems ); - for (int i = 0; i < treeWidget->topLevelItemCount(); i++) - treeWidget->expandItem( treeWidget->topLevelItem(i) ); + for ( int i = 0; i < treeWidget->topLevelItemCount(); i++ ) + treeWidget->expandItem( treeWidget->topLevelItem( i ) ); // load check states from the settings reset(); - treeWidget->sortItems(0, Qt::AscendingOrder); - treeWidget->resizeColumnToContents(0); + treeWidget->sortItems( 0, Qt::AscendingOrder ); + treeWidget->resizeColumnToContents( 0 ); } QTreeWidgetItem * QgsCustomizationDialog::createTreeItemWidgets() @@ -281,11 +288,11 @@ QTreeWidgetItem * QgsCustomizationDialog::createTreeItemWidgets() QDomDocument myDoc( "QgsWidgets" ); QFile myFile( QgsApplication::pkgDataPath() + "/resources/customization.xml" ); - if( !myFile.open( QIODevice::ReadOnly ) ) + if ( !myFile.open( QIODevice::ReadOnly ) ) { return NULL; } - if( !myDoc.setContent( &myFile ) ) + if ( !myDoc.setContent( &myFile ) ) { myFile.close(); return NULL; @@ -293,63 +300,64 @@ QTreeWidgetItem * QgsCustomizationDialog::createTreeItemWidgets() myFile.close(); QDomElement myRoot = myDoc.documentElement(); - if( myRoot.tagName() != "qgiswidgets" ) + if ( myRoot.tagName() != "qgiswidgets" ) { return NULL; } - QTreeWidgetItem *myItem = readWidgetsXmlNode ( myRoot ); - myItem->setData ( 0, Qt::DisplayRole, tr("Widgets" ) ); - + QTreeWidgetItem *myItem = readWidgetsXmlNode( myRoot ); + myItem->setData( 0, Qt::DisplayRole, tr( "Widgets" ) ); + return myItem; } -QTreeWidgetItem * QgsCustomizationDialog::readWidgetsXmlNode ( QDomNode theNode ) +QTreeWidgetItem * QgsCustomizationDialog::readWidgetsXmlNode( QDomNode theNode ) { QgsDebugMsg( "Entered" ); QDomElement myElement = theNode.toElement(); - QString name = myElement.attribute( "objectName", ""); + QString name = myElement.attribute( "objectName", "" ); QStringList data( name ); - data << myElement.attribute( "label", name); - data << myElement.attribute( "description", ""); - - QTreeWidgetItem *myItem = new QTreeWidgetItem ( data ); + data << myElement.attribute( "label", name ); + data << myElement.attribute( "description", "" ); + + QTreeWidgetItem *myItem = new QTreeWidgetItem( data ); // It is nice to have icons for each Qt widget class, is it too heavy? // There are 47 png files, total 196K in qt/tools/designer/src/components/formeditor/images/ - QString iconName = myElement.attribute( "class", "" ).toLower().mid(1) + ".png"; + QString iconName = myElement.attribute( "class", "" ).toLower().mid( 1 ) + ".png"; QString iconPath = QgsApplication::iconPath( "/customization/" + iconName ); QgsDebugMsg( "iconPath = " + iconPath ); - if ( QFile::exists( iconPath ) ) + if ( QFile::exists( iconPath ) ) { - myItem->setIcon (0, QIcon(iconPath) ); + myItem->setIcon( 0, QIcon( iconPath ) ); } - myItem->setFlags ( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable ); - myItem->setCheckState(0, Qt::Checked); + myItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable ); + myItem->setCheckState( 0, Qt::Checked ); QDomNode n = theNode.firstChild(); - while( !n.isNull() ) + while ( !n.isNull() ) { QDomElement e = n.toElement(); - if( !e.isNull() ) + if ( !e.isNull() ) { - QTreeWidgetItem *wi = readWidgetsXmlNode ( n ); - myItem->insertChild ( 0, wi ); + QTreeWidgetItem *wi = readWidgetsXmlNode( n ); + myItem->insertChild( 0, wi ); } n = n.nextSibling(); } return myItem; } -bool QgsCustomizationDialog::switchWidget ( QWidget * widget, QMouseEvent *event ) +bool QgsCustomizationDialog::switchWidget( QWidget * widget, QMouseEvent *event ) { - QgsDebugMsg ( "Entered" ); - if ( !actionCatch->isChecked() ) { return false; } - QString path = widgetPath(widget); - QgsDebugMsg ( "path = " + path ); + QgsDebugMsg( "Entered" ); + if ( !actionCatch->isChecked() ) + return false; + QString path = widgetPath( widget ); + QgsDebugMsg( "path = " + path ); - if ( path.startsWith ( "/QgsCustomizationDialogBase" ) ) + if ( path.startsWith( "/QgsCustomizationDialogBase" ) ) { // do not allow modification of this dialog return false; @@ -358,13 +366,13 @@ bool QgsCustomizationDialog::switchWidget ( QWidget * widget, QMouseEvent *event { // changes to main window // (work with toolbars, tool buttons) - if (widget->inherits("QToolBar")) + if ( widget->inherits( "QToolBar" ) ) { path = "/Toolbars/" + widget->objectName(); } - else if (widget->inherits("QToolButton")) + else if ( widget->inherits( "QToolButton" ) ) { - QToolButton* toolbutton = qobject_cast(widget); + QToolButton* toolbutton = qobject_cast( widget ); QAction* action = toolbutton->defaultAction(); QString toolbarName = widget->parent()->objectName(); QString actionName = action->objectName(); @@ -382,20 +390,22 @@ bool QgsCustomizationDialog::switchWidget ( QWidget * widget, QMouseEvent *event path = "/Widgets" + path; } - QgsDebugMsg ( "path final = " + path ); - bool on = !itemChecked ( path ); + QgsDebugMsg( "path final = " + path ); + bool on = !itemChecked( path ); - QgsDebugMsg ( QString ( "on = %1" ).arg(on) ); + QgsDebugMsg( QString( "on = %1" ).arg( on ) ); - setItemChecked ( path, on ); - QTreeWidgetItem *myItem = item ( path ); - if ( myItem ) { - treeWidget->scrollToItem ( myItem, QAbstractItemView::PositionAtCenter ); - treeWidget->clearSelection(); - myItem->setSelected ( true ); + setItemChecked( path, on ); + QTreeWidgetItem *myItem = item( path ); + if ( myItem ) + { + treeWidget->scrollToItem( myItem, QAbstractItemView::PositionAtCenter ); + treeWidget->clearSelection(); + myItem->setSelected( true ); QString style; - if ( !on ) { + if ( !on ) + { style = "background-color: #FFCCCC;"; } widget->setStyleSheet( style ); @@ -404,19 +414,20 @@ bool QgsCustomizationDialog::switchWidget ( QWidget * widget, QMouseEvent *event return true; } -QString QgsCustomizationDialog::widgetPath ( QWidget * theWidget, QString thePath ) +QString QgsCustomizationDialog::widgetPath( QWidget * theWidget, QString thePath ) { // go up until QDialog is reached QString name = theWidget->objectName(); QString path = thePath; - if ( !QgsCustomization::mInternalWidgets.contains ( name ) ) + if ( !QgsCustomization::mInternalWidgets.contains( name ) ) { - if ( !path.isEmpty() ) { + if ( !path.isEmpty() ) + { path = name + "/" + path; - } - else + } + else { path = name; } @@ -424,145 +435,145 @@ QString QgsCustomizationDialog::widgetPath ( QWidget * theWidget, QString thePat QWidget * parent = theWidget->parentWidget(); - if ( !parent || theWidget->inherits("QDialog") ) + if ( !parent || theWidget->inherits( "QDialog" ) ) { return "/" + path; } - return widgetPath ( parent, path ); + return widgetPath( parent, path ); } -void QgsCustomizationDialog::setCatch ( bool on ) +void QgsCustomizationDialog::setCatch( bool on ) { - actionCatch->setChecked ( on ); + actionCatch->setChecked( on ); } -bool QgsCustomizationDialog::catchOn ( ) +bool QgsCustomizationDialog::catchOn( ) { - return actionCatch->isChecked ( ); + return actionCatch->isChecked( ); } -void QgsCustomization::addTreeItemActions(QTreeWidgetItem* parentItem, const QList& actions) +void QgsCustomization::addTreeItemActions( QTreeWidgetItem* parentItem, const QList& actions ) { - foreach (QAction* action, actions) + foreach( QAction* action, actions ) { - if (action->menu()) + if ( action->menu() ) { // it is a submenu - addTreeItemMenu(parentItem, action->menu()); + addTreeItemMenu( parentItem, action->menu() ); } else { // it is an ordinary action QStringList strs; strs << action->objectName() << action->text(); - QTreeWidgetItem* myItem = new QTreeWidgetItem(parentItem, strs); + QTreeWidgetItem* myItem = new QTreeWidgetItem( parentItem, strs ); myItem->setIcon( 0, action->icon() ); - myItem->setFlags ( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable ); - myItem->setCheckState(0, Qt::Checked); + myItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable ); + myItem->setCheckState( 0, Qt::Checked ); } } } -void QgsCustomization::addTreeItemMenu(QTreeWidgetItem* parentItem, QMenu* menu) +void QgsCustomization::addTreeItemMenu( QTreeWidgetItem* parentItem, QMenu* menu ) { QStringList menustrs; menustrs << menu->objectName() << menu->title(); - QTreeWidgetItem* menuItem = new QTreeWidgetItem( parentItem, menustrs); - menuItem->setFlags ( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable ); - menuItem->setCheckState(0, Qt::Checked); + QTreeWidgetItem* menuItem = new QTreeWidgetItem( parentItem, menustrs ); + menuItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable ); + menuItem->setCheckState( 0, Qt::Checked ); - addTreeItemActions(menuItem, menu->actions()); + addTreeItemActions( menuItem, menu->actions() ); } -void QgsCustomization::createTreeItemMenus ( ) +void QgsCustomization::createTreeItemMenus( ) { QStringList data; data << "Menus"; - QTreeWidgetItem *topItem = new QTreeWidgetItem ( data ); + QTreeWidgetItem *topItem = new QTreeWidgetItem( data ); QMenuBar* menubar = QgisApp::instance()->menuBar(); - foreach (QObject* obj, menubar->children()) + foreach( QObject* obj, menubar->children() ) { - if (obj->inherits("QMenu")) + if ( obj->inherits( "QMenu" ) ) { - QMenu* menu = qobject_cast(obj); - addTreeItemMenu(topItem, menu); + QMenu* menu = qobject_cast( obj ); + addTreeItemMenu( topItem, menu ); } } mMainWindowItems << topItem; } -void QgsCustomization::createTreeItemToolbars ( ) +void QgsCustomization::createTreeItemToolbars( ) { QStringList data; data << "Toolbars"; - QTreeWidgetItem *topItem = new QTreeWidgetItem ( data ); + QTreeWidgetItem *topItem = new QTreeWidgetItem( data ); QMainWindow* mw = QgisApp::instance(); - foreach (QObject* obj, mw->children()) + foreach( QObject* obj, mw->children() ) { - if (obj->inherits("QToolBar")) + if ( obj->inherits( "QToolBar" ) ) { - QToolBar* tb = qobject_cast(obj); + QToolBar* tb = qobject_cast( obj ); QStringList tbstrs; tbstrs << tb->objectName() << tb->windowTitle(); QTreeWidgetItem* tbItem = new QTreeWidgetItem( topItem, tbstrs ); - tbItem->setFlags ( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable ); - tbItem->setCheckState(0, Qt::Checked); + tbItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable ); + tbItem->setCheckState( 0, Qt::Checked ); - addTreeItemActions(tbItem, tb->actions()); + addTreeItemActions( tbItem, tb->actions() ); } } mMainWindowItems << topItem; } -void QgsCustomization::createTreeItemDocks ( ) +void QgsCustomization::createTreeItemDocks( ) { QStringList data; data << "Docks"; - QTreeWidgetItem *topItem = new QTreeWidgetItem ( data ); + QTreeWidgetItem *topItem = new QTreeWidgetItem( data ); QMainWindow* mw = QgisApp::instance(); - foreach (QObject* obj, mw->children()) + foreach( QObject* obj, mw->children() ) { - if (obj->inherits("QDockWidget")) + if ( obj->inherits( "QDockWidget" ) ) { - QDockWidget* dw = qobject_cast (obj); + QDockWidget* dw = qobject_cast ( obj ); QStringList dwstrs; dwstrs << dw->objectName() << dw->windowTitle(); QTreeWidgetItem* dwItem = new QTreeWidgetItem( topItem, dwstrs ); - dwItem->setFlags ( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable ); - dwItem->setCheckState(0, Qt::Checked); + dwItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable ); + dwItem->setCheckState( 0, Qt::Checked ); } } mMainWindowItems << topItem; } -void QgsCustomization::createTreeItemStatus ( ) +void QgsCustomization::createTreeItemStatus( ) { QStringList data; data << "StatusBar"; - QTreeWidgetItem *topItem = new QTreeWidgetItem ( data ); - topItem->setFlags ( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable ); - topItem->setCheckState(0, Qt::Checked); + QTreeWidgetItem *topItem = new QTreeWidgetItem( data ); + topItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable ); + topItem->setCheckState( 0, Qt::Checked ); QStatusBar* sb = QgisApp::instance()->statusBar(); - foreach (QObject* obj, sb->children()) + foreach( QObject* obj, sb->children() ) { - if (obj->inherits("QWidget") && !obj->objectName().isEmpty()) + if ( obj->inherits( "QWidget" ) && !obj->objectName().isEmpty() ) { QStringList strs; strs << obj->objectName(); QTreeWidgetItem* item = new QTreeWidgetItem( topItem, strs ); - item->setFlags ( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable ); - item->setCheckState(0, Qt::Checked); + item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable ); + item->setCheckState( 0, Qt::Checked ); } } @@ -582,10 +593,10 @@ QgsCustomization *QgsCustomization::instance() } QgsCustomization::QgsCustomization( ) : - pDialog(0), - mEnabled(true), - mStatusPath("/Customization/status"), - mSettings ( "QuantumGIS", "QGISCUSTOMIZATION" ) + pDialog( 0 ), + mEnabled( true ), + mStatusPath( "/Customization/status" ), + mSettings( "QuantumGIS", "QGISCUSTOMIZATION" ) { QgsDebugMsg( "Entered" ); } @@ -602,29 +613,29 @@ void QgsCustomization::updateMainWindow( QMenu * theToolBarMenu ) createTreeItemDocks(); createTreeItemStatus(); - if (!mEnabled) + if ( !mEnabled ) return; QMainWindow* mw = QgisApp::instance(); QMenuBar* menubar = mw->menuBar(); - mSettings.beginGroup("Customization/Menus"); + mSettings.beginGroup( "Customization/Menus" ); // hide menus and menu actions - foreach (QObject* obj, menubar->children()) + foreach( QObject* obj, menubar->children() ) { - if (obj->inherits("QMenu")) + if ( obj->inherits( "QMenu" ) ) { - QMenu* menu = qobject_cast(obj); - bool visible = mSettings.value(menu->objectName(), true).toBool(); - if (!visible) + QMenu* menu = qobject_cast( obj ); + bool visible = mSettings.value( menu->objectName(), true ).toBool(); + if ( !visible ) { - menubar->removeAction(menu->menuAction()); + menubar->removeAction( menu->menuAction() ); } else { - updateMenu(menu, mSettings); + updateMenu( menu, mSettings ); } } } @@ -633,28 +644,28 @@ void QgsCustomization::updateMainWindow( QMenu * theToolBarMenu ) // remove toolbars, toolbar actions - mSettings.beginGroup("Customization/Toolbars"); - foreach (QObject* obj, mw->children()) + mSettings.beginGroup( "Customization/Toolbars" ); + foreach( QObject* obj, mw->children() ) { - if (obj->inherits("QToolBar")) + if ( obj->inherits( "QToolBar" ) ) { - QToolBar* tb = qobject_cast(obj); - bool visible = mSettings.value(tb->objectName(), true).toBool(); - if (!visible) + QToolBar* tb = qobject_cast( obj ); + bool visible = mSettings.value( tb->objectName(), true ).toBool(); + if ( !visible ) { - mw->removeToolBar(tb); + mw->removeToolBar( tb ); // remove also from menu, because toolbars removed here, switched on later from menu don't work correctly - theToolBarMenu->removeAction( tb->toggleViewAction() ); + theToolBarMenu->removeAction( tb->toggleViewAction() ); } else { - mSettings.beginGroup(tb->objectName()); + mSettings.beginGroup( tb->objectName() ); // hide individual toolbar actions - foreach (QAction* action, tb->actions()) + foreach( QAction* action, tb->actions() ) { - visible = mSettings.value(action->objectName(), true).toBool(); - if (!visible) - tb->removeAction(action); + visible = mSettings.value( action->objectName(), true ).toBool(); + if ( !visible ) + tb->removeAction( action ); } mSettings.endGroup(); } @@ -665,15 +676,15 @@ void QgsCustomization::updateMainWindow( QMenu * theToolBarMenu ) // remove dock widgets - mSettings.beginGroup("Customization/Docks"); - foreach (QObject* obj, mw->children()) + mSettings.beginGroup( "Customization/Docks" ); + foreach( QObject* obj, mw->children() ) { - if (obj->inherits("QDockWidget")) + if ( obj->inherits( "QDockWidget" ) ) { - bool visible = mSettings.value(obj->objectName(), true).toBool(); - if (!visible) + bool visible = mSettings.value( obj->objectName(), true ).toBool(); + if ( !visible ) { - mw->removeDockWidget(qobject_cast(obj)); + mw->removeDockWidget( qobject_cast( obj ) ); } } } @@ -682,20 +693,20 @@ void QgsCustomization::updateMainWindow( QMenu * theToolBarMenu ) // remove status bar widgets - if (mSettings.value("Customization/StatusBar", true).toBool()) + if ( mSettings.value( "Customization/StatusBar", true ).toBool() ) { - mSettings.beginGroup("Customization/StatusBar"); + mSettings.beginGroup( "Customization/StatusBar" ); QStatusBar* sb = mw->statusBar(); - foreach (QObject* obj, sb->children()) + foreach( QObject* obj, sb->children() ) { - if (obj->inherits("QWidget")) + if ( obj->inherits( "QWidget" ) ) { - QWidget* widget = qobject_cast(obj); - bool visible = mSettings.value(widget->objectName(), true).toBool(); - if (!visible) + QWidget* widget = qobject_cast( obj ); + bool visible = mSettings.value( widget->objectName(), true ).toBool(); + if ( !visible ) { - sb->removeWidget(widget); + sb->removeWidget( widget ); } } } @@ -709,20 +720,20 @@ void QgsCustomization::updateMainWindow( QMenu * theToolBarMenu ) } } -void QgsCustomization::updateMenu(QMenu* menu, QSettings& settings) +void QgsCustomization::updateMenu( QMenu* menu, QSettings& settings ) { - settings.beginGroup(menu->objectName()); + settings.beginGroup( menu->objectName() ); // hide individual menu actions and call recursively on visible submenus - foreach (QAction* action, menu->actions()) + foreach( QAction* action, menu->actions() ) { - QString objName = (action->menu() ? action->menu()->objectName() : action->objectName()); - bool visible = settings.value(objName, true).toBool(); - if (!visible) - menu->removeAction(action); - else if (action->menu()) + QString objName = ( action->menu() ? action->menu()->objectName() : action->objectName() ); + bool visible = settings.value( objName, true ).toBool(); + if ( !visible ) + menu->removeAction( action ); + else if ( action->menu() ) { // it is a submenu - let's look if there isn't something to remove - updateMenu(action->menu(), settings); + updateMenu( action->menu(), settings ); } } settings.endGroup(); @@ -731,9 +742,10 @@ void QgsCustomization::updateMenu(QMenu* menu, QSettings& settings) void QgsCustomization::openDialog() { QgsDebugMsg( "Entered" ); - if ( !pDialog ) { + if ( !pDialog ) + { pDialog = new QgsCustomizationDialog(); - } + } // I am trying too enable switching widget status by clicking in main app, so I need non modal pDialog->show(); @@ -742,11 +754,12 @@ void QgsCustomization::openDialog() void QgsCustomization::customizeWidget( QWidget * widget, QEvent * event ) { // Test if the widget is child of QDialog - if ( !widget->inherits("QDialog") ) return; + if ( !widget->inherits( "QDialog" ) ) + return; - QgsDebugMsg( QString ( "objectName = %1 event type = %2" ).arg( widget->objectName()).arg( event->type() ) ); + QgsDebugMsg( QString( "objectName = %1 event type = %2" ).arg( widget->objectName() ).arg( event->type() ) ); - QgsDebugMsg( QString ( "%1 x %2").arg(typeid( *widget ).name()).arg(typeid( QDialog ).name() )); + QgsDebugMsg( QString( "%1 x %2" ).arg( widget->metaObject()->className() ).arg( QDialog::staticMetaObject.className() ) ); QString path = "/Customization/Widgets/"; QgsCustomization::customizeWidget( path, widget ); @@ -754,30 +767,31 @@ void QgsCustomization::customizeWidget( QWidget * widget, QEvent * event ) void QgsCustomization::customizeWidget( QString thePath, QWidget * theWidget ) { - QSettings mySettings ("QuantumGIS", "QGISCUSTOMIZATION" ); + QSettings mySettings( "QuantumGIS", "QGISCUSTOMIZATION" ); QString name = theWidget->objectName(); QString myPath = thePath; - // Qt may insert some internal classes in the tree, e.g. QTabWidgetPrivate inserts + // Qt may insert some internal classes in the tree, e.g. QTabWidgetPrivate inserts // qt_tabwidget_stackedwidget, such widgets do not appear in the tree generated // from ui files and do not have sense from user poin of view -> skip - - if ( !QgsCustomization::mInternalWidgets.contains ( name ) ) + + if ( !QgsCustomization::mInternalWidgets.contains( name ) ) { - myPath = thePath + "/" + name; + myPath = thePath + "/" + name; } QObjectList children = theWidget->children(); QObjectList::iterator i; - for ( i = children.begin(); i != children.end(); ++i) + for ( i = children.begin(); i != children.end(); ++i ) { - if ( !(*i)->inherits("QWidget") ) continue; - QWidget * w = qobject_cast(*i); + if ( !( *i )->inherits( "QWidget" ) ) + continue; + QWidget * w = qobject_cast( *i ); QString p = myPath + "/" + w->objectName(); bool on = mySettings.value( p, true ).toBool(); - QgsDebugMsg( QString("p = %1 on = %2").arg(p).arg(on) ); + QgsDebugMsg( QString( "p = %1 on = %2" ).arg( p ).arg( on ) ); if ( on ) { QgsCustomization::customizeWidget( myPath, w ); @@ -802,19 +816,20 @@ void QgsCustomization::customizeWidget( QString thePath, QWidget * theWidget ) void QgsCustomization::removeFromLayout( QLayout *theLayout, QWidget * theWidget ) { - if ( theLayout->indexOf( theWidget ) >= 0 ) + if ( theLayout->indexOf( theWidget ) >= 0 ) { - theLayout->removeWidget ( theWidget ); + theLayout->removeWidget( theWidget ); return; - } + } else { QObjectList children = theLayout->children(); QObjectList::iterator i; - for ( i = children.begin(); i != children.end(); ++i) + for ( i = children.begin(); i != children.end(); ++i ) { - if ( !(*i)->inherits("QLayout") ) continue; - QLayout *l = qobject_cast(*i); + if ( !( *i )->inherits( "QLayout" ) ) + continue; + QLayout *l = qobject_cast( *i ); QgsCustomization::removeFromLayout( l, theWidget ); } @@ -823,42 +838,44 @@ void QgsCustomization::removeFromLayout( QLayout *theLayout, QWidget * theWidget void QgsCustomization::preNotify( QObject * receiver, QEvent * event, bool * done ) { - QWidget * widget = 0; - if ( receiver->isWidgetType() ) - { - widget = static_cast( receiver ); - } + QWidget *widget = qobject_cast( receiver ); if ( mEnabled && widget && event->type() == QEvent::Show ) { - QgsCustomization::customizeWidget ( widget, event ); - if ( widget->inherits("QDialog") && pDialog && pDialog->isVisible() ) { + QgsCustomization::customizeWidget( widget, event ); + if ( widget->inherits( "QDialog" ) && pDialog && pDialog->isVisible() ) + { + // TODO? } } - else if ( mEnabled && widget && (event->type() == QEvent::Hide || event->type() == QEvent::Close) ) + else if ( mEnabled && widget && ( event->type() == QEvent::Hide || event->type() == QEvent::Close ) ) { - if ( widget->inherits("QDialog") && pDialog && pDialog->isVisible() ){ + if ( widget->inherits( "QDialog" ) && pDialog && pDialog->isVisible() ) + { + // TODO? } } else if ( widget && event->type() == QEvent::MouseButtonPress ) { QgsDebugMsg( "click" ); - if ( pDialog && pDialog->isVisible() ) { - QMouseEvent *e = static_cast(event); - *done = pDialog->switchWidget ( widget, e ); + if ( pDialog && pDialog->isVisible() ) + { + QMouseEvent *e = static_cast( event ); + *done = pDialog->switchWidget( widget, e ); } } - // Shortcut arrives only if it is defined and used in main app + // Shortcut arrives only if it is defined and used in main app // This would be also possible without necessity to add shortcut to main app // but it is better to have it there to avoid future conflicts else if ( event->type() == QEvent::KeyPress ) { - if ( pDialog && pDialog->isVisible() ) { - QKeyEvent *e = static_cast(event); - QgsDebugMsg( QString("key = %1 modifiers = %2").arg(e->key()).arg(e->modifiers() ) ) ; + if ( pDialog && pDialog->isVisible() ) + { + QKeyEvent *e = static_cast( event ); + QgsDebugMsg( QString( "key = %1 modifiers = %2" ).arg( e->key() ).arg( e->modifiers() ) ) ; if ( e->key() == Qt::Key_M && e->modifiers() == Qt::ControlModifier ) { - pDialog->setCatch ( !pDialog->catchOn() ); + pDialog->setCatch( !pDialog->catchOn() ); } } } @@ -869,31 +886,32 @@ void QgsCustomization::loadDefault() QSettings mySettings; // Check customization state - int status = mySettings.value( mStatusPath, QgsCustomization::NotSet).toInt(); + int status = mySettings.value( mStatusPath, QgsCustomization::NotSet ).toInt(); QgsDebugMsg( "Status path = " + mStatusPath ); - QgsDebugMsg( QString("status = %1").arg(status) ); - if ( status == QgsCustomization::User || status == QgsCustomization::Default ) return; - - // Look for default + QgsDebugMsg( QString( "status = %1" ).arg( status ) ); + if ( status == QgsCustomization::User || status == QgsCustomization::Default ) + return; + + // Look for default QString path = QgsApplication::pkgDataPath() + "/resources/customization.ini"; - if ( ! QFile::exists( path ) ) + if ( ! QFile::exists( path ) ) { - QgsDebugMsg( "Default customization not found in " + path ); + QgsDebugMsg( "Default customization not found in " + path ); return; } QgsDebugMsg( "Loading default customization from " + path ); - QSettings fileSettings( path, QSettings::IniFormat); + QSettings fileSettings( path, QSettings::IniFormat ); QStringList keys = fileSettings.allKeys(); - QgsDebugMsg( QString("size = %1").arg( keys.size () ) ); + QgsDebugMsg( QString( "size = %1" ).arg( keys.size() ) ); QStringList::const_iterator i; - for ( i = keys.begin(); i != keys.end(); ++i) + for ( i = keys.begin(); i != keys.end(); ++i ) { - QString p(*i); + QString p( *i ); - bool val = fileSettings.value(p).toBool(); + bool val = fileSettings.value( p ).toBool(); - mSettings.setValue(p, val); + mSettings.setValue( p, val ); } - mySettings.setValue(mStatusPath, QgsCustomization::Default); + mySettings.setValue( mStatusPath, QgsCustomization::Default ); } diff --git a/src/app/qgscustomization.h b/src/app/qgscustomization.h index 12238642116..52ce084e1e9 100644 --- a/src/app/qgscustomization.h +++ b/src/app/qgscustomization.h @@ -1,5 +1,5 @@ /*************************************************************************** - qgscustomization.h - Customization + qgscustomization.h - Customization ------------------- begin : 2011-04-01 copyright : (C) 2011 Radim Blazek @@ -39,14 +39,14 @@ class QgsCustomizationDialog : public QMainWindow, private Ui::QgsCustomizationD ~QgsCustomizationDialog(); // get item by path - QTreeWidgetItem *item ( QString thePath, QTreeWidgetItem *theItem=0 ); + QTreeWidgetItem *item( QString thePath, QTreeWidgetItem *theItem = 0 ); - // + // // return current item state for given path - bool itemChecked ( QString thePath ); + bool itemChecked( QString thePath ); // set item state for given path - void setItemChecked ( QString thePath, bool on ); + void setItemChecked( QString thePath, bool on ); // recursively save tree item to settings void itemToSettings( QString thePath, QTreeWidgetItem *theItem, QSettings *theSettings ); @@ -54,19 +54,19 @@ class QgsCustomizationDialog : public QMainWindow, private Ui::QgsCustomizationD void settingsToItem( QString thePath, QTreeWidgetItem *theItem, QSettings *theSettings ); // save current tree to settings - void treeToSettings ( QSettings *theSettings ); + void treeToSettings( QSettings *theSettings ); // restore current tree from settings - void settingsToTree ( QSettings *theSettings ); + void settingsToTree( QSettings *theSettings ); // switch widget item in tree - bool switchWidget ( QWidget * widget, QMouseEvent *event ); + bool switchWidget( QWidget * widget, QMouseEvent *event ); - // Get path of the widget - QString widgetPath ( QWidget * theWidget, QString thePath = QString() ); + // Get path of the widget + QString widgetPath( QWidget * theWidget, QString thePath = QString() ); - void setCatch ( bool on ); - bool catchOn ( ); + void setCatch( bool on ); + bool catchOn( ); private slots: //void on_btnQgisUser_clicked(); @@ -92,8 +92,8 @@ class QgsCustomizationDialog : public QMainWindow, private Ui::QgsCustomizationD private: void init(); - QTreeWidgetItem * createTreeItemWidgets ( ); - QTreeWidgetItem * readWidgetsXmlNode ( QDomNode theNode ); + QTreeWidgetItem * createTreeItemWidgets( ); + QTreeWidgetItem * readWidgetsXmlNode( QDomNode theNode ); QString mLastDirSettingsName; QSettings mSettings; @@ -122,7 +122,7 @@ class QgsCustomization : public QObject void updateMainWindow( QMenu * theToolBarMenu ); // make sure to enable/disable before creating QgisApp in order to get it customized (or not) - void setEnabled(bool enabled) { mEnabled = enabled; } + void setEnabled( bool enabled ) { mEnabled = enabled; } bool isEnabled() const { return mEnabled; } // Load and set default customization @@ -144,13 +144,13 @@ class QgsCustomization : public QObject bool mEnabled; QString mStatusPath; - void updateMenu(QMenu* menu, QSettings& settings); - void createTreeItemMenus ( ); - void createTreeItemToolbars ( ); - void createTreeItemDocks ( ); - void createTreeItemStatus ( ); - void addTreeItemMenu(QTreeWidgetItem* parentItem, QMenu* menu); - void addTreeItemActions(QTreeWidgetItem* parentItem, const QList& actions); + void updateMenu( QMenu* menu, QSettings& settings ); + void createTreeItemMenus( ); + void createTreeItemToolbars( ); + void createTreeItemDocks( ); + void createTreeItemStatus( ); + void addTreeItemMenu( QTreeWidgetItem* parentItem, QMenu* menu ); + void addTreeItemActions( QTreeWidgetItem* parentItem, const QList& actions ); QList mMainWindowItems; friend class QgsCustomizationDialog; // in order to access mMainWindowItems diff --git a/src/app/qgsmaptooladdpart.cpp b/src/app/qgsmaptooladdpart.cpp index 85eff4e56d8..38e5f4f35fa 100644 --- a/src/app/qgsmaptooladdpart.cpp +++ b/src/app/qgsmaptooladdpart.cpp @@ -134,6 +134,9 @@ void QgsMapToolAddPart::canvasReleaseEvent( QMouseEvent * e ) stopCapturing(); } break; + default: + Q_ASSERT( !"invalid capture mode" ); + break; } QString errorMessage; diff --git a/src/app/qgspluginmanager.cpp b/src/app/qgspluginmanager.cpp index eec2a7d09d9..de16c507802 100644 --- a/src/app/qgspluginmanager.cpp +++ b/src/app/qgspluginmanager.cpp @@ -175,7 +175,8 @@ void QgsPluginManager::getPythonPluginDescriptions() QString version = mPythonUtils->getPluginMetadata( packageName, "version" ); QString iconName = mPythonUtils->getPluginMetadata( packageName, "icon" ); - if ( pluginName == "__error__" || description == "__error__" || version == "__error__" ) continue; + if ( pluginName == "__error__" || description == "__error__" || version == "__error__" ) + continue; bool isCompatible = QgsPluginRegistry::instance()->isPythonPluginCompatible( packageName ); QString compatibleString; // empty by default diff --git a/src/app/qgspluginregistry.cpp b/src/app/qgspluginregistry.cpp index c141236355b..8e3a3b4736e 100644 --- a/src/app/qgspluginregistry.cpp +++ b/src/app/qgspluginregistry.cpp @@ -189,13 +189,16 @@ bool QgsPluginRegistry::checkQgisVersion( QString minVersion ) int minVerMajor, minVerMinor, minVerBugfix = 0; bool ok; minVerMajor = minVersionParts.at( 0 ).toInt( &ok ); - if ( !ok ) return false; + if ( !ok ) + return false; minVerMinor = minVersionParts.at( 1 ).toInt( &ok ); - if ( !ok ) return false; + if ( !ok ) + return false; if ( minVersionParts.count() == 3 ) { minVerBugfix = minVersionParts.at( 2 ).toInt( &ok ); - if ( !ok ) return false; + if ( !ok ) + return false; } // our qgis version - cut release name after version number @@ -207,15 +210,19 @@ bool QgsPluginRegistry::checkQgisVersion( QString minVersion ) int qgisBugfix = qgisVersionParts.at( 2 ).toInt(); // first check major version - if ( minVerMajor > qgisMajor ) return false; - if ( minVerMajor < qgisMajor ) return true; - + if ( minVerMajor > qgisMajor ) + return false; + if ( minVerMajor < qgisMajor ) + return true; // if same, check minor version - if ( minVerMinor > qgisMinor ) return false; - if ( minVerMinor < qgisMinor ) return true; + if ( minVerMinor > qgisMinor ) + return false; + if ( minVerMinor < qgisMinor ) + return true; // if still same, check bugfix version - if ( minVerBugfix > qgisBugfix ) return false; + if ( minVerBugfix > qgisBugfix ) + return false; // looks like min version is the same as our version - that's fine return true; diff --git a/src/browser/main.cpp b/src/browser/main.cpp index c479727ecfd..4752d972676 100644 --- a/src/browser/main.cpp +++ b/src/browser/main.cpp @@ -41,7 +41,7 @@ int main( int argc, char ** argv ) #if defined(Q_WS_WIN) QString prefixPath = QApplication::applicationDirPath(); #else - QString prefixPath = QApplication::applicationDirPath()+"/.."; + QString prefixPath = QApplication::applicationDirPath() + "/.."; #endif a.setPrefixPath( prefixPath, true ); a.initQgis(); @@ -51,7 +51,7 @@ int main( int argc, char ** argv ) QCoreApplication::setOrganizationDomain( "qgis.org" ); QCoreApplication::setApplicationName( "QGIS" ); -/* +#if 0 QString myTranslationCode = ""; // This is mostly copy from Help viewer - not sure if important @@ -76,28 +76,28 @@ int main( int argc, char ** argv ) } } QgsDebugMsg( QString( "Setting translation to %1/qgis_%2" ).arg( i18nPath ).arg( myTranslationCode ) ); -*/ + /* Translation file for Qt. * The strings from the QMenuBar context section are used by Qt/Mac to shift * the About, Preferences and Quit items to the Mac Application menu. * These items must be translated identically in both qt_ and qgis_ files. */ -/* + QTranslator qttor( 0 ); if ( qttor.load( QString( "qt_" ) + myTranslationCode, i18nPath ) ) { a.installTranslator( &qttor ); } -*/ + /* Translation file for QGIS. */ -/* + QTranslator qgistor( 0 ); if ( qgistor.load( QString( "qgis_" ) + myTranslationCode, i18nPath ) ) { a.installTranslator( &qgistor ); } -*/ +#endif QgsBrowser w; diff --git a/src/browser/qgsbrowser.cpp b/src/browser/qgsbrowser.cpp index 0820faf7f71..c15fff2e9c9 100644 --- a/src/browser/qgsbrowser.cpp +++ b/src/browser/qgsbrowser.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - qgs.cpp - + qgsbrowser.cpp - ------------------- begin : 2011-04-01 copyright : (C) 2011 Radim Blazek @@ -15,11 +15,10 @@ * * ***************************************************************************/ /* $Id$ */ -#include - #include #include #include +#include #include "qgsapplication.h" #include "qgsdataitem.h" @@ -38,39 +37,39 @@ QgsBrowser::QgsBrowser( QWidget *parent, Qt::WFlags flags ) : QMainWindow( parent, flags ), mDirtyMetadata( true ), mDirtyPreview( true ), mDirtyAttributes( true ), - mLayer( 0 ), mParamWidget(0) + mLayer( 0 ), mParamWidget( 0 ) { setupUi( this ); // Disable tabs by default - tabWidget->setTabEnabled ( tabWidget->indexOf( paramTab ), false ); - tabWidget->setTabEnabled ( tabWidget->indexOf( metaTab ), false ); - tabWidget->setTabEnabled ( tabWidget->indexOf( previewTab ), false ); - tabWidget->setTabEnabled ( tabWidget->indexOf( attributesTab ), false ); - - mModel = new QgsBrowserModel(treeView); - treeView->setModel(mModel); + tabWidget->setTabEnabled( tabWidget->indexOf( paramTab ), false ); + tabWidget->setTabEnabled( tabWidget->indexOf( metaTab ), false ); + tabWidget->setTabEnabled( tabWidget->indexOf( previewTab ), false ); + tabWidget->setTabEnabled( tabWidget->indexOf( attributesTab ), false ); + + mModel = new QgsBrowserModel( treeView ); + treeView->setModel( mModel ); // Last expanded is stored, dont cover whole height with file system //treeView->expand( mModel->index(0,0) ); - connect(treeView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(itemClicked(const QModelIndex&))); + connect( treeView, SIGNAL( clicked( const QModelIndex& ) ), this, SLOT( itemClicked( const QModelIndex& ) ) ); - treeView->setExpandsOnDoubleClick (false); - connect(treeView, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(itemDoubleClicked(const QModelIndex&))); - connect(treeView, SIGNAL(expanded(const QModelIndex&)), this, SLOT(itemExpanded(const QModelIndex&))); + treeView->setExpandsOnDoubleClick( false ); + connect( treeView, SIGNAL( doubleClicked( const QModelIndex& ) ), this, SLOT( itemDoubleClicked( const QModelIndex& ) ) ); + connect( treeView, SIGNAL( expanded( const QModelIndex& ) ), this, SLOT( itemExpanded( const QModelIndex& ) ) ); - connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged())); + connect( tabWidget, SIGNAL( currentChanged( int ) ), this, SLOT( tabChanged() ) ); connect( mActionNewVectorLayer, SIGNAL( triggered() ), this, SLOT( newVectorLayer() ) ); - connect(stopRenderingButton, SIGNAL(clicked()), this, SLOT(stopRendering()) ); + connect( stopRenderingButton, SIGNAL( clicked() ), this, SLOT( stopRendering() ) ); - mapCanvas->setCanvasColor(Qt::white); + mapCanvas->setCanvasColor( Qt::white ); - QSettings settings; - QString lastPath = settings.value ( "/Browser/lastExpanded" ).toString(); - QgsDebugMsg ( "lastPath = " + lastPath ); + QSettings settings; + QString lastPath = settings.value( "/Browser/lastExpanded" ).toString(); + QgsDebugMsg( "lastPath = " + lastPath ); if ( !lastPath.isEmpty() ) { expand( lastPath ); @@ -84,29 +83,29 @@ QgsBrowser::~QgsBrowser() void QgsBrowser::expand( QString path, const QModelIndex& index ) { - QStringList paths = path.split('/'); - for ( int i = 0; i < mModel->rowCount(index); i++ ) + QStringList paths = path.split( '/' ); + for ( int i = 0; i < mModel->rowCount( index ); i++ ) { - QModelIndex idx = mModel->index(i, 0, index); - QgsDataItem* ptr = (QgsDataItem*) idx.internalPointer(); + QModelIndex idx = mModel->index( i, 0, index ); + QgsDataItem* ptr = ( QgsDataItem* ) idx.internalPointer(); - if ( path.indexOf ( ptr->path() ) == 0 ) + if ( path.indexOf( ptr->path() ) == 0 ) { treeView->expand( idx ); - treeView->scrollTo (idx, QAbstractItemView::PositionAtTop ); + treeView->scrollTo( idx, QAbstractItemView::PositionAtTop ); expand( path, idx ); break; } } } -void QgsBrowser::itemClicked(const QModelIndex& index) +void QgsBrowser::itemClicked( const QModelIndex& index ) { mIndex = index; - QgsDataItem* ptr = (QgsDataItem*) index.internalPointer(); + QgsDataItem* ptr = ( QgsDataItem* ) index.internalPointer(); - // Disable preview, attributes tab + // Disable preview, attributes tab bool paramEnable = false; bool metaEnable = false; @@ -123,8 +122,9 @@ void QgsBrowser::itemClicked(const QModelIndex& index) QList nolayers; mapCanvas->setLayerSet( nolayers ); metaTextBrowser->clear(); - if ( mParamWidget ) { - paramLayout->removeWidget ( mParamWidget ); + if ( mParamWidget ) + { + paramLayout->removeWidget( mParamWidget ); mParamWidget->hide(); delete mParamWidget; mParamWidget = 0; @@ -139,59 +139,61 @@ void QgsBrowser::itemClicked(const QModelIndex& index) mParamWidget = ptr->paramWidget(); - if ( mParamWidget ) { - paramLayout->addWidget ( mParamWidget ); + if ( mParamWidget ) + { + paramLayout->addWidget( mParamWidget ); mParamWidget->show(); paramEnable = true; } - if (ptr->type() == QgsDataItem::Layer) + if ( ptr->type() == QgsDataItem::Layer ) { - QgsLayerItem* item = static_cast(ptr); - bool res = layerClicked(item); + QgsLayerItem* item = static_cast( ptr ); + bool res = layerClicked( item ); - if (res) + if ( res ) { metaEnable = true; previewEnable = true; - if ( mLayer->type() == QgsMapLayer::VectorLayer ) { + if ( mLayer->type() == QgsMapLayer::VectorLayer ) + { attributesEnable = true; } } } else { - mActionSetProjection->setEnabled ( false ); + mActionSetProjection->setEnabled( false ); } // force update of the current tab updateCurrentTab(); int selected = -1; - if ( mLastTab.contains( typeid(*ptr).name() ) ) + if ( mLastTab.contains( ptr->metaObject()->className() ) ) { - selected = mLastTab[ typeid(*ptr).name()]; + selected = mLastTab[ ptr->metaObject()->className() ]; } // Enabling tabs call tabChanged ! - tabWidget->setTabEnabled ( tabWidget->indexOf( paramTab ), paramEnable); - tabWidget->setTabEnabled ( tabWidget->indexOf( metaTab ), metaEnable ); - tabWidget->setTabEnabled ( tabWidget->indexOf( previewTab ), previewEnable ); - tabWidget->setTabEnabled ( tabWidget->indexOf( attributesTab ), attributesEnable ); + tabWidget->setTabEnabled( tabWidget->indexOf( paramTab ), paramEnable ); + tabWidget->setTabEnabled( tabWidget->indexOf( metaTab ), metaEnable ); + tabWidget->setTabEnabled( tabWidget->indexOf( previewTab ), previewEnable ); + tabWidget->setTabEnabled( tabWidget->indexOf( attributesTab ), attributesEnable ); // select tab according last selection for this data item - if ( selected >= 0 ) + if ( selected >= 0 ) { - qDebug("set tab %s %d", typeid(*ptr).name(), selected ); - tabWidget->setCurrentIndex ( selected ); + qDebug( "set tab %s %d", ptr->metaObject()->className(), selected ); + tabWidget->setCurrentIndex( selected ); } - qDebug("clicked: %d %d %s", index.row(), index.column(), ptr->name().toAscii().data()); + qDebug( "clicked: %d %d %s", index.row(), index.column(), ptr->name().toAscii().data() ); } -bool QgsBrowser::layerClicked(QgsLayerItem* ptr) +bool QgsBrowser::layerClicked( QgsLayerItem* ptr ) { - mActionSetProjection->setEnabled ( ptr->capabilities() & QgsLayerItem::SetCrs ); + mActionSetProjection->setEnabled( ptr->capabilities() & QgsLayerItem::SetCrs ); QString uri = ptr->uri(); if ( !uri.isEmpty() ) @@ -199,14 +201,14 @@ bool QgsBrowser::layerClicked(QgsLayerItem* ptr) QgsMapLayer::LayerType type = ptr->mapLayerType(); QString providerKey = ptr->providerKey(); - QgsDebugMsg ( providerKey + " : " + uri ); - if ( type == QgsMapLayer::VectorLayer ) + QgsDebugMsg( providerKey + " : " + uri ); + if ( type == QgsMapLayer::VectorLayer ) { - mLayer = new QgsVectorLayer( uri, QString(), providerKey); + mLayer = new QgsVectorLayer( uri, QString(), providerKey ); } - if ( type == QgsMapLayer::RasterLayer ) + if ( type == QgsMapLayer::RasterLayer ) { - // This should go to WMS provider + // This should go to WMS provider QStringList URIParts = uri.split( "|" ); QString rasterLayerPath = URIParts.at( 0 ); QStringList layers; @@ -220,13 +222,17 @@ bool QgsBrowser::layerClicked(QgsLayerItem* ptr) QString field = part.left( pos ); QString value = part.mid( pos + 1 ); - if ( field == "layers" ) layers = value.split(","); - if ( field == "styles" ) styles = value.split(","); - if ( field == "format" ) format = value; - if ( field == "crs" ) crs = value; + if ( field == "layers" ) + layers = value.split( "," ); + if ( field == "styles" ) + styles = value.split( "," ); + if ( field == "format" ) + format = value; + if ( field == "crs" ) + crs = value; } - QgsDebugMsg ( "rasterLayerPath = " + rasterLayerPath ); - QgsDebugMsg ( "layers = " + layers.join(" " ) ); + QgsDebugMsg( "rasterLayerPath = " + rasterLayerPath ); + QgsDebugMsg( "layers = " + layers.join( " " ) ); mLayer = new QgsRasterLayer( 0, rasterLayerPath, "", providerKey, layers, styles, format, crs ); } @@ -234,39 +240,39 @@ bool QgsBrowser::layerClicked(QgsLayerItem* ptr) if ( !mLayer || !mLayer->isValid() ) { - qDebug("No layer" ); + qDebug( "No layer" ); return false; } - QgsDebugMsg ( "Layer created"); + QgsDebugMsg( "Layer created" ); - QgsMapLayerRegistry::instance()->addMapLayer(mLayer); + QgsMapLayerRegistry::instance()->addMapLayer( mLayer ); return true; } -void QgsBrowser::itemDoubleClicked(const QModelIndex& index) +void QgsBrowser::itemDoubleClicked( const QModelIndex& index ) { - QgsDataItem* ptr = (QgsDataItem*) index.internalPointer(); + QgsDataItem* ptr = ( QgsDataItem* ) index.internalPointer(); // Currently doing nothing - qDebug("doubleclicked: %d %d %s", index.row(), index.column(), ptr->name().toAscii().data()); + qDebug( "doubleclicked: %d %d %s", index.row(), index.column(), ptr->name().toAscii().data() ); } -void QgsBrowser::itemExpanded(const QModelIndex& index) +void QgsBrowser::itemExpanded( const QModelIndex& index ) { - QSettings settings; - QgsDataItem* ptr = (QgsDataItem*) index.internalPointer(); -/* - if (ptr->mType == QgsDataItem::Directory || ptr->mType == QgsDataItem::Collection ) - { - QgsDirectoryItem* i = (QgsDirectoryItem*) ptr; - settings.setValue ( "/Browser/lastExpandedDir", i->mPath ); - } -*/ + QSettings settings; + QgsDataItem* ptr = ( QgsDataItem* ) index.internalPointer(); + /* + if (ptr->mType == QgsDataItem::Directory || ptr->mType == QgsDataItem::Collection ) + { + QgsDirectoryItem* i = (QgsDirectoryItem*) ptr; + settings.setValue ( "/Browser/lastExpandedDir", i->mPath ); + } + */ // TODO: save separately each type (FS, WMS) - settings.setValue ( "/Browser/lastExpanded", ptr->path() ); + settings.setValue( "/Browser/lastExpanded", ptr->path() ); QgsDebugMsg( "last expanded: " + ptr->path() ); } @@ -274,7 +280,7 @@ void QgsBrowser::newVectorLayer() { // Set file dialog to last selected dir QSettings settings; - QString lastPath = settings.value ( "/Browser/lastExpanded" ).toString(); + QString lastPath = settings.value( "/Browser/lastExpanded" ).toString(); if ( !lastPath.isEmpty() ) { settings.setValue( "/UI/lastVectorFileFilterDir", lastPath ); @@ -286,15 +292,15 @@ void QgsBrowser::newVectorLayer() { QgsDebugMsg( "New vector layer: " + fileName ); expand( fileName ); - QFileInfo fileInfo ( fileName ); + QFileInfo fileInfo( fileName ); QString dirPath = fileInfo.absoluteDir().path(); - mModel->refresh ( dirPath ); + mModel->refresh( dirPath ); } } void QgsBrowser::on_mActionWmsConnections_triggered() { - QDialog *wmss = dynamic_cast ( QgsProviderRegistry::instance()->getSelectWidget( QString("wms"), this ) ); + QDialog *wmss = dynamic_cast( QgsProviderRegistry::instance()->selectWidget( QString( "wms" ), this ) ); if ( !wmss ) { QMessageBox::warning( this, tr( "WMS" ), tr( "Cannot get WMS select dialog from provider." ) ); @@ -308,7 +314,8 @@ void QgsBrowser::on_mActionWmsConnections_triggered() void QgsBrowser::on_mActionSetProjection_triggered() { - if ( !mLayer ) { return; } + if ( !mLayer ) + return; QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector( this ); mySelector->setMessage(); mySelector->setSelectedCrsId( mLayer->crs().srsid() ); @@ -320,13 +327,13 @@ void QgsBrowser::on_mActionSetProjection_triggered() // Is this safe? // selectedIndexes() is protected - QgsDataItem* ptr = (QgsDataItem*) mIndex.internalPointer(); + QgsDataItem* ptr = ( QgsDataItem* ) mIndex.internalPointer(); if ( ptr->type() == QgsDataItem::Layer ) { - QgsLayerItem* layerItem = static_cast(ptr); - if ( ! layerItem->setCrs ( srs ) ) + QgsLayerItem* layerItem = static_cast( ptr ); + if ( ! layerItem->setCrs( srs ) ) { - QMessageBox::critical( this, tr( "CRS" ), tr( "Cannot set layer CRS" )); + QMessageBox::critical( this, tr( "CRS" ), tr( "Cannot set layer CRS" ) ); } } QgsDebugMsg( srs.authid() + " - " + srs.description() ); @@ -365,14 +372,14 @@ void QgsBrowser::restoreWindowState() QList sizes; sizes << size0; sizes << settings.value( "/Windows/Browser/sizes/1" ).toInt(); - QgsDebugMsg( QString("set splitter sizes to %1 %2").arg(sizes[0]).arg(sizes[1]) ); - splitter->setSizes(sizes); + QgsDebugMsg( QString( "set splitter sizes to %1 %2" ).arg( sizes[0] ).arg( sizes[1] ) ); + splitter->setSizes( sizes ); } } void QgsBrowser::keyPressEvent( QKeyEvent * e ) { - QgsDebugMsg( "Entered"); + QgsDebugMsg( "Entered" ); if ( e->key() == Qt::Key_Escape ) { stopRendering(); @@ -386,7 +393,7 @@ void QgsBrowser::keyPressEvent( QKeyEvent * e ) void QgsBrowser::stopRendering() { // you might have seen this already in QgisApp - QgsDebugMsg( "Entered"); + QgsDebugMsg( "Entered" ); if ( mapCanvas ) { QgsMapRenderer* mypMapRenderer = mapCanvas->mapRenderer(); @@ -404,9 +411,9 @@ void QgsBrowser::stopRendering() QgsBrowser::Tab QgsBrowser::activeTab() { QWidget* curr = tabWidget->currentWidget(); - if (curr == metaTab) + if ( curr == metaTab ) return Metadata; - if (curr == previewTab) + if ( curr == previewTab ) return Preview; return Attributes; } @@ -417,9 +424,9 @@ void QgsBrowser::updateCurrentTab() Tab current = activeTab(); - if (current == Metadata && mDirtyMetadata) + if ( current == Metadata && mDirtyMetadata ) { - if (mLayer && mLayer->isValid()) + if ( mLayer && mLayer->isValid() ) { // Set meta QString myStyle = QgsApplication::reportStyleSheet(); @@ -429,33 +436,33 @@ void QgsBrowser::updateCurrentTab() } else { - metaTextBrowser->setHtml(QString()); + metaTextBrowser->setHtml( QString() ); } mDirtyMetadata = false; } - if (current == Preview && mDirtyPreview) + if ( current == Preview && mDirtyPreview ) { - if (mLayer && mLayer->isValid()) + if ( mLayer && mLayer->isValid() ) { // Create preview: add to map canvas QList layers; - layers << QgsMapCanvasLayer(mLayer); - mapCanvas->setLayerSet(layers); + layers << QgsMapCanvasLayer( mLayer ); + mapCanvas->setLayerSet( layers ); QgsRectangle fullExtent = mLayer->extent(); - fullExtent.scale(1.05); // add some border - mapCanvas->setExtent(fullExtent); + fullExtent.scale( 1.05 ); // add some border + mapCanvas->setExtent( fullExtent ); mapCanvas->refresh(); } mDirtyPreview = false; } - if (current == Attributes && mDirtyAttributes) + if ( current == Attributes && mDirtyAttributes ) { if ( mLayer && mLayer->isValid() && mLayer->type() == QgsMapLayer::VectorLayer ) { QgsVectorLayer* vlayer = qobject_cast( mLayer ); - QApplication::setOverrideCursor(Qt::WaitCursor); + QApplication::setOverrideCursor( Qt::WaitCursor ); attributeTable->setLayer( vlayer ); QApplication::restoreOverrideCursor(); } @@ -471,11 +478,11 @@ void QgsBrowser::tabChanged() { updateCurrentTab(); // Store last selected tab for selected data item - if ( mIndex.isValid() ) + if ( mIndex.isValid() ) { - QObject* ptr = (QObject*) mIndex.internalPointer(); - QgsDebugMsg( QString("save last tab %1 : %2").arg( typeid(*ptr).name() ).arg(tabWidget->currentIndex()) ); - mLastTab[typeid(*ptr).name()] = tabWidget->currentIndex(); + QObject* ptr = ( QObject* ) mIndex.internalPointer(); + QgsDebugMsg( QString( "save last tab %1 : %2" ).arg( ptr->metaObject()->className() ).arg( tabWidget->currentIndex() ) ); + mLastTab[ ptr->metaObject()->className() ] = tabWidget->currentIndex(); } } @@ -488,16 +495,16 @@ void QgsBrowser::on_mActionRefresh_triggered() void QgsBrowser::refresh( const QModelIndex& index ) { QgsDebugMsg( "Entered" ); - if ( index.isValid() ) + if ( index.isValid() ) { - QgsDataItem* item = (QgsDataItem*) index.internalPointer(); + QgsDataItem* item = ( QgsDataItem* ) index.internalPointer(); QgsDebugMsg( "path = " + item->path() ); } mModel->refresh( index ); - for ( int i = 0 ; i < mModel->rowCount(index); i++ ) + for ( int i = 0 ; i < mModel->rowCount( index ); i++ ) { - QModelIndex idx = mModel->index(i, 0, index); - if ( treeView->isExpanded ( idx ) ) + QModelIndex idx = mModel->index( i, 0, index ); + if ( treeView->isExpanded( idx ) ) { refresh( idx ); } diff --git a/src/browser/qgsbrowser.h b/src/browser/qgsbrowser.h index 318218565d8..a54d75746db 100644 --- a/src/browser/qgsbrowser.h +++ b/src/browser/qgsbrowser.h @@ -35,14 +35,14 @@ class QgsBrowser : public QMainWindow, private Ui::QgsBrowserBase ~QgsBrowser(); // Expand to given path - void expand ( QString path, const QModelIndex& index = QModelIndex() ); + void expand( QString path, const QModelIndex& index = QModelIndex() ); public slots: - void itemClicked(const QModelIndex& index); - void itemDoubleClicked(const QModelIndex& index); - void itemExpanded(const QModelIndex& index); + void itemClicked( const QModelIndex& index ); + void itemDoubleClicked( const QModelIndex& index ); + void itemExpanded( const QModelIndex& index ); void on_mActionSetProjection_triggered(); void on_mActionWmsConnections_triggered(); void on_mActionRefresh_triggered(); @@ -56,12 +56,12 @@ class QgsBrowser : public QMainWindow, private Ui::QgsBrowserBase void stopRendering(); // Refresh all leaf or expanded items - void refresh ( const QModelIndex& index= QModelIndex() ); + void refresh( const QModelIndex& index = QModelIndex() ); -protected: + protected: void keyPressEvent( QKeyEvent * e ); - bool layerClicked(QgsLayerItem* ptr); + bool layerClicked( QgsLayerItem* ptr ); enum Tab { @@ -78,7 +78,7 @@ protected: QModelIndex mIndex; QWidget *mParamWidget; // last (selected) tab for each - QMap mLastTab; + QMap mLastTab; }; #endif // QGSBROWSER_H diff --git a/src/browser/qgsbrowsermodel.cpp b/src/browser/qgsbrowsermodel.cpp index bcd33f2ad1b..c940151286e 100755 --- a/src/browser/qgsbrowsermodel.cpp +++ b/src/browser/qgsbrowsermodel.cpp @@ -31,8 +31,9 @@ QgsBrowserModel::QgsBrowserModel( QObject *parent ) : // Add non file top level items foreach( QString key, QgsProviderRegistry::instance()->providerList() ) { - QLibrary *library = QgsProviderRegistry::instance()->getLibrary( key ); - if ( !library ) continue; + QLibrary *library = QgsProviderRegistry::instance()->providerLibrary( key ); + if ( !library ) + continue; dataCapabilities_t * dataCapabilities = ( dataCapabilities_t * ) cast_to_fptr( library->resolve( "dataCapabilities" ) ); if ( !dataCapabilities ) @@ -277,7 +278,8 @@ void QgsBrowserModel::beginInsertItems( QgsDataItem* parent, int first, int last { QgsDebugMsg( "parent mPath = " + parent->path() ); QModelIndex idx = index( parent ); - if ( !idx.isValid() ) return; + if ( !idx.isValid() ) + return; QgsDebugMsg( "valid" ); beginInsertRows( idx, first, last ); QgsDebugMsg( "end" ); @@ -291,7 +293,8 @@ void QgsBrowserModel::beginRemoveItems( QgsDataItem* parent, int first, int last { QgsDebugMsg( "parent mPath = " + parent->path() ); QModelIndex idx = index( parent ); - if ( !idx.isValid() ) return; + if ( !idx.isValid() ) + return; beginRemoveRows( idx, first, last ); } void QgsBrowserModel::endRemoveItems() diff --git a/src/browser/qgsbrowsermodel.h b/src/browser/qgsbrowsermodel.h index 106188add5c..19c5bad5fa3 100644 --- a/src/browser/qgsbrowsermodel.h +++ b/src/browser/qgsbrowsermodel.h @@ -9,8 +9,8 @@ class QgsBrowserModel : public QAbstractItemModel { Q_OBJECT -public: - explicit QgsBrowserModel(QObject *parent = 0); + public: + explicit QgsBrowserModel( QObject *parent = 0 ); ~QgsBrowserModel(); // implemented methods from QAbstractItemModel for read-only access @@ -31,7 +31,7 @@ public: virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const; /** Provides the number of columns of data exposed by the model. List models do not provide this function because it is already implemented in QAbstractListModel. */ - virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const; + virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const; /** Returns the index of the item in the model specified by the given row, column and parent index. */ virtual QModelIndex index( int row, int column, const QModelIndex & parent = QModelIndex() ) const; @@ -42,17 +42,17 @@ public: virtual QModelIndex parent( const QModelIndex & index ) const; - bool hasChildren ( const QModelIndex & parent = QModelIndex() ) const; + bool hasChildren( const QModelIndex & parent = QModelIndex() ) const; // Refresh item specified by path void refresh( QString path, const QModelIndex& index = QModelIndex() ); // Refresh item childs void refresh( const QModelIndex& index = QModelIndex() ); - void connectItem ( QgsDataItem * item ); -signals: + void connectItem( QgsDataItem * item ); + signals: -public slots: + public slots: //void removeItems( QgsDataItem * parent, QVectoritems ); //void addItems( QgsDataItem * parent, QVectoritems ); //void refreshItems( QgsDataItem * parent, QVectoritems ); @@ -62,7 +62,7 @@ public slots: void beginRemoveItems( QgsDataItem* parent, int first, int last ); void endRemoveItems(); -protected: + protected: QVector mRootItems; QIcon mIconDirectory; }; diff --git a/src/core/pal/rtree.hpp b/src/core/pal/rtree.hpp index 2c7310ebe77..757fef85ccc 100644 --- a/src/core/pal/rtree.hpp +++ b/src/core/pal/rtree.hpp @@ -1079,7 +1079,7 @@ namespace pal { ASSERT( a_rectA && a_rectB ); - Rect newRect = { {0,}, {0,} }; + Rect newRect = { {0, }, {0, } }; for ( int index = 0; index < NUMDIMS; ++index ) { diff --git a/src/core/qgsapplication.cpp b/src/core/qgsapplication.cpp index 90ecb705b1b..4ac0f0993db 100644 --- a/src/core/qgsapplication.cpp +++ b/src/core/qgsapplication.cpp @@ -115,7 +115,8 @@ bool QgsApplication::notify( QObject * receiver, QEvent * event ) bool done = false; emit preNotify( receiver, event, &done ); - if ( done ) return true; + if ( done ) + return true; // Send event to receiver and catch unhandled exceptions done = true; diff --git a/src/core/qgscoordinatereferencesystem.cpp b/src/core/qgscoordinatereferencesystem.cpp index 509b65f38d2..34780b52c2c 100644 --- a/src/core/qgscoordinatereferencesystem.cpp +++ b/src/core/qgscoordinatereferencesystem.cpp @@ -104,8 +104,10 @@ bool QgsCoordinateReferenceSystem::createFromString( const QString theDefinition { QString authName = reCrsId.cap( 1 ).toLower(); CrsType type = InternalCrsId; - if ( authName == "epsg" ) type = EpsgCrsId; - if ( authName == "postgis" ) type = PostgisCrsId; + if ( authName == "epsg" ) + type = EpsgCrsId; + if ( authName == "postgis" ) + type = PostgisCrsId; long id = reCrsId.cap( 2 ).toLong(); result = createFromId( id, type ); } diff --git a/src/core/qgscoordinatetransform.cpp b/src/core/qgscoordinatetransform.cpp index 6e6b519c6dc..a70a41fd009 100644 --- a/src/core/qgscoordinatetransform.cpp +++ b/src/core/qgscoordinatetransform.cpp @@ -222,7 +222,8 @@ void QgsCoordinateTransform::initialise() QgsPoint QgsCoordinateTransform::transform( const QgsPoint thePoint, TransformDirection direction ) const { - if ( mShortCircuit || !mInitialisedFlag ) return thePoint; + if ( mShortCircuit || !mInitialisedFlag ) + return thePoint; // transform x double x = thePoint.x(); double y = thePoint.y(); @@ -258,7 +259,8 @@ QgsPoint QgsCoordinateTransform::transform( const double theX, const double theY QgsRectangle QgsCoordinateTransform::transform( const QgsRectangle theRect, TransformDirection direction ) const { - if ( mShortCircuit || !mInitialisedFlag ) return theRect; + if ( mShortCircuit || !mInitialisedFlag ) + return theRect; // transform x double x1 = theRect.xMinimum(); double y1 = theRect.yMinimum(); diff --git a/src/core/qgsdataitem.cpp b/src/core/qgsdataitem.cpp index 797b04413ff..ced6c049c27 100755 --- a/src/core/qgsdataitem.cpp +++ b/src/core/qgsdataitem.cpp @@ -166,7 +166,8 @@ void QgsDataItem::populate() int QgsDataItem::rowCount() { - if ( !mPopulated ) populate(); + if ( !mPopulated ) + populate(); return mChildren.size(); } bool QgsDataItem::hasChildren() @@ -180,10 +181,13 @@ void QgsDataItem::addChildItem( QgsDataItem * child, bool refresh ) int i; for ( i = 0; i < mChildren.size(); i++ ) { - if ( mChildren[i]->mName.localeAwareCompare( child->mName ) >= 0 ) break; + if ( mChildren[i]->mName.localeAwareCompare( child->mName ) >= 0 ) + break; } - if ( refresh ) emit beginInsertItems( this, i, i ); + if ( refresh ) + emit beginInsertItems( this, i, i ); + mChildren.insert( i, child ); connect( child, SIGNAL( beginInsertItems( QgsDataItem*, int, int ) ), @@ -195,8 +199,8 @@ void QgsDataItem::addChildItem( QgsDataItem * child, bool refresh ) connect( child, SIGNAL( endRemoveItems() ), this, SLOT( emitEndRemoveItems() ) ); - if ( refresh ) emit endInsertItems(); - + if ( refresh ) + emit endInsertItems(); } void QgsDataItem::deleteChildItem( QgsDataItem * child ) { @@ -214,7 +218,8 @@ int QgsDataItem::findItem( QVector items, QgsDataItem * item ) for ( int i = 0; i < items.size(); i++ ) { QgsDebugMsg( QString::number( i ) + " : " + items[i]->mPath + " x " + item->mPath ); - if ( items[i]->equal( item ) ) return i; + if ( items[i]->equal( item ) ) + return i; } return -1; } @@ -229,7 +234,8 @@ void QgsDataItem::refresh() QVector remove; foreach( QgsDataItem *child, mChildren ) { - if ( findItem( items, child ) >= 0 ) continue; + if ( findItem( items, child ) >= 0 ) + continue; remove.append( child ); } foreach( QgsDataItem *child, remove ) @@ -280,7 +286,8 @@ QgsLayerItem::QgsLayerItem( QgsDataItem* parent, QString name, QString path, QSt QgsMapLayer::LayerType QgsLayerItem::mapLayerType() { - if ( mLayerType == QgsLayerItem::Raster ) return QgsMapLayer::RasterLayer; + if ( mLayerType == QgsLayerItem::Raster ) + return QgsMapLayer::RasterLayer; return QgsMapLayer::VectorLayer; } @@ -328,7 +335,7 @@ QgsDirectoryItem::QgsDirectoryItem( QgsDataItem* parent, QString name, QString p QString k( *i ); // some providers hangs with empty uri (Postgis) etc... // -> using libraries directly - QLibrary *library = QgsProviderRegistry::instance()->getLibrary( k ); + QLibrary *library = QgsProviderRegistry::instance()->providerLibrary( k ); if ( library ) { dataCapabilities_t * dataCapabilities = ( dataCapabilities_t * ) cast_to_fptr( library->resolve( "dataCapabilities" ) ); @@ -384,7 +391,10 @@ QVector QgsDirectoryItem::createChildren( ) // TODO: use existing fileVectorFilters(),directoryDrivers() ? dataCapabilities_t * dataCapabilities = ( dataCapabilities_t * ) cast_to_fptr( library->resolve( "dataCapabilities" ) ); - if ( !dataCapabilities ) continue; + if ( !dataCapabilities ) + { + continue; + } int capabilities = dataCapabilities(); diff --git a/src/core/qgsdistancearea.cpp b/src/core/qgsdistancearea.cpp index 4b8c21d86f6..069e5104cec 100644 --- a/src/core/qgsdistancearea.cpp +++ b/src/core/qgsdistancearea.cpp @@ -667,7 +667,8 @@ void QgsDistanceArea::computeAreaInit() m_Qp = getQ( M_PI / 2 ); m_E = 4 * M_PI * m_Qp * m_AE; - if ( m_E < 0.0 ) m_E = -m_E; + if ( m_E < 0.0 ) + m_E = -m_E; } @@ -720,8 +721,10 @@ double QgsDistanceArea::computePolygonArea( const QList& points ) * the difference between total surface area of the earth and * the "north pole" area. */ - if ( area > m_E ) area = m_E; - if ( area > m_E / 2 ) area = m_E - area; + if ( area > m_E ) + area = m_E; + if ( area > m_E / 2 ) + area = m_E - area; return area; } diff --git a/src/core/qgsmaplayer.h b/src/core/qgsmaplayer.h index c2833922dbb..21956106b24 100644 --- a/src/core/qgsmaplayer.h +++ b/src/core/qgsmaplayer.h @@ -334,7 +334,7 @@ class CORE_EXPORT QgsMapLayer : public QObject /** \brief Obtain Metadata for this layer */ virtual QString metadata(); - + /** Time stamp of data source in the moment when data/metadata were loaded by provider */ virtual QDateTime timestamp() const { return QDateTime() ; } diff --git a/src/core/qgspallabeling.cpp b/src/core/qgspallabeling.cpp index 7a710155af3..cab7cf79e75 100644 --- a/src/core/qgspallabeling.cpp +++ b/src/core/qgspallabeling.cpp @@ -62,7 +62,8 @@ class QgsPalGeometry : public PalGeometry ~QgsPalGeometry() { - if ( mG ) GEOSGeom_destroy( mG ); + if ( mG ) + GEOSGeom_destroy( mG ); delete mInfo; } @@ -82,7 +83,8 @@ class QgsPalGeometry : public PalGeometry pal::LabelInfo* info( QFontMetricsF* fm, const QgsMapToPixel* xform, double fontScale ) { - if ( mInfo ) return mInfo; + if ( mInfo ) + return mInfo; // create label info! QgsPoint ptZero = xform->toMapCoordinates( 0, 0 ); @@ -714,7 +716,7 @@ int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QSet& attrIndices, case QgsPalLayerSettings::Curved: arrangement = P_CURVED; break; case QgsPalLayerSettings::Horizontal: arrangement = P_HORIZ; break; case QgsPalLayerSettings::Free: arrangement = P_FREE; break; - default: Q_ASSERT( "unsupported placement" && 0 ); return 0; break; + default: Q_ASSERT( "unsupported placement" && 0 ); return 0; } // create the pal layer diff --git a/src/core/qgsproviderregistry.cpp b/src/core/qgsproviderregistry.cpp index 74b3befb938..c356d5c4b75 100644 --- a/src/core/qgsproviderregistry.cpp +++ b/src/core/qgsproviderregistry.cpp @@ -331,8 +331,7 @@ typedef QgsDataProvider * classFactoryFunction_t( const QString * ); * It seems more sensible to provide the code in one place rather than * in qgsrasterlayer, qgsvectorlayer, serversourceselect, etc. */ -QgsDataProvider* QgsProviderRegistry::getProvider( QString const & providerKey, - QString const & dataSource ) +QgsDataProvider *QgsProviderRegistry::provider( QString const & providerKey, QString const & dataSource ) { // XXX should I check for and possibly delete any pre-existing providers? // XXX How often will that scenario occur? @@ -430,24 +429,25 @@ QgsDataProvider* QgsProviderRegistry::getProvider( QString const & providerKey, // This should be QWidget, not QDialog typedef QWidget * selectFactoryFunction_t( QWidget * parent, Qt::WFlags fl ); -QWidget* QgsProviderRegistry::getSelectWidget( const QString & providerKey, - QWidget * parent, Qt::WFlags fl ) +QWidget* QgsProviderRegistry::selectWidget( const QString & providerKey, + QWidget * parent, Qt::WFlags fl ) { - QLibrary *myLib = getLibrary( providerKey ); - if ( !myLib ) return 0; + QLibrary *myLib = providerLibrary( providerKey ); + if ( !myLib ) + return 0; selectFactoryFunction_t * selectFactory = ( selectFactoryFunction_t * ) cast_to_fptr( myLib->resolve( "selectWidget" ) ); - if ( !selectFactory ) return 0; + if ( !selectFactory ) + return 0; - QWidget *widget = ( *selectFactory )( parent, fl ); - return widget; + return selectFactory( parent, fl ); } - -void * QgsProviderRegistry::getFunction( QString const & providerKey, - QString const & functionName ) + +void * QgsProviderRegistry::function( QString const & providerKey, + QString const & functionName ) { QString lib = library( providerKey ); @@ -467,20 +467,20 @@ void * QgsProviderRegistry::getFunction( QString const & providerKey, return 0; } -QLibrary * QgsProviderRegistry::getLibrary( QString const & providerKey ) +QLibrary *QgsProviderRegistry::providerLibrary( QString const & providerKey ) { QString lib = library( providerKey ); - QLibrary* myLib = new QLibrary( lib ); + QLibrary *myLib = new QLibrary( lib ); QgsDebugMsg( "Library name is " + myLib->fileName() ); bool loaded = myLib->load(); - + if ( loaded ) { return myLib; - } + } delete myLib; return 0; } diff --git a/src/core/qgsproviderregistry.h b/src/core/qgsproviderregistry.h index be191df8b4f..bcb15d74932 100644 --- a/src/core/qgsproviderregistry.h +++ b/src/core/qgsproviderregistry.h @@ -65,21 +65,21 @@ class CORE_EXPORT QgsProviderRegistry @param dataSource string containing data source for the provider @return instance of provider or NULL on error */ - QgsDataProvider * getProvider( const QString & providerKey, - const QString & dataSource ); + QgsDataProvider *provider( const QString & providerKey, + const QString & dataSource ); - QWidget * getSelectWidget ( const QString & providerKey, - QWidget * parent=0, Qt::WFlags fl=0 ); + QWidget *selectWidget( const QString & providerKey, + QWidget * parent = 0, Qt::WFlags fl = 0 ); /** Get pointer to provider function @param providerKey identificator of the provider @param functionName name of function @return pointer to function or NULL on error */ - void * getFunction( const QString & providerKey, - const QString & functionName ); + void *function( const QString & providerKey, + const QString & functionName ); - QLibrary * getLibrary ( const QString & providerKey ); + QLibrary *providerLibrary( const QString & providerKey ); /** Return list of available providers by their keys */ QStringList providerList() const; diff --git a/src/core/qgspythonrunner.cpp b/src/core/qgspythonrunner.cpp index 951d2f2ca4a..46a822284e9 100644 --- a/src/core/qgspythonrunner.cpp +++ b/src/core/qgspythonrunner.cpp @@ -19,7 +19,7 @@ bool QgsPythonRunner::run( QString command, QString messageOnError ) } else { - QgsDebugMsg("Unable to run Python command: runner not available!"); + QgsDebugMsg( "Unable to run Python command: runner not available!" ); return false; } } diff --git a/src/core/qgspythonrunner.h b/src/core/qgspythonrunner.h index 4933bd12bf4..f5158466c8e 100644 --- a/src/core/qgspythonrunner.h +++ b/src/core/qgspythonrunner.h @@ -14,7 +14,7 @@ */ class CORE_EXPORT QgsPythonRunner { -public: + public: /** returns true if the runner has an instance (and thus is able to run commands) */ @@ -28,7 +28,7 @@ public: Takes ownership of the object, deletes previous instance. */ static void setInstance( QgsPythonRunner* runner ); -protected: + protected: /** protected constructor: can be instantiated only from children */ QgsPythonRunner(); virtual ~QgsPythonRunner(); diff --git a/src/core/qgsrasterdataprovider.cpp b/src/core/qgsrasterdataprovider.cpp index b707fe6df30..e3d5727037a 100644 --- a/src/core/qgsrasterdataprovider.cpp +++ b/src/core/qgsrasterdataprovider.cpp @@ -54,7 +54,8 @@ void QgsRasterDataProvider::readBlock( int bandNo, QgsRectangle const & viewExt // TODO: init data by nulls // If we zoom out too much, projector srcRows / srcCols maybe 0, which can cause problems in providers - if ( myProjector.srcRows() <= 0 || myProjector.srcCols() <= 0 ) return; + if ( myProjector.srcRows() <= 0 || myProjector.srcCols() <= 0 ) + return; // Allocate memory for not projected source data int mySize = dataTypeSize( bandNo ) / 8; diff --git a/src/core/qgsrasterprojector.cpp b/src/core/qgsrasterprojector.cpp index f54c3412189..d9d6df6f524 100644 --- a/src/core/qgsrasterprojector.cpp +++ b/src/core/qgsrasterprojector.cpp @@ -16,8 +16,6 @@ ***************************************************************************/ /* $Id: qgsrasterprojector.cpp 15005 2011-01-08 16:35:21Z rblazek $ */ -#include - #include "qgslogger.h" #include "qgsrasterprojector.h" #include "qgscoordinatetransform.h" @@ -176,10 +174,12 @@ QString QgsRasterProjector::cpToString() QString myString; for ( int i = 0; i < mCPRows; i++ ) { - if ( i > 0 ) myString += "\n"; + if ( i > 0 ) + myString += "\n"; for ( int j = 0; j < mCPCols; j++ ) { - if ( j > 0 ) myString += " "; + if ( j > 0 ) + myString += " "; QgsPoint myPoint = mCPMatrix[i][j]; myString += myPoint.toString(); } @@ -210,10 +210,12 @@ void QgsRasterProjector::calcSrcRowsCols() QgsPoint myPointB = mCPMatrix[i][j+1]; QgsPoint myPointC = mCPMatrix[i+1][j]; double mySize = sqrt( myPointA.sqrDist( myPointB ) ) / myDestColsPerMatrixCell; - if ( mySize < myMinSize ) { myMinSize = mySize; } + if ( mySize < myMinSize ) + myMinSize = mySize; mySize = sqrt( myPointA.sqrDist( myPointC ) ) / myDestRowsPerMatrixCell; - if ( mySize < myMinSize ) { myMinSize = mySize; } + if ( mySize < myMinSize ) + myMinSize = mySize; } } @@ -294,7 +296,8 @@ void QgsRasterProjector::nextHelper() void QgsRasterProjector::srcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol ) { - if ( mApproximate ) approximateSrcRowCol( theDestRow, theDestCol, theSrcRow, theSrcCol ); + if ( mApproximate ) + approximateSrcRowCol( theDestRow, theDestCol, theSrcRow, theSrcCol ); else preciseSrcRowCol( theDestRow, theDestCol, theSrcRow, theSrcCol ); } @@ -321,13 +324,17 @@ void QgsRasterProjector::preciseSrcRowCol( int theDestRow, int theDestCol, int * // With epsg 32661 (Polar Stereographic) it was happening that *theSrcCol == mSrcCols // For now silently correct limits to avoid crashes // TODO: review - if ( *theSrcRow >= mSrcRows ) *theSrcRow = mSrcRows - 1; - if ( *theSrcRow < 0 ) *theSrcRow = 0; - if ( *theSrcCol >= mSrcCols ) *theSrcCol = mSrcCols - 1; - if ( *theSrcCol < 0 ) *theSrcCol = 0; + if ( *theSrcRow >= mSrcRows ) + *theSrcRow = mSrcRows - 1; + if ( *theSrcRow < 0 ) + *theSrcRow = 0; + if ( *theSrcCol >= mSrcCols ) + *theSrcCol = mSrcCols - 1; + if ( *theSrcCol < 0 ) + *theSrcCol = 0; - assert( *theSrcRow < mSrcRows ); - assert( *theSrcCol < mSrcCols ); + Q_ASSERT( *theSrcRow < mSrcRows ); + Q_ASSERT( *theSrcCol < mSrcCols ); } void QgsRasterProjector::approximateSrcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol ) @@ -373,12 +380,16 @@ void QgsRasterProjector::approximateSrcRowCol( int theDestRow, int theDestCol, i // For now silently correct limits to avoid crashes // TODO: review - if ( *theSrcRow >= mSrcRows ) *theSrcRow = mSrcRows - 1; - if ( *theSrcRow < 0 ) *theSrcRow = 0; - if ( *theSrcCol >= mSrcCols ) *theSrcCol = mSrcCols - 1; - if ( *theSrcCol < 0 ) *theSrcCol = 0; - assert( *theSrcRow < mSrcRows ); - assert( *theSrcCol < mSrcCols ); + if ( *theSrcRow >= mSrcRows ) + *theSrcRow = mSrcRows - 1; + if ( *theSrcRow < 0 ) + *theSrcRow = 0; + if ( *theSrcCol >= mSrcCols ) + *theSrcCol = mSrcCols - 1; + if ( *theSrcCol < 0 ) + *theSrcCol = 0; + Q_ASSERT( *theSrcRow < mSrcRows ); + Q_ASSERT( *theSrcCol < mSrcCols ); } void QgsRasterProjector::insertRows() @@ -466,7 +477,8 @@ bool QgsRasterProjector::checkCols() QgsPoint mySrcApprox(( mySrcPoint1.x() + mySrcPoint3.x() ) / 2, ( mySrcPoint1.y() + mySrcPoint3.y() ) / 2 ); QgsPoint myDestApprox = mCoordinateTransform.transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform ); double mySqrDist = myDestApprox.sqrDist( myDestPoint ); - if ( mySqrDist > mSqrTolerance ) { return false; } + if ( mySqrDist > mSqrTolerance ) + return false; } } return true; @@ -489,7 +501,8 @@ bool QgsRasterProjector::checkRows() QgsPoint mySrcApprox(( mySrcPoint1.x() + mySrcPoint3.x() ) / 2, ( mySrcPoint1.y() + mySrcPoint3.y() ) / 2 ); QgsPoint myDestApprox = mCoordinateTransform.transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform ); double mySqrDist = myDestApprox.sqrDist( myDestPoint ); - if ( mySqrDist > mSqrTolerance ) { return false; } + if ( mySqrDist > mSqrTolerance ) + return false; } } return true; diff --git a/src/core/qgsrasterprojector.h b/src/core/qgsrasterprojector.h index 60e29032184..61c6b73ce02 100644 --- a/src/core/qgsrasterprojector.h +++ b/src/core/qgsrasterprojector.h @@ -200,7 +200,7 @@ class QgsRasterProjector /** Maximum source resolution */ double mMaxSrcXRes; double mMaxSrcYRes; - + /** Use approximation */ bool mApproximate; }; diff --git a/src/core/qgsrectangle.cpp b/src/core/qgsrectangle.cpp index 289f2c3c9a7..b322c4271fe 100644 --- a/src/core/qgsrectangle.cpp +++ b/src/core/qgsrectangle.cpp @@ -150,10 +150,12 @@ bool QgsRectangle::intersects( const QgsRectangle& rect ) const { double x1 = ( xmin > rect.xmin ? xmin : rect.xmin ); double x2 = ( xmax < rect.xmax ? xmax : rect.xmax ); - if ( x1 > x2 ) return false; + if ( x1 > x2 ) + return false; double y1 = ( ymin > rect.ymin ? ymin : rect.ymin ); double y2 = ( ymax < rect.ymax ? ymax : rect.ymax ); - if ( y1 > y2 ) return false; + if ( y1 > y2 ) + return false; return true; } @@ -300,10 +302,14 @@ QgsRectangle & QgsRectangle::operator=( const QgsRectangle & r ) void QgsRectangle::unionRect( const QgsRectangle& r ) { - if ( r.xMinimum() < xMinimum() ) setXMinimum( r.xMinimum() ); - if ( r.xMaximum() > xMaximum() ) setXMaximum( r.xMaximum() ); - if ( r.yMinimum() < yMinimum() ) setYMinimum( r.yMinimum() ); - if ( r.yMaximum() > yMaximum() ) setYMaximum( r.yMaximum() ); + if ( r.xMinimum() < xMinimum() ) + setXMinimum( r.xMinimum() ); + if ( r.xMaximum() > xMaximum() ) + setXMaximum( r.xMaximum() ); + if ( r.yMinimum() < yMinimum() ) + setYMinimum( r.yMinimum() ); + if ( r.yMaximum() > yMaximum() ) + setYMaximum( r.yMaximum() ); } bool QgsRectangle::isFinite() const diff --git a/src/core/qgssearchtreenode.cpp b/src/core/qgssearchtreenode.cpp index a99d3028be4..ae0a8ee6621 100644 --- a/src/core/qgssearchtreenode.cpp +++ b/src/core/qgssearchtreenode.cpp @@ -644,19 +644,24 @@ QgsSearchTreeValue QgsSearchTreeNode::valueAgainst( const QgsFieldMap& fields, Q { if ( mLeft->type() != tNodeList ) { - if ( !getValue( value1, mLeft, fields, f ) ) return value1; + if ( !getValue( value1, mLeft, fields, f ) ) + return value1; } else { - if ( mLeft->mNodeList.size() > 0 && !getValue( value1, mLeft->mNodeList[0], fields, f ) ) return value1; - if ( mLeft->mNodeList.size() > 1 && !getValue( value2, mLeft->mNodeList[1], fields, f ) ) return value2; - if ( mLeft->mNodeList.size() > 2 && !getValue( value3, mLeft->mNodeList[2], fields, f ) ) return value3; + if ( mLeft->mNodeList.size() > 0 && !getValue( value1, mLeft->mNodeList[0], fields, f ) ) + return value1; + if ( mLeft->mNodeList.size() > 1 && !getValue( value2, mLeft->mNodeList[1], fields, f ) ) + return value2; + if ( mLeft->mNodeList.size() > 2 && !getValue( value3, mLeft->mNodeList[2], fields, f ) ) + return value3; } } if ( mRight ) { Q_ASSERT( !mLeft || mLeft->type() != tNodeList ); - if ( !getValue( value2, mRight, fields, f ) ) return value2; + if ( !getValue( value2, mRight, fields, f ) ) + return value2; } if ( mOp == opLENGTH || mOp == opAREA || mOp == opPERIMETER || mOp == opX || mOp == opY ) diff --git a/src/core/qgsvectorlayer.cpp b/src/core/qgsvectorlayer.cpp index e0b38a87e44..b3025ca54a6 100644 --- a/src/core/qgsvectorlayer.cpp +++ b/src/core/qgsvectorlayer.cpp @@ -2711,7 +2711,7 @@ bool QgsVectorLayer::setDataProvider( QString const & provider ) //XXX - This was a dynamic cast but that kills the Windows // version big-time with an abnormal termination error mDataProvider = - ( QgsVectorDataProvider* )( QgsProviderRegistry::instance()->getProvider( provider, mDataSource ) ); + ( QgsVectorDataProvider* )( QgsProviderRegistry::instance()->provider( provider, mDataSource ) ); if ( mDataProvider ) { @@ -2902,11 +2902,15 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage if ( returnCode == 1 ) { - errorMessage = tr( "No renderer object" ); delete renderer; return false; + errorMessage = tr( "No renderer object" ); + delete renderer; + return false; } else if ( returnCode == 2 ) { - errorMessage = tr( "Classification field not found" ); delete renderer; return false; + errorMessage = tr( "Classification field not found" ); + delete renderer; + return false; } mRenderer = renderer; @@ -5514,7 +5518,7 @@ QString QgsVectorLayer::metadata() myMetadata += ""; return myMetadata; } - + QgsVectorLayer::ValueRelationData &QgsVectorLayer::valueRelation( int idx ) { const QgsFieldMap &fields = pendingFields(); diff --git a/src/core/raster/qgscontrastenhancement.cpp b/src/core/raster/qgscontrastenhancement.cpp index 84a176c4adb..f3cdd09dbec 100644 --- a/src/core/raster/qgscontrastenhancement.cpp +++ b/src/core/raster/qgscontrastenhancement.cpp @@ -193,10 +193,14 @@ bool QgsContrastEnhancement::generateLookupTable() { mEnhancementDirty = false; - if ( 0 == mContrastEnhancementFunction ) { return false; } - if ( NoEnhancement == mContrastEnhancementAlgorithm ) { return false; } - if ( QGS_Byte != mRasterDataType && QGS_UInt16 != mRasterDataType && QGS_Int16 != mRasterDataType ) { return false; } - if ( !mLookupTable ) { return false; } + if ( !mContrastEnhancementFunction ) + return false; + if ( NoEnhancement == mContrastEnhancementAlgorithm ) + return false; + if ( QGS_Byte != mRasterDataType && QGS_UInt16 != mRasterDataType && QGS_Int16 != mRasterDataType ) + return false; + if ( !mLookupTable ) + return false; QgsDebugMsg( "building lookup table" ); QgsDebugMsg( "***MinimumValue : " + QString::number( mMinimumValue ) ); diff --git a/src/core/raster/qgsrasterlayer.cpp b/src/core/raster/qgsrasterlayer.cpp index 32455e84307..2250cc544f9 100644 --- a/src/core/raster/qgsrasterlayer.cpp +++ b/src/core/raster/qgsrasterlayer.cpp @@ -238,7 +238,8 @@ QDateTime QgsRasterLayer::lastModified( QString const & name ) QFileInfo fi( name ); // Is it file? - if ( !fi.exists() ) return t; + if ( !fi.exists() ) + return t; t = fi.lastModified(); @@ -580,7 +581,8 @@ QString QgsRasterLayer::colorShadingAlgorithmAsString() const */ void QgsRasterLayer::computeMinimumMaximumEstimates( int theBand, double* theMinMax ) { - if ( 0 == theMinMax ) { return; } + if ( !theMinMax ) + return; if ( 0 < theBand && theBand <= ( int ) bandCount() ) { @@ -612,7 +614,8 @@ void QgsRasterLayer::computeMinimumMaximumEstimates( int theBand, double& theMin */ void QgsRasterLayer::computeMinimumMaximumFromLastExtent( int theBand, double* theMinMax ) { - if ( 0 == theMinMax ) { return; } + if ( !theMinMax ) + return; int myDataType = mDataProvider->dataType( theBand ); void* myScanData = readData( theBand, &mLastViewPort ); @@ -2543,7 +2546,7 @@ void QgsRasterLayer::setColorShadingAlgorithm( ColorShadingAlgorithm theShadingA QgsDebugMsg( "called with [" + QString::number( theShadingAlgorithm ) + "]" ); if ( mColorShadingAlgorithm != theShadingAlgorithm ) { - if ( 0 == mRasterShader ) + if ( !mRasterShader ) { mRasterShader = new QgsRasterShader(); } @@ -2898,7 +2901,8 @@ QStringList QgsRasterLayer::subLayers() const void QgsRasterLayer::thumbnailAsPixmap( QPixmap * theQPixmap ) { //TODO: This should be depreciated and a new function written that just returns a new QPixmap, it will be safer - if ( 0 == theQPixmap ) { return; } + if ( !theQPixmap ) + return; theQPixmap->fill( ); //defaults to white @@ -2950,7 +2954,9 @@ void QgsRasterLayer::thumbnailAsPixmap( QPixmap * theQPixmap ) void QgsRasterLayer::thumbnailAsImage( QImage * thepImage ) { //TODO: This should be depreciated and a new function written that just returns a new QImage, it will be safer - if ( 0 == thepImage ) { return; } + if ( !thepImage ) + return; + thepImage->fill( Qt::white ); //defaults to white diff --git a/src/core/symbology-ng/qgscolorbrewerpalette.h b/src/core/symbology-ng/qgscolorbrewerpalette.h index fb10ed02f08..62a8f444e74 100644 --- a/src/core/symbology-ng/qgscolorbrewerpalette.h +++ b/src/core/symbology-ng/qgscolorbrewerpalette.h @@ -33,7 +33,8 @@ class CORE_EXPORT QgsColorBrewerPalette foreach( QString entry, list ) { QStringList items = entry.split( QChar( '-' ) ); - if ( items.count() != 3 ) continue; + if ( items.count() != 3 ) + continue; if ( !schemes.contains( items[0] ) ) schemes << items[0]; } @@ -49,7 +50,8 @@ class CORE_EXPORT QgsColorBrewerPalette foreach( QString entry, list ) { QStringList items = entry.split( QChar( '-' ) ); - if ( items.count() != 3 || items[0] != schemeName ) continue; + if ( items.count() != 3 || items[0] != schemeName ) + continue; variants << items[1].toInt(); } @@ -59,7 +61,8 @@ class CORE_EXPORT QgsColorBrewerPalette static QColor parseColor( QString color ) { QStringList p = color.split( QChar( ',' ) ); - if ( p.count() != 3 ) return QColor(); + if ( p.count() != 3 ) + return QColor(); return QColor( p[0].toInt(), p[1].toInt(), p[2].toInt() ); } diff --git a/src/core/symbology-ng/qgsfillsymbollayerv2.cpp b/src/core/symbology-ng/qgsfillsymbollayerv2.cpp index dce0dc61efb..81549acf789 100644 --- a/src/core/symbology-ng/qgsfillsymbollayerv2.cpp +++ b/src/core/symbology-ng/qgsfillsymbollayerv2.cpp @@ -64,7 +64,8 @@ void QgsSimpleFillSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context QColor selColor = context.selectionColor(); // selColor.setAlphaF( context.alpha() ); mSelBrush = QBrush( selColor ); - if ( selectFillStyle ) mSelBrush.setStyle( mBrushStyle ); + if ( selectFillStyle ) + mSelBrush.setStyle( mBrushStyle ); mBorderColor.setAlphaF( context.alpha() ); mPen = QPen( mBorderColor ); mPen.setStyle( mBorderStyle ); @@ -251,7 +252,8 @@ void QgsSVGFillSymbolLayer::renderPolygon( const QPolygonF& points, QListsetBrush( QBrush( selColor ) ); _renderPolygon( p, points, rings ); } diff --git a/src/core/symbology-ng/qgslinesymbollayerv2.cpp b/src/core/symbology-ng/qgslinesymbollayerv2.cpp index c224670b2c8..4599ea90081 100644 --- a/src/core/symbology-ng/qgslinesymbollayerv2.cpp +++ b/src/core/symbology-ng/qgslinesymbollayerv2.cpp @@ -86,7 +86,8 @@ void QgsSimpleLineSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context mSelPen = mPen; QColor selColor = context.selectionColor(); - if ( ! selectionIsOpaque ) selColor.setAlphaF( context.alpha() ); + if ( ! selectionIsOpaque ) + selColor.setAlphaF( context.alpha() ); mSelPen.setColor( selColor ); } @@ -619,7 +620,8 @@ void QgsLineDecorationSymbolLayerV2::startRender( QgsSymbolV2RenderContext& cont mPen.setWidth( context.outputLineWidth( mWidth ) ); mPen.setColor( penColor ); QColor selColor = context.selectionColor(); - if ( ! selectionIsOpaque ) selColor.setAlphaF( context.alpha() ); + if ( ! selectionIsOpaque ) + selColor.setAlphaF( context.alpha() ); mSelPen.setWidth( context.outputLineWidth( mWidth ) ); mSelPen.setColor( selColor ); } diff --git a/src/core/symbology-ng/qgssinglesymbolrendererv2.cpp b/src/core/symbology-ng/qgssinglesymbolrendererv2.cpp index 214333b7b8e..0c7f66052ea 100644 --- a/src/core/symbology-ng/qgssinglesymbolrendererv2.cpp +++ b/src/core/symbology-ng/qgssinglesymbolrendererv2.cpp @@ -80,8 +80,10 @@ void QgsSingleSymbolRendererV2::startRender( QgsRenderContext& context, const Qg mTempSymbol = mSymbol->clone(); int hints = 0; - if ( mRotationFieldIdx != -1 ) hints |= QgsSymbolV2::DataDefinedRotation; - if ( mSizeScaleFieldIdx != -1 ) hints |= QgsSymbolV2::DataDefinedSizeScale; + if ( mRotationFieldIdx != -1 ) + hints |= QgsSymbolV2::DataDefinedRotation; + if ( mSizeScaleFieldIdx != -1 ) + hints |= QgsSymbolV2::DataDefinedSizeScale; mTempSymbol->setRenderHints( hints ); mTempSymbol->startRender( context ); diff --git a/src/core/symbology-ng/qgssymbollayerv2utils.cpp b/src/core/symbology-ng/qgssymbollayerv2utils.cpp index f41ac72ffdd..786e7a92dac 100644 --- a/src/core/symbology-ng/qgssymbollayerv2utils.cpp +++ b/src/core/symbology-ng/qgssymbollayerv2utils.cpp @@ -366,7 +366,8 @@ QPolygonF offsetLine( QPolygonF polyline, double dist ) // if it's not the first line segment // calc intersection with last line (with offset) QPointF pt_tmp = linesIntersection( pt_old, t_old, pt_new, t_new ); - if ( !pt_tmp.isNull() ) pt_new = pt_tmp; + if ( !pt_tmp.isNull() ) + pt_new = pt_tmp; } newLine.append( pt_new ); diff --git a/src/core/symbology-ng/qgsvectorcolorrampv2.cpp b/src/core/symbology-ng/qgsvectorcolorrampv2.cpp index a71ddc6fc5f..b2b51e3e6fd 100644 --- a/src/core/symbology-ng/qgsvectorcolorrampv2.cpp +++ b/src/core/symbology-ng/qgsvectorcolorrampv2.cpp @@ -25,7 +25,8 @@ QgsVectorColorRampV2* QgsVectorGradientColorRampV2::create( const QgsStringMap& foreach( QString stop, props["stops"].split( ':' ) ) { int i = stop.indexOf( ';' ); - if ( i == -1 ) continue; + if ( i == -1 ) + continue; QColor c = QgsSymbolLayerV2Utils::decodeColor( stop.mid( i + 1 ) ); stops.insert( stop.left( i ).toDouble(), c ); diff --git a/src/core/symbology/qgsmarkercatalogue.cpp b/src/core/symbology/qgsmarkercatalogue.cpp index 00b646251a3..301c9b916cf 100644 --- a/src/core/symbology/qgsmarkercatalogue.cpp +++ b/src/core/symbology/qgsmarkercatalogue.cpp @@ -205,7 +205,8 @@ QPicture QgsMarkerCatalogue::pictureMarker( QString fullName, double size, QPen { // TODO Change this logic so width is size and height is same // proportion of scale factor as in oritignal SVG TS XXX - if ( size < 1 ) size = 1; + if ( size < 1 ) + size = 1; myPicture = QPicture( size ); } diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 010859ee53d..34c6920025c 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -116,7 +116,6 @@ qgsmaptoolemitpoint.h qgsmessageviewer.h qgsnewhttpconnection.h qgsnewvectorlayerdialog.h -qgsnumericsortlistviewitem.h qgscredentialdialog.h qgsprojectionselector.h qgsquickprint.h diff --git a/src/gui/attributetable/qgsattributetableview.cpp b/src/gui/attributetable/qgsattributetableview.cpp index 994fc94bbb0..d322085d7fc 100644 --- a/src/gui/attributetable/qgsattributetableview.cpp +++ b/src/gui/attributetable/qgsattributetableview.cpp @@ -109,7 +109,7 @@ void QgsAttributeTableView::contextMenuEvent( QContextMenuEvent *event ) mActionPopup = new QMenu(); // let some other parts of the application add some actions - emit willShowContextMenu(mActionPopup, idx); + emit willShowContextMenu( mActionPopup, idx ); if ( mActionPopup->actions().count() > 0 ) { diff --git a/src/gui/qgsdetaileditemdelegate.cpp b/src/gui/qgsdetaileditemdelegate.cpp index 6bc2e64c41c..ccb54b73ce3 100644 --- a/src/gui/qgsdetaileditemdelegate.cpp +++ b/src/gui/qgsdetaileditemdelegate.cpp @@ -277,8 +277,10 @@ QStringList QgsDetailedItemDelegate::wordWrap( QString theString, QFontMetrics theMetrics, int theWidth ) const { - if ( theString.isEmpty() ) return QStringList(); - if ( 50 >= theWidth ) return QStringList() << theString; + if ( theString.isEmpty() ) + return QStringList(); + if ( 50 >= theWidth ) + return QStringList() << theString; //QString myDebug = QString("Word wrapping: %1 into %2 pixels").arg(theString).arg(theWidth); //qDebug(myDebug.toLocal8Bit()); //iterate the string diff --git a/src/gui/qgsdetaileditemdelegate.h b/src/gui/qgsdetaileditemdelegate.h index 4e1b5380127..bb50a68c769 100644 --- a/src/gui/qgsdetaileditemdelegate.h +++ b/src/gui/qgsdetaileditemdelegate.h @@ -33,7 +33,7 @@ class QFont; * @see also QgsDetailedItemData */ class GUI_EXPORT QgsDetailedItemDelegate : - public QAbstractItemDelegate + public QAbstractItemDelegate { Q_OBJECT public: diff --git a/src/gui/qgsdetaileditemwidget.h b/src/gui/qgsdetaileditemwidget.h index 4d6f94b6b37..1f8d194324d 100644 --- a/src/gui/qgsdetaileditemwidget.h +++ b/src/gui/qgsdetaileditemwidget.h @@ -26,7 +26,7 @@ * @see also QgsDetailedItem and QgsDetailedItemData. */ class QgsDetailedItemWidget : - public QWidget, private Ui::QgsDetailedItemWidgetBase + public QWidget, private Ui::QgsDetailedItemWidgetBase { Q_OBJECT public: diff --git a/src/gui/qgsmanageconnectionsdialog.cpp b/src/gui/qgsmanageconnectionsdialog.cpp index 72420ea2a7f..8d934b3bd1e 100644 --- a/src/gui/qgsmanageconnectionsdialog.cpp +++ b/src/gui/qgsmanageconnectionsdialog.cpp @@ -395,22 +395,28 @@ void QgsManageConnectionsDialog::loadWMSConnections( const QDomDocument &doc, co // check for duplicates if ( keys.contains( connectionName ) && prompt ) { - int res = QMessageBox::warning( this, tr( "Loading connections" ), + int res = QMessageBox::warning( this, + tr( "Loading connections" ), tr( "Connection with name '%1' already exists. Overwrite?" ) .arg( connectionName ), QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel ); switch ( res ) { - case QMessageBox::Cancel: return; - case QMessageBox::No: child = child.nextSiblingElement(); + case QMessageBox::Cancel: + return; + case QMessageBox::No: + child = child.nextSiblingElement(); continue; - case QMessageBox::Yes: overwrite = true; - break; - case QMessageBox::YesToAll: prompt = false; + case QMessageBox::Yes: overwrite = true; break; - case QMessageBox::NoToAll: prompt = false; + case QMessageBox::YesToAll: + prompt = false; + overwrite = true; + break; + case QMessageBox::NoToAll: + prompt = false; overwrite = false; break; } @@ -471,22 +477,28 @@ void QgsManageConnectionsDialog::loadWFSConnections( const QDomDocument &doc, co // check for duplicates if ( keys.contains( connectionName ) && prompt ) { - int res = QMessageBox::warning( this, tr( "Loading connections" ), + int res = QMessageBox::warning( this, + tr( "Loading connections" ), tr( "Connection with name '%1' already exists. Overwrite?" ) .arg( connectionName ), QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel ); switch ( res ) { - case QMessageBox::Cancel: return; - case QMessageBox::No: child = child.nextSiblingElement(); + case QMessageBox::Cancel: + return; + case QMessageBox::No: + child = child.nextSiblingElement(); continue; - case QMessageBox::Yes: overwrite = true; - break; - case QMessageBox::YesToAll: prompt = false; + case QMessageBox::Yes: overwrite = true; break; - case QMessageBox::NoToAll: prompt = false; + case QMessageBox::YesToAll: + prompt = false; + overwrite = true; + break; + case QMessageBox::NoToAll: + prompt = false; overwrite = false; break; } @@ -554,15 +566,20 @@ void QgsManageConnectionsDialog::loadPgConnections( const QDomDocument &doc, con QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel ); switch ( res ) { - case QMessageBox::Cancel: return; - case QMessageBox::No: child = child.nextSiblingElement(); + case QMessageBox::Cancel: + return; + case QMessageBox::No: + child = child.nextSiblingElement(); continue; - case QMessageBox::Yes: overwrite = true; - break; - case QMessageBox::YesToAll: prompt = false; + case QMessageBox::Yes: overwrite = true; break; - case QMessageBox::NoToAll: prompt = false; + case QMessageBox::YesToAll: + prompt = false; + overwrite = true; + break; + case QMessageBox::NoToAll: + prompt = false; overwrite = false; break; } diff --git a/src/gui/qgsmapcanvas.cpp b/src/gui/qgsmapcanvas.cpp index 0c7299166c2..cfcbeac1650 100644 --- a/src/gui/qgsmapcanvas.cpp +++ b/src/gui/qgsmapcanvas.cpp @@ -518,7 +518,8 @@ void QgsMapCanvas::setExtent( QgsRectangle const & r ) updateScale(); if ( mMapOverview ) mMapOverview->drawExtentRect(); - if ( mLastExtent.size() > 20 ) mLastExtent.removeAt( 0 ); + if ( mLastExtent.size() > 20 ) + mLastExtent.removeAt( 0 ); //clear all extent items after current index for ( int i = mLastExtent.size() - 1; i > mLastExtentIndex; i-- ) diff --git a/src/gui/qgsmapoverviewcanvas.cpp b/src/gui/qgsmapoverviewcanvas.cpp index bee014fa495..4a5f33db10b 100644 --- a/src/gui/qgsmapoverviewcanvas.cpp +++ b/src/gui/qgsmapoverviewcanvas.cpp @@ -127,10 +127,14 @@ void QgsMapOverviewCanvas::drawExtentRect() #if 0 // test whether panning widget should be drawn bool show = false; - if ( ur.x() >= 0 && ur.x() < width() ) show = true; - if ( ll.x() >= 0 && ll.x() < width() ) show = true; - if ( ur.y() >= 0 && ur.y() < height() ) show = true; - if ( ll.y() >= 0 && ll.y() < height() ) show = true; + if ( ur.x() >= 0 && ur.x() < width() ) + show = true; + if ( ll.x() >= 0 && ll.x() < width() ) + show = true; + if ( ur.y() >= 0 && ur.y() < height() ) + show = true; + if ( ll.y() >= 0 && ll.y() < height() ) + show = true; if ( !show ) { QgsDebugMsg( "panning: extent out of overview area" ); @@ -153,8 +157,10 @@ void QgsMapOverviewCanvas::drawExtentRect() // are drawn at odd locations) if both coords are at limit. This may // have something to do with Qt calculating dimensions as x2 - x1 + 1. // (INT_MAX - INT_MIN + 1 is UINT_MAX + 1) - if ( x1 == INT_MIN && x2 == INT_MAX ) x1 += 1; // x2 -= 1 works too - if ( y1 == INT_MIN && y2 == INT_MAX ) y1 += 1; + if ( x1 == INT_MIN && x2 == INT_MAX ) + x1 += 1; // x2 -= 1 works too + if ( y1 == INT_MIN && y2 == INT_MAX ) + y1 += 1; #endif QRect r( x1, y1, x2 - x1 + 1, y2 - y1 + 1 ); diff --git a/src/gui/qgsquickprint.cpp b/src/gui/qgsquickprint.cpp index 796ec28dc19..0f3b0644296 100644 --- a/src/gui/qgsquickprint.cpp +++ b/src/gui/qgsquickprint.cpp @@ -227,7 +227,8 @@ void QgsQuickPrint::printMap() // int myOriginalDpi = mpMapRenderer->outputDpi(); //sensible default to prevent divide by zero - if ( 0 == myOriginalDpi ) myOriginalDpi = 96; + if ( 0 == myOriginalDpi ) + myOriginalDpi = 96; QSize myOriginalSize = mpMapRenderer->outputSize(); //define the font sizes and family @@ -797,7 +798,8 @@ void QgsQuickPrint::renderPrintScaleBar( QPainter * thepPainter, // // Exit if the canvas width is 0 or layercount is 0 or QGIS will freeze int myLayerCount = thepMapRenderer->layerSet().count(); - if ( !myLayerCount || !myMapUnitsPerPixelDouble ) return; + if ( !myLayerCount || !myMapUnitsPerPixelDouble ) + return; //Calculate size of scale bar for preferred number of map units double myScaleBarWidth = myPreferredSize; @@ -1072,9 +1074,8 @@ QString QgsQuickPrint::pageSizeToString( QPrinter::PageSize theSize ) if ( theSize == QPrinter::Ledger ) return "QPrinter::Ledger"; if ( theSize == QPrinter::Legal ) return "QPrinter::Legal"; if ( theSize == QPrinter::Letter ) return "QPrinter::Letter"; - //falback + //fallback return "QPrinter::A4"; - } QPrinter::PageSize QgsQuickPrint::stringToPageSize( QString theSize ) @@ -1108,10 +1109,6 @@ QPrinter::PageSize QgsQuickPrint::stringToPageSize( QString theSize ) if ( theSize == "QPrinter::Ledger" ) return QPrinter::Ledger; if ( theSize == "QPrinter::Legal" ) return QPrinter::Legal; if ( theSize == "QPrinter::Letter" ) return QPrinter::Letter; - //falback + //fallback return QPrinter::A4; - } - - - diff --git a/src/gui/symbology-ng/qgsrulebasedrendererv2widget.cpp b/src/gui/symbology-ng/qgsrulebasedrendererv2widget.cpp index 6793d703747..d1b12c375ca 100644 --- a/src/gui/symbology-ng/qgsrulebasedrendererv2widget.cpp +++ b/src/gui/symbology-ng/qgsrulebasedrendererv2widget.cpp @@ -120,7 +120,8 @@ void QgsRuleBasedRendererV2Widget::addRule() void QgsRuleBasedRendererV2Widget::editRule() { QTreeWidgetItem * item = treeRules->currentItem(); - if ( ! item ) return; + if ( ! item ) + return; int rule_index = item->data( 0, Qt::UserRole + 1 ).toInt(); if ( rule_index < 0 ) @@ -144,7 +145,8 @@ void QgsRuleBasedRendererV2Widget::editRule() void QgsRuleBasedRendererV2Widget::removeRule() { QTreeWidgetItem * item = treeRules->currentItem(); - if ( ! item ) return; + if ( ! item ) + return; int rule_index = item->data( 0, Qt::UserRole + 1 ).toInt(); if ( rule_index < 0 ) @@ -182,10 +184,12 @@ void QgsRuleBasedRendererV2Widget::removeRule() void QgsRuleBasedRendererV2Widget::refineRule( int type ) { QTreeWidgetItem * item = treeRules->currentItem(); - if ( ! item ) return; + if ( ! item ) + return; int rule_index = item->data( 0, Qt::UserRole + 1 ).toInt(); - if ( rule_index < 0 ) return; + if ( rule_index < 0 ) + return; QgsRuleBasedRendererV2::Rule& initialRule = mRenderer->ruleAt( rule_index ); @@ -429,7 +433,8 @@ QString QgsRendererRulesTreeWidget::formatScale( int denom, int size ) #include "qgslogger.h" void QgsRendererRulesTreeWidget::populateRules() { - if ( !mR ) return; + if ( !mR ) + return; clear(); @@ -473,7 +478,8 @@ void QgsRendererRulesTreeWidget::populateRulesNoGrouping() item->setIcon( 0, QgsSymbolLayerV2Utils::symbolPreviewIcon( rule.symbol(), QSize( 16, 16 ) ) ); QString txtRule = rule.filterExpression(); - if ( txtRule.isEmpty() ) txtRule = tr( "(no filter)" ); + if ( txtRule.isEmpty() ) + txtRule = tr( "(no filter)" ); item->setText( 1, txtRule ); if ( rule.dependsOnScale() ) @@ -536,7 +542,8 @@ void QgsRendererRulesTreeWidget::populateRulesGroupByScale() item->setIcon( 0, QgsSymbolLayerV2Utils::symbolPreviewIcon( rule.symbol(), QSize( 16, 16 ) ) ); QString txtRule = rule.filterExpression(); - if ( txtRule.isEmpty() ) txtRule = tr( "(no filter)" ); + if ( txtRule.isEmpty() ) + txtRule = tr( "(no filter)" ); item->setText( 1, txtRule ); if ( rule.dependsOnScale() ) diff --git a/src/gui/symbology-ng/qgsstylev2exportimportdialog.cpp b/src/gui/symbology-ng/qgsstylev2exportimportdialog.cpp index cef4324f80f..129bafa3042 100644 --- a/src/gui/symbology-ng/qgsstylev2exportimportdialog.cpp +++ b/src/gui/symbology-ng/qgsstylev2exportimportdialog.cpp @@ -205,14 +205,19 @@ void QgsStyleV2ExportImportDialog::moveStyles( QModelIndexList* selection, QgsSt QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel ); switch ( res ) { - case QMessageBox::Cancel: return; - case QMessageBox::No: continue; - case QMessageBox::Yes: dst->addSymbol( symbolName, symbol ); + case QMessageBox::Cancel: + return; + case QMessageBox::No: continue; - case QMessageBox::YesToAll: prompt = false; + case QMessageBox::Yes: + dst->addSymbol( symbolName, symbol ); + continue; + case QMessageBox::YesToAll: + prompt = false; overwrite = true; break; - case QMessageBox::NoToAll: prompt = false; + case QMessageBox::NoToAll: + prompt = false; overwrite = false; break; } @@ -241,11 +246,15 @@ void QgsStyleV2ExportImportDialog::moveStyles( QModelIndexList* selection, QgsSt QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel ); switch ( res ) { - case QMessageBox::Cancel: return; - case QMessageBox::No: continue; - case QMessageBox::Yes: dst->addColorRamp( symbolName, ramp ); + case QMessageBox::Cancel: + return; + case QMessageBox::No: continue; - case QMessageBox::YesToAll: prompt = false; + case QMessageBox::Yes: + dst->addColorRamp( symbolName, ramp ); + continue; + case QMessageBox::YesToAll: + prompt = false; overwrite = true; break; case QMessageBox::NoToAll: prompt = false; diff --git a/src/gui/symbology-ng/qgsstylev2managerdialog.cpp b/src/gui/symbology-ng/qgsstylev2managerdialog.cpp index ee13c7fd521..89acbceeaec 100644 --- a/src/gui/symbology-ng/qgsstylev2managerdialog.cpp +++ b/src/gui/symbology-ng/qgsstylev2managerdialog.cpp @@ -83,10 +83,17 @@ void QgsStyleV2ManagerDialog::populateTypes() { switch ( mStyle->symbolRef( symbolNames[i] )->type() ) { - case QgsSymbolV2::Marker: markerCount++; break; - case QgsSymbolV2::Line: lineCount++; break; - case QgsSymbolV2::Fill: fillCount++; break; - default: Q_ASSERT( 0 && "unknown symbol type" ); break; + case QgsSymbolV2::Marker: + markerCount++; + break; + case QgsSymbolV2::Line: + lineCount++; + break; + case QgsSymbolV2::Fill: + fillCount++; + break; + default: Q_ASSERT( 0 && "unknown symbol type" ); + break; } } @@ -216,10 +223,18 @@ bool QgsStyleV2ManagerDialog::addSymbol() QgsSymbolV2* symbol; switch ( currentItemType() ) { - case QgsSymbolV2::Marker: symbol = new QgsMarkerSymbolV2(); break; - case QgsSymbolV2::Line: symbol = new QgsLineSymbolV2(); break; - case QgsSymbolV2::Fill: symbol = new QgsFillSymbolV2(); break; - default: Q_ASSERT( 0 && "unknown symbol type" ); return false; break; + case QgsSymbolV2::Marker: + symbol = new QgsMarkerSymbolV2(); + break; + case QgsSymbolV2::Line: + symbol = new QgsLineSymbolV2(); + break; + case QgsSymbolV2::Fill: + symbol = new QgsFillSymbolV2(); + break; + default: + Q_ASSERT( 0 && "unknown symbol type" ); + return false; } // get symbol design diff --git a/src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp b/src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp index 578543d3af4..27417245de7 100644 --- a/src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp +++ b/src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp @@ -300,7 +300,7 @@ void QgsSymbolV2PropertiesDialog::layerChanged() // get layer info QgsSymbolLayerV2* layer = currentLayer(); - if ( layer == NULL ) + if ( !layer ) return; // update layer type combo box @@ -316,8 +316,8 @@ void QgsSymbolV2PropertiesDialog::layerChanged() void QgsSymbolV2PropertiesDialog::updateLockButton() { QgsSymbolLayerV2* layer = currentLayer(); - if ( layer == NULL ) return; - + if ( !layer ) + return; btnLock->setChecked( layer->isLocked() ); } @@ -325,8 +325,8 @@ void QgsSymbolV2PropertiesDialog::updateLockButton() void QgsSymbolV2PropertiesDialog::layerTypeChanged() { QgsSymbolLayerV2* layer = currentLayer(); - if ( layer == NULL ) return; - + if ( !layer ) + return; QString newLayerType = cboLayerType->itemData( cboLayerType->currentIndex() ).toString(); if ( layer->layerType() == newLayerType ) return; @@ -372,7 +372,8 @@ void QgsSymbolV2PropertiesDialog::addLayer() void QgsSymbolV2PropertiesDialog::removeLayer() { int idx = currentLayerIndex(); - if ( idx < 0 ) return; + if ( idx < 0 ) + return; int row = currentRowIndex(); mSymbol->deleteSymbolLayer( idx ); @@ -417,8 +418,8 @@ void QgsSymbolV2PropertiesDialog::moveLayerByOffset( int offset ) void QgsSymbolV2PropertiesDialog::lockLayer() { QgsSymbolLayerV2* layer = currentLayer(); - if ( layer == NULL ) return; - + if ( !layer ) + return; layer->setLocked( btnLock->isChecked() ); } diff --git a/src/gui/symbology-ng/qgsvectorgradientcolorrampv2dialog.cpp b/src/gui/symbology-ng/qgsvectorgradientcolorrampv2dialog.cpp index 917679fd746..07df93d2866 100644 --- a/src/gui/symbology-ng/qgsvectorgradientcolorrampv2dialog.cpp +++ b/src/gui/symbology-ng/qgsvectorgradientcolorrampv2dialog.cpp @@ -129,9 +129,9 @@ void QgsVectorGradientColorRampV2Dialog::stopDoubleClicked( QTreeWidgetItem* ite if ( column == 0 ) { #if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA) - // Native Mac dialog works only for Qt Carbon - // Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889 - // FIXME need to also check max QT_VERSION when Qt bug fixed + // Native Mac dialog works only for Qt Carbon + // Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889 + // FIXME need to also check max QT_VERSION when Qt bug fixed QColor color = QColorDialog::getColor( item->data( 0, StopColorRole ).value(), this, "", QColorDialog::DontUseNativeDialog ); #else QColor color = QColorDialog::getColor( item->data( 0, StopColorRole ).value(), this ); diff --git a/src/mapserver/qgis_map_serv.cpp b/src/mapserver/qgis_map_serv.cpp index f4e5821d17b..5dbde3036ca 100644 --- a/src/mapserver/qgis_map_serv.cpp +++ b/src/mapserver/qgis_map_serv.cpp @@ -296,7 +296,7 @@ int main( int argc, char * argv[] ) if ( requestIt->second == "GetCapabilities" ) { const QDomDocument* capabilitiesDocument = capabilitiesCache.searchCapabilitiesDocument( configFilePath ); - if( !capabilitiesDocument ) //capabilities xml not in cache. Create a new one + if ( !capabilitiesDocument ) //capabilities xml not in cache. Create a new one { QgsMSDebugMsg( "Capabilities document not found in cache" ); QDomDocument doc; @@ -319,7 +319,7 @@ int main( int argc, char * argv[] ) QgsMSDebugMsg( "Found capabilities document in cache" ); } - if( capabilitiesDocument ) + if ( capabilitiesDocument ) { theRequestHandler->sendGetCapabilitiesResponse( *capabilitiesDocument ); } diff --git a/src/mapserver/qgscapabilitiescache.cpp b/src/mapserver/qgscapabilitiescache.cpp index 7253c94e838..4989ba86b64 100644 --- a/src/mapserver/qgscapabilitiescache.cpp +++ b/src/mapserver/qgscapabilitiescache.cpp @@ -32,19 +32,19 @@ const QDomDocument* QgsCapabilitiesCache::searchCapabilitiesDocument( const QStr { QCoreApplication::processEvents(); //get updates from file system watcher QHash< QString, QDomDocument >::const_iterator it = mCachedCapabilities.find( configFilePath ); - if( it == mCachedCapabilities.constEnd() ) + if ( it == mCachedCapabilities.constEnd() ) { return 0; } else { - return &(it.value()); + return &( it.value() ); } } void QgsCapabilitiesCache::insertCapabilitiesDocument( const QString& configFilePath, const QDomDocument* doc ) { - if( mCachedCapabilities.size() > 40 ) + if ( mCachedCapabilities.size() > 40 ) { //remove another cache entry to avoid memory problems QHash::iterator capIt = mCachedCapabilities.begin(); @@ -59,7 +59,7 @@ void QgsCapabilitiesCache::removeChangedEntry( const QString& path ) { QgsMSDebugMsg( "Remove capabilities cache entry because file changed" ); QHash< QString, QDomDocument >::iterator it = mCachedCapabilities.find( path ); - if( it != mCachedCapabilities.end() ) + if ( it != mCachedCapabilities.end() ) { mCachedCapabilities.erase( it ); } diff --git a/src/mapserver/qgscapabilitiescache.h b/src/mapserver/qgscapabilitiescache.h index 086ba3f7121..897ef159251 100644 --- a/src/mapserver/qgscapabilitiescache.h +++ b/src/mapserver/qgscapabilitiescache.h @@ -26,7 +26,7 @@ /**A cache for capabilities xml documents (by configuration file path)*/ class QgsCapabilitiesCache: public QObject { - Q_OBJECT + Q_OBJECT public: QgsCapabilitiesCache(); ~QgsCapabilitiesCache(); diff --git a/src/mapserver/qgswmsserver.cpp b/src/mapserver/qgswmsserver.cpp index eb6bd707ad3..5278e4e46ce 100644 --- a/src/mapserver/qgswmsserver.cpp +++ b/src/mapserver/qgswmsserver.cpp @@ -868,13 +868,17 @@ int QgsWMSServer::configureMapRender( const QPaintDevice* paintDevice ) const bool bboxOk = true; QString bbString = bbIt->second; minx = bbString.section( ",", 0, 0 ).toDouble( &conversionSuccess ); - if ( !conversionSuccess ) {bboxOk = false;} + if ( !conversionSuccess ) + bboxOk = false; miny = bbString.section( ",", 1, 1 ).toDouble( &conversionSuccess ); - if ( !conversionSuccess ) {bboxOk = false;} + if ( !conversionSuccess ) + bboxOk = false; maxx = bbString.section( ",", 2, 2 ).toDouble( &conversionSuccess ); - if ( !conversionSuccess ) {bboxOk = false;} + if ( !conversionSuccess ) + bboxOk = false; maxy = bbString.section( ",", 3, 3 ).toDouble( &conversionSuccess ); - if ( !conversionSuccess ) {bboxOk = false;} + if ( !conversionSuccess ) + bboxOk = false; if ( !bboxOk ) { diff --git a/src/plugins/delimited_text/qgsdelimitedtextplugingui.cpp b/src/plugins/delimited_text/qgsdelimitedtextplugingui.cpp index 24a0c247c09..85247c0d6de 100644 --- a/src/plugins/delimited_text/qgsdelimitedtextplugingui.cpp +++ b/src/plugins/delimited_text/qgsdelimitedtextplugingui.cpp @@ -165,11 +165,16 @@ void QgsDelimitedTextPluginGui::on_buttonBox_rejected() QString QgsDelimitedTextPluginGui::selectedChars() { QString chars = ""; - if ( cbxDelimSpace->isChecked() ) chars += " "; - if ( cbxDelimTab->isChecked() ) chars += "\\t"; - if ( cbxDelimSemicolon->isChecked() ) chars += ";"; - if ( cbxDelimComma->isChecked() ) chars += ","; - if ( cbxDelimColon->isChecked() ) chars += ":"; + if ( cbxDelimSpace->isChecked() ) + chars += " "; + if ( cbxDelimTab->isChecked() ) + chars += "\\t"; + if ( cbxDelimSemicolon->isChecked() ) + chars += ";"; + if ( cbxDelimComma->isChecked() ) + chars += ","; + if ( cbxDelimColon->isChecked() ) + chars += ":"; return chars; } @@ -254,7 +259,8 @@ void QgsDelimitedTextPluginGui::updateFieldLists() cmbYField->setEnabled( false ); cmbWktField->setEnabled( false ); - if ( ! haveValidFileAndDelimiters() ) return; + if ( ! haveValidFileAndDelimiters() ) + return; QFile file( txtFilePath->text() ); if ( !file.open( QIODevice::ReadOnly ) ) diff --git a/src/plugins/diagram_overlay/qgssvgdiagramfactorywidget.cpp b/src/plugins/diagram_overlay/qgssvgdiagramfactorywidget.cpp index ecaa335640e..6a44778715e 100644 --- a/src/plugins/diagram_overlay/qgssvgdiagramfactorywidget.cpp +++ b/src/plugins/diagram_overlay/qgssvgdiagramfactorywidget.cpp @@ -62,7 +62,8 @@ QgsDiagramFactory* QgsSVGDiagramFactoryWidget::createFactory() QgsSVGDiagramFactory* factory = new QgsSVGDiagramFactory(); if ( !factory->setSVGData( svgData, filePath ) ) { - delete factory; return 0; + delete factory; + return 0; } return factory; @@ -194,7 +195,8 @@ int QgsSVGDiagramFactoryWidget::addDirectoryToPreview( const QString& path ) //exclude files that are not svg or image if ( !fileIsSvg ) { - ++counter; continue; + ++counter; + continue; } QListWidgetItem * listItem = new QListWidgetItem( mPreviewListWidget ); diff --git a/src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.cpp b/src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.cpp index de6149bf1c3..993262fbc18 100644 --- a/src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.cpp +++ b/src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.cpp @@ -266,7 +266,8 @@ bool eVisGenericEventBrowserGui::initBrowser( ) mFeatureIds = mVectorLayer->selectedFeaturesIds( ).toList( ); } - if ( 0 == mFeatureIds.size( ) ) { return false; } + if ( 0 == mFeatureIds.size( ) ) + return false; //get the first feature in the list so we can set the field in the pulldown menues QgsFeature* myFeature = featureAtId( mFeatureIds.at( mCurrentFeatureIndex ) ); @@ -534,7 +535,8 @@ void eVisGenericEventBrowserGui::displayImage( ) //get a copy of the feature QgsFeature* myFeature = featureAtId( mFeatureIds.at( mCurrentFeatureIndex ) ); - if ( 0 == myFeature ) { return; } + if ( 0 == myFeature ) + return; QgsPoint myPoint = myFeature->geometry( )->asPoint( ); myPoint = mCanvas->mapRenderer( )->layerToMapCoordinates( mVectorLayer, myPoint ); @@ -581,7 +583,8 @@ void eVisGenericEventBrowserGui::loadRecord( ) QgsFeature* myFeature; myFeature = featureAtId( mFeatureIds.at( mCurrentFeatureIndex ) ); - if ( 0 == myFeature ) { return; } + if ( 0 == myFeature ) + return; QString myCompassBearingField = cboxCompassBearingField->currentText( ); QString myCompassOffsetField = cboxCompassOffsetField->currentText( ); @@ -834,7 +837,8 @@ void eVisGenericEventBrowserGui::on_cboxEventImagePathField_currentIndexChanged( QgsFieldMap myFieldMap = mDataProvider->fields( ); QgsFeature* myFeature = featureAtId( mFeatureIds.at( mCurrentFeatureIndex ) ); - if ( 0 == myFeature ) { return; } + if ( 0 == myFeature ) + return; QgsAttributeMap myAttributeMap = myFeature->attributeMap( ); for ( QgsAttributeMap::const_iterator it = myAttributeMap.begin( ); it != myAttributeMap.end( ); ++it ) @@ -860,7 +864,8 @@ void eVisGenericEventBrowserGui::on_cboxCompassBearingField_currentIndexChanged( QgsFieldMap myFieldMap = mDataProvider->fields( ); QgsFeature* myFeature = featureAtId( mFeatureIds.at( mCurrentFeatureIndex ) ); - if ( 0 == myFeature ) { return; } + if ( 0 == myFeature ) + return; QgsAttributeMap myAttributeMap = myFeature->attributeMap( ); for ( QgsAttributeMap::const_iterator it = myAttributeMap.begin( ); it != myAttributeMap.end( ); ++it ) @@ -886,7 +891,8 @@ void eVisGenericEventBrowserGui::on_cboxCompassOffsetField_currentIndexChanged( QgsFieldMap myFieldMap = mDataProvider->fields( ); QgsFeature* myFeature = featureAtId( mFeatureIds.at( mCurrentFeatureIndex ) ); - if ( 0 == myFeature ) { return; } + if ( 0 == myFeature ) + return; QgsAttributeMap myAttributeMap = myFeature->attributeMap( ); for ( QgsAttributeMap::const_iterator it = myAttributeMap.begin( ); it != myAttributeMap.end( ); ++it ) @@ -1110,7 +1116,8 @@ void eVisGenericEventBrowserGui::renderSymbol( QPainter* thePainter ) //Get a pointer to the current feature QgsFeature* myFeature = featureAtId( mFeatureIds.at( mCurrentFeatureIndex ) ); - if ( 0 == myFeature ) { return; } + if ( 0 == myFeature ) + return; QgsPoint myPoint = myFeature->geometry( )->asPoint( ); myPoint = mCanvas->mapRenderer( )->layerToMapCoordinates( mVectorLayer, myPoint ); diff --git a/src/plugins/evis/idtool/eviseventidtool.cpp b/src/plugins/evis/idtool/eviseventidtool.cpp index bb14478a9ae..f3caa2505bf 100644 --- a/src/plugins/evis/idtool/eviseventidtool.cpp +++ b/src/plugins/evis/idtool/eviseventidtool.cpp @@ -60,7 +60,8 @@ eVisEventIdTool::eVisEventIdTool( QgsMapCanvas* theCanvas ) */ void eVisEventIdTool::canvasReleaseEvent( QMouseEvent* theMouseEvent ) { - if ( 0 == mCanvas || 0 == theMouseEvent ) { return; } + if ( 0 == mCanvas || 0 == theMouseEvent ) + return; //Check to see if there is a layer selected if ( mCanvas->currentLayer( ) ) @@ -88,19 +89,20 @@ void eVisEventIdTool::canvasReleaseEvent( QMouseEvent* theMouseEvent ) void eVisEventIdTool::select( QgsPoint thePoint ) { - if ( 0 == mCanvas ) { return; } - + if ( 0 == mCanvas ) + return; + QgsVectorLayer* myLayer = ( QgsVectorLayer* )mCanvas->currentLayer( ); - + // create the search rectangle. this was modeled after the QgsMapIdentifyTool in core QGIS application double searchWidth = mCanvas->extent( ).width( ) * (( double )QGis::DEFAULT_IDENTIFY_RADIUS / 100.0 ); - + QgsRectangle myRectangle; myRectangle.setXMinimum( thePoint.x( ) - searchWidth ); myRectangle.setXMaximum( thePoint.x( ) + searchWidth ); myRectangle.setYMinimum( thePoint.y( ) - searchWidth ); myRectangle.setYMaximum( thePoint.y( ) + searchWidth ); - + //Transform rectange to map coordinates myRectangle = toLayerCoordinates( myLayer, myRectangle ); @@ -108,7 +110,7 @@ void eVisEventIdTool::select( QgsPoint thePoint ) myLayer->removeSelection( false ); //select features myLayer->select( QgsAttributeList(), myRectangle, true, true ); - + QgsFeature f; QgsFeatureIds newSelectedFeatures; while ( myLayer->nextFeature( f ) ) @@ -117,7 +119,7 @@ void eVisEventIdTool::select( QgsPoint thePoint ) } myLayer->setSelectedFeatures( newSelectedFeatures ); - + //Launch a new event browser to view selected features mBrowser = new eVisGenericEventBrowserGui( mCanvas, mCanvas, NULL ); mBrowser->setAttribute( Qt::WA_DeleteOnClose ); diff --git a/src/plugins/georeferencer/qgsgcplist.cpp b/src/plugins/georeferencer/qgsgcplist.cpp index 63f2447420d..6fd80c536df 100644 --- a/src/plugins/georeferencer/qgsgcplist.cpp +++ b/src/plugins/georeferencer/qgsgcplist.cpp @@ -61,7 +61,8 @@ int QgsGCPList::size() const const_iterator it = begin(); while ( it != end() ) { - if (( *it )->isEnabled() ) s++; + if (( *it )->isEnabled() ) + s++; it++; } return s; diff --git a/src/plugins/georeferencer/qgsgeorefplugingui.cpp b/src/plugins/georeferencer/qgsgeorefplugingui.cpp index 2cc9bb3b4d5..a44398db917 100644 --- a/src/plugins/georeferencer/qgsgeorefplugingui.cpp +++ b/src/plugins/georeferencer/qgsgeorefplugingui.cpp @@ -751,7 +751,8 @@ void QgsGeorefPluginGui::updateMouseCoordinatePrecision() dp = QgsProject::instance()->readNumEntry( "PositionPrecision", "/DecimalPlaces" ); // Keep dp sensible - if ( dp < 0 ) dp = 0; + if ( dp < 0 ) + dp = 0; mMousePrecisionDecimalPlaces = dp; } @@ -1872,10 +1873,18 @@ QgsRectangle QgsGeorefPluginGui::transformViewportBoundingBox( const QgsRectangl QgsPoint src, raster; switch ( edge ) { - case 0: src = QgsPoint( oX + ( double )s*stepX, oY ); break; - case 1: src = QgsPoint( oX + ( double )s*stepX, dY ); break; - case 2: src = QgsPoint( oX, oY + ( double )s*stepY ); break; - case 3: src = QgsPoint( dX, oY + ( double )s*stepY ); break; + case 0: + src = QgsPoint( oX + ( double )s * stepX, oY ); + break; + case 1: + src = QgsPoint( oX + ( double )s * stepX, dY ); + break; + case 2: + src = QgsPoint( oX, oY + ( double )s * stepY ); + break; + case 3: + src = QgsPoint( dX, oY + ( double )s * stepY ); + break; } t.transform( src, raster, rasterToWorld ); minX = qMin( raster.x(), minX ); diff --git a/src/plugins/georeferencer/qgsgeoreftransform.cpp b/src/plugins/georeferencer/qgsgeoreftransform.cpp index 941dd89aa9d..9f65d19165e 100644 --- a/src/plugins/georeferencer/qgsgeoreftransform.cpp +++ b/src/plugins/georeferencer/qgsgeoreftransform.cpp @@ -246,7 +246,6 @@ QgsGeorefTransformInterface *QgsGeorefTransform::createImplementation( Transform case ThinPlateSpline: return new QgsGDALGeorefTransform( true, 0 ); case Projective: return new QgsProjectiveGeorefTransform; default: return NULL; - break; } } @@ -310,7 +309,8 @@ bool QgsGeorefTransform::gdal_transform( const QgsPoint &src, QgsPoint &dst, int { GDALTransformerFunc t = GDALTransformer(); // Fail if no transformer function was returned - if ( !t ) return false; + if ( !t ) + return false; // Copy the source coordinate for inplace transform double x = src.x(); @@ -492,7 +492,8 @@ QgsGDALGeorefTransform::~QgsGDALGeorefTransform() bool QgsGDALGeorefTransform::updateParametersFromGCPs( const std::vector &mapCoords, const std::vector &pixelCoords ) { assert( mapCoords.size() == pixelCoords.size() ); - if ( mapCoords.size() != pixelCoords.size() ) return false; + if ( mapCoords.size() != pixelCoords.size() ) + return false; int n = mapCoords.size(); GDAL_GCP *GCPList = new GDAL_GCP[n]; @@ -533,7 +534,8 @@ uint QgsGDALGeorefTransform::getMinimumGCPCount() const GDALTransformerFunc QgsGDALGeorefTransform::GDALTransformer() const { // Fail if no arguments were calculated through updateParametersFromGCP - if ( !mGDALTransformerArgs ) return NULL; + if ( !mGDALTransformerArgs ) + return NULL; if ( mIsTPSTransform ) return GDALTPSTransform; diff --git a/src/plugins/georeferencer/qgsimagewarper.cpp b/src/plugins/georeferencer/qgsimagewarper.cpp index e0d2b08adc1..53898323eb0 100644 --- a/src/plugins/georeferencer/qgsimagewarper.cpp +++ b/src/plugins/georeferencer/qgsimagewarper.cpp @@ -51,7 +51,8 @@ bool QgsImageWarper::openSrcDSAndGetWarpOpt( const QString &input, const Resampl // Open input file GDALAllRegister(); hSrcDS = GDALOpen( TO8F( input ), GA_ReadOnly ); - if ( hSrcDS == NULL ) return false; + if ( !hSrcDS ) + return false; // Setup warp options. psWarpOptions = GDALCreateWarpOptions(); @@ -80,7 +81,7 @@ bool QgsImageWarper::createDestinationDataset( { // create the output file GDALDriverH driver = GDALGetDriverByName( "GTiff" ); - if ( driver == NULL ) + if ( !driver ) { return false; } @@ -91,7 +92,7 @@ bool QgsImageWarper::createDestinationDataset( GDALGetRasterCount( hSrcDS ), GDALGetRasterDataType( GDALGetRasterBand( hSrcDS, 1 ) ), papszOptions ); - if ( hDstDS == NULL ) + if ( !hDstDS ) { return false; } @@ -187,12 +188,16 @@ int QgsImageWarper::warpFile( const QString& input, if ( destResX != 0.0 || destResY != 0.0 ) { // If only one scale has been specified, fill in the other from the GDAL suggestion - if ( destResX == 0.0 ) destResX = adfGeoTransform[1]; - if ( destResY == 0.0 ) destResY = adfGeoTransform[5]; + if ( destResX == 0.0 ) + destResX = adfGeoTransform[1]; + if ( destResY == 0.0 ) + destResY = adfGeoTransform[5]; // Make sure user-specified coordinate system has canonical orientation - if ( destResX < 0.0 ) destResX = -destResX; - if ( destResY > 0.0 ) destResY = -destResY; + if ( destResX < 0.0 ) + destResX = -destResX; + if ( destResY > 0.0 ) + destResY = -destResY; // Assert that the north-up convention is fullfiled by GDALSuggestedWarpOutput (should always be the case) assert( adfGeoTransform[0] > 0.0 ); @@ -289,7 +294,7 @@ int QgsImageWarper::GeoToPixelTransform( void *pTransformerArg, int bDstToSrc, i double *x, double *y, double *z, int *panSuccess ) { TransformChain *chain = static_cast( pTransformerArg ); - if ( chain == NULL ) + if ( !chain ) { return false; } @@ -304,7 +309,8 @@ int QgsImageWarper::GeoToPixelTransform( void *pTransformerArg, int bDstToSrc, i // Transform from georeferenced to pixel/line for ( int i = 0; i < nPointCount; ++i ) { - if ( !panSuccess[i] ) continue; + if ( !panSuccess[i] ) + continue; double xP = x[i]; double yP = y[i]; x[i] = chain->adfInvGeotransform[0] + xP * chain->adfInvGeotransform[1] + yP * chain->adfInvGeotransform[2]; diff --git a/src/plugins/georeferencer/qgstransformsettingsdialog.cpp b/src/plugins/georeferencer/qgstransformsettingsdialog.cpp index 729ba15e863..a78d81fcf24 100644 --- a/src/plugins/georeferencer/qgstransformsettingsdialog.cpp +++ b/src/plugins/georeferencer/qgstransformsettingsdialog.cpp @@ -69,9 +69,11 @@ QgsTransformSettingsDialog::QgsTransformSettingsDialog( const QString &raster, c cbxUserResolution->setChecked( s.value( "/Plugin-Georeferencer/user_specified_resolution", false ).toBool() ); bool ok; dsbHorizRes->setValue( s.value( "/Plugin-GeoReferencer/user_specified_resx", 1.0 ).toDouble( &ok ) ); - if ( !ok ) dsbHorizRes->setValue( 1.0 ); + if ( !ok ) + dsbHorizRes->setValue( 1.0 ); dsbVerticalRes->setValue( s.value( "/Plugin-GeoReferencer/user_specified_resy", -1.0 ).toDouble( &ok ) ); - if ( !ok ) dsbHorizRes->setValue( -1.0 ); + if ( !ok ) + dsbHorizRes->setValue( -1.0 ); // Activate spin boxes for vertical/horizontal resolution, if the option is checked dsbHorizRes->setEnabled( cbxUserResolution->isChecked() ); diff --git a/src/plugins/gps_importer/qgsgpsplugin.cpp b/src/plugins/gps_importer/qgsgpsplugin.cpp index 4050d58c49c..6e50f65c2f6 100644 --- a/src/plugins/gps_importer/qgsgpsplugin.cpp +++ b/src/plugins/gps_importer/qgsgpsplugin.cpp @@ -320,14 +320,10 @@ void QgsGPSPlugin::convertGPSFile( QString inputFileName, switch ( convertType ) { - case 0: - convertStrings << "-x" << "transform,wpt=rte,del"; break; - case 1: - convertStrings << "-x" << "transform,rte=wpt,del"; break; - case 2: - convertStrings << "-x" << "transform,trk=wpt,del"; break; - case 3: - convertStrings << "-x" << "transform,wpt=trk,del"; break; + case 0: convertStrings << "-x" << "transform,wpt=rte,del"; break; + case 1: convertStrings << "-x" << "transform,rte=wpt,del"; break; + case 2: convertStrings << "-x" << "transform,trk=wpt,del"; break; + case 3: convertStrings << "-x" << "transform,wpt=trk,del"; break; default: QgsDebugMsg( "Illegal conversion index!" ); return; diff --git a/src/plugins/grass/qgsgrassattributes.cpp b/src/plugins/grass/qgsgrassattributes.cpp index e4674fdcb48..b72538c440e 100644 --- a/src/plugins/grass/qgsgrassattributes.cpp +++ b/src/plugins/grass/qgsgrassattributes.cpp @@ -138,7 +138,8 @@ int QgsGrassAttributes::addTab( const QString & label ) { bool ok = settings.contains( path + QString::number( i ) ); int cw = settings.value( path + QString::number( i ), 30 ).toInt(); - if ( ok ) tb->setColumnWidth( i, cw ); + if ( ok ) + tb->setColumnWidth( i, cw ); } connect( tb->horizontalHeader(), SIGNAL( sectionResized( int, int, int ) ), @@ -220,7 +221,8 @@ void QgsGrassAttributes::updateAttributes( ) { QgsDebugMsg( "entered." ); - if ( tabCats->count() == 0 ) return; + if ( tabCats->count() == 0 ) + return; QTableWidget *tb = static_cast( tabCats->currentWidget() ); @@ -235,7 +237,8 @@ void QgsGrassAttributes::updateAttributes( ) for ( int i = 2; i < tb->rowCount(); i++ ) { - if ( i > 2 ) sql.append( ", " ); + if ( i > 2 ) + sql.append( ", " ); QString val = tb->item( i, 1 )->text().trimmed(); @@ -291,7 +294,8 @@ void QgsGrassAttributes::deleteCat( ) { QgsDebugMsg( "entered." ); - if ( tabCats->count() == 0 ) return; + if ( tabCats->count() == 0 ) + return; QTableWidget *tb = static_cast( tabCats->currentWidget() ); diff --git a/src/plugins/grass/qgsgrassbrowser.cpp b/src/plugins/grass/qgsgrassbrowser.cpp index 499c324a1d9..814da2c489f 100644 --- a/src/plugins/grass/qgsgrassbrowser.cpp +++ b/src/plugins/grass/qgsgrassbrowser.cpp @@ -179,7 +179,8 @@ void QgsGrassBrowser::addMap() else if ( type == QgsGrassModel::Region ) { struct Cell_head window; - if ( !getItemRegion( *it, &window ) ) continue; + if ( !getItemRegion( *it, &window ) ) + continue; writeRegion( &window ); } } @@ -267,7 +268,8 @@ void QgsGrassBrowser::copyMap() QString newName = ed.getItem( element, tr( "New name" ), tr( "New name for layer \"%1\"" ).arg( map ), suggest, source, &ok ); - if ( !ok ) return; + if ( !ok ) + return; QString module = "g.copy"; #ifdef WIN32 @@ -315,7 +317,8 @@ void QgsGrassBrowser::renameMap() QString mapset = mModel->itemMapset( *it ); QString map = mModel->itemMap( *it ); - if ( mapset != QgsGrass::getDefaultMapset() ) continue; // should not happen + if ( mapset != QgsGrass::getDefaultMapset() ) + continue; // should not happen QString typeName; QString element; @@ -340,7 +343,8 @@ void QgsGrassBrowser::renameMap() QString newName = ed.getItem( element, tr( "New name" ), tr( "New name for layer \"%1\"" ).arg( map ), "", map, &ok ); - if ( !ok ) return; + if ( !ok ) + return; QString module = "g.rename"; #ifdef WIN32 @@ -396,9 +400,12 @@ void QgsGrassBrowser::deleteMap() QString map = mModel->itemMap( *it ); QString typeName; - if ( type == QgsGrassModel::Raster ) typeName = "rast"; - else if ( type == QgsGrassModel::Vector ) typeName = "vect"; - else if ( type == QgsGrassModel::Region ) typeName = "region"; + if ( type == QgsGrassModel::Raster ) + typeName = "rast"; + else if ( type == QgsGrassModel::Vector ) + typeName = "vect"; + else if ( type == QgsGrassModel::Region ) + typeName = "region"; if ( mapset != QgsGrass::getDefaultMapset() ) { @@ -442,7 +449,8 @@ void QgsGrassBrowser::setRegion() QList::const_iterator it = indexes.begin(); for ( ; it != indexes.end(); ++it ) { - if ( !getItemRegion( *it, &window ) ) return; + if ( !getItemRegion( *it, &window ) ) + return; } writeRegion( &window ); } diff --git a/src/plugins/grass/qgsgrassedit.cpp b/src/plugins/grass/qgsgrassedit.cpp index ab648ebe10f..c8b89843d50 100644 --- a/src/plugins/grass/qgsgrassedit.cpp +++ b/src/plugins/grass/qgsgrassedit.cpp @@ -168,7 +168,8 @@ QgsGrassEdit::QgsGrassEdit( QgisInterface *iface, QgsMapLayer* layer, bool newMa mCanvas = mIface->mapCanvas(); - if ( !isEditable( layer ) ) return; + if ( !isEditable( layer ) ) + return; //TODO dynamic_cast ? mLayer = ( QgsVectorLayer* )layer; @@ -182,7 +183,8 @@ QgsGrassEdit::QgsGrassEdit( QgisInterface *iface, QgsMapLayer* layer, bool newMa bool QgsGrassEdit::isEditable( QgsMapLayer *layer ) { - if ( !layer ) return false; + if ( !layer ) + return false; QgsDebugMsgLevel( "layer name: " + layer->name(), 3 ); @@ -466,7 +468,8 @@ void QgsGrassEdit::init() for ( int i = 0; i < SYMB_COUNT; i++ ) { - if ( i == SYMB_NODE_0 ) continue; + if ( i == SYMB_NODE_0 ) + continue; QPixmap pm( 40, 15 ); pm.fill( mSymb[i].color() ); @@ -645,7 +648,8 @@ void QgsGrassEdit::columnTypeChanged( int row, int col ) { QgsDebugMsg( QString( "row = %1 col = %2" ).arg( row ).arg( col ) ); - if ( col != 1 ) return; + if ( col != 1 ) + return; QTableWidgetItem *ti = mAttributeTable->item( row, 2 ); if ( ti ) @@ -677,7 +681,8 @@ void QgsGrassEdit::alterTable( void ) for ( int i = 0; i < mAttributeTable->rowCount(); i++ ) { - if ( i > 0 ) sql.append( ", " ); + if ( i > 0 ) + sql.append( ", " ); type = mAttributeTable->item( i, 1 )->text(); sql.append( mAttributeTable->item( i, 0 )->text() + " " + type ); @@ -709,7 +714,8 @@ void QgsGrassEdit::alterTable( void ) for ( int i = 0; i < mAttributeTable->rowCount(); i++ ) { - if ( !( mAttributeTable->item( i, 0 )->flags() & Qt::ItemIsEnabled ) ) continue; + if ( !( mAttributeTable->item( i, 0 )->flags() & Qt::ItemIsEnabled ) ) + continue; type = mAttributeTable->item( i, 1 )->text(); sql = mAttributeTable->item( i, 0 )->text() + " " + type; @@ -738,13 +744,15 @@ void QgsGrassEdit::changeSymbology( QTreeWidgetItem * item, int col ) QSettings settings; - if ( !item ) return; + if ( !item ) + return; int index = item->text( 3 ).toInt(); if ( col == 0 ) { - if ( index == SYMB_BACKGROUND || index == SYMB_HIGHLIGHT || index == SYMB_DYNAMIC ) return; + if ( index == SYMB_BACKGROUND || index == SYMB_HIGHLIGHT || index == SYMB_DYNAMIC ) + return; mSymbDisplay[index] = item->checkState( 0 ) == Qt::Checked; @@ -825,7 +833,8 @@ void QgsGrassEdit::updateSymb( void ) { int line = mProvider->updatedLine( i ); QgsDebugMsg( QString( "updated line = %1" ).arg( line ) ); - if ( !( mProvider->lineAlive( line ) ) ) continue; + if ( !( mProvider->lineAlive( line ) ) ) + continue; mLineSymb[line] = lineSymbFromMap( line ); } @@ -838,7 +847,8 @@ void QgsGrassEdit::updateSymb( void ) for ( unsigned int i = 0; i < nnodes; i++ ) { int node = mProvider->updatedNode( i ); - if ( !( mProvider->nodeAlive( node ) ) ) continue; + if ( !( mProvider->nodeAlive( node ) ) ) + continue; mNodeSymb[node] = nodeSymbFromMap( node ); QgsDebugMsg( QString( "node = %1 mNodeSymb = %2" ).arg( node ).arg( mNodeSymb[node] ) ); } @@ -875,7 +885,8 @@ int QgsGrassEdit::lineSymbFromMap( int line ) int type = mProvider->readLine( NULL, NULL, line ); - if ( type < 0 ) return 0; + if ( type < 0 ) + return 0; switch ( type ) { @@ -890,22 +901,31 @@ int QgsGrassEdit::lineSymbFromMap( int line ) case GV_BOUNDARY: int left, right, nareas; - if ( !( mProvider->lineAreas( line, &left, &right ) ) ) return 0; + if ( !( mProvider->lineAreas( line, &left, &right ) ) ) + return 0; /* Count areas on both sides */ nareas = 0; - if ( left > 0 || ( left < 0 && mProvider->isleArea( -left ) > 0 ) ) nareas++; - if ( right > 0 || ( right < 0 && mProvider->isleArea( -right ) > 0 ) ) nareas++; - if ( nareas == 0 ) return SYMB_BOUNDARY_0; - else if ( nareas == 1 ) return SYMB_BOUNDARY_1; - else return SYMB_BOUNDARY_2; + if ( left > 0 || ( left < 0 && mProvider->isleArea( -left ) > 0 ) ) + nareas++; + if ( right > 0 || ( right < 0 && mProvider->isleArea( -right ) > 0 ) ) + nareas++; + if ( nareas == 0 ) + return SYMB_BOUNDARY_0; + else if ( nareas == 1 ) + return SYMB_BOUNDARY_1; + else + return SYMB_BOUNDARY_2; break; case GV_CENTROID: int area = mProvider->centroidArea( line ); - if ( area == 0 ) return SYMB_CENTROID_OUT; - else if ( area > 0 ) return SYMB_CENTROID_IN; - else return SYMB_CENTROID_DUPL; /* area < 0 */ + if ( area == 0 ) + return SYMB_CENTROID_OUT; + else if ( area > 0 ) + return SYMB_CENTROID_IN; + else + return SYMB_CENTROID_DUPL; /* area < 0 */ break; } @@ -1198,7 +1218,8 @@ void QgsGrassEdit::snap( QgsPoint & point, double startX, double startY ) // Start double startDist = hypot( x - startX, y - startY ); bool startIn = false; - if ( startDist <= thresh ) startIn = true; + if ( startDist <= thresh ) + startIn = true; // Nearest node double nodeX = 0; @@ -1404,14 +1425,16 @@ void QgsGrassEdit::checkOrphan( int field, int cat ) tr( "Cannot check orphan record: %1" ).arg( *error ) ); return; } - if ( !orphan ) return; + if ( !orphan ) + return; QMessageBox::StandardButton ret = QMessageBox::question( 0, tr( "Warning" ), tr( "Orphan record was left in attribute table. " "
Delete the record?" ), QMessageBox::Ok | QMessageBox::Cancel ); - if ( ret == QMessageBox::Cancel ) return; + if ( ret == QMessageBox::Cancel ) + return; // Delete record error = mProvider->deleteAttributes( field, cat ); @@ -1496,7 +1519,8 @@ void QgsGrassEdit::addCat( int line ) line = mProvider->rewriteLine( line, type, mPoints, mCats ); mSelectedLine = line; - if ( mAttributes ) mAttributes->setLine( line ); + if ( mAttributes ) + mAttributes->setLine( line ); updateSymb(); increaseMaxCat(); @@ -1533,7 +1557,8 @@ void QgsGrassEdit::deleteCat( int line, int field, int cat ) line = mProvider->rewriteLine( line, type, mPoints, mCats ); mSelectedLine = line; - if ( mAttributes ) mAttributes->setLine( line ); + if ( mAttributes ) + mAttributes->setLine( line ); // Check orphan record checkOrphan( field, cat ); @@ -1550,7 +1575,8 @@ void QgsGrassEdit::postRender( QPainter * ) // after disconnect (is it a queue?) // -> check mValid - if ( !mValid ) return; + if ( !mValid ) + return; displayMap(); @@ -1594,7 +1620,8 @@ void QgsGrassEdit::displayMap() { for ( int node = 1; node <= nnodes; node++ ) { - if ( mNodeSymb[node] == SYMB_NODE_0 ) continue; // do not display nodes with points only + if ( mNodeSymb[node] == SYMB_NODE_0 ) + continue; // do not display nodes with points only displayNode( node, mSymb[mNodeSymb[node]], mSize, painter ); } } @@ -1624,7 +1651,8 @@ void QgsGrassEdit::displayUpdated( void ) for ( int i = 0; i < nlines; i++ ) { int line = mProvider->updatedLine( i ); - if ( !( mProvider->lineAlive( line ) ) ) continue; + if ( !( mProvider->lineAlive( line ) ) ) + continue; displayElement( line, mSymb[mLineSymb[line]], mSize, painter ); } @@ -1634,8 +1662,10 @@ void QgsGrassEdit::displayUpdated( void ) for ( int i = 0; i < nnodes; i++ ) { int node = mProvider->updatedNode( i ); - if ( !( mProvider->nodeAlive( node ) ) ) continue; - if ( mNodeSymb[node] == SYMB_NODE_0 ) continue; // do not display nodes with points only + if ( !( mProvider->nodeAlive( node ) ) ) + continue; + if ( mNodeSymb[node] == SYMB_NODE_0 ) + continue; // do not display nodes with points only displayNode( node, mSymb[mNodeSymb[node]], mSize, painter ); } @@ -1656,10 +1686,12 @@ void QgsGrassEdit::displayElement( int line, const QPen & pen, int size, QPainte if ( line == 0 ) return; - if ( !mSymbDisplay[mLineSymb[line]] ) return; + if ( !mSymbDisplay[mLineSymb[line]] ) + return; int type = mProvider->readLine( mPoints, NULL, line ); - if ( type < 0 ) return; + if ( type < 0 ) + return; QPainter *myPainter; if ( !painter ) @@ -1708,7 +1740,8 @@ void QgsGrassEdit::eraseElement( int line ) QgsDebugMsg( QString( "line = %1" ).arg( line ) ); int type = mProvider->readLine( NULL, NULL, line ); - if ( type < 0 ) return; + if ( type < 0 ) + return; // Erase line displayElement( line, mSymb[SYMB_BACKGROUND], mSize ); @@ -1782,11 +1815,13 @@ void QgsGrassEdit::displayNode( int node, const QPen & pen, int size, QPainter * { QgsDebugMsg( QString( "node = %1" ).arg( node ) ); - if ( !mSymbDisplay[mNodeSymb[node]] ) return; + if ( !mSymbDisplay[mNodeSymb[node]] ) + return; double x, y; - if ( !( mProvider->nodeCoor( node, &x, &y ) ) ) return; + if ( !( mProvider->nodeCoor( node, &x, &y ) ) ) + return; displayIcon( x, y, pen, QgsVertexMarker::ICON_X, size, painter ); } @@ -1876,9 +1911,12 @@ void QgsGrassEdit::setCanvasPrompt( QString left, QString mid, QString right ) { QgsDebugMsg( "entered." ); mCanvasPrompt = ""; - if ( left.length() > 0 ) mCanvasPrompt.append( tr( "Left: %1 " ).arg( left ) ); - if ( mid.length() > 0 ) mCanvasPrompt.append( tr( "Middle: %1" ).arg( mid ) ); - if ( right.length() > 0 ) mCanvasPrompt.append( tr( "Right: %1" ).arg( right ) ); + if ( left.length() > 0 ) + mCanvasPrompt.append( tr( "Left: %1 " ).arg( left ) ); + if ( mid.length() > 0 ) + mCanvasPrompt.append( tr( "Middle: %1" ).arg( mid ) ); + if ( right.length() > 0 ) + mCanvasPrompt.append( tr( "Right: %1" ).arg( right ) ); } void QgsGrassEdit::attributesClosed() diff --git a/src/plugins/grass/qgsgrassedittools.cpp b/src/plugins/grass/qgsgrassedittools.cpp index 3a509c075b6..25f33d234a6 100644 --- a/src/plugins/grass/qgsgrassedittools.cpp +++ b/src/plugins/grass/qgsgrassedittools.cpp @@ -313,7 +313,8 @@ void QgsGrassEditMoveVertex::mouseClick( QgsPoint & point, Qt::MouseButton butto double dist2 = Vect_points_distance( xl, yl, 0.0, e->mEditPoints->x[e->mSelectedPart], e->mEditPoints->y[e->mSelectedPart], 0.0, 0 ); - if ( dist1 < dist2 ) e->mSelectedPart--; + if ( dist1 < dist2 ) + e->mSelectedPart--; e->setCanvasPrompt( tr( "Select new position" ), "", "Release vertex" ); } @@ -579,7 +580,8 @@ void QgsGrassEditDeleteVertex::mouseClick( QgsPoint & point, Qt::MouseButton but double dist2 = Vect_points_distance( xl, yl, 0.0, e->mEditPoints->x[e->mSelectedPart], e->mEditPoints->y[e->mSelectedPart], 0.0, 0 ); - if ( dist1 < dist2 ) e->mSelectedPart--; + if ( dist1 < dist2 ) + e->mSelectedPart--; e->displayDynamic( e->mEditPoints->x[e->mSelectedPart], e->mEditPoints->y[e->mSelectedPart], QgsVertexMarker::ICON_BOX, e->mSize ); diff --git a/src/plugins/grass/qgsgrassmapcalc.cpp b/src/plugins/grass/qgsgrassmapcalc.cpp index 4b005dac701..f112f3b02d7 100644 --- a/src/plugins/grass/qgsgrassmapcalc.cpp +++ b/src/plugins/grass/qgsgrassmapcalc.cpp @@ -452,7 +452,8 @@ QStringList QgsGrassMapcalc::checkOutput() QString value = mOutputLineEdit->text().trimmed(); - if ( value.length() == 0 ) return QStringList(); + if ( value.length() == 0 ) + return QStringList(); QString path = QgsGrass::getDefaultGisdbase() + "/" + QgsGrass::getDefaultLocation() + "/" @@ -633,8 +634,10 @@ void QgsGrassMapcalc::setOption() { QgsDebugMsg( "entered." ); - if ( mTool != Select ) return; - if ( !mObject ) return; + if ( mTool != Select ) + return; + if ( !mObject ) + return; switch ( mObject->type() ) { @@ -666,8 +669,10 @@ void QgsGrassMapcalc::setOption() case QgsGrassMapcalcObject::Function : for ( unsigned int i = 0; i < mFunctions.size(); i++ ) { - if ( mFunctions[i].name() != mObject->function().name() ) continue; - if ( mFunctions[i].inputCount() != mObject->function().inputCount() ) continue; + if ( mFunctions[i].name() != mObject->function().name() ) + continue; + if ( mFunctions[i].inputCount() != mObject->function().inputCount() ) + continue; mFunctionComboBox->setCurrentIndex( i ); break; @@ -684,13 +689,17 @@ void QgsGrassMapcalc::setTool( int tool ) // Clear old if ( mTool == Select ) { - if ( mObject ) mObject->setSelected( false ); - if ( mConnector ) mConnector->setSelected( false ); + if ( mObject ) + mObject->setSelected( false ); + if ( mConnector ) + mConnector->setSelected( false ); } else { - if ( mObject ) delete mObject; - if ( mConnector ) delete mConnector; + if ( mObject ) + delete mObject; + if ( mConnector ) + delete mConnector; mCanvas->update(); } mObject = 0; @@ -846,7 +855,8 @@ void QgsGrassMapcalc::updateMaps() { QgsMapLayer *layer = canvas->layer( i ); - if ( layer->type() != QgsMapLayer::RasterLayer ) continue; + if ( layer->type() != QgsMapLayer::RasterLayer ) + continue; // Check if it is GRASS raster QString source = QDir::cleanPath( layer->source() ); @@ -855,16 +865,19 @@ void QgsGrassMapcalc::updateMaps() //QChar sep = QDir::separator(); QChar sep = '/'; - if ( source.contains( "cellhd" ) == 0 ) continue; + if ( source.contains( "cellhd" ) == 0 ) + continue; // Most probably GRASS layer, check GISBASE and LOCATION QStringList split = source.split( sep, QString::SkipEmptyParts ); - if ( split.size() < 4 ) continue; + if ( split.size() < 4 ) + continue; QString map = split.last(); split.pop_back(); // map - if ( split.last() != "cellhd" ) continue; + if ( split.last() != "cellhd" ) + continue; split.pop_back(); // cellhd QString mapset = split.last(); @@ -879,12 +892,17 @@ void QgsGrassMapcalc::updateMaps() QDir curlocDir( QgsGrass::getDefaultGisdbase() + sep + QgsGrass::getDefaultLocation() ); QString curloc = curlocDir.canonicalPath(); - if ( loc != curloc ) continue; + if ( loc != curloc ) + continue; - //if ( mUpdate && mapset != QgsGrass::getDefaultMapset() ) continue; +#if 0 + if ( mUpdate && mapset != QgsGrass::getDefaultMapset() ) + continue; +#endif mMapComboBox->addItem( layer->name() ); - //if ( layer->name() == current ) mMapComboBox->setItemText( mMapComboBox->currentIndex(), current ); + //if ( layer->name() == current ) + // mMapComboBox->setItemText( mMapComboBox->currentIndex(), current ); mMaps.push_back( map + "@" + mapset ); } } @@ -893,8 +911,10 @@ void QgsGrassMapcalc::mapChanged() { QgsDebugMsg( "entered." ); - if (( mTool != AddMap && mTool != Select ) || !mObject ) return; - if ( mObject->type() != QgsGrassMapcalcObject::Map ) return; + if (( mTool != AddMap && mTool != Select ) || !mObject ) + return; + if ( mObject->type() != QgsGrassMapcalcObject::Map ) + return; mObject->setValue( mMaps[mMapComboBox->currentIndex()], mMapComboBox->currentText() ); @@ -905,8 +925,10 @@ void QgsGrassMapcalc::constantChanged() { QgsDebugMsg( "entered." ); - if (( mTool != AddConstant && mTool != Select ) || !mObject ) return; - if ( mObject->type() != QgsGrassMapcalcObject::Constant ) return; + if (( mTool != AddConstant && mTool != Select ) || !mObject ) + return; + if ( mObject->type() != QgsGrassMapcalcObject::Constant ) + return; mObject->setValue( mConstantLineEdit->text() ); mCanvas->update(); @@ -916,8 +938,10 @@ void QgsGrassMapcalc::functionChanged() { QgsDebugMsg( "entered." ); - if (( mTool != AddFunction && mTool != Select ) || !mObject ) return; - if ( mObject->type() != QgsGrassMapcalcObject::Function ) return; + if (( mTool != AddFunction && mTool != Select ) || !mObject ) + return; + if ( mObject->type() != QgsGrassMapcalcObject::Function ) + return; mObject->setFunction( mFunctions[ mFunctionComboBox->currentIndex()] ); mCanvas->update(); @@ -925,10 +949,14 @@ void QgsGrassMapcalc::functionChanged() void QgsGrassMapcalc::limit( QPoint *point ) { - if ( point->x() < 0 ) point->setX( 0 ); - if ( point->y() < 0 ) point->setY( 0 ); - if ( point->x() > mCanvas->width() ) point->setX( mCanvas->width() ); - if ( point->y() > mCanvas->height() ) point->setY( mCanvas->height() ); + if ( point->x() < 0 ) + point->setX( 0 ); + if ( point->y() < 0 ) + point->setY( 0 ); + if ( point->x() > mCanvas->width() ) + point->setX( mCanvas->width() ); + if ( point->y() > mCanvas->height() ) + point->setY( mCanvas->height() ); } void QgsGrassMapcalc::resizeCanvas( int width, int height ) @@ -1007,10 +1035,14 @@ void QgsGrassMapcalc::autoGrow() QgsDebugMsg( QString( "r.left = %1 r.right = %2 r.top = %3 bottom = %4" ).arg( r.left() ).arg( r.right() ).arg( r.top() ).arg( r.bottom() ) ); - if ( r.left() - thresh < left ) left = r.left() - thresh; - if ( r.right() + thresh > right ) right = r.right() + thresh; - if ( r.top() - thresh < top ) top = r.top() - thresh; - if ( r.bottom() + thresh > bottom ) bottom = r.bottom() + thresh; + if ( r.left() - thresh < left ) + left = r.left() - thresh; + if ( r.right() + thresh > right ) + right = r.right() + thresh; + if ( r.top() - thresh < top ) + top = r.top() - thresh; + if ( r.bottom() + thresh > bottom ) + bottom = r.bottom() + thresh; QgsDebugMsg( QString( "left = %1 right = %2 top = %3 bottom = %4" ).arg( left ).arg( right ).arg( top ).arg( bottom ) ); } @@ -1051,7 +1083,8 @@ void QgsGrassMapcalc::saveAs() bool ok; name = QInputDialog::getText( this, tr( "New mapcalc" ), tr( "Enter new mapcalc name:" ), QLineEdit::Normal, mFileName, &ok ); - if ( !ok ) return; + if ( !ok ) + return; name = name.trimmed(); if ( name.isEmpty() ) @@ -1067,7 +1100,8 @@ void QgsGrassMapcalc::saveAs() tr( "The file already exists. Overwrite?" ), QMessageBox::Ok | QMessageBox::Cancel ); - if ( ret == QMessageBox::Cancel ) continue; + if ( ret == QMessageBox::Cancel ) + continue; } break; } @@ -1217,7 +1251,8 @@ void QgsGrassMapcalc::load() QgsDebugMsg( "entered." ); QgsGrassSelect *sel = new QgsGrassSelect( QgsGrassSelect::MAPCALC ); - if ( sel->exec() == QDialog::Rejected ) return; + if ( sel->exec() == QDialog::Rejected ) + return; // Open file QString path = sel->gisdbase + "/" + sel->location + "/" @@ -1269,7 +1304,8 @@ void QgsGrassMapcalc::load() { QDomNode node = objectNodes.item( n ); QDomElement e = node.toElement(); - if ( e.isNull() ) continue; + if ( e.isNull() ) + continue; QgsDebugMsg( QString( "id = %1" ).arg( e.attribute( "id", "?" ).toLocal8Bit().constData() ) ); unsigned int id = e.attribute( "id", "0" ).toInt(); @@ -1278,7 +1314,8 @@ void QgsGrassMapcalc::load() QString typeName = e.attribute( "type", "constant" ); QString value = e.attribute( "value", "???" ); - if ( id >= mNextId ) mNextId = id + 1; + if ( id >= mNextId ) + mNextId = id + 1; if ( id >= objects.size() ) { objects.resize( id + 1 ); @@ -1297,7 +1334,8 @@ void QgsGrassMapcalc::load() else if ( typeName == "output" ) type = QgsGrassMapcalcObject::Output; - if ( type == -1 ) continue; + if ( type == -1 ) + continue; QgsGrassMapcalcObject *obj = new QgsGrassMapcalcObject( type ); objects[id] = obj; @@ -1328,8 +1366,10 @@ void QgsGrassMapcalc::load() int fn = -1; for ( unsigned int i = 0; i < mFunctions.size(); i++ ) { - if ( mFunctions[i].name() != value ) continue; - if ( mFunctions[i].inputCount() != inputCount ) continue; + if ( mFunctions[i].name() != value ) + continue; + if ( mFunctions[i].inputCount() != inputCount ) + continue; fn = i; } @@ -1349,11 +1389,13 @@ void QgsGrassMapcalc::load() { QDomNode node = connectorNodes.item( n ); QDomElement e = node.toElement(); - if ( e.isNull() ) continue; + if ( e.isNull() ) + continue; QgsDebugMsg( QString( "id = %1" ).arg( e.attribute( "id", "?" ).toLocal8Bit().constData() ) ); unsigned int id = e.attribute( "id", "0" ).toInt(); - if ( id >= mNextId ) mNextId = id + 1; + if ( id >= mNextId ) + mNextId = id + 1; QgsGrassMapcalcConnector *con = new QgsGrassMapcalcConnector( mCanvas ); @@ -1367,7 +1409,8 @@ void QgsGrassMapcalc::load() { QDomNode node2 = endNodes.item( n2 ); QDomElement e2 = node2.toElement(); - if ( e2.isNull() ) continue; + if ( e2.isNull() ) + continue; int x = e2.attribute( "x", "0" ).toInt(); int y = e2.attribute( "y", "0" ).toInt(); @@ -1377,7 +1420,8 @@ void QgsGrassMapcalc::load() int objId = e2.attribute( "object", "-1" ).toInt(); QgsDebugMsg( QString( "objId = %1" ).arg( objId ) ); - if ( objId < 0 ) continue; // not connected + if ( objId < 0 ) + continue; // not connected if ( static_cast( objId ) < objects.size() && objects[objId] ) { @@ -1458,7 +1502,8 @@ QgsGrassMapcalcObject::QgsGrassMapcalcObject( int type ) mInputCount = 0; mOutputCount = 1; - if ( mType == Function ) mInputCount = 2; + if ( mType == Function ) + mInputCount = 2; if ( mType == Output ) { @@ -1608,7 +1653,8 @@ void QgsGrassMapcalcObject::resetSize() */ QString l = mFunction.inputLabels().at( i ); int len = metrics.width( l ); - if ( len > mInputTextWidth ) mInputTextWidth = len; + if ( len > mInputTextWidth ) + mInputTextWidth = len; } } @@ -1738,7 +1784,8 @@ bool QgsGrassMapcalcObject::tryConnect( QgsGrassMapcalcConnector *connector, { for ( int i = 0; i < mInputCount; i++ ) { - if ( mInputConnectors[i] ) continue; // used + if ( mInputConnectors[i] ) + continue; // used double d = sqrt( pow(( double )( mInputPoints[i].x() + pos().x() - p.x() ), 2.0 ) + pow(( double )( mInputPoints[i].y() + pos().y() - p.y() ), 2.0 ) ); @@ -2010,7 +2057,8 @@ void QgsGrassMapcalcConnector::setSocket( int end, mSocketDir[end] = direction; mSocket[end] = socket; - if ( !object ) return; // disconnect only + if ( !object ) + return; // disconnect only mSocketObjects[end]->setConnector( mSocketDir[end], mSocket[end], this, end ); @@ -2036,8 +2084,10 @@ QString QgsGrassMapcalcConnector::expression() QgsDebugMsg( "entered." ); for ( int i = 0; i < 2; i++ ) { - if ( !mSocketObjects[i] ) continue; - if ( mSocketDir[i] != QgsGrassMapcalcObject::Out ) continue; + if ( !mSocketObjects[i] ) + continue; + if ( mSocketDir[i] != QgsGrassMapcalcObject::Out ) + continue; return mSocketObjects[i]->expression(); } @@ -2057,7 +2107,8 @@ QgsGrassMapcalcFunction::QgsGrassMapcalcFunction( int type, QString name, mLabel( label ), mDescription( description ), mDrawLabel( drawLabel ) { - if ( mLabel.isEmpty() ) mLabel = mName; + if ( mLabel.isEmpty() ) + mLabel = mName; if ( !labels.isEmpty() ) { diff --git a/src/plugins/grass/qgsgrassmodel.cpp b/src/plugins/grass/qgsgrassmodel.cpp index f42756a7e9b..448b27ef663 100644 --- a/src/plugins/grass/qgsgrassmodel.cpp +++ b/src/plugins/grass/qgsgrassmodel.cpp @@ -99,7 +99,8 @@ void QgsGrassModelItem::copyNames( QgsGrassModelItem *item ) QVariant QgsGrassModelItem::data( int role ) { - if ( role != Qt::DisplayRole ) return QVariant(); + if ( role != Qt::DisplayRole ) + return QVariant(); return name(); } @@ -520,7 +521,8 @@ void QgsGrassModelItem::populate() { QgsDebugMsg( "called." ); - if ( mPopulated ) return; + if ( mPopulated ) + return; mModel->refreshItem( this ); } @@ -708,9 +710,12 @@ void QgsGrassModel::refreshItem( QgsGrassModelItem *item ) "windows" ); QStringList list; - if ( vectors.count() > 0 ) list.append( "vector" ); - if ( rasters.count() > 0 ) list.append( "raster" ); - if ( regions.count() > 0 ) list.append( "region" ); + if ( vectors.count() > 0 ) + list.append( "vector" ); + if ( rasters.count() > 0 ) + list.append( "raster" ); + if ( regions.count() > 0 ) + list.append( "region" ); removeItems( item, list ); @@ -796,7 +801,8 @@ QModelIndex QgsGrassModel::index( int row, int column, // for example if beginInsertRows(,0,0) is called and the first // item was previously deleted => check if row < 0 // and return empty QModelIndex, but is it correct? - if ( row < 0 ) return QModelIndex(); + if ( row < 0 ) + return QModelIndex(); QgsGrassModelItem *item; if ( !parent.isValid() ) @@ -807,8 +813,10 @@ QModelIndex QgsGrassModel::index( int row, int column, { item = static_cast( parent.internalPointer() ); } - //if ( !item->populated() ) refreshItem(item); - if ( !item->populated() ) item->populate(); + //if ( !item->populated() ) + //refreshItem(item); + if ( !item->populated() ) + item->populate(); return createIndex( row, column, item->child( row ) ); } @@ -816,14 +824,16 @@ QModelIndex QgsGrassModel::parent( const QModelIndex & index ) const { // QgsDebugMsg("entered."); - if ( !index.isValid() ) return QModelIndex(); + if ( !index.isValid() ) + return QModelIndex(); QgsGrassModelItem *item = static_cast( index.internalPointer() ); QgsGrassModelItem *parentNode = item->mParent; - if ( parentNode == 0 || parentNode == mRoot ) return QModelIndex(); + if ( parentNode == 0 || parentNode == mRoot ) + return QModelIndex(); // parent's row QVector children = parentNode->mParent ? @@ -855,8 +865,10 @@ int QgsGrassModel::rowCount( const QModelIndex & parent ) const } // QgsDebugMsg(QString("name = %1").arg(item->name())); // QgsDebugMsg(QString("count = %1").arg(item->mChildren.size())); - if ( !item->populated() ) item->populate(); - //if ( !item->populated() ) refreshItem(item); + if ( !item->populated() ) + item->populate(); + //if ( !item->populated() ) + //refreshItem(item); return item->mChildren.size(); } @@ -870,8 +882,10 @@ QVariant QgsGrassModel::data( const QModelIndex &index, int role ) const { // QgsDebugMsg("entered."); - if ( !index.isValid() ) { return QVariant(); } - if ( role != Qt::DisplayRole && role != Qt::DecorationRole ) return QVariant(); + if ( !index.isValid() ) + return QVariant(); + if ( role != Qt::DisplayRole && role != Qt::DecorationRole ) + return QVariant(); QgsGrassModelItem *item; item = static_cast( index.internalPointer() ); @@ -920,7 +934,8 @@ QVariant QgsGrassModel::data( const QModelIndex &index, int role ) const QString QgsGrassModel::itemName( const QModelIndex &index ) { - if ( !index.isValid() ) { return QString(); } + if ( !index.isValid() ) + return QString(); QgsGrassModelItem *item; item = static_cast( index.internalPointer() ); @@ -930,7 +945,8 @@ QString QgsGrassModel::itemName( const QModelIndex &index ) QString QgsGrassModel::itemMapset( const QModelIndex &index ) { - if ( !index.isValid() ) { return QString(); } + if ( !index.isValid() ) + return QString(); QgsGrassModelItem *item; item = static_cast( index.internalPointer() ); @@ -940,7 +956,8 @@ QString QgsGrassModel::itemMapset( const QModelIndex &index ) QString QgsGrassModel::itemMap( const QModelIndex &index ) { - if ( !index.isValid() ) { return QString(); } + if ( !index.isValid() ) + return QString(); QgsGrassModelItem *item; item = static_cast( index.internalPointer() ); @@ -950,7 +967,8 @@ QString QgsGrassModel::itemMap( const QModelIndex &index ) QString QgsGrassModel::itemInfo( const QModelIndex &index ) { - if ( !index.isValid() ) { return QString(); } + if ( !index.isValid() ) + return QString(); QgsGrassModelItem *item; item = static_cast( index.internalPointer() ); @@ -960,7 +978,8 @@ QString QgsGrassModel::itemInfo( const QModelIndex &index ) int QgsGrassModel::itemType( const QModelIndex &index ) const { - if ( !index.isValid() ) { return QgsGrassModel::None; } + if ( !index.isValid() ) + return QgsGrassModel::None; QgsGrassModelItem *item; item = static_cast( index.internalPointer() ); return item->type(); @@ -968,7 +987,8 @@ int QgsGrassModel::itemType( const QModelIndex &index ) const QString QgsGrassModel::uri( const QModelIndex &index ) const { - if ( !index.isValid() ) { return QString(); } + if ( !index.isValid() ) + return QString(); QgsGrassModelItem *item; item = static_cast( index.internalPointer() ); return item->uri(); diff --git a/src/plugins/grass/qgsgrassmodule.cpp b/src/plugins/grass/qgsgrassmodule.cpp index c6a06745a32..258f899550a 100644 --- a/src/plugins/grass/qgsgrassmodule.cpp +++ b/src/plugins/grass/qgsgrassmodule.cpp @@ -73,7 +73,8 @@ QString QgsGrassModule::findExec( QString file ) mExecPathInited = true; } - if ( QFile::exists( file ) ) return file; // full path + if ( QFile::exists( file ) ) + return file; // full path #ifdef WIN32 // On windows try .bat first @@ -658,10 +659,12 @@ void QgsGrassModuleStandardOptions::freezeOutput() { QgsMapLayer *layer = mCanvas->layer( i ); - if ( layer->type() != QgsMapLayer::VectorLayer ) continue; + if ( layer->type() != QgsMapLayer::VectorLayer ) + continue; QgsVectorLayer *vector = ( QgsVectorLayer* )layer; - if ( vector->providerType() != "grass" ) continue; + if ( vector->providerType() != "grass" ) + continue; //TODO dynamic_cast ? QgsGrassProvider *provider = ( QgsGrassProvider * ) vector->dataProvider(); @@ -674,7 +677,8 @@ void QgsGrassModuleStandardOptions::freezeOutput() // Check GISBASE and LOCATION QStringList split = source.split( sep ); - if ( split.size() < 4 ) continue; + if ( split.size() < 4 ) + continue; split.pop_back(); // layer QString map = split.last(); @@ -689,11 +693,14 @@ void QgsGrassModuleStandardOptions::freezeOutput() QDir curlocDir( QgsGrass::getDefaultGisdbase() + sep + QgsGrass::getDefaultLocation() ); QString curloc = curlocDir.canonicalPath(); - if ( loc != curloc ) continue; + if ( loc != curloc ) + continue; - if ( mapset != QgsGrass::getDefaultMapset() ) continue; + if ( mapset != QgsGrass::getDefaultMapset() ) + continue; - if ( provider->isFrozen() ) continue; + if ( provider->isFrozen() ) + continue; provider->freeze(); } @@ -727,10 +734,12 @@ void QgsGrassModuleStandardOptions::thawOutput() { QgsMapLayer *layer = mCanvas->layer( i ); - if ( layer->type() != QgsMapLayer::VectorLayer ) continue; + if ( layer->type() != QgsMapLayer::VectorLayer ) + continue; QgsVectorLayer *vector = ( QgsVectorLayer* )layer; - if ( vector->providerType() != "grass" ) continue; + if ( vector->providerType() != "grass" ) + continue; //TODO dynamic_cast ? QgsGrassProvider *provider = ( QgsGrassProvider * ) vector->dataProvider(); @@ -743,7 +752,8 @@ void QgsGrassModuleStandardOptions::thawOutput() // Check GISBASE and LOCATION QStringList split = source.split( sep ); - if ( split.size() < 4 ) continue; + if ( split.size() < 4 ) + continue; split.pop_back(); // layer QString map = split.last(); @@ -758,11 +768,14 @@ void QgsGrassModuleStandardOptions::thawOutput() QDir curlocDir( QgsGrass::getDefaultGisdbase() + sep + QgsGrass::getDefaultLocation() ); QString curloc = curlocDir.canonicalPath(); - if ( loc != curloc ) continue; + if ( loc != curloc ) + continue; - if ( mapset != QgsGrass::getDefaultMapset() ) continue; + if ( mapset != QgsGrass::getDefaultMapset() ) + continue; - if ( !provider->isFrozen() ) continue; + if ( !provider->isFrozen() ) + continue; provider->thaw(); } @@ -815,7 +828,8 @@ bool QgsGrassModuleStandardOptions::hasOutput( int type ) if ( opt->isOutput() ) { - if ( opt->outputType() == type ) return true; + if ( opt->outputType() == type ) + return true; } } @@ -875,7 +889,8 @@ QStringList QgsGrassModuleStandardOptions::checkRegion() QStringList mm = item->currentMap().split( "@" ); QString map = mm.at( 0 ); QString mapset = QgsGrass::getDefaultMapset(); - if ( mm.size() > 1 ) mapset = mm.at( 1 ); + if ( mm.size() > 1 ) + mapset = mm.at( 1 ); if ( !QgsGrass::mapRegion( mapType, QgsGrass::getDefaultGisdbase(), QgsGrass::getDefaultLocation(), mapset, map, @@ -918,7 +933,8 @@ bool QgsGrassModuleStandardOptions::inputRegion( struct Cell_head *window, bool if ( !item ) continue; - if ( !all && !item->useRegion() ) continue; + if ( !all && !item->useRegion() ) + continue; QgsGrass::MapType mapType = QgsGrass::Vector; @@ -935,7 +951,8 @@ bool QgsGrassModuleStandardOptions::inputRegion( struct Cell_head *window, bool QStringList mm = item->currentMap().split( "@" ); QString map = mm.at( 0 ); QString mapset = QgsGrass::getDefaultMapset(); - if ( mm.size() > 1 ) mapset = mm.at( 1 ); + if ( mm.size() > 1 ) + mapset = mm.at( 1 ); if ( !QgsGrass::mapRegion( mapType, QgsGrass::getDefaultGisdbase(), QgsGrass::getDefaultLocation(), mapset, map, @@ -1061,14 +1078,16 @@ QPixmap QgsGrassModule::pixmap( QString path, int height ) if ( fi.exists() ) { QSvgRenderer pic; - if ( ! pic.load( fpath ) ) break; + if ( ! pic.load( fpath ) ) + break; QRect br( QPoint( 0, 0 ), pic.defaultSize() ); double scale = 1. * height / br.height(); int width = ( int )( scale * br.width() ); - if ( width <= 0 ) width = height; // should not happen + if ( width <= 0 ) + width = height; // should not happen QPixmap pixmap( width, height ); pixmap.fill( Qt::transparent ); //pixmap.fill( QColor( 255, 255, 255 ) ); @@ -1085,11 +1104,13 @@ QPixmap QgsGrassModule::pixmap( QString path, int height ) fpath = path + "." + QString::number( cnt ) + ".png"; fi.setFile( fpath ); - if ( !fi.exists() ) break; + if ( !fi.exists() ) + break; QPixmap pixmap; - if ( ! pixmap.load( fpath, "PNG" ) ) break; + if ( ! pixmap.load( fpath, "PNG" ) ) + break; double scale = 1. * height / pixmap.height(); int width = ( int )( scale * pixmap.width() ); @@ -1110,7 +1131,8 @@ QPixmap QgsGrassModule::pixmap( QString path, int height ) width += pixmaps[i].width(); } - if ( width <= 0 ) width = height; //should not happen + if ( width <= 0 ) + width = height; //should not happen QString iconsPath = QgsApplication::pkgDataPath() + "/grass/modules/"; QFileInfo iconsfi( iconsPath ); @@ -1130,7 +1152,8 @@ QPixmap QgsGrassModule::pixmap( QString path, int height ) img = img.scaled( arrowWidth, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); arrowPixmap = QPixmap::fromImage( img ); } - /*if ( iconsfi.exists() ) +#if 0 + if ( iconsfi.exists() ) { QSvgRenderer pic; if ( pic.load( arrowPath ) ) @@ -1140,7 +1163,8 @@ QPixmap QgsGrassModule::pixmap( QString path, int height ) double scale = 1. * height / br.height(); arrowWidth = ( int )( scale * br.width() ); - if ( arrowWidth <= 0 ) arrowWidth = height; // should not happen + if ( arrowWidth <= 0 ) + arrowWidth = height; // should not happen arrowPixmap = QPixmap( arrowWidth, height ); arrowPixmap.fill( Qt::transparent ); QPainter painter( &arrowPixmap ); @@ -1149,12 +1173,14 @@ QPixmap QgsGrassModule::pixmap( QString path, int height ) pic.render( &painter ); painter.end(); } - }*/ + } +#endif QString plusPath = iconsPath + "grass_plus.svg"; QPixmap plusPixmap; iconsfi.setFile( plusPath ); - /*if ( iconsfi.exists() && plusPixmap.load( plusPath, "PNG" ) ) +#if 0 + if ( iconsfi.exists() && plusPixmap.load( plusPath, "PNG" ) ) { double scale = 1. * height / plusPixmap.height(); plusWidth = ( int )( scale * plusPixmap.width() ); @@ -1162,7 +1188,8 @@ QPixmap QgsGrassModule::pixmap( QString path, int height ) QImage img = plusPixmap.toImage(); img = img.scaled( plusWidth, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); plusPixmap = QPixmap::fromImage( img ); - }*/ + } +#endif if ( iconsfi.exists() ) { QSvgRenderer pic; @@ -1173,7 +1200,8 @@ QPixmap QgsGrassModule::pixmap( QString path, int height ) double scale = 1. * height / br.height(); plusWidth = ( int )( scale * br.width() ); - if ( plusWidth <= 0 ) plusWidth = height; // should not happen + if ( plusWidth <= 0 ) + plusWidth = height; // should not happen plusPixmap = QPixmap( plusWidth, height ); plusPixmap.fill( Qt::transparent ); QPainter painter( &plusPixmap ); @@ -1184,8 +1212,10 @@ QPixmap QgsGrassModule::pixmap( QString path, int height ) } } int buffer = height / 3; // buffer around a sign - if ( pixmaps.size() > 1 ) width += arrowWidth + 2 * buffer; // -> - if ( pixmaps.size() > 2 ) width += plusWidth + 2 * buffer; // + + if ( pixmaps.size() > 1 ) + width += arrowWidth + 2 * buffer; // -> + if ( pixmaps.size() > 2 ) + width += plusWidth + 2 * buffer; // + QPixmap pixmap( width, height ); pixmap.fill( Qt::transparent ); @@ -1278,8 +1308,10 @@ void QgsGrassModule::run() } questionBox.exec(); QAbstractButton *clicked = questionBox.clickedButton(); - if ( clicked == questionBox.button( QMessageBox::Cancel ) ) return; - if ( clicked == resetButton ) resetRegion = true; + if ( clicked == questionBox.button( QMessageBox::Cancel ) ) + return; + if ( clicked == resetButton ) + resetRegion = true; if ( resetRegion ) { @@ -1434,7 +1466,8 @@ void QgsGrassModule::run() break; } } - if ( used ) continue; + if ( used ) + continue; QString env = "GIS_FLAG_" + QString( allFlagNames.at( i ).toUpper() ) + "=0"; @@ -1587,7 +1620,8 @@ void QgsGrassModule::viewOutput() { QgsDebugMsg( "called." ); - if ( !mSuccess ) return; + if ( !mSuccess ) + return; for ( int i = 0; i < mOutputVector.size(); i++ ) { @@ -1644,7 +1678,10 @@ void QgsGrassModule::viewOutput() } } -QgisInterface *QgsGrassModule::qgisIface() { return mIface; } +QgisInterface *QgsGrassModule::qgisIface() +{ + return mIface; +} QgsGrassModule::~QgsGrassModule() { @@ -1696,7 +1733,8 @@ QgsGrassModuleOption::QgsGrassModuleOption( QgsGrassModule *module, QString key, QgsDebugMsg( "called." ); setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum ); - if ( mHidden ) hide(); + if ( mHidden ) + hide(); mLayout = new QVBoxLayout(); @@ -1967,7 +2005,8 @@ void QgsGrassModuleOption::removeLineEdit() { QgsDebugMsg( "called." ); - if ( mLineEdits.size() < 2 ) return; + if ( mLineEdits.size() < 2 ) + return; delete mLineEdits.at( mLineEdits.size() - 1 ); mLineEdits.pop_back(); } @@ -1976,7 +2015,8 @@ QString QgsGrassModuleOption::outputExists() { QgsDebugMsg( "called." ); - if ( !mIsOutput ) return QString(); + if ( !mIsOutput ) + return QString(); QLineEdit *lineEdit = mLineEdits.at( 0 ); QString value = lineEdit->text().trimmed(); @@ -1984,7 +2024,8 @@ QString QgsGrassModuleOption::outputExists() QgsDebugMsg( "value = " + value ); QgsDebugMsg( "mOutputElement = " + mOutputElement ); - if ( value.length() == 0 ) return QString(); + if ( value.length() == 0 ) + return QString(); QString path = QgsGrass::getDefaultGisdbase() + "/" + QgsGrass::getDefaultLocation() + "/" @@ -2012,7 +2053,8 @@ QString QgsGrassModuleOption::value() QLineEdit *lineEdit = mLineEdits.at( i ); if ( lineEdit->text().trimmed().length() > 0 ) { - if ( value.length() > 0 ) value.append( "," ); + if ( value.length() > 0 ) + value.append( "," ); value.append( lineEdit->text().trimmed() ); } } @@ -2082,7 +2124,8 @@ QgsGrassModuleFlag::QgsGrassModuleFlag( QgsGrassModule *module, QString key, { QgsDebugMsg( "called." ); - if ( mHidden ) hide(); + if ( mHidden ) + hide(); if ( mAnswer == "on" ) setChecked( true ); @@ -2374,7 +2417,8 @@ void QgsGrassModuleInput::updateQgisLayers() { QgsVectorLayer *vector = ( QgsVectorLayer* )layer; QgsDebugMsg( "vector->providerType() = " + vector->providerType() ); - if ( vector->providerType() != "grass" ) continue; + if ( vector->providerType() != "grass" ) + continue; //TODO dynamic_cast ? QgsGrassProvider *provider = ( QgsGrassProvider * ) vector->dataProvider(); @@ -2398,7 +2442,8 @@ void QgsGrassModuleInput::updateQgisLayers() // Check GISBASE and LOCATION QStringList split = source.split( sep, QString::SkipEmptyParts ); - if ( split.size() < 4 ) continue; + if ( split.size() < 4 ) + continue; split.pop_back(); // layer QString map = split.last(); @@ -2420,15 +2465,18 @@ void QgsGrassModuleInput::updateQgisLayers() QgsDebugMsg( "mapset = " + mapset ); QgsDebugMsg( "QgsGrass::getDefaultMapset() = " + QgsGrass::getDefaultMapset() ); - if ( loc != curloc ) continue; + if ( loc != curloc ) + continue; - if ( mUpdate && mapset != QgsGrass::getDefaultMapset() ) continue; + if ( mUpdate && mapset != QgsGrass::getDefaultMapset() ) + continue; // Check if it comes from source map if necessary if ( !mMapId.isEmpty() ) { QString cm = map + "@" + mapset; - if ( sourceMap != cm ) continue; + if ( sourceMap != cm ) + continue; } mMaps.push_back( map + "@" + mapset ); @@ -2459,7 +2507,8 @@ void QgsGrassModuleInput::updateQgisLayers() + " " + grassLayer + " " + type + " )"; mLayerComboBox->addItem( label ); - if ( label == current ) mLayerComboBox->setCurrentIndex( mLayerComboBox->count() - 1 ); + if ( label == current ) + mLayerComboBox->setCurrentIndex( mLayerComboBox->count() - 1 ); mMapLayers.push_back( vector ); mVectorLayerNames.push_back( grassLayer ); @@ -2476,16 +2525,19 @@ void QgsGrassModuleInput::updateQgisLayers() // Check if it is GRASS raster QString source = QDir::cleanPath( layer->source() ); - if ( source.contains( "cellhd" ) == 0 ) continue; + if ( source.contains( "cellhd" ) == 0 ) + continue; // Most probably GRASS layer, check GISBASE and LOCATION QStringList split = source.split( sep, QString::SkipEmptyParts ); - if ( split.size() < 4 ) continue; + if ( split.size() < 4 ) + continue; QString map = split.last(); split.pop_back(); // map - if ( split.last() != "cellhd" ) continue; + if ( split.last() != "cellhd" ) + continue; split.pop_back(); // cellhd QString mapset = split.last(); @@ -2499,16 +2551,19 @@ void QgsGrassModuleInput::updateQgisLayers() QDir curlocDir( QgsGrass::getDefaultGisdbase() + sep + QgsGrass::getDefaultLocation() ); QString curloc = curlocDir.canonicalPath(); - if ( loc != curloc ) continue; + if ( loc != curloc ) + continue; - if ( mUpdate && mapset != QgsGrass::getDefaultMapset() ) continue; + if ( mUpdate && mapset != QgsGrass::getDefaultMapset() ) + continue; mMaps.push_back( map + "@" + mapset ); QString label = layer->name() + " ( " + map + "@" + mapset + " )"; mLayerComboBox->addItem( label ); - if ( label == current ) mLayerComboBox->setCurrentIndex( mLayerComboBox->count() - 1 ); + if ( label == current ) + mLayerComboBox->setCurrentIndex( mLayerComboBox->count() - 1 ); } } } @@ -2703,9 +2758,15 @@ QgsGrassModuleItem::QgsGrassModuleItem( QgsGrassModule *module, QString key, mId = qdesc.attribute( "id" ); } -bool QgsGrassModuleItem::hidden() { return mHidden; } +bool QgsGrassModuleItem::hidden() +{ + return mHidden; +} -QStringList QgsGrassModuleItem::options() { return QStringList(); } +QStringList QgsGrassModuleItem::options() +{ + return QStringList(); +} QgsGrassModuleItem::~QgsGrassModuleItem() {} @@ -2912,7 +2973,8 @@ void QgsGrassModuleGdalInput::updateQgisLayers() QgsDebugMsg( "ogrLayer = " + ogrLayer ); mLayerComboBox->addItem( layer->name() ); - if ( layer->name() == current ) mLayerComboBox->setItemText( mLayerComboBox->currentIndex(), current ); + if ( layer->name() == current ) + mLayerComboBox->setItemText( mLayerComboBox->currentIndex(), current ); mUri.push_back( uri ); mOgrLayers.push_back( ogrLayer ); @@ -2922,7 +2984,8 @@ void QgsGrassModuleGdalInput::updateQgisLayers() { QString uri = layer->source(); mLayerComboBox->addItem( layer->name() ); - if ( layer->name() == current ) mLayerComboBox->setItemText( mLayerComboBox->currentIndex(), current ); + if ( layer->name() == current ) + mLayerComboBox->setItemText( mLayerComboBox->currentIndex(), current ); mUri.push_back( uri ); mOgrLayers.push_back( "" ); mOgrWheres.push_back( "" ); @@ -3055,7 +3118,8 @@ void QgsGrassModuleField::updateFields() //QgsMapCanvas *canvas = mModule->qgisIface()->mapCanvas(); - if ( mLayerInput == 0 ) return; + if ( mLayerInput == 0 ) + return; std::vector fields = mLayerInput->currentFields(); @@ -3132,10 +3196,12 @@ void QgsGrassModuleSelection::updateSelection() mLineEdit->setText( "" ); //QgsMapCanvas *canvas = mModule->qgisIface()->mapCanvas(); - if ( mLayerInput == 0 ) return; + if ( mLayerInput == 0 ) + return; QgsMapLayer *layer = mLayerInput->currentLayer(); - if ( !layer ) return; + if ( !layer ) + return; QgsVectorLayer *vector = qobject_cast( layer ); QgsGrassProvider *provider = ( QgsGrassProvider * ) vector->dataProvider(); @@ -3143,7 +3209,8 @@ void QgsGrassModuleSelection::updateSelection() const QgsFeatureIds& selected = vector->selectedFeaturesIds(); int keyField = provider->keyField(); - if ( keyField < 0 ) return; + if ( keyField < 0 ) + return; QString cats; provider->select( allAttributes, QgsRectangle(), true ); @@ -3158,7 +3225,8 @@ void QgsGrassModuleSelection::updateSelection() QgsAttributeMap attr = feature.attributeMap(); if ( attr.size() > keyField ) { - if ( i > 0 ) cats.append( "," ); + if ( i > 0 ) + cats.append( "," ); cats.append( attr[keyField].toString() ); i++; } diff --git a/src/plugins/grass/qgsgrassmodule.h b/src/plugins/grass/qgsgrassmodule.h index a9e4d1bf3d7..fcca101b1f2 100644 --- a/src/plugins/grass/qgsgrassmodule.h +++ b/src/plugins/grass/qgsgrassmodule.h @@ -180,10 +180,10 @@ class QgsGrassModuleOptions virtual QStringList checkOutput() { return QStringList() ; } //! Freeze output vector maps used in QGIS on Windows - virtual void freezeOutput() { return; } + virtual void freezeOutput() {} //! Thaw output vector maps used in QGIS on Windows - virtual void thawOutput() { return; } + virtual void thawOutput() { } //! Check if option is ready // Returns empty string or error message diff --git a/src/plugins/grass/qgsgrassnewmapset.cpp b/src/plugins/grass/qgsgrassnewmapset.cpp index 0876c745402..9d276181db4 100644 --- a/src/plugins/grass/qgsgrassnewmapset.cpp +++ b/src/plugins/grass/qgsgrassnewmapset.cpp @@ -198,7 +198,8 @@ void QgsGrassNewMapset::databaseChanged() QDir d( mDatabaseLineEdit->text() ); for ( unsigned int i = 0; i < d.count(); i++ ) { - if ( d[i] == "." || d[i] == ".." ) continue; + if ( d[i] == "." || d[i] == ".." ) + continue; QString windName = mDatabaseLineEdit->text() + "/" + d[i] + "/PERMANENT/DEFAULT_WIND"; QString locationName = mDatabaseLineEdit->text() + "/" + d[i]; @@ -246,7 +247,8 @@ void QgsGrassNewMapset::setLocations( ) int sel = -1; for ( unsigned int i = 0; i < d.count(); i++ ) { - if ( d[i] == "." || d[i] == ".." ) continue; + if ( d[i] == "." || d[i] == ".." ) + continue; QString windName = mDatabaseLineEdit->text() + "/" + d[i] + "/PERMANENT/DEFAULT_WIND"; QString locationName = mDatabaseLineEdit->text() + "/" + d[i]; @@ -684,7 +686,8 @@ void QgsGrassNewMapset::checkRegion() err = true; } - if ( err ) return; + if ( err ) + return; mCellHead.north = n; mCellHead.south = s; @@ -762,22 +765,30 @@ void QgsGrassNewMapset::loadRegions() QDomElement elem = node.toElement(); QDomNodeList nameNodes = elem.elementsByTagName( "gml:name" ); - if ( nameNodes.count() == 0 ) continue; - if ( nameNodes.item( 0 ).isNull() ) continue; + if ( nameNodes.count() == 0 ) + continue; + if ( nameNodes.item( 0 ).isNull() ) + continue; QDomElement nameElem = nameNodes.item( 0 ).toElement(); - if ( nameElem.text().isNull() ) continue; + if ( nameElem.text().isNull() ) + continue; QDomNodeList envNodes = elem.elementsByTagName( "gml:Envelope" ); - if ( envNodes.count() == 0 ) continue; - if ( envNodes.item( 0 ).isNull() ) continue; + if ( envNodes.count() == 0 ) + continue; + if ( envNodes.item( 0 ).isNull() ) + continue; QDomElement envElem = envNodes.item( 0 ).toElement(); QDomNodeList coorNodes = envElem.elementsByTagName( "gml:coordinates" ); - if ( coorNodes.count() == 0 ) continue; - if ( coorNodes.item( 0 ).isNull() ) continue; + if ( coorNodes.count() == 0 ) + continue; + if ( coorNodes.item( 0 ).isNull() ) + continue; QDomElement coorElem = coorNodes.item( 0 ).toElement(); - if ( coorElem.text().isNull() ) continue; + if ( coorElem.text().isNull() ) + continue; QStringList coor = coorElem.text().split( " ", QString::SkipEmptyParts ); if ( coor.size() != 2 ) @@ -886,21 +897,29 @@ void QgsGrassNewMapset::setSelectedRegion() e = points[1].x(); w = points[0].x(); - if ( n > 90 ) n = 90; - if ( s < -90 ) s = -90; + if ( n > 90 ) + n = 90; + if ( s < -90 ) + s = -90; #if 0 - if ( e > 180 ) e = 180; - if ( w < -180 ) w = 180; + if ( e > 180 ) + e = 180; + if ( w < -180 ) + w = 180; #endif } else { for ( int i = 0; i < 4; i++ ) { - if ( i == 0 || points[i].y() > n ) n = points[i].y(); - if ( i == 0 || points[i].y() < s ) s = points[i].y(); - if ( i == 0 || points[i].x() > e ) e = points[i].x(); - if ( i == 0 || points[i].x() < w ) w = points[i].x(); + if ( i == 0 || points[i].y() > n ) + n = points[i].y(); + if ( i == 0 || points[i].y() < s ) + s = points[i].y(); + if ( i == 0 || points[i].x() > e ) + e = points[i].x(); + if ( i == 0 || points[i].x() < w ) + w = points[i].x(); } } @@ -987,7 +1006,8 @@ void QgsGrassNewMapset::drawRegion() QPixmap pm = mPixmap; mRegionMap->setPixmap( pm ); - if ( mCellHead.proj == PROJECTION_XY ) return; + if ( mCellHead.proj == PROJECTION_XY ) + return; QgsDebugMsg( QString( "pm.isNull() = %1" ).arg( pm.isNull() ) ); QPainter p( &pm ); @@ -1071,8 +1091,10 @@ void QgsGrassNewMapset::drawRegion() // use 89.9 - for draw it is not so important if ( mCellHead.proj == PROJECTION_LL ) { - if ( points[i].y() >= 89.9 ) points[i].setY( 89.9 ); - if ( points[i].y() <= -89.9 ) points[i].setY( -89.9 ); + if ( points[i].y() >= 89.9 ) + points[i].setY( 89.9 ); + if ( points[i].y() <= -89.9 ) + points[i].setY( -89.9 ); } QgsDebugMsg( QString( "%1,%2" ).arg( points[i].x() ).arg( points[i].y() ) ); @@ -1149,7 +1171,8 @@ void QgsGrassNewMapset::setMapsets() // Add all subdirs containing WIND for ( unsigned int i = 0; i < d.count(); i++ ) { - if ( d[i] == "." || d[i] == ".." ) continue; + if ( d[i] == "." || d[i] == ".." ) + continue; QString mapsetPath = locationPath + "/" + d[i]; QString windPath = mapsetPath + "/WIND"; diff --git a/src/plugins/grass/qgsgrassplugin.cpp b/src/plugins/grass/qgsgrassplugin.cpp index 5aaa544efde..22bb96e7503 100644 --- a/src/plugins/grass/qgsgrassplugin.cpp +++ b/src/plugins/grass/qgsgrassplugin.cpp @@ -69,8 +69,10 @@ QgsGrassPlugin::QgsGrassPlugin( QgisInterface * theQgisInterFace ): QgsGrassPlugin::~QgsGrassPlugin() { - if ( mTools ) mTools->closeTools(); - if ( mEdit ) mEdit->closeEdit(); + if ( mTools ) + mTools->closeTools(); + if ( mEdit ) + mEdit->closeEdit(); QString err = QgsGrass::closeMapset(); } @@ -509,7 +511,8 @@ void QgsGrassPlugin::newVector() name = dialog.getItem( "vector", tr( "New vector name" ), tr( "New vector name" ), "", "", &ok ); - if ( !ok ) return; + if ( !ok ) + return; // Create new map QgsGrass::setMapset( QgsGrass::getDefaultGisdbase(), @@ -589,10 +592,12 @@ void QgsGrassPlugin::displayRegion() // QgsDebugMsg("entered."); mRegionBand->reset(); - if ( !mRegionAction->isChecked() ) { return; } + if ( !mRegionAction->isChecked() ) + return; // Display region of current mapset if in active mode - if ( !QgsGrass::activeMode() ) return; + if ( !QgsGrass::activeMode() ) + return; QString gisdbase = QgsGrass::getDefaultGisdbase(); QString location = QgsGrass::getDefaultLocation(); @@ -693,7 +698,8 @@ void QgsGrassPlugin::openMapset() QgsGrassSelect *sel = new QgsGrassSelect( QgsGrassSelect::MAPSET ); - if ( !sel->exec() ) return; + if ( !sel->exec() ) + return; QString err = QgsGrass::openMapset( sel->gisdbase, sel->location, sel->mapset ); diff --git a/src/plugins/grass/qgsgrassregion.cpp b/src/plugins/grass/qgsgrassregion.cpp index e827ad5768f..fe3934a95d9 100644 --- a/src/plugins/grass/qgsgrassregion.cpp +++ b/src/plugins/grass/qgsgrassregion.cpp @@ -71,7 +71,8 @@ void QgsGrassRegionEdit::canvasPressEvent( QMouseEvent * event ) //! mouse movement in map canvas void QgsGrassRegionEdit::canvasMoveEvent( QMouseEvent * event ) { - if ( !mDraw ) return; + if ( !mDraw ) + return; mEndPoint = toMapCoordinates( event->pos() ); setRegion( mStartPoint, mEndPoint ); @@ -80,7 +81,8 @@ void QgsGrassRegionEdit::canvasMoveEvent( QMouseEvent * event ) //! mouse button released void QgsGrassRegionEdit::canvasReleaseEvent( QMouseEvent * event ) { - if ( !mDraw ) return; + if ( !mDraw ) + return; mEndPoint = toMapCoordinates( event->pos() ); setRegion( mStartPoint, mEndPoint ); @@ -162,7 +164,8 @@ void QgsGrassRegionEdit::drawRegion( QgsMapCanvas *canvas, QgsRubberBand* rubber for ( int i = 0; i < points.size(); i++ ) { bool update = false; // true to update canvas - if ( i == points.size() - 1 ) update = true; + if ( i == points.size() - 1 ) + update = true; rubberBand->addPoint( points[i], update ); } rubberBand->show(); @@ -327,7 +330,8 @@ QgsGrassRegion::~QgsGrassRegion() void QgsGrassRegion::northChanged() { - if ( mUpdatingGui ) return; + if ( mUpdatingGui ) + return; mWindow.north = mNorth->text().toDouble(); if ( mWindow.north < mWindow.south ) @@ -339,7 +343,8 @@ void QgsGrassRegion::northChanged() void QgsGrassRegion::southChanged() { - if ( mUpdatingGui ) return; + if ( mUpdatingGui ) + return; mWindow.south = mSouth->text().toDouble(); if ( mWindow.south > mWindow.north ) @@ -351,7 +356,8 @@ void QgsGrassRegion::southChanged() void QgsGrassRegion::eastChanged() { - if ( mUpdatingGui ) return; + if ( mUpdatingGui ) + return; mWindow.east = mEast->text().toDouble(); if ( mWindow.east < mWindow.west ) @@ -363,7 +369,8 @@ void QgsGrassRegion::eastChanged() void QgsGrassRegion::westChanged() { - if ( mUpdatingGui ) return; + if ( mUpdatingGui ) + return; mWindow.west = mWest->text().toDouble(); if ( mWindow.west > mWindow.east ) @@ -375,7 +382,8 @@ void QgsGrassRegion::westChanged() void QgsGrassRegion::NSResChanged() { - if ( mUpdatingGui ) return; + if ( mUpdatingGui ) + return; mWindow.ns_res = mNSRes->text().toDouble(); if ( mWindow.ns_res <= 0 ) @@ -387,7 +395,8 @@ void QgsGrassRegion::NSResChanged() void QgsGrassRegion::EWResChanged() { - if ( mUpdatingGui ) return; + if ( mUpdatingGui ) + return; mWindow.ew_res = mEWRes->text().toDouble(); if ( mWindow.ew_res <= 0 ) @@ -399,7 +408,8 @@ void QgsGrassRegion::EWResChanged() void QgsGrassRegion::rowsChanged() { - if ( mUpdatingGui ) return; + if ( mUpdatingGui ) + return; mWindow.rows = mRows->text().toInt(); if ( mWindow.rows < 1 ) @@ -411,7 +421,8 @@ void QgsGrassRegion::rowsChanged() void QgsGrassRegion::colsChanged() { - if ( mUpdatingGui ) return; + if ( mUpdatingGui ) + return; mWindow.cols = mCols->text().toInt(); if ( mWindow.cols < 1 ) diff --git a/src/plugins/grass/qgsgrassselect.cpp b/src/plugins/grass/qgsgrassselect.cpp index 326dda7e035..3372097e7c6 100644 --- a/src/plugins/grass/qgsgrassselect.cpp +++ b/src/plugins/grass/qgsgrassselect.cpp @@ -122,18 +122,21 @@ void QgsGrassSelect::setLocations() // Add all subdirs containing PERMANENT/DEFAULT_WIND for ( unsigned int i = 0; i < d.count(); i++ ) { - if ( d[i] == "." || d[i] == ".." ) continue; + if ( d[i] == "." || d[i] == ".." ) + continue; QString ldpath = egisdbase->text() + "/" + d[i]; if ( QgsGrass::versionMajor() > 6 || QgsGrass::versionMinor() > 0 ) { - if ( !G_is_location( ldpath.toLocal8Bit().constData() ) ) continue; + if ( !G_is_location( ldpath.toLocal8Bit().constData() ) ) + continue; } else { QString chf = egisdbase->text() + "/" + d[i] + "/PERMANENT/DEFAULT_WIND"; - if ( !QFile::exists( chf ) ) continue; + if ( !QFile::exists( chf ) ) + continue; } // if type is MAPSET check also if at least one mapset owned by user exists @@ -145,10 +148,12 @@ void QgsGrassSelect::setLocations() for ( unsigned int j = 0; j < ld.count(); j++ ) { - if ( !QgsGrass::isMapset( ldpath + "/" + ld[j] ) ) continue; + if ( !QgsGrass::isMapset( ldpath + "/" + ld[j] ) ) + continue; QFileInfo info( ldpath + "/" + ld[j] ); - if ( !info.isWritable() ) continue; + if ( !info.isWritable() ) + continue; // TODO: check if owner == user: how to get uer name in QT @@ -156,7 +161,8 @@ void QgsGrassSelect::setLocations() break; } - if ( !exists ) continue; + if ( !exists ) + continue; } elocation->addItem( QString( d[i] ) ); @@ -185,7 +191,8 @@ void QgsGrassSelect::setMapsets() emap->clear(); elayer->clear(); - if ( elocation->count() < 1 ) return; + if ( elocation->count() < 1 ) + return; // Location directory QString ldpath = egisdbase->text() + "/" + elocation->currentText(); @@ -227,7 +234,8 @@ void QgsGrassSelect::setMaps() emap->clear(); elayer->clear(); - if ( emapset->count() < 1 ) return; + if ( emapset->count() < 1 ) + return; // Mapset directory QString ldpath = egisdbase->text() + "/" + elocation->currentText() + "/" + emapset->currentText(); @@ -244,7 +252,8 @@ void QgsGrassSelect::setMaps() for ( int j = 0; j < list.count(); j++ ) { emap->addItem( list[j] ); - if ( list[j] == lastVectorMap ) sel = idx; + if ( list[j] == lastVectorMap ) + sel = idx; idx++; } @@ -258,7 +267,8 @@ void QgsGrassSelect::setMaps() for ( int j = 0; j < list.count(); j++ ) { emap->addItem( list[j] ); - if ( list[j] == lastRasterMap ) sel = idx; + if ( list[j] == lastRasterMap ) + sel = idx; idx++; } @@ -269,7 +279,8 @@ void QgsGrassSelect::setMaps() for ( unsigned int j = 0; j < md.count(); j++ ) { - if ( md[j] == "." || md[j] == ".." ) continue; + if ( md[j] == "." || md[j] == ".." ) + continue; QString m = QString( md[j] + " (GROUP)" ); emap->addItem( m ); @@ -320,8 +331,10 @@ void QgsGrassSelect::setLayers() elayer->clear(); - if ( type != VECTOR ) return; - if ( emap->count() < 1 ) return; + if ( type != VECTOR ) + return; + if ( emap->count() < 1 ) + return; QStringList layers = QgsGrass::vectorLayers( egisdbase->text(), elocation->currentText(), emapset->currentText(), @@ -332,7 +345,8 @@ void QgsGrassSelect::setLayers() for ( int i = 0; i < layers.count(); i++ ) { elayer->addItem( layers[i] ); - if ( layers[i] == lastLayer ) sel = idx; + if ( layers[i] == lastLayer ) + sel = idx; idx++; } diff --git a/src/plugins/grass/qgsgrasstools.cpp b/src/plugins/grass/qgsgrasstools.cpp index 8108987c317..dc1fa743a65 100644 --- a/src/plugins/grass/qgsgrasstools.cpp +++ b/src/plugins/grass/qgsgrasstools.cpp @@ -120,7 +120,8 @@ QgsGrassTools::QgsGrassTools( QgisInterface *iface, void QgsGrassTools::moduleClicked( QTreeWidgetItem * item, int column ) { QgsDebugMsg( "entered." ); - if ( !item ) return; + if ( !item ) + return; QString name = item->text( 1 ); QgsDebugMsg( QString( "name = %1" ).arg( name ) ); @@ -129,7 +130,8 @@ void QgsGrassTools::moduleClicked( QTreeWidgetItem * item, int column ) void QgsGrassTools::runModule( QString name ) { - if ( name.length() == 0 ) return; // Section + if ( name.length() == 0 ) + return; // Section #ifndef WIN32 QgsGrassShell* sh = 0; @@ -184,12 +186,15 @@ void QgsGrassTools::runModule( QString name ) // We must call resize to reset COLUMNS environment variable // used by bash !!! +#if 0 /* TODO: Implement something that resizes the terminal without * crashes. - #ifndef WIN32 - if ( sh ) sh->resizeTerminal(); - #endif - */ + */ +#ifndef WIN32 + if ( sh ) + sh->resizeTerminal(); +#endif +#endif } bool QgsGrassTools::loadConfig( QString filePath ) diff --git a/src/plugins/grass/qgsgrassutils.cpp b/src/plugins/grass/qgsgrassutils.cpp index d41ecd15adc..5b7af009ec8 100644 --- a/src/plugins/grass/qgsgrassutils.cpp +++ b/src/plugins/grass/qgsgrassutils.cpp @@ -29,21 +29,19 @@ QString QgsGrassUtils::vectorLayerName( QString map, QString layer, int nLayers ) { QString name = map; - if ( nLayers > 1 ) name += " " + layer; + if ( nLayers > 1 ) + name += " " + layer; return name; } void QgsGrassUtils::addVectorLayers( QgisInterface *iface, QString gisbase, QString location, QString mapset, QString map ) { - QStringList layers = QgsGrass::vectorLayers( - gisbase, location, mapset, map ); - + QStringList layers = QgsGrass::vectorLayers( gisbase, location, mapset, map ); for ( int i = 0; i < layers.count(); i++ ) { - QString name = QgsGrassUtils::vectorLayerName( - map, layers[i], layers.size() ); + QString name = QgsGrassUtils::vectorLayerName( map, layers[i], layers.size() ); QString uri = gisbase + "/" + location + "/" + mapset + "/" + map + "/" + layers[i]; @@ -78,7 +76,8 @@ QString QgsGrassElementDialog::getItem( QString element, QString text, QString source, bool * ok ) { QgsDebugMsg( "entered." ); - if ( ok ) *ok = false; + if ( ok ) + *ok = false; mElement = element; mSource = source; mDialog = new QDialog(); diff --git a/src/plugins/scale_bar/plugin.cpp b/src/plugins/scale_bar/plugin.cpp index 6962666394f..43ceeb90af3 100644 --- a/src/plugins/scale_bar/plugin.cpp +++ b/src/plugins/scale_bar/plugin.cpp @@ -164,9 +164,15 @@ void QgsScaleBarPlugin::run() int myUnits = qGisInterface->mapCanvas()->mapUnits(); switch ( myUnits ) { - case 0: myPluginGui->getSpinSize()->setSuffix( tr( " metres/km" ) ); break; - case 1: myPluginGui->getSpinSize()->setSuffix( tr( " feet/miles" ) ); break; - case 2: myPluginGui->getSpinSize()->setSuffix( tr( " degrees" ) ); break; + case 0: + myPluginGui->getSpinSize()->setSuffix( tr( " metres/km" ) ); + break; + case 1: + myPluginGui->getSpinSize()->setSuffix( tr( " feet/miles" ) ); + break; + case 2: + myPluginGui->getSpinSize()->setSuffix( tr( " degrees" ) ); + break; default: QgsDebugMsg( QString( "Error: not picked up map units - actual value = %1" ).arg( myUnits ) ); }; @@ -196,7 +202,8 @@ void QgsScaleBarPlugin::renderScaleBar( QPainter * theQPainter ) // Exit if the canvas width is 0 or layercount is 0 or QGIS will freeze int myLayerCount = qGisInterface->mapCanvas()->layerCount(); - if ( !myLayerCount || !myCanvasWidth || !myMapUnitsPerPixelDouble ) return; + if ( !myLayerCount || !myCanvasWidth || !myMapUnitsPerPixelDouble ) + return; //Large if statement which determines whether to render the scale bar if ( mEnabled ) diff --git a/src/plugins/sqlanywhere/sadbtablemodel.cpp b/src/plugins/sqlanywhere/sadbtablemodel.cpp index b680dec6e7f..c0d96ff9e27 100644 --- a/src/plugins/sqlanywhere/sadbtablemodel.cpp +++ b/src/plugins/sqlanywhere/sadbtablemodel.cpp @@ -304,7 +304,10 @@ QIcon SaDbTableModel::iconForType( QGis::WkbType type ) const { return SqlAnywhere::getThemeIcon( "/mIconPolygonLayer.png" ); } - else return QIcon(); + else + { + return QIcon(); + } } QGis::WkbType SaDbTableModel::qgisTypeFromDbType( const QString& dbType ) const diff --git a/src/plugins/sqlanywhere/sasourceselect.cpp b/src/plugins/sqlanywhere/sasourceselect.cpp index f8b5e7ad850..68369a5d0d6 100644 --- a/src/plugins/sqlanywhere/sasourceselect.cpp +++ b/src/plugins/sqlanywhere/sasourceselect.cpp @@ -404,7 +404,8 @@ void SaSourceSelect::on_btnConnect_clicked() SaDebugMsg( "Unable to get list of spatially enabled tables " "from the database" ); } - if ( cmbConnections->count() > 0 ) mAddButton->setEnabled( true ); + if ( cmbConnections->count() > 0 ) + mAddButton->setEnabled( true ); conn->release(); diff --git a/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp b/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp index 3be196c22e2..a9fd8a7b606 100644 --- a/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp +++ b/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp @@ -155,13 +155,20 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( QString uri ) QString xField; QString yField; - if ( url.hasQueryItem( "delimiter" ) ) mDelimiter = url.queryItemValue( "delimiter" ); - if ( url.hasQueryItem( "delimiterType" ) ) mDelimiterType = url.queryItemValue( "delimiterType" ); - if ( url.hasQueryItem( "wktField" ) ) wktField = url.queryItemValue( "wktField" ); - if ( url.hasQueryItem( "xField" ) ) xField = url.queryItemValue( "xField" ); - if ( url.hasQueryItem( "yField" ) ) yField = url.queryItemValue( "yField" ); - if ( url.hasQueryItem( "skipLines" ) ) mSkipLines = url.queryItemValue( "skipLines" ).toInt(); - if ( url.hasQueryItem( "crs" ) ) mCrs.createFromString( url.queryItemValue( "crs" ) ); + if ( url.hasQueryItem( "delimiter" ) ) + mDelimiter = url.queryItemValue( "delimiter" ); + if ( url.hasQueryItem( "delimiterType" ) ) + mDelimiterType = url.queryItemValue( "delimiterType" ); + if ( url.hasQueryItem( "wktField" ) ) + wktField = url.queryItemValue( "wktField" ); + if ( url.hasQueryItem( "xField" ) ) + xField = url.queryItemValue( "xField" ); + if ( url.hasQueryItem( "yField" ) ) + yField = url.queryItemValue( "yField" ); + if ( url.hasQueryItem( "skipLines" ) ) + mSkipLines = url.queryItemValue( "skipLines" ).toInt(); + if ( url.hasQueryItem( "crs" ) ) + mCrs.createFromString( url.queryItemValue( "crs" ) ); QgsDebugMsg( "Data source uri is " + uri ); QgsDebugMsg( "Delimited text file is: " + mFileName ); diff --git a/src/providers/gdal/qgsgdalprovider.cpp b/src/providers/gdal/qgsgdalprovider.cpp index a506f0a1774..4659c39d66e 100644 --- a/src/providers/gdal/qgsgdalprovider.cpp +++ b/src/providers/gdal/qgsgdalprovider.cpp @@ -105,7 +105,8 @@ QgsGdalProvider::QgsGdalProvider( QString const & uri ) registerGdalDrivers(); // To get buildSupportedRasterFileFilter the provider is called with empty uri - if ( uri.isEmpty() ) return; + if ( uri.isEmpty() ) + return; mGdalDataset = NULL; @@ -390,7 +391,8 @@ QgsGdalProvider::~QgsGdalProvider() // This was used by raster layer to reload data void QgsGdalProvider::closeDataset() { - if ( !mValid ) return; + if ( !mValid ) + return; mValid = false; GDALDereferenceDataset( mGdalBaseDataset ); @@ -918,7 +920,8 @@ double QgsGdalProvider::noDataValue() const void QgsGdalProvider::computeMinMax( int theBandNo ) { QgsDebugMsg( QString( "theBandNo = %1 mMinMaxComputed = %2" ).arg( theBandNo ).arg( mMinMaxComputed[theBandNo-1] ) ); - if ( mMinMaxComputed[theBandNo-1] ) return; + if ( mMinMaxComputed[theBandNo-1] ) + return; double GDALrange[2]; GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, theBandNo ); GDALComputeRasterMinMax( myGdalBand, 1, GDALrange ); //Approximate @@ -1723,7 +1726,7 @@ void buildSupportedRasterFileFilterAndExtensions( QString & theFileFiltersString { // XXX add check for SDTS; in that case we want (*CATD.DDF) QString glob = "*." + myGdalDriverExtension.replace( "/", " *." ); - theExtensions << myGdalDriverExtension.replace( "/", "" ).replace("*", "").replace(".",""); + theExtensions << myGdalDriverExtension.replace( "/", "" ).replace( "*", "" ).replace( ".", "" ); // Add only the first JP2 driver found to the filter list (it's the one GDAL uses) if ( myGdalDriverDescription == "JPEG2000" || myGdalDriverDescription.startsWith( "JP2" ) ) // JP2ECW, JP2KAK, JP2MrSID @@ -1869,18 +1872,19 @@ QGISEXTERN void buildSupportedRasterFileFilter( QString & theFileFiltersString ) buildSupportedRasterFileFilterAndExtensions( theFileFiltersString, exts, wildcards ); } -QGISEXTERN int dataCapabilities () { +QGISEXTERN int dataCapabilities() +{ return QgsDataProvider::File | QgsDataProvider::Dir; } -QgsGdalLayerItem::QgsGdalLayerItem ( QgsDataItem* parent, - QString name, QString path, QString uri ) - : QgsLayerItem ( parent, name, path, uri, QgsLayerItem::Raster, "gdal" ) +QgsGdalLayerItem::QgsGdalLayerItem( QgsDataItem* parent, + QString name, QString path, QString uri ) + : QgsLayerItem( parent, name, path, uri, QgsLayerItem::Raster, "gdal" ) { } -QgsGdalLayerItem::~QgsGdalLayerItem () +QgsGdalLayerItem::~QgsGdalLayerItem() { } @@ -1891,37 +1895,40 @@ QgsLayerItem::Capability QgsGdalLayerItem::capabilities() GDALAllRegister(); GDALDatasetH hDS = GDALOpen( TO8F( mPath ), GA_Update ); - if ( hDS == NULL ) return NoCapabilities; + if ( !hDS ) + return NoCapabilities; return SetCrs; } -bool QgsGdalLayerItem::setCrs ( QgsCoordinateReferenceSystem crs ) +bool QgsGdalLayerItem::setCrs( QgsCoordinateReferenceSystem crs ) { QgsDebugMsg( "mPath = " + mPath ); GDALAllRegister(); GDALDatasetH hDS = GDALOpen( TO8F( mPath ), GA_Update ); - if ( hDS == NULL ) return false; + if ( !hDS ) + return false; QString wkt = crs.toWkt(); - if ( GDALSetProjection ( hDS, wkt.toLocal8Bit().data() ) != CE_None ) + if ( GDALSetProjection( hDS, wkt.toLocal8Bit().data() ) != CE_None ) { QgsDebugMsg( "Could not set CRS" ); return false; } - GDALClose ( hDS ); + GDALClose( hDS ); return true; } static QStringList extensions = QStringList(); static QStringList wildcards = QStringList(); -QGISEXTERN QgsDataItem * dataItem ( QString thePath, QgsDataItem* parentItem ) +QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem ) { - if ( thePath.isEmpty() ) return 0; + if ( thePath.isEmpty() ) + return 0; - QFileInfo info ( thePath ); + QFileInfo info( thePath ); if ( info.isFile() ) { // Filter files by extension @@ -1929,29 +1936,30 @@ QGISEXTERN QgsDataItem * dataItem ( QString thePath, QgsDataItem* parentItem ) { QString filterString; buildSupportedRasterFileFilterAndExtensions( filterString, extensions, wildcards ); - QgsDebugMsg( "extensions: " + extensions.join(" ") ); - QgsDebugMsg( "wildcards: " + wildcards.join(" ") ); + QgsDebugMsg( "extensions: " + extensions.join( " " ) ); + QgsDebugMsg( "wildcards: " + wildcards.join( " " ) ); } - if ( extensions.indexOf ( info.suffix().toLower() ) < 0 ) + if ( extensions.indexOf( info.suffix().toLower() ) < 0 ) { bool matches = false; - foreach (QString wildcard, wildcards) + foreach( QString wildcard, wildcards ) { - QRegExp rx(wildcard, Qt::CaseInsensitive, QRegExp::Wildcard); - if (rx.exactMatch(info.fileName())) + QRegExp rx( wildcard, Qt::CaseInsensitive, QRegExp::Wildcard ); + if ( rx.exactMatch( info.fileName() ) ) { matches = true; break; } } - if (!matches) + if ( !matches ) return 0; } GDALAllRegister(); GDALDatasetH hDS = GDALOpen( TO8F( thePath ), GA_ReadOnly ); - if ( hDS == NULL ) return 0; + if ( !hDS ) + return 0; QgsDebugMsg( "GdalDataset opened " + thePath ); diff --git a/src/providers/gdal/qgsgdalprovider.h b/src/providers/gdal/qgsgdalprovider.h index dbfdf901624..f3fc59709d8 100644 --- a/src/providers/gdal/qgsgdalprovider.h +++ b/src/providers/gdal/qgsgdalprovider.h @@ -289,11 +289,11 @@ class QgsGdalProvider : public QgsRasterDataProvider class QgsGdalLayerItem : public QgsLayerItem { public: - QgsGdalLayerItem ( QgsDataItem* parent, + QgsGdalLayerItem( QgsDataItem* parent, QString name, QString path, QString uri ); - ~QgsGdalLayerItem (); + ~QgsGdalLayerItem(); - bool setCrs ( QgsCoordinateReferenceSystem crs ); + bool setCrs( QgsCoordinateReferenceSystem crs ); Capability capabilities(); }; diff --git a/src/providers/grass/qgis.g.info.c b/src/providers/grass/qgis.g.info.c index 818c48f9586..613abb7b88d 100644 --- a/src/providers/grass/qgis.g.info.c +++ b/src/providers/grass/qgis.g.info.c @@ -161,8 +161,10 @@ int main( int argc, char **argv ) { col = ( int ) G_easting_to_col( x, &window ); row = ( int ) G_northing_to_row( y, &window ); - if ( col == window.cols ) col--; - if ( row == window.rows ) row--; + if ( col == window.cols ) + col--; + if ( row == window.rows ) + row--; if ( col < 0 || col > window.cols || row < 0 || row > window.rows ) { diff --git a/src/providers/grass/qgsgrass.cpp b/src/providers/grass/qgsgrass.cpp index 40b2836742a..252a70284bf 100644 --- a/src/providers/grass/qgsgrass.cpp +++ b/src/providers/grass/qgsgrass.cpp @@ -299,13 +299,15 @@ bool QgsGrass::isValidGrassBaseDir( QString const gisBase ) #if 0 if ( QgsGrass::versionMajor() > 6 || QgsGrass::versionMinor() > 0 ) { - if ( G_is_gisbase( gisBase.toUtf8().constData() ) ) return true; + if ( G_is_gisbase( gisBase.toUtf8().constData() ) ) + return true; } else { #endif QFileInfo gbi( gisBase + "/etc/element_list" ); - if ( gbi.exists() ) return true; + if ( gbi.exists() ) + return true; #if 0 } #endif @@ -443,7 +445,8 @@ QString GRASS_EXPORT QgsGrass::openMapset( QString gisdbase, QString location, Q // Check if the mapset is in use QString gisBase = getenv( "GISBASE" ); - if ( gisBase.isEmpty() ) return QObject::tr( "GISBASE is not set." ); + if ( gisBase.isEmpty() ) + return QObject::tr( "GISBASE is not set." ); QFileInfo fi( mapsetPath + "/WIND" ); if ( !fi.exists() ) @@ -546,7 +549,8 @@ QString GRASS_EXPORT QgsGrass::openMapset( QString gisdbase, QString location, Q { continue; } - if ( line.contains( "GRASS_GUI:" ) ) guiSet = true; + if ( line.contains( "GRASS_GUI:" ) ) + guiSet = true; stream << line; } in.close(); @@ -635,7 +639,8 @@ QString QgsGrass::closeMapset( ) QDir dir( mTmp ); for ( unsigned int i = 0; i < dir.count(); i++ ) { - if ( dir[i] == "." || dir[i] == ".." ) continue; + if ( dir[i] == "." || dir[i] == ".." ) + continue; dir.remove( dir[i] ); if ( dir.remove( dir[i] ) ) @@ -660,7 +665,8 @@ QStringList GRASS_EXPORT QgsGrass::locations( QString gisbase ) QStringList list; - if ( gisbase.isEmpty() ) return list; + if ( gisbase.isEmpty() ) + return list; QDir d = QDir( gisbase ); d.setFilter( QDir::NoDotAndDotDot | QDir::Dirs ); @@ -692,7 +698,8 @@ QStringList GRASS_EXPORT QgsGrass::mapsets( QString locationPath ) QStringList list; - if ( locationPath.isEmpty() ) return list; + if ( locationPath.isEmpty() ) + return list; QDir d = QDir( locationPath ); d.setFilter( QDir::NoDotAndDotDot | QDir::Dirs ); @@ -750,7 +757,8 @@ QStringList GRASS_EXPORT QgsGrass::vectors( QString mapsetPath ) QStringList list; - if ( mapsetPath.isEmpty() ) return list; + if ( mapsetPath.isEmpty() ) + return list; QDir d = QDir( mapsetPath + "/vector" ); d.setFilter( QDir::NoDotAndDotDot | QDir::Dirs ); @@ -905,7 +913,8 @@ QStringList GRASS_EXPORT QgsGrass::rasters( QString mapsetPath ) QStringList list; - if ( mapsetPath.isEmpty() ) return list; + if ( mapsetPath.isEmpty() ) + return list; QDir d = QDir( mapsetPath + "/cellhd" ); d.setFilter( QDir::Files ); @@ -933,7 +942,8 @@ QStringList GRASS_EXPORT QgsGrass::elements( QString mapsetPath, QString element QStringList list; - if ( mapsetPath.isEmpty() ) return list; + if ( mapsetPath.isEmpty() ) + return list; QDir d = QDir( mapsetPath + "/" + element ); d.setFilter( QDir::Files ); @@ -1356,7 +1366,8 @@ QHash GRASS_EXPORT QgsGrass::info( QString gisdbase, QString l for ( int i = 0; i < list.size(); i++ ) { QStringList keyVal = list[i].split( ':' ); - if ( list[i].isEmpty() ) { continue; } + if ( list[i].isEmpty() ) + continue; if ( keyVal.size() != 2 ) { throw QgsGrass::Exception( "Cannot parse GRASS map info key value : " + list[i] + " (" + str + " ) " ); @@ -1385,7 +1396,8 @@ QList GRASS_EXPORT QgsGrass::colors( QString gisdbase, QString for ( int i = 0; i < list.size(); i++ ) { QgsGrass::Color c; - if ( list[i].isEmpty() ) { continue; } + if ( list[i].isEmpty() ) + continue; if ( sscanf( list[i].toUtf8().data(), "%lf %lf %d %d %d %d %d %d", &( c.value1 ), &( c.value2 ), &( c.red1 ), &( c.green1 ), &( c.blue1 ), &( c.red2 ), &( c.green2 ), &( c.blue2 ) ) != 8 ) { throw QgsGrass::Exception( "Cannot parse GRASS colors" + list[i] + " (" + str + " ) " ); @@ -1462,19 +1474,24 @@ QString GRASS_EXPORT QgsGrass::versionString() bool GRASS_EXPORT QgsGrass::isMapset( QString path ) { +#if 0 /* TODO: G_is_mapset() was added to GRASS 6.1 06-05-24, enable its use after some period (others do update) */ - /* + if ( QgsGrass::versionMajor() > 6 || QgsGrass::versionMinor() > 0 ) { - if ( G_is_mapset( path.toUtf8().constData() ) ) return true; + if ( G_is_mapset( path.toUtf8().constData() ) ) + return true; } else { - */ - QString windf = path + "/WIND"; - if ( QFile::exists( windf ) ) return true; - //} +#endif + QString windf = path + "/WIND"; + if ( QFile::exists( windf ) ) + return true; +#if 0 + } +#endif return false; } diff --git a/src/providers/grass/qgsgrassprovider.cpp b/src/providers/grass/qgsgrassprovider.cpp index 65e476797d5..1add895e966 100644 --- a/src/providers/grass/qgsgrassprovider.cpp +++ b/src/providers/grass/qgsgrassprovider.cpp @@ -247,7 +247,8 @@ void QgsGrassProvider::update( void ) QgsDebugMsg( QString( "mNumberFeatures = %1 mCidxFieldIndex = %2 mCidxFieldNumCats = %3" ).arg( mNumberFeatures ).arg( mCidxFieldIndex ).arg( mCidxFieldNumCats ) ); // Create selection array - if ( mSelection ) free( mSelection ); + if ( mSelection ) + free( mSelection ); mSelectionSize = allocateSelection( mMap, &mSelection ); resetSelection( 1 ); @@ -431,7 +432,8 @@ bool QgsGrassProvider::nextFeature( QgsFeature& feature ) void QgsGrassProvider::resetSelection( bool sel ) { QgsDebugMsg( "entered." ); - if ( !mValid ) return; + if ( !mValid ) + return; memset( mSelection, ( int ) sel, mSelectionSize ); mNextCidx = 0; } @@ -646,7 +648,8 @@ int QgsGrassProvider::openLayer( QString gisdbase, QString location, QString map for ( unsigned int i = 0; i < mLayers.size(); i++ ) { - if ( !( mLayers[i].valid ) ) continue; + if ( !( mLayers[i].valid ) ) + continue; GMAP *mp = &( mMaps[mLayers[i].mapId] ); @@ -729,7 +732,8 @@ void QgsGrassProvider::loadAttributes( GLAYER &layer ) // TODO: free old attributes - if ( !layer.map ) return; + if ( !layer.map ) + return; // Get field info layer.fieldInfo = Vect_get_field( layer.map, layer.field ); // should work also with field = 0 @@ -740,7 +744,7 @@ void QgsGrassProvider::loadAttributes( GLAYER &layer ) layer.attributes = 0; layer.fields.clear(); layer.keyColumn = -1; - if ( layer.fieldInfo == NULL ) + if ( !layer.fieldInfo ) { QgsDebugMsg( "No field info -> no attribute table" ); } @@ -750,7 +754,7 @@ void QgsGrassProvider::loadAttributes( GLAYER &layer ) dbDriver *databaseDriver = db_start_driver_open_database( layer.fieldInfo->driver, layer.fieldInfo->database ); - if ( databaseDriver == NULL ) + if ( !databaseDriver ) { QgsDebugMsg( QString( "Cannot open database %1 by driver %2" ).arg( layer.fieldInfo->database ).arg( layer.fieldInfo->driver ) ); } @@ -843,15 +847,18 @@ void QgsGrassProvider::loadAttributes( GLAYER &layer ) QgsDebugMsg( "Cannot fetch DB record" ); break; } - if ( !more ) break; // no more records + if ( !more ) + break; // no more records // Check cat value dbColumn *column = db_get_table_column( databaseTable, layer.keyColumn ); dbValue *value = db_get_column_value( column ); - if ( db_test_value_isnull( value ) ) continue; + if ( db_test_value_isnull( value ) ) + continue; layer.attributes[layer.nAttributes].cat = db_get_value_int( value ); - if ( layer.attributes[layer.nAttributes].cat < 0 ) continue; + if ( layer.attributes[layer.nAttributes].cat < 0 ) + continue; layer.attributes[layer.nAttributes].values = ( char ** ) malloc( layer.nColumns * sizeof( char* ) ); @@ -1016,7 +1023,7 @@ int QgsGrassProvider::openMap( QString gisdbase, QString location, QString mapse // Find the vector const char *ms = G_find_vector2( mapName.toUtf8().data(), mapset.toUtf8().data() ) ; - if ( ms == NULL ) + if ( !ms ) { QgsDebugMsg( "Cannot find GRASS vector" ); return -1; @@ -1051,7 +1058,8 @@ int QgsGrassProvider::openMap( QString gisdbase, QString location, QString mapse tr( "GRASS vector map %1 does not have topology. Build topology?" ).arg( mapName ), QMessageBox::Ok | QMessageBox::Cancel ); - if ( ret == QMessageBox::Cancel ) return -1; + if ( ret == QMessageBox::Cancel ) + return -1; } // Open vector @@ -1148,7 +1156,8 @@ void QgsGrassProvider::updateMap( int mapId ) for ( unsigned int i = 0; i < mLayers.size(); i++ ) { - // if ( !(mLayers[i].valid) ) continue; // ? + // if ( !(mLayers[i].valid) ) + // continue; // ? if ( mLayers[i].mapId == mapId ) { @@ -1179,7 +1188,7 @@ void QgsGrassProvider::closeMap( int mapId ) if ( mMaps[mapId].valid ) { - bool mapsetunset = G__getenv( "MAPSET" ) == NULL || *G__getenv( "MAPSET" ) == 0; + bool mapsetunset = !G__getenv( "MAPSET" ) || !*G__getenv( "MAPSET" ); if ( mapsetunset ) G__setenv(( char * )"MAPSET", mMaps[mapId].mapset.toUtf8().data() ); try @@ -1403,11 +1412,13 @@ void QgsGrassProvider::freeze() { QgsDebugMsg( "entered." ); - if ( !isValid() ) return; + if ( !isValid() ) + return; GMAP *map = &( mMaps[mLayers[mLayerId].mapId] ); - if ( map->frozen ) return; + if ( map->frozen ) + return; map->frozen = true; Vect_close( map->map ); @@ -1417,10 +1428,12 @@ void QgsGrassProvider::thaw() { QgsDebugMsg( "entered." ); - if ( !isValid() ) return; + if ( !isValid() ) + return; GMAP *map = &( mMaps[mLayers[mLayerId].mapId] ); - if ( !map->frozen ) return; + if ( !map->frozen ) + return; if ( reopenMap() ) { @@ -1556,7 +1569,8 @@ bool QgsGrassProvider::closeEdit( bool newMap ) map->update = false; - if ( !reopenMap() ) return false; + if ( !reopenMap() ) + return false; map->valid = true; @@ -1591,7 +1605,8 @@ bool QgsGrassProvider::reopenMap() // Reload sources to layers for ( unsigned int i = 0; i < mLayers.size(); i++ ) { - // if ( !(mLayers[i].valid) ) continue; // ? + // if ( !(mLayers[i].valid) ) + // continue; // ? if ( mLayers[i].mapId == mLayers[mLayerId].mapId ) { @@ -1626,7 +1641,8 @@ int QgsGrassProvider::readLine( struct line_pnts *Points, struct line_cats *Cats if ( Cats ) Vect_reset_cats( Cats ); - if ( !Vect_line_alive( mMap, line ) ) return -1; + if ( !Vect_line_alive( mMap, line ) ) + return -1; return ( Vect_read_line( mMap, Points, Cats, line ) ); } @@ -1821,7 +1837,7 @@ QString *QgsGrassProvider::key( int field ) struct field_info *fi = Vect_get_field( mMap, field ); // should work also with field = 0 - if ( fi == NULL ) + if ( !fi ) { QgsDebugMsg( "No field info -> no attributes" ); return key; @@ -1840,7 +1856,7 @@ std::vector *QgsGrassProvider::columns( int field ) struct field_info *fi = Vect_get_field( mMap, field ); // should work also with field = 0 // Read attributes - if ( fi == NULL ) + if ( !fi ) { QgsDebugMsg( "No field info -> no attributes" ); return ( col ); @@ -1850,7 +1866,7 @@ std::vector *QgsGrassProvider::columns( int field ) QgsGrass::setMapset( mGisdbase, mLocation, mMapset ); dbDriver *driver = db_start_driver_open_database( fi->driver, fi->database ); - if ( driver == NULL ) + if ( !driver ) { QgsDebugMsg( QString( "Cannot open database %1 by driver %2" ).arg( fi->database ).arg( fi->driver ) ); return ( col ); @@ -1914,7 +1930,7 @@ QgsAttributeMap *QgsGrassProvider::attributes( int field, int cat ) struct field_info *fi = Vect_get_field( mMap, field ); // should work also with field = 0 // Read attributes - if ( fi == NULL ) + if ( !fi ) { QgsDebugMsg( "No field info -> no attributes" ); return att; @@ -1924,7 +1940,7 @@ QgsAttributeMap *QgsGrassProvider::attributes( int field, int cat ) QgsGrass::setMapset( mGisdbase, mLocation, mMapset ); dbDriver *driver = db_start_driver_open_database( fi->driver, fi->database ); - if ( driver == NULL ) + if ( !driver ) { QgsDebugMsg( QString( "Cannot open database %1 by driver %2" ).arg( fi->database ).arg( fi->driver ) ); return att; @@ -1995,7 +2011,7 @@ QString *QgsGrassProvider::updateAttributes( int field, int cat, const QString & struct field_info *fi = Vect_get_field( mMap, field ); // should work also with field = 0 // Read attributes - if ( fi == NULL ) + if ( !fi ) { QgsDebugMsg( "No field info -> no attributes" ); *error = QString::fromLatin1( "Cannot get field info" ); @@ -2006,7 +2022,7 @@ QString *QgsGrassProvider::updateAttributes( int field, int cat, const QString & QgsGrass::setMapset( mGisdbase, mLocation, mMapset ); dbDriver *driver = db_start_driver_open_database( fi->driver, fi->database ); - if ( driver == NULL ) + if ( !driver ) { QgsDebugMsg( QString( "Cannot open database %1 by driver %2" ).arg( fi->database ).arg( fi->driver ) ); *error = QString::fromUtf8( "Cannot open database" ); @@ -2066,7 +2082,8 @@ int QgsGrassProvider::dbLinkField( int link ) struct field_info *fi = Vect_get_dblink( mMap, link ); - if ( fi == NULL ) return 0; + if ( !fi ) + return 0; return ( fi->number ); } @@ -2079,7 +2096,7 @@ QString *QgsGrassProvider::executeSql( int field, const QString &sql ) struct field_info *fi = Vect_get_field( mMap, field ); // should work also with field = 0 // Read attributes - if ( fi == NULL ) + if ( !fi ) { QgsDebugMsg( "No field info -> no attributes" ); *error = QString::fromLatin1( "Cannot get field info" ); @@ -2091,7 +2108,7 @@ QString *QgsGrassProvider::executeSql( int field, const QString &sql ) QgsGrass::setMapset( mGisdbase, mLocation, mMapset ); dbDriver *driver = db_start_driver_open_database( fi->driver, fi->database ); - if ( driver == NULL ) + if ( !driver ) { QgsDebugMsg( QString( "Cannot open database %1 by driver %2" ).arg( fi->database ).arg( fi->driver ) ); *error = QString::fromUtf8( "Cannot open database" ); @@ -2152,8 +2169,7 @@ QString *QgsGrassProvider::createTable( int field, const QString &key, const QSt } dbDriver *driver = db_start_driver_open_database( fi->driver, fi->database ); - - if ( driver == NULL ) + if ( !driver ) { QgsDebugMsg( QString( "Cannot open database %1 by driver %2" ).arg( fi->database ).arg( fi->driver ) ); *error = QString::fromUtf8( "Cannot open database" ); @@ -2182,7 +2198,8 @@ QString *QgsGrassProvider::createTable( int field, const QString &key, const QSt db_close_database_shutdown_driver( driver ); db_free_string( &dbstr ); - if ( !error->isEmpty() ) return error; + if ( !error->isEmpty() ) + return error; ret = Vect_map_add_dblink( mMap, field, NULL, fi->table, key.toLatin1().data(), fi->database, fi->driver ); @@ -2204,7 +2221,7 @@ QString *QgsGrassProvider::addColumn( int field, const QString &column ) struct field_info *fi = Vect_get_field( mMap, field ); // should work also with field = 0 // Read attributes - if ( fi == NULL ) + if ( !fi ) { QgsDebugMsg( "No field info" ); *error = QString::fromLatin1( "Cannot get field info" ); @@ -2227,7 +2244,7 @@ QString *QgsGrassProvider::insertAttributes( int field, int cat ) struct field_info *fi = Vect_get_field( mMap, field ); // should work also with field = 0 // Read attributes - if ( fi == NULL ) + if ( !fi ) { QgsDebugMsg( "No field info -> no attributes" ); *error = QString::fromLatin1( "Cannot get field info" ); @@ -2250,7 +2267,7 @@ QString *QgsGrassProvider::deleteAttributes( int field, int cat ) struct field_info *fi = Vect_get_field( mMap, field ); // should work also with field = 0 // Read attributes - if ( fi == NULL ) + if ( !fi ) { QgsDebugMsg( "No field info -> no attributes" ); *error = QString::fromLatin1( "Cannot get field info" ); @@ -2291,7 +2308,7 @@ QString *QgsGrassProvider::isOrphan( int field, int cat, int *orphan ) struct field_info *fi = Vect_get_field( mMap, field ); // should work also with field = 0 // Read attributes - if ( fi == NULL ) + if ( !fi ) { QgsDebugMsg( "No field info -> no attributes" ); *orphan = false; @@ -2302,7 +2319,7 @@ QString *QgsGrassProvider::isOrphan( int field, int cat, int *orphan ) QgsGrass::setMapset( mGisdbase, mLocation, mMapset ); dbDriver *driver = db_start_driver_open_database( fi->driver, fi->database ); - if ( driver == NULL ) + if ( !driver ) { QgsDebugMsg( QString( "Cannot open database %1 by driver %2" ).arg( fi->database ).arg( fi->driver ) ); *error = QString::fromUtf8( "Cannot open database" ); @@ -2330,7 +2347,8 @@ QString *QgsGrassProvider::isOrphan( int field, int cat, int *orphan ) int nRecords = db_get_num_rows( &cursor ); QgsDebugMsg( QString( "Number of records: %1" ).arg( nRecords ) ); - if ( nRecords > 0 ) { *orphan = true; } + if ( nRecords > 0 ) + *orphan = true; db_close_database_shutdown_driver( driver ); db_free_string( &dbstr ); @@ -2444,16 +2462,22 @@ QVector QgsGrassMapsetItem::createChildren() QString path = mPath + QDir::separator() + "vector" + QDir::separator() + name; QgsDataCollectionItem *map; - if ( layerNames.size() != 1 ) map = new QgsDataCollectionItem( this, name ); + if ( layerNames.size() != 1 ) + map = new QgsDataCollectionItem( this, name ); foreach( QString layerName, layerNames ) { QString uri = mPath + QDir::separator() + name + QDir::separator() +layerName; QgsLayerItem::LayerType layerType = QgsLayerItem::Vector; QString typeName = layerName.split("_")[1]; QString baseLayerName = layerName.split("_")[0]; - if ( typeName == "point" ) layerType = QgsLayerItem::Point; - else if ( typeName == "line" ) layerType = QgsLayerItem::Line; - else if ( typeName == "polygon" ) layerType = QgsLayerItem::Polygon; + + if ( typeName == "point" ) + layerType = QgsLayerItem::Point; + else if ( typeName == "line" ) + layerType = QgsLayerItem::Line; + else if ( typeName == "polygon" ) + layerType = QgsLayerItem::Polygon; + if ( layerNames.size() == 1 ) { @@ -2466,7 +2490,8 @@ QVector QgsGrassMapsetItem::createChildren() map->addChild( layer ); } } - if ( layerNames.size() != 1 ) items.append( map ); + if ( layerNames.size() != 1 ) + items.append( map ); } QStringList rasterNames = QgsGrass::rasters( mPath ); @@ -2496,4 +2521,4 @@ QGISEXTERN QgsDataItem * dataItem ( QString thePath, QgsDataItem* parentItem ) return location; } return 0; -} \ No newline at end of file +} diff --git a/src/providers/grass/qgsgrassrasterprovider.cpp b/src/providers/grass/qgsgrassrasterprovider.cpp index e4df8855d66..af932d2c955 100644 --- a/src/providers/grass/qgsgrassrasterprovider.cpp +++ b/src/providers/grass/qgsgrassrasterprovider.cpp @@ -211,7 +211,8 @@ void QgsGrassRasterProvider::readBlock( int bandNo, QgsRectangle const & viewEx QgsDebugMsg( "pixelHeight = " + QString::number( pixelHeight ) ); QgsDebugMsg( "viewExtent: " + viewExtent.toString() ); - if ( pixelWidth <= 0 || pixelHeight <= 0 ) return; + if ( pixelWidth <= 0 || pixelHeight <= 0 ) + return; QStringList arguments; arguments.append( "map=" + mMapName + "@" + mMapset ); @@ -572,7 +573,8 @@ QgsGrassRasterValue::~QgsGrassRasterValue() QString QgsGrassRasterValue::value( double x, double y ) { QString value = "error"; - if ( !mProcess ) return value; // throw some exception? + if ( !mProcess ) + return value; // throw some exception? QString coor = QString( "%1 %2\n" ).arg( x ).arg( y ); QgsDebugMsg( "coor : " + coor ); mProcess->write( coor.toAscii() ); // how to flush, necessary? diff --git a/src/providers/memory/qgsmemoryprovider.cpp b/src/providers/memory/qgsmemoryprovider.cpp index e152d4854cf..b10e984a431 100644 --- a/src/providers/memory/qgsmemoryprovider.cpp +++ b/src/providers/memory/qgsmemoryprovider.cpp @@ -123,7 +123,8 @@ QgsMemoryProvider::QgsMemoryProvider( QString uri ) precision = reFieldDef.cap( 3 ).toInt(); } } - if ( name != "" ) attributes.append( QgsField( name, type, typeName, length, precision ) ); + if ( name != "" ) + attributes.append( QgsField( name, type, typeName, length, precision ) ); } addAttributes( attributes ); } @@ -447,7 +448,8 @@ bool QgsMemoryProvider::addAttributes( const QList &attributes ) // add new field as a last one int nextId = -1; for ( QgsFieldMap::iterator it2 = mFields.begin(); it2 != mFields.end(); ++it2 ) - if ( it2.key() > nextId ) nextId = it2.key(); + if ( it2.key() > nextId ) + nextId = it2.key(); mFields[nextId+1] = *it; } return true; diff --git a/src/providers/ogr/qgsogrprovider.cpp b/src/providers/ogr/qgsogrprovider.cpp index e8e181b0000..b9f64d75e56 100644 --- a/src/providers/ogr/qgsogrprovider.cpp +++ b/src/providers/ogr/qgsogrprovider.cpp @@ -159,7 +159,7 @@ QgsOgrProvider::QgsOgrProvider( QString const & uri ) CPLSetConfigOption( "OGR_ORGANIZE_POLYGONS", "ONLY_CCW" ); // "SKIP" returns MULTIPOLYGONs for multiringed POLYGONs ogrDataSource = OGROpen( TO8F( mFilePath ), true, &ogrDriver ); - if ( ogrDataSource == NULL ) + if ( !ogrDataSource ) { // try to open read-only ogrDataSource = OGROpen( TO8F( mFilePath ), false, &ogrDriver ); @@ -168,7 +168,7 @@ QgsOgrProvider::QgsOgrProvider( QString const & uri ) //TODO is in read-only mode, otherwise edit ops will fail //TODO: capabilities() should now reflect this; need to test. } - if ( ogrDataSource != NULL ) + if ( ogrDataSource ) { QgsDebugMsg( "Data source is valid" ); @@ -357,7 +357,7 @@ void QgsOgrProvider::setEncoding( const QString& e ) } // This is reused by dataItem -int getOgrGeomType ( OGRLayerH ogrLayer ) +int getOgrGeomType( OGRLayerH ogrLayer ) { OGRFeatureDefnH fdef = OGR_L_GetLayerDefn( ogrLayer ); int geomType = wkbUnknown; @@ -391,7 +391,7 @@ void QgsOgrProvider::loadFields() //the attribute fields need to be read again when the encoding changes mAttributeFields.clear(); - geomType = getOgrGeomType ( ogrLayer ); + geomType = getOgrGeomType( ogrLayer ); OGRFeatureDefnH fdef = OGR_L_GetLayerDefn( ogrLayer ); if ( fdef ) { @@ -463,13 +463,13 @@ bool QgsOgrProvider::featureAtId( int featureId, setRelevantFields( fetchGeometry, fetchAttributes ); OGRFeatureH fet = OGR_L_GetFeature( ogrLayer, featureId ); - if ( fet == NULL ) + if ( !fet ) return false; feature.setFeatureId( OGR_F_GetFID( fet ) ); feature.clearAttributeMap(); // skip features without geometry - if ( OGR_F_GetGeometryRef( fet ) == NULL && !mFetchFeaturesWithoutGeom ) + if ( !OGR_F_GetGeometryRef( fet ) && !mFetchFeaturesWithoutGeom ) { OGR_F_Destroy( fet ); return false; @@ -521,10 +521,10 @@ bool QgsOgrProvider::nextFeature( QgsFeature& feature ) setRelevantFields( mFetchGeom, mAttributesToFetch ); - while (( fet = OGR_L_GetNextFeature( ogrLayer ) ) != NULL ) + while ( ( fet = OGR_L_GetNextFeature( ogrLayer ) ) ) { // skip features without geometry - if ( !mFetchFeaturesWithoutGeom && OGR_F_GetGeometryRef( fet ) == NULL ) + if ( !mFetchFeaturesWithoutGeom && !OGR_F_GetGeometryRef( fet ) ) { OGR_F_Destroy( fet ); continue; @@ -657,8 +657,8 @@ unsigned char * QgsOgrProvider::getGeometryPointer( OGRFeatureH fet ) OGRGeometryH geom = OGR_F_GetGeometryRef( fet ); unsigned char *gPtr = 0; - if ( geom == NULL ) - return NULL; + if ( !geom ) + return 0; // get the wkb representation gPtr = new unsigned char[OGR_G_WkbSize( geom )]; @@ -978,7 +978,7 @@ bool QgsOgrProvider::changeAttributeValues( const QgsChangedAttributesMap & attr int f = it2.key(); OGRFieldDefnH fd = OGR_F_GetFieldDefnRef( of, f ); - if ( fd == NULL ) + if ( !fd ) { QgsLogger::warning( "QgsOgrProvider::changeAttributeValues, Field " + QString::number( f ) + " doesn't exist" ); continue; @@ -1558,11 +1558,11 @@ QString createFilters( QString type ) } if ( type == "extensions" ) { - return myExtensions.join("|"); + return myExtensions.join( "|" ); } - if (type == "wildcards" ) + if ( type == "wildcards" ) { - return myWildcards.join("|"); + return myWildcards.join( "|" ); } else { @@ -1613,12 +1613,12 @@ QString QgsOgrProvider::directoryDrivers() const QGISEXTERN QStringList fileExtensions() { - return createFilters( "extensions" ).split("|"); + return createFilters( "extensions" ).split( "|" ); } QGISEXTERN QStringList wildcards() { - return createFilters( "wildcards" ).split("|"); + return createFilters( "wildcards" ).split( "|" ); } @@ -1677,7 +1677,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri, OGRSFDriverH driver; QgsApplication::registerOgrDrivers(); driver = OGRGetDriverByName( format.toAscii() ); - if ( driver == NULL ) + if ( !driver ) { return false; } @@ -1714,7 +1714,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri, OGRDataSourceH dataSource; dataSource = OGR_Dr_CreateDataSource( driver, TO8F( uri ), NULL ); - if ( dataSource == NULL ) + if ( !dataSource ) { return false; } @@ -1771,7 +1771,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri, OGRLayerH layer; layer = OGR_DS_CreateLayer( dataSource, TO8F( QFileInfo( uri ).completeBaseName() ), reference, OGRvectortype, NULL ); - if ( layer == NULL ) + if ( !layer ) { return false; } @@ -2126,128 +2126,133 @@ void QgsOgrProvider::recalculateFeatureCount() } } -QGISEXTERN int dataCapabilities () { +QGISEXTERN int dataCapabilities() +{ return QgsDataProvider::File | QgsDataProvider::Dir; } -QgsOgrLayerItem::QgsOgrLayerItem ( QgsDataItem* parent, - QString name, QString path, QString uri, LayerType layerType ) - : QgsLayerItem ( parent, name, path, uri, layerType, "ogr" ) +QgsOgrLayerItem::QgsOgrLayerItem( QgsDataItem* parent, + QString name, QString path, QString uri, LayerType layerType ) + : QgsLayerItem( parent, name, path, uri, layerType, "ogr" ) { } -QgsOgrLayerItem::~QgsOgrLayerItem () +QgsOgrLayerItem::~QgsOgrLayerItem() { } QgsLayerItem::Capability QgsOgrLayerItem::capabilities() { - QgsDebugMsg( "mPath = " + mPath ); - OGRRegisterAll(); - OGRSFDriverH hDriver; - OGRDataSourceH hDataSource = OGROpen( TO8F( mPath ), true, &hDriver ); - - if ( hDataSource == NULL ) return NoCapabilities; - - QString driverName = OGR_Dr_GetName( hDriver ); - OGR_DS_Destroy( hDataSource ); - - if ( driverName == "ESRI Shapefile" ) return SetCrs; + QgsDebugMsg( "mPath = " + mPath ); + OGRRegisterAll(); + OGRSFDriverH hDriver; + OGRDataSourceH hDataSource = OGROpen( TO8F( mPath ), true, &hDriver ); + if ( !hDataSource ) return NoCapabilities; + + QString driverName = OGR_Dr_GetName( hDriver ); + OGR_DS_Destroy( hDataSource ); + + if ( driverName == "ESRI Shapefile" ) + return SetCrs; + + return NoCapabilities; } -bool QgsOgrLayerItem::setCrs ( QgsCoordinateReferenceSystem crs ) +bool QgsOgrLayerItem::setCrs( QgsCoordinateReferenceSystem crs ) { - QgsDebugMsg( "mPath = " + mPath ); - OGRRegisterAll(); - OGRSFDriverH hDriver; - OGRDataSourceH hDataSource = OGROpen( TO8F( mPath ), true, &hDriver ); + QgsDebugMsg( "mPath = " + mPath ); + OGRRegisterAll(); + OGRSFDriverH hDriver; + OGRDataSourceH hDataSource = OGROpen( TO8F( mPath ), true, &hDriver ); - if ( hDataSource == NULL ) return false; + if ( !hDataSource ) + return false; - QString driverName = OGR_Dr_GetName( hDriver ); - OGR_DS_Destroy( hDataSource ); + QString driverName = OGR_Dr_GetName( hDriver ); + OGR_DS_Destroy( hDataSource ); - // we are able to assign CRS only to shapefiles :-( - if ( driverName == "ESRI Shapefile" ) + // we are able to assign CRS only to shapefiles :-( + if ( driverName == "ESRI Shapefile" ) + { + QString layerName = mPath.left( mPath.indexOf( ".shp", Qt::CaseInsensitive ) ); + QString wkt = crs.toWkt(); + + // save ordinary .prj file + OGRSpatialReferenceH hSRS = OSRNewSpatialReference( wkt.toLocal8Bit().data() ); + OSRMorphToESRI( hSRS ); // this is the important stuff for shapefile .prj + char* pszOutWkt = NULL; + OSRExportToWkt( hSRS, &pszOutWkt ); + QFile prjFile( layerName + ".prj" ); + if ( prjFile.open( QIODevice::WriteOnly ) ) { - QString layerName = mPath.left( mPath.indexOf( ".shp", Qt::CaseInsensitive ) ); - QString wkt = crs.toWkt(); + QTextStream prjStream( &prjFile ); + prjStream << pszOutWkt << endl; + prjFile.close(); + } + else + { + QgsDebugMsg( "Couldn't open file " + layerName + ".prj" ); + return false; + } + OSRDestroySpatialReference( hSRS ); + CPLFree( pszOutWkt ); - // save ordinary .prj file - OGRSpatialReferenceH hSRS = OSRNewSpatialReference( wkt.toLocal8Bit().data() ); - OSRMorphToESRI(hSRS); // this is the important stuff for shapefile .prj - char* pszOutWkt = NULL; - OSRExportToWkt(hSRS, &pszOutWkt); - QFile prjFile( layerName + ".prj" ); - if ( prjFile.open( QIODevice::WriteOnly ) ) - { - QTextStream prjStream( &prjFile ); - prjStream << pszOutWkt << endl; - prjFile.close(); - } - else - { - QgsDebugMsg( "Couldn't open file " + layerName + ".prj" ); - return false; - } - OSRDestroySpatialReference(hSRS); - CPLFree(pszOutWkt); - - // save qgis-specific .qpj file (maybe because of better wkt compatibility?) - QFile qpjFile( layerName + ".qpj" ); - if ( qpjFile.open( QIODevice::WriteOnly ) ) - { - QTextStream qpjStream( &qpjFile ); - qpjStream << wkt.toLocal8Bit().data() << endl; - qpjFile.close(); - } - else - { - QgsDebugMsg( "Couldn't open file " + layerName + ".qpj" ); - return false; - } - - return true; + // save qgis-specific .qpj file (maybe because of better wkt compatibility?) + QFile qpjFile( layerName + ".qpj" ); + if ( qpjFile.open( QIODevice::WriteOnly ) ) + { + QTextStream qpjStream( &qpjFile ); + qpjStream << wkt.toLocal8Bit().data() << endl; + qpjFile.close(); + } + else + { + QgsDebugMsg( "Couldn't open file " + layerName + ".qpj" ); + return false; } - // It it is impossible to assign a crs to an existing layer - // No OGR_L_SetSpatialRef : http://trac.osgeo.org/gdal/ticket/4032 - return false; + return true; + } + + // It it is impossible to assign a crs to an existing layer + // No OGR_L_SetSpatialRef : http://trac.osgeo.org/gdal/ticket/4032 + return false; } -QGISEXTERN QgsDataItem * dataItem ( QString thePath, QgsDataItem* parentItem ) +QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem ) { - if ( thePath.isEmpty() ) return 0; + if ( thePath.isEmpty() ) + return 0; - QFileInfo info ( thePath ); + QFileInfo info( thePath ); if ( info.isFile() ) { // We have to filter by extensions, otherwise e.g. all Shapefile files are displayed // because OGR drive can open also .dbf, .shx. QStringList myExtensions = fileExtensions(); - if ( myExtensions.indexOf ( info.suffix().toLower() ) < 0 ) + if ( myExtensions.indexOf( info.suffix().toLower() ) < 0 ) { bool matches = false; - foreach (QString wildcard, wildcards()) + foreach( QString wildcard, wildcards() ) { - QRegExp rx(wildcard, Qt::CaseInsensitive, QRegExp::Wildcard); - if (rx.exactMatch(info.fileName())) + QRegExp rx( wildcard, Qt::CaseInsensitive, QRegExp::Wildcard ); + if ( rx.exactMatch( info.fileName() ) ) { matches = true; break; } } - if (!matches) + if ( !matches ) return 0; } // .dbf should probably appear if .shp is not present - if (info.suffix().toLower() == "dbf") + if ( info.suffix().toLower() == "dbf" ) { - QString pathShp = thePath.left(thePath.count()-4) + ".shp"; - if (QFileInfo( pathShp ).exists()) + QString pathShp = thePath.left( thePath.count() - 4 ) + ".shp"; + if ( QFileInfo( pathShp ).exists() ) return 0; } @@ -2255,27 +2260,30 @@ QGISEXTERN QgsDataItem * dataItem ( QString thePath, QgsDataItem* parentItem ) OGRSFDriverH hDriver; OGRDataSourceH hDataSource = OGROpen( TO8F( thePath ), false, &hDriver ); - if ( hDataSource == NULL ) return 0; + if ( !hDataSource ) + return 0; QString driverName = OGR_Dr_GetName( hDriver ); QgsDebugMsg( "OGR Driver : " + driverName ); - int numLayers = OGR_DS_GetLayerCount ( hDataSource ); + int numLayers = OGR_DS_GetLayerCount( hDataSource ); - if ( numLayers == 0 ) return 0; + if ( numLayers == 0 ) + return 0; QgsDataCollectionItem * collection = 0; if ( numLayers > 1 ) { collection = new QgsDataCollectionItem( parentItem, info.fileName(), thePath ); } - for ( int i = 0; i < numLayers; i++ ) + + for ( int i = 0; i < numLayers; i++ ) { - OGRLayerH hLayer = OGR_DS_GetLayer ( hDataSource, i ); + OGRLayerH hLayer = OGR_DS_GetLayer( hDataSource, i ); OGRFeatureDefnH hDef = OGR_L_GetLayerDefn( hLayer ); QgsLayerItem::LayerType layerType = QgsLayerItem::Vector; - int ogrType = getOgrGeomType ( hLayer ); + int ogrType = getOgrGeomType( hLayer ); switch ( ogrType ) { case wkbUnknown: @@ -2285,28 +2293,28 @@ QGISEXTERN QgsDataItem * dataItem ( QString thePath, QgsDataItem* parentItem ) layerType = QgsLayerItem::TableLayer; break; case wkbPoint: - case wkbMultiPoint: - case wkbPoint25D: - case wkbMultiPoint25D: + case wkbMultiPoint: + case wkbPoint25D: + case wkbMultiPoint25D: layerType = QgsLayerItem::Point; break; case wkbLineString: case wkbMultiLineString: - case wkbLineString25D: + case wkbLineString25D: case wkbMultiLineString25D: layerType = QgsLayerItem::Line; break; - case wkbPolygon: - case wkbMultiPolygon: - case wkbPolygon25D: - case wkbMultiPolygon25D: + case wkbPolygon: + case wkbMultiPolygon: + case wkbPolygon25D: + case wkbMultiPolygon25D: layerType = QgsLayerItem::Polygon; break; - default: + default: break; } - QgsDebugMsg( QString( "ogrType = %1 layertype = %2").arg(ogrType).arg(layerType) ); + QgsDebugMsg( QString( "ogrType = %1 layertype = %2" ).arg( ogrType ).arg( layerType ) ); QString name = info.fileName(); @@ -2314,22 +2322,24 @@ QGISEXTERN QgsDataItem * dataItem ( QString thePath, QgsDataItem* parentItem ) QgsDebugMsg( "OGR layer name : " + layerName ); QString path = thePath; - if ( numLayers > 1 ) + if ( numLayers > 1 ) { - name = layerName; - path += "/" + name; + name = layerName; + path += "/" + name; } QString layerUri = thePath + "|layerid=" + QString::number( i ); QgsDebugMsg( "OGR layer uri : " + layerUri ); QgsOgrLayerItem * item = new QgsOgrLayerItem( collection ? collection : parentItem, name, path, layerUri, layerType ); - if ( numLayers == 1 ) return item; + if ( numLayers == 1 ) + return item; collection->addChild( item ); } collection->setPopulated(); return collection; } + return 0; } diff --git a/src/providers/ogr/qgsogrprovider.h b/src/providers/ogr/qgsogrprovider.h index c59aeb41d29..bf38cb701f2 100644 --- a/src/providers/ogr/qgsogrprovider.h +++ b/src/providers/ogr/qgsogrprovider.h @@ -307,12 +307,12 @@ class QgsOgrProvider : public QgsVectorDataProvider class QgsOgrLayerItem : public QgsLayerItem { - Q_OBJECT + Q_OBJECT public: - QgsOgrLayerItem ( QgsDataItem* parent, QString name, QString path, QString uri, LayerType layerType ); - ~QgsOgrLayerItem (); + QgsOgrLayerItem( QgsDataItem* parent, QString name, QString path, QString uri, LayerType layerType ); + ~QgsOgrLayerItem(); - bool setCrs ( QgsCoordinateReferenceSystem crs ); + bool setCrs( QgsCoordinateReferenceSystem crs ); Capability capabilities(); }; diff --git a/src/providers/spatialite/qgsspatialiteprovider.cpp b/src/providers/spatialite/qgsspatialiteprovider.cpp index 22b6975dbc9..577ae19b888 100644 --- a/src/providers/spatialite/qgsspatialiteprovider.cpp +++ b/src/providers/spatialite/qgsspatialiteprovider.cpp @@ -406,12 +406,12 @@ bool QgsSpatiaLiteProvider::featureAtId( int featureId, QgsFeature & feature, bo size_t geom_size = 0; const void *blob = sqlite3_column_blob( stmt, ic ); size_t blob_size = sqlite3_column_bytes( stmt, ic ); - convertToGeosWKB ( (const unsigned char *)blob, blob_size, - &featureGeom, &geom_size ); + convertToGeosWKB(( const unsigned char * )blob, blob_size, + &featureGeom, &geom_size ); if ( featureGeom ) - feature.setGeometryAndOwnership( featureGeom, geom_size ); + feature.setGeometryAndOwnership( featureGeom, geom_size ); else - feature.setGeometryAndOwnership( 0, 0 ); + feature.setGeometryAndOwnership( 0, 0 ); } else { @@ -534,12 +534,12 @@ bool QgsSpatiaLiteProvider::nextFeature( QgsFeature & feature ) size_t geom_size = 0; const void *blob = sqlite3_column_blob( sqliteStatement, ic ); size_t blob_size = sqlite3_column_bytes( sqliteStatement, ic ); - convertToGeosWKB ( (const unsigned char *)blob, blob_size, - &featureGeom, &geom_size ); + convertToGeosWKB(( const unsigned char * )blob, blob_size, + &featureGeom, &geom_size ); if ( featureGeom ) - feature.setGeometryAndOwnership( featureGeom, geom_size ); + feature.setGeometryAndOwnership( featureGeom, geom_size ); else - feature.setGeometryAndOwnership( 0, 0 ); + feature.setGeometryAndOwnership( 0, 0 ); } else { @@ -565,2266 +565,2266 @@ bool QgsSpatiaLiteProvider::nextFeature( QgsFeature & feature ) } int QgsSpatiaLiteProvider::computeSizeFromGeosWKB2D( const unsigned char *blob, - size_t size, int type, int nDims, - int little_endian, int endian_arch ) + size_t size, int type, int nDims, + int little_endian, int endian_arch ) { -// calculating the size required to store this WKB - int rings; - int points; - int ib; - const unsigned char *p_in = blob; - int gsize = 5; +// calculating the size required to store this WKB + int rings; + int points; + int ib; + const unsigned char *p_in = blob; + int gsize = 5; - p_in = blob + 5; - switch ( type ) - { - // compunting the required size - case GAIA_POINT: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gsize += 4 * sizeof(double); - break; - case GAIA_XY_M: - case GAIA_XY_Z: - gsize += 3 * sizeof(double); - break; - default: - gsize += 2 * sizeof(double); - break; - } - break; - case GAIA_LINESTRING: - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - gsize += 4; - switch ( nDims ) - { - case GAIA_XY_Z_M: - gsize += points * ( 4 * sizeof(double) ); - break; - case GAIA_XY_M: - case GAIA_XY_Z: - gsize += points * ( 3 * sizeof(double) ); - break; - default: - gsize += points * ( 2 * sizeof(double) ); - break; - } - break; - case GAIA_POLYGON: - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gsize += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gsize += 4; - switch ( nDims ) - { - case GAIA_XY_Z_M: - gsize += points * ( 4 * sizeof(double) ); - break; - case GAIA_XY_M: - case GAIA_XY_Z: - gsize += points * ( 3 * sizeof(double) ); - break; - default: - gsize += points * ( 2 * sizeof(double) ); - break; - } - p_in += points * ( 2 * sizeof(double) ); - } - break; + p_in = blob + 5; + switch ( type ) + { + // compunting the required size + case GAIA_POINT: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gsize += 4 * sizeof( double ); + break; + case GAIA_XY_M: + case GAIA_XY_Z: + gsize += 3 * sizeof( double ); + break; default: - gsize += computeSizeFromMultiWKB2D( p_in, nDims, little_endian, - endian_arch ); + gsize += 2 * sizeof( double ); + break; + } + break; + case GAIA_LINESTRING: + points = gaiaImport32( p_in, little_endian, endian_arch ); + gsize += 4; + switch ( nDims ) + { + case GAIA_XY_Z_M: + gsize += points * ( 4 * sizeof( double ) ); + break; + case GAIA_XY_M: + case GAIA_XY_Z: + gsize += points * ( 3 * sizeof( double ) ); + break; + default: + gsize += points * ( 2 * sizeof( double ) ); + break; + } + break; + case GAIA_POLYGON: + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gsize += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gsize += 4; + switch ( nDims ) + { + case GAIA_XY_Z_M: + gsize += points * ( 4 * sizeof( double ) ); break; - } - - return gsize; + case GAIA_XY_M: + case GAIA_XY_Z: + gsize += points * ( 3 * sizeof( double ) ); + break; + default: + gsize += points * ( 2 * sizeof( double ) ); + break; + } + p_in += points * ( 2 * sizeof( double ) ); + } + break; + default: + gsize += computeSizeFromMultiWKB2D( p_in, nDims, little_endian, + endian_arch ); + break; + } + + return gsize; } int QgsSpatiaLiteProvider::computeSizeFromMultiWKB2D( const unsigned char *p_in, - int nDims, - int little_endian, - int endian_arch ) + int nDims, + int little_endian, + int endian_arch ) { // calculating the size required to store this WKB - int entities; - int type; - int rings; - int points; - int ie; - int ib; - int size = 0; - - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - size += 4; - for ( ie = 0; ie < entities; ie++ ) - { - type = gaiaImport32 ( p_in + 1, little_endian, endian_arch ); - p_in += 5; - size += 5; - switch ( type ) - { - // compunting the required size - case GAIA_POINT: - switch ( nDims ) - { - case GAIA_XY_Z_M: - size += 4 * sizeof(double); - break; - case GAIA_XY_Z: - case GAIA_XY_M: - size += 3 * sizeof(double); - break; - default: - size += 2 * sizeof(double); - break; - } - p_in += 2 * sizeof(double); - break; - case GAIA_LINESTRING: - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - size += 4; - switch ( nDims ) - { - case GAIA_XY_Z_M: - size += points * ( 4 * sizeof(double) ); - break; - case GAIA_XY_Z: - case GAIA_XY_M: - size += points * ( 3 * sizeof(double) ); - break; - default: - size += points * ( 2 * sizeof(double) ); - break; - } - p_in += points * ( 2 * sizeof(double) ); - break; - case GAIA_POLYGON: - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - size += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - size += 4; - switch ( nDims ) - { - case GAIA_XY_Z_M: - size += points * ( 4 * sizeof(double) ); - break; - case GAIA_XY_Z: - case GAIA_XY_M: - size += points * ( 3 * sizeof(double) ); - break; - default: - size += points * ( 2 * sizeof(double) ); - break; - } - p_in += points * ( 2 * sizeof(double) ); - } - break; - } - } + int entities; + int type; + int rings; + int points; + int ie; + int ib; + int size = 0; - return size; + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + size += 4; + for ( ie = 0; ie < entities; ie++ ) + { + type = gaiaImport32( p_in + 1, little_endian, endian_arch ); + p_in += 5; + size += 5; + switch ( type ) + { + // compunting the required size + case GAIA_POINT: + switch ( nDims ) + { + case GAIA_XY_Z_M: + size += 4 * sizeof( double ); + break; + case GAIA_XY_Z: + case GAIA_XY_M: + size += 3 * sizeof( double ); + break; + default: + size += 2 * sizeof( double ); + break; + } + p_in += 2 * sizeof( double ); + break; + case GAIA_LINESTRING: + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + size += 4; + switch ( nDims ) + { + case GAIA_XY_Z_M: + size += points * ( 4 * sizeof( double ) ); + break; + case GAIA_XY_Z: + case GAIA_XY_M: + size += points * ( 3 * sizeof( double ) ); + break; + default: + size += points * ( 2 * sizeof( double ) ); + break; + } + p_in += points * ( 2 * sizeof( double ) ); + break; + case GAIA_POLYGON: + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + size += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + size += 4; + switch ( nDims ) + { + case GAIA_XY_Z_M: + size += points * ( 4 * sizeof( double ) ); + break; + case GAIA_XY_Z: + case GAIA_XY_M: + size += points * ( 3 * sizeof( double ) ); + break; + default: + size += points * ( 2 * sizeof( double ) ); + break; + } + p_in += points * ( 2 * sizeof( double ) ); + } + break; + } + } + + return size; } int QgsSpatiaLiteProvider::computeSizeFromGeosWKB3D( const unsigned char *blob, - size_t size, int type, int nDims, - int little_endian, int endian_arch ) + size_t size, int type, int nDims, + int little_endian, int endian_arch ) { -// calculating the size required to store this WKB - int rings; - int points; - int ib; - const unsigned char *p_in = blob; - int gsize = 5; +// calculating the size required to store this WKB + int rings; + int points; + int ib; + const unsigned char *p_in = blob; + int gsize = 5; - p_in = blob + 5; - switch ( type ) - { - // compunting the required size - case GEOS_3D_POINT: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gsize += 4 * sizeof(double); - break; - case GAIA_XY_M: - case GAIA_XY_Z: - gsize += 3 * sizeof(double); - break; - default: - gsize += 2 * sizeof(double); - break; - } - break; - case GEOS_3D_LINESTRING: - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - gsize += 4; - switch ( nDims ) - { - case GAIA_XY_Z_M: - gsize += points * ( 4 * sizeof(double) ); - break; - case GAIA_XY_M: - case GAIA_XY_Z: - gsize += points * ( 3 * sizeof(double) ); - break; - default: - gsize += points * ( 2 * sizeof(double) ); - break; - } - break; - case GEOS_3D_POLYGON: - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gsize += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gsize += 4; - switch ( nDims ) - { - case GAIA_XY_Z_M: - gsize += points * ( 4 * sizeof(double) ); - break; - case GAIA_XY_M: - case GAIA_XY_Z: - gsize += points * ( 3 * sizeof(double) ); - break; - default: - gsize += points * ( 2 * sizeof(double) ); - break; - } - p_in += points * ( 3 * sizeof(double) ); - } - break; + p_in = blob + 5; + switch ( type ) + { + // compunting the required size + case GEOS_3D_POINT: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gsize += 4 * sizeof( double ); + break; + case GAIA_XY_M: + case GAIA_XY_Z: + gsize += 3 * sizeof( double ); + break; default: - gsize += computeSizeFromMultiWKB3D( p_in, nDims, little_endian, - endian_arch ); + gsize += 2 * sizeof( double ); + break; + } + break; + case GEOS_3D_LINESTRING: + points = gaiaImport32( p_in, little_endian, endian_arch ); + gsize += 4; + switch ( nDims ) + { + case GAIA_XY_Z_M: + gsize += points * ( 4 * sizeof( double ) ); + break; + case GAIA_XY_M: + case GAIA_XY_Z: + gsize += points * ( 3 * sizeof( double ) ); + break; + default: + gsize += points * ( 2 * sizeof( double ) ); + break; + } + break; + case GEOS_3D_POLYGON: + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gsize += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gsize += 4; + switch ( nDims ) + { + case GAIA_XY_Z_M: + gsize += points * ( 4 * sizeof( double ) ); break; - } - - return gsize; + case GAIA_XY_M: + case GAIA_XY_Z: + gsize += points * ( 3 * sizeof( double ) ); + break; + default: + gsize += points * ( 2 * sizeof( double ) ); + break; + } + p_in += points * ( 3 * sizeof( double ) ); + } + break; + default: + gsize += computeSizeFromMultiWKB3D( p_in, nDims, little_endian, + endian_arch ); + break; + } + + return gsize; } int QgsSpatiaLiteProvider::computeSizeFromMultiWKB3D( const unsigned char *p_in, - int nDims, - int little_endian, - int endian_arch ) + int nDims, + int little_endian, + int endian_arch ) { // calculating the size required to store this WKB - int entities; - int type; - int rings; - int points; - int ie; - int ib; - int size = 0; - - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - size += 4; - for ( ie = 0; ie < entities; ie++ ) - { - type = gaiaImport32 ( p_in + 1, little_endian, endian_arch ); - p_in += 5; - size += 5; - switch ( type ) - { - // compunting the required size - case GEOS_3D_POINT: - switch ( nDims ) - { - case GAIA_XY_Z_M: - size += 4 * sizeof(double); - break; - case GAIA_XY_Z: - case GAIA_XY_M: - size += 3 * sizeof(double); - break; - default: - size += 2 * sizeof(double); - break; - } - p_in += 3 * sizeof(double); - break; - case GEOS_3D_LINESTRING: - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - size += 4; - switch ( nDims ) - { - case GAIA_XY_Z_M: - size += points * ( 4 * sizeof(double) ); - break; - case GAIA_XY_Z: - case GAIA_XY_M: - size += points * ( 3 * sizeof(double) ); - break; - default: - size += points * ( 2 * sizeof(double) ); - break; - } - p_in += points * ( 3 * sizeof(double) ); - break; - case GEOS_3D_POLYGON: - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - size += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - size += 4; - switch ( nDims ) - { - case GAIA_XY_Z_M: - size += points * ( 4 * sizeof(double) ); - break; - case GAIA_XY_Z: - case GAIA_XY_M: - size += points * ( 3 * sizeof(double) ); - break; - default: - size += points * ( 2 * sizeof(double) ); - break; - } - p_in += points * ( 3 * sizeof(double) ); - } - break; - } - } + int entities; + int type; + int rings; + int points; + int ie; + int ib; + int size = 0; - return size; + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + size += 4; + for ( ie = 0; ie < entities; ie++ ) + { + type = gaiaImport32( p_in + 1, little_endian, endian_arch ); + p_in += 5; + size += 5; + switch ( type ) + { + // compunting the required size + case GEOS_3D_POINT: + switch ( nDims ) + { + case GAIA_XY_Z_M: + size += 4 * sizeof( double ); + break; + case GAIA_XY_Z: + case GAIA_XY_M: + size += 3 * sizeof( double ); + break; + default: + size += 2 * sizeof( double ); + break; + } + p_in += 3 * sizeof( double ); + break; + case GEOS_3D_LINESTRING: + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + size += 4; + switch ( nDims ) + { + case GAIA_XY_Z_M: + size += points * ( 4 * sizeof( double ) ); + break; + case GAIA_XY_Z: + case GAIA_XY_M: + size += points * ( 3 * sizeof( double ) ); + break; + default: + size += points * ( 2 * sizeof( double ) ); + break; + } + p_in += points * ( 3 * sizeof( double ) ); + break; + case GEOS_3D_POLYGON: + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + size += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + size += 4; + switch ( nDims ) + { + case GAIA_XY_Z_M: + size += points * ( 4 * sizeof( double ) ); + break; + case GAIA_XY_Z: + case GAIA_XY_M: + size += points * ( 3 * sizeof( double ) ); + break; + default: + size += points * ( 2 * sizeof( double ) ); + break; + } + p_in += points * ( 3 * sizeof( double ) ); + } + break; + } + } + + return size; } -void QgsSpatiaLiteProvider::convertFromGeosWKB ( const unsigned char *blob, - size_t blob_size, - unsigned char **wkb, - size_t *geom_size, - int nDims ) +void QgsSpatiaLiteProvider::convertFromGeosWKB( const unsigned char *blob, + size_t blob_size, + unsigned char **wkb, + size_t *geom_size, + int nDims ) { // attempting to convert from 2D/3D GEOS own WKB - int type; - int gDims; - int gsize; - int little_endian; - int endian_arch = gaiaEndianArch (); - - *wkb = NULL; - *geom_size = 0; - if ( blob_size < 5 ) - return; - if ( *( blob + 0 ) == 0x01 ) - little_endian = GAIA_LITTLE_ENDIAN; - else - little_endian = GAIA_BIG_ENDIAN; - type = gaiaImport32 ( blob + 1, little_endian, endian_arch ); - if (type == GEOS_3D_POINT || type == GEOS_3D_LINESTRING - || type == GEOS_3D_POLYGON - || type == GEOS_3D_MULTIPOINT || type == GEOS_3D_MULTILINESTRING - || type == GEOS_3D_MULTIPOLYGON || type == GEOS_3D_GEOMETRYCOLLECTION) - gDims = 3; - else if (type == GAIA_POINT || type == GAIA_LINESTRING - || type == GAIA_POLYGON || type == GAIA_MULTIPOINT - || type == GAIA_MULTILINESTRING || type == GAIA_MULTIPOLYGON - || type == GAIA_GEOMETRYCOLLECTION) - gDims = 2; - else - return; - - if ( gDims == 2 && nDims == GAIA_XY ) - { + int type; + int gDims; + int gsize; + int little_endian; + int endian_arch = gaiaEndianArch(); + + *wkb = NULL; + *geom_size = 0; + if ( blob_size < 5 ) + return; + if ( *( blob + 0 ) == 0x01 ) + little_endian = GAIA_LITTLE_ENDIAN; + else + little_endian = GAIA_BIG_ENDIAN; + type = gaiaImport32( blob + 1, little_endian, endian_arch ); + if ( type == GEOS_3D_POINT || type == GEOS_3D_LINESTRING + || type == GEOS_3D_POLYGON + || type == GEOS_3D_MULTIPOINT || type == GEOS_3D_MULTILINESTRING + || type == GEOS_3D_MULTIPOLYGON || type == GEOS_3D_GEOMETRYCOLLECTION ) + gDims = 3; + else if ( type == GAIA_POINT || type == GAIA_LINESTRING + || type == GAIA_POLYGON || type == GAIA_MULTIPOINT + || type == GAIA_MULTILINESTRING || type == GAIA_MULTIPOLYGON + || type == GAIA_GEOMETRYCOLLECTION ) + gDims = 2; + else + return; + + if ( gDims == 2 && nDims == GAIA_XY ) + { // already 2D: simply copying is required - unsigned char *wkbGeom = new unsigned char[blob_size + 1]; - memset( wkbGeom, '\0', blob_size + 1 ); - memcpy( wkbGeom, blob, blob_size ); - *wkb = wkbGeom; - *geom_size = blob_size + 1; - return; - } - + unsigned char *wkbGeom = new unsigned char[blob_size + 1]; + memset( wkbGeom, '\0', blob_size + 1 ); + memcpy( wkbGeom, blob, blob_size ); + *wkb = wkbGeom; + *geom_size = blob_size + 1; + return; + } + // we need creating a GAIA WKB - if ( gDims == 3 ) - gsize = computeSizeFromGeosWKB3D( blob, blob_size, type, nDims, - little_endian, endian_arch ); - else - gsize = computeSizeFromGeosWKB2D( blob, blob_size, type, nDims, - little_endian, endian_arch ); - - unsigned char *wkbGeom = new unsigned char[gsize]; - memset( wkbGeom, '\0', gsize ); - - if ( gDims == 3 ) - convertFromGeosWKB3D( blob, blob_size, wkbGeom, gsize, nDims, - little_endian, endian_arch ); - else - convertFromGeosWKB2D( blob, blob_size, wkbGeom, gsize, nDims, - little_endian, endian_arch ); - - *wkb = wkbGeom; - *geom_size = gsize; + if ( gDims == 3 ) + gsize = computeSizeFromGeosWKB3D( blob, blob_size, type, nDims, + little_endian, endian_arch ); + else + gsize = computeSizeFromGeosWKB2D( blob, blob_size, type, nDims, + little_endian, endian_arch ); + + unsigned char *wkbGeom = new unsigned char[gsize]; + memset( wkbGeom, '\0', gsize ); + + if ( gDims == 3 ) + convertFromGeosWKB3D( blob, blob_size, wkbGeom, gsize, nDims, + little_endian, endian_arch ); + else + convertFromGeosWKB2D( blob, blob_size, wkbGeom, gsize, nDims, + little_endian, endian_arch ); + + *wkb = wkbGeom; + *geom_size = gsize; } -void QgsSpatiaLiteProvider::convertFromGeosWKB2D ( const unsigned char *blob, - size_t blob_size, - unsigned char *wkb, - size_t geom_size, - int nDims, - int little_endian, - int endian_arch ) +void QgsSpatiaLiteProvider::convertFromGeosWKB2D( const unsigned char *blob, + size_t blob_size, + unsigned char *wkb, + size_t geom_size, + int nDims, + int little_endian, + int endian_arch ) { // attempting to convert from 2D GEOS own WKB - int type; - int entities; - int rings; - int points; - int ie; - int ib; - int iv; - const unsigned char *p_in; - unsigned char *p_out = wkb; - double coord; - + int type; + int entities; + int rings; + int points; + int ie; + int ib; + int iv; + const unsigned char *p_in; + unsigned char *p_out = wkb; + double coord; + // building from GEOS 2D WKB - *p_out++ = 0x01; // little endian byte order - type = gaiaImport32 ( blob + 1, little_endian, endian_arch ); - switch ( type ) - { - // setting Geometry TYPE - case GAIA_POINT: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_POINTZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_POINTZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_POINTM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_POINT, 1, endian_arch); - break; - } + *p_out++ = 0x01; // little endian byte order + type = gaiaImport32( blob + 1, little_endian, endian_arch ); + switch ( type ) + { + // setting Geometry TYPE + case GAIA_POINT: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_POINTZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_POINTZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_POINTM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_POINT, 1, endian_arch ); + break; + } + break; + case GAIA_LINESTRING: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_LINESTRINGZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_LINESTRINGZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_LINESTRINGM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_LINESTRING, 1, endian_arch ); + break; + } + break; + case GAIA_POLYGON: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_POLYGONZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_POLYGONZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_POLYGONM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_POLYGON, 1, endian_arch ); + break; + } + break; + case GAIA_MULTIPOINT: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_MULTIPOINTZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_MULTIPOINTZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_MULTIPOINTM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_MULTIPOINT, 1, endian_arch ); + break; + } + break; + case GAIA_MULTILINESTRING: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_MULTILINESTRINGZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_MULTILINESTRINGZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_MULTILINESTRINGM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_MULTILINESTRING, 1, endian_arch ); + break; + } + break; + case GAIA_MULTIPOLYGON: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_MULTIPOLYGONZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_MULTIPOLYGONZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_MULTIPOLYGONM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_MULTIPOLYGON, 1, endian_arch ); + break; + } + break; + case GAIA_GEOMETRYCOLLECTION: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_GEOMETRYCOLLECTIONZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_GEOMETRYCOLLECTIONZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_GEOMETRYCOLLECTIONM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_GEOMETRYCOLLECTION, 1, endian_arch ); + break; + } + break; + } + p_in = blob + 5; + p_out += 4; + switch ( type ) + { + // setting Geometry values + case GAIA_POINT: + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_out += sizeof( double ); + } + if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); + } + break; + case GAIA_LINESTRING: + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_out += sizeof( double ); + } + if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); + } + } + break; + case GAIA_POLYGON: + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, rings, 1, endian_arch ); + p_out += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_out += sizeof( double ); + } + if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); + } + } + } + break; + case GAIA_MULTIPOINT: + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, entities, 1, endian_arch ); + p_out += 4; + for ( ie = 0; ie < entities; ie++ ) + { + p_in += 5; + *p_out++ = 0x01; + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_POINTZM, 1, endian_arch ); break; - case GAIA_LINESTRING: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_LINESTRINGZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_LINESTRINGZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_LINESTRINGM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_LINESTRING, 1, endian_arch); - break; - } + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_POINTZ, 1, endian_arch ); break; - case GAIA_POLYGON: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_POLYGONZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_POLYGONZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_POLYGONM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_POLYGON, 1, endian_arch); - break; - } + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_POINTM, 1, endian_arch ); break; - case GAIA_MULTIPOINT: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_MULTIPOINTZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_MULTIPOINTZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_MULTIPOINTM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_MULTIPOINT, 1, endian_arch); - break; - } + default: + gaiaExport32( p_out, GAIA_POINT, 1, endian_arch ); break; - case GAIA_MULTILINESTRING: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_MULTILINESTRINGZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_MULTILINESTRINGZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_MULTILINESTRINGM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_MULTILINESTRING, 1, endian_arch); - break; - } + } + p_out += 4; + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_out += sizeof( double ); + } + if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); + } + } + break; + case GAIA_MULTILINESTRING: + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, entities, 1, endian_arch ); + p_out += 4; + for ( ie = 0; ie < entities; ie++ ) + { + p_in += 5; + *p_out++ = 0x01; + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_LINESTRINGZM, 1, endian_arch ); break; - case GAIA_MULTIPOLYGON: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_MULTIPOLYGONZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_MULTIPOLYGONZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_MULTIPOLYGONM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_MULTIPOLYGON, 1, endian_arch); - break; - } + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_LINESTRINGZ, 1, endian_arch ); break; - case GAIA_GEOMETRYCOLLECTION: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_GEOMETRYCOLLECTIONZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_GEOMETRYCOLLECTIONZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_GEOMETRYCOLLECTIONM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_GEOMETRYCOLLECTION, 1, endian_arch); - break; - } + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_LINESTRINGM, 1, endian_arch ); break; - } - p_in = blob + 5; - p_out += 4; - switch ( type ) - { - // setting Geometry values - case GAIA_POINT: - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); + default: + gaiaExport32( p_out, GAIA_LINESTRING, 1, endian_arch ); + break; + } + p_out += 4; + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_out += sizeof( double ); + } + if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); + } + } + } + break; + case GAIA_MULTIPOLYGON: + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, entities, 1, endian_arch ); + p_out += 4; + for ( ie = 0; ie < entities; ie++ ) + { + p_in += 5; + *p_out++ = 0x01; + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_POLYGONZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_POLYGONZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_POLYGONM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_POLYGON, 1, endian_arch ); + break; + } + p_out += 4; + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, rings, 1, endian_arch ); + p_out += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_out += sizeof(double); + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); + } + } + } + } + break; + case GAIA_GEOMETRYCOLLECTION: + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, entities, 1, endian_arch ); + p_out += 4; + for ( ie = 0; ie < entities; ie++ ) + { + int type2 = gaiaImport32( p_in + 1, little_endian, endian_arch ); + p_in += 5; + *p_out++ = 0x01; + switch ( type2 ) + { + case GAIA_POINT: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_POINTZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_POINTZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_POINTM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_POINT, 1, endian_arch ); + break; } break; - case GAIA_LINESTRING: - points = gaiaImport32 ( p_in, little_endian, endian_arch ); + case GAIA_LINESTRING: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_LINESTRINGZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_LINESTRINGZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_LINESTRINGM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_LINESTRING, 1, endian_arch ); + break; + } + break; + case GAIA_POLYGON: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_POLYGONZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_POLYGONZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_POLYGONM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_POLYGON, 1, endian_arch ); + break; + } + break; + } + p_out += 4; + switch ( type2 ) + { + // setting sub-Geometry values + case GAIA_POINT: + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_out += sizeof( double ); + } + if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); + } + break; + case GAIA_LINESTRING: + points = gaiaImport32( p_in, little_endian, endian_arch ); p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); + gaiaExport32( p_out, points, 1, endian_arch ); p_out += 4; for ( iv = 0; iv < points; iv++ ) { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_out += sizeof(double); - } - if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); - } + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_out += sizeof( double ); + } + if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); + } } break; - case GAIA_POLYGON: - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); + case GAIA_POLYGON: + rings = gaiaImport32( p_in, little_endian, endian_arch ); p_in += 4; - gaiaExport32 ( p_out, rings, 1, endian_arch); + gaiaExport32( p_out, rings, 1, endian_arch ); p_out += 4; for ( ib = 0; ib < rings; ib++ ) { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_out += sizeof(double); - } - if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); - } - } - } - break; - case GAIA_MULTIPOINT: - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, entities, 1, endian_arch); - p_out += 4; - for ( ie = 0; ie < entities; ie++ ) - { - p_in += 5; - *p_out++ = 0x01; - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_POINTZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_POINTZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_POINTM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_POINT, 1, endian_arch); - break; - } - p_out += 4; - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_out += sizeof(double); + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); } + } } break; - case GAIA_MULTILINESTRING: - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, entities, 1, endian_arch); - p_out += 4; - for ( ie = 0; ie < entities; ie++ ) - { - p_in += 5; - *p_out++ = 0x01; - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_LINESTRINGZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_LINESTRINGZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_LINESTRINGM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_LINESTRING, 1, endian_arch); - break; - } - p_out += 4; - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_out += sizeof(double); - } - if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); - } - } - } - break; - case GAIA_MULTIPOLYGON: - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, entities, 1, endian_arch); - p_out += 4; - for ( ie = 0; ie < entities; ie++ ) - { - p_in += 5; - *p_out++ = 0x01; - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_POLYGONZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_POLYGONZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_POLYGONM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_POLYGON, 1, endian_arch); - break; - } - p_out += 4; - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, rings, 1, endian_arch); - p_out += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_out += sizeof(double); - } - if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); - } - } - } - } - break; - case GAIA_GEOMETRYCOLLECTION: - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, entities, 1, endian_arch ); - p_out += 4; - for ( ie = 0; ie < entities; ie++ ) - { - int type2 = gaiaImport32 ( p_in + 1, little_endian, endian_arch ); - p_in += 5; - *p_out++ = 0x01; - switch (type2) - { - case GAIA_POINT: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_POINTZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_POINTZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_POINTM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_POINT, 1, endian_arch); - break; - } - break; - case GAIA_LINESTRING: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_LINESTRINGZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_LINESTRINGZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_LINESTRINGM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_LINESTRING, 1, endian_arch); - break; - } - break; - case GAIA_POLYGON: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_POLYGONZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_POLYGONZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_POLYGONM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_POLYGON, 1, endian_arch); - break; - } - break; - } - p_out += 4; - switch ( type2 ) - { - // setting sub-Geometry values - case GAIA_POINT: - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_out += sizeof(double); - } - if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); - } - break; - case GAIA_LINESTRING: - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_out += sizeof(double); - } - if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); - } - } - break; - case GAIA_POLYGON: - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, rings, 1, endian_arch); - p_out += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_out += sizeof(double); - } - if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); - } - } - } - break; - } - } - break; - } + } + } + break; + } } -void QgsSpatiaLiteProvider::convertFromGeosWKB3D ( const unsigned char *blob, - size_t blob_size, - unsigned char *wkb, - size_t geom_size, - int nDims, - int little_endian, - int endian_arch ) +void QgsSpatiaLiteProvider::convertFromGeosWKB3D( const unsigned char *blob, + size_t blob_size, + unsigned char *wkb, + size_t geom_size, + int nDims, + int little_endian, + int endian_arch ) { // attempting to convert from 3D GEOS own WKB - int type; - int entities; - int rings; - int points; - int ie; - int ib; - int iv; - const unsigned char *p_in; - unsigned char *p_out = wkb; - double coord; - + int type; + int entities; + int rings; + int points; + int ie; + int ib; + int iv; + const unsigned char *p_in; + unsigned char *p_out = wkb; + double coord; + // building from GEOS 3D WKB - *p_out++ = 0x01; // little endian byte order - type = gaiaImport32 ( blob + 1, little_endian, endian_arch ); - switch ( type ) - { - // setting Geometry TYPE - case GEOS_3D_POINT: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_POINTZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_POINTZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_POINTM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_POINT, 1, endian_arch); - break; - } + *p_out++ = 0x01; // little endian byte order + type = gaiaImport32( blob + 1, little_endian, endian_arch ); + switch ( type ) + { + // setting Geometry TYPE + case GEOS_3D_POINT: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_POINTZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_POINTZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_POINTM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_POINT, 1, endian_arch ); + break; + } + break; + case GEOS_3D_LINESTRING: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_LINESTRINGZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_LINESTRINGZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_LINESTRINGM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_LINESTRING, 1, endian_arch ); + break; + } + break; + case GEOS_3D_POLYGON: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_POLYGONZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_POLYGONZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_POLYGONM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_POLYGON, 1, endian_arch ); + break; + } + break; + case GEOS_3D_MULTIPOINT: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_MULTIPOINTZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_MULTIPOINTZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_MULTIPOINTM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_MULTIPOINT, 1, endian_arch ); + break; + } + break; + case GEOS_3D_MULTILINESTRING: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_MULTILINESTRINGZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_MULTILINESTRINGZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_MULTILINESTRINGM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_MULTILINESTRING, 1, endian_arch ); + break; + } + break; + case GEOS_3D_MULTIPOLYGON: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_MULTIPOLYGONZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_MULTIPOLYGONZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_MULTIPOLYGONM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_MULTIPOLYGON, 1, endian_arch ); + break; + } + break; + case GEOS_3D_GEOMETRYCOLLECTION: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_GEOMETRYCOLLECTIONZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_GEOMETRYCOLLECTIONZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_GEOMETRYCOLLECTIONM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_GEOMETRYCOLLECTION, 1, endian_arch ); + break; + } + break; + } + p_in = blob + 5; + p_out += 4; + switch ( type ) + { + // setting Geometry values + case GEOS_3D_POINT: + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + p_in += sizeof( double ); + if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_out += sizeof( double ); + } + if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); + } + break; + case GEOS_3D_LINESTRING: + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + p_in += sizeof( double ); + if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_out += sizeof( double ); + } + if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); + } + } + break; + case GEOS_3D_POLYGON: + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, rings, 1, endian_arch ); + p_out += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + p_in += sizeof( double ); + if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_out += sizeof( double ); + } + if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); + } + } + } + break; + case GEOS_3D_MULTIPOINT: + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, entities, 1, endian_arch ); + p_out += 4; + for ( ie = 0; ie < entities; ie++ ) + { + p_in += 5; + *p_out++ = 0x01; + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_POINTZM, 1, endian_arch ); break; - case GEOS_3D_LINESTRING: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_LINESTRINGZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_LINESTRINGZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_LINESTRINGM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_LINESTRING, 1, endian_arch); - break; - } + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_POINTZ, 1, endian_arch ); break; - case GEOS_3D_POLYGON: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_POLYGONZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_POLYGONZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_POLYGONM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_POLYGON, 1, endian_arch); - break; - } + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_POINTM, 1, endian_arch ); break; - case GEOS_3D_MULTIPOINT: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_MULTIPOINTZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_MULTIPOINTZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_MULTIPOINTM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_MULTIPOINT, 1, endian_arch); - break; - } + default: + gaiaExport32( p_out, GAIA_POINT, 1, endian_arch ); break; - case GEOS_3D_MULTILINESTRING: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_MULTILINESTRINGZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_MULTILINESTRINGZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_MULTILINESTRINGM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_MULTILINESTRING, 1, endian_arch); - break; - } + } + p_out += 4; + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + p_in += sizeof( double ); + if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_out += sizeof( double ); + } + if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); + } + } + break; + case GEOS_3D_MULTILINESTRING: + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, entities, 1, endian_arch ); + p_out += 4; + for ( ie = 0; ie < entities; ie++ ) + { + p_in += 5; + *p_out++ = 0x01; + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_LINESTRINGZM, 1, endian_arch ); break; - case GEOS_3D_MULTIPOLYGON: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_MULTIPOLYGONZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_MULTIPOLYGONZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_MULTIPOLYGONM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_MULTIPOLYGON, 1, endian_arch); - break; - } + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_LINESTRINGZ, 1, endian_arch ); break; - case GEOS_3D_GEOMETRYCOLLECTION: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_GEOMETRYCOLLECTIONZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_GEOMETRYCOLLECTIONZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_GEOMETRYCOLLECTIONM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_GEOMETRYCOLLECTION, 1, endian_arch); - break; - } + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_LINESTRINGM, 1, endian_arch ); break; - } - p_in = blob + 5; - p_out += 4; - switch ( type ) - { - // setting Geometry values - case GEOS_3D_POINT: - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - p_in += sizeof(double); + default: + gaiaExport32( p_out, GAIA_LINESTRING, 1, endian_arch ); + break; + } + p_out += 4; + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + p_in += sizeof( double ); + if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_out += sizeof( double ); + } + if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); + } + } + } + break; + case GEOS_3D_MULTIPOLYGON: + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, entities, 1, endian_arch ); + p_out += 4; + for ( ie = 0; ie < entities; ie++ ) + { + p_in += 5; + *p_out++ = 0x01; + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_POLYGONZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_POLYGONZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_POLYGONM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_POLYGON, 1, endian_arch ); + break; + } + p_out += 4; + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, rings, 1, endian_arch ); + p_out += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + p_in += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_out += sizeof(double); + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); + } + } + } + } + break; + case GEOS_3D_GEOMETRYCOLLECTION: + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, entities, 1, endian_arch ); + p_out += 4; + for ( ie = 0; ie < entities; ie++ ) + { + int type2 = gaiaImport32( p_in + 1, little_endian, endian_arch ); + p_in += 5; + *p_out++ = 0x01; + switch ( type2 ) + { + case GEOS_3D_POINT: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_POINTZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_POINTZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_POINTM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_POINT, 1, endian_arch ); + break; } break; - case GEOS_3D_LINESTRING: - points = gaiaImport32 ( p_in, little_endian, endian_arch ); + case GEOS_3D_LINESTRING: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_LINESTRINGZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_LINESTRINGZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_LINESTRINGM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_LINESTRING, 1, endian_arch ); + break; + } + break; + case GEOS_3D_POLYGON: + switch ( nDims ) + { + case GAIA_XY_Z_M: + gaiaExport32( p_out, GAIA_POLYGONZM, 1, endian_arch ); + break; + case GAIA_XY_Z: + gaiaExport32( p_out, GAIA_POLYGONZ, 1, endian_arch ); + break; + case GAIA_XY_M: + gaiaExport32( p_out, GAIA_POLYGONM, 1, endian_arch ); + break; + default: + gaiaExport32( p_out, GAIA_POLYGON, 1, endian_arch ); + break; + } + break; + } + p_out += 4; + switch ( type2 ) + { + // setting sub-Geometry values + case GEOS_3D_POINT: + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + p_in += sizeof( double ); + if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_out += sizeof( double ); + } + if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); + } + break; + case GEOS_3D_LINESTRING: + points = gaiaImport32( p_in, little_endian, endian_arch ); p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); + gaiaExport32( p_out, points, 1, endian_arch ); p_out += 4; for ( iv = 0; iv < points; iv++ ) { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - p_in += sizeof(double); - if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_out += sizeof(double); - } - if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); - } + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + p_in += sizeof( double ); + if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_out += sizeof( double ); + } + if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) + { + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); + } } break; - case GEOS_3D_POLYGON: - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); + case GEOS_3D_POLYGON: + rings = gaiaImport32( p_in, little_endian, endian_arch ); p_in += 4; - gaiaExport32 ( p_out, rings, 1, endian_arch); + gaiaExport32( p_out, rings, 1, endian_arch ); p_out += 4; for ( ib = 0; ib < rings; ib++ ) { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - p_in += sizeof(double); - if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_out += sizeof(double); - } - if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); - } - } - } - break; - case GEOS_3D_MULTIPOINT: - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, entities, 1, endian_arch); - p_out += 4; - for ( ie = 0; ie < entities; ie++ ) - { - p_in += 5; - *p_out++ = 0x01; - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_POINTZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_POINTZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_POINTM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_POINT, 1, endian_arch); - break; - } - p_out += 4; - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - p_in += sizeof(double); + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + p_in += sizeof( double ); if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) { - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_out += sizeof(double); + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_out += sizeof( double ); } if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); + gaiaExport64( p_out, 0.0, 1, endian_arch ); // M + p_out += sizeof( double ); } + } } break; - case GEOS_3D_MULTILINESTRING: - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, entities, 1, endian_arch); - p_out += 4; - for ( ie = 0; ie < entities; ie++ ) - { - p_in += 5; - *p_out++ = 0x01; - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_LINESTRINGZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_LINESTRINGZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_LINESTRINGM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_LINESTRING, 1, endian_arch); - break; - } - p_out += 4; - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - p_in += sizeof(double); - if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_out += sizeof(double); - } - if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); - } - } - } - break; - case GEOS_3D_MULTIPOLYGON: - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, entities, 1, endian_arch); - p_out += 4; - for ( ie = 0; ie < entities; ie++ ) - { - p_in += 5; - *p_out++ = 0x01; - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_POLYGONZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_POLYGONZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_POLYGONM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_POLYGON, 1, endian_arch); - break; - } - p_out += 4; - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, rings, 1, endian_arch); - p_out += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - p_in += sizeof(double); - if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_out += sizeof(double); - } - if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); - } - } - } - } - break; - case GEOS_3D_GEOMETRYCOLLECTION: - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, entities, 1, endian_arch ); - p_out += 4; - for ( ie = 0; ie < entities; ie++ ) - { - int type2 = gaiaImport32 ( p_in + 1, little_endian, endian_arch ); - p_in += 5; - *p_out++ = 0x01; - switch (type2) - { - case GEOS_3D_POINT: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_POINTZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_POINTZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_POINTM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_POINT, 1, endian_arch); - break; - } - break; - case GEOS_3D_LINESTRING: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_LINESTRINGZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_LINESTRINGZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_LINESTRINGM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_LINESTRING, 1, endian_arch); - break; - } - break; - case GEOS_3D_POLYGON: - switch ( nDims ) - { - case GAIA_XY_Z_M: - gaiaExport32 ( p_out, GAIA_POLYGONZM, 1, endian_arch); - break; - case GAIA_XY_Z: - gaiaExport32 ( p_out, GAIA_POLYGONZ, 1, endian_arch); - break; - case GAIA_XY_M: - gaiaExport32 ( p_out, GAIA_POLYGONM, 1, endian_arch); - break; - default: - gaiaExport32 ( p_out, GAIA_POLYGON, 1, endian_arch); - break; - } - break; - } - p_out += 4; - switch ( type2 ) - { - // setting sub-Geometry values - case GEOS_3D_POINT: - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - p_in += sizeof(double); - if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_out += sizeof(double); - } - if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); - } - break; - case GEOS_3D_LINESTRING: - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - p_in += sizeof(double); - if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_out += sizeof(double); - } - if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); - } - } - break; - case GEOS_3D_POLYGON: - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, rings, 1, endian_arch); - p_out += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - p_in += sizeof(double); - if ( nDims == GAIA_XY_Z || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_out += sizeof(double); - } - if ( nDims == GAIA_XY_M || nDims == GAIA_XY_Z_M ) - { - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // M - p_out += sizeof(double); - } - } - } - break; - } - } - break; - } + } + } + break; + } } -void QgsSpatiaLiteProvider::convertToGeosWKB ( const unsigned char *blob, - size_t blob_size, - unsigned char **wkb, - size_t *geom_size ) +void QgsSpatiaLiteProvider::convertToGeosWKB( const unsigned char *blob, + size_t blob_size, + unsigned char **wkb, + size_t *geom_size ) { // attempting to convert to 2D/3D GEOS own WKB - int type; - int dims; - int little_endian; - int endian_arch = gaiaEndianArch (); - int entities; - int rings; - int points; - int ie; - int ib; - int iv; - size_t gsize = 6; - const unsigned char *p_in; - unsigned char *p_out; - double coord; - - *wkb = NULL; - *geom_size = 0; - if ( blob_size < 5 ) - return; - if ( *( blob + 0 ) == 0x01 ) - little_endian = GAIA_LITTLE_ENDIAN; - else - little_endian = GAIA_BIG_ENDIAN; - type = gaiaImport32 ( blob + 1, little_endian, endian_arch ); - if (type == GAIA_POINTZ || type == GAIA_LINESTRINGZ - || type == GAIA_POLYGONZ - || type == GAIA_MULTIPOINTZ || type == GAIA_MULTILINESTRINGZ - || type == GAIA_MULTIPOLYGONZ || type == GAIA_GEOMETRYCOLLECTIONZ) - dims = 3; - else if (type == GAIA_POINTM || type == GAIA_LINESTRINGM - || type == GAIA_POLYGONM || type == GAIA_MULTIPOINTM - || type == GAIA_MULTILINESTRINGM || type == GAIA_MULTIPOLYGONM - || type == GAIA_GEOMETRYCOLLECTIONM) - dims = 3; - else if (type == GAIA_POINTZM || type == GAIA_LINESTRINGZM - || type == GAIA_POLYGONZM || type == GAIA_MULTIPOINTZM - || type == GAIA_MULTILINESTRINGZM || type == GAIA_MULTIPOLYGONZM - || type == GAIA_GEOMETRYCOLLECTIONZM) - dims = 4; - else if (type == GAIA_POINT || type == GAIA_LINESTRING - || type == GAIA_POLYGON || type == GAIA_MULTIPOINT - || type == GAIA_MULTILINESTRING || type == GAIA_MULTIPOLYGON - || type == GAIA_GEOMETRYCOLLECTION) - dims = 2; - else - return; - - if ( dims == 2 ) - { + int type; + int dims; + int little_endian; + int endian_arch = gaiaEndianArch(); + int entities; + int rings; + int points; + int ie; + int ib; + int iv; + size_t gsize = 6; + const unsigned char *p_in; + unsigned char *p_out; + double coord; + + *wkb = NULL; + *geom_size = 0; + if ( blob_size < 5 ) + return; + if ( *( blob + 0 ) == 0x01 ) + little_endian = GAIA_LITTLE_ENDIAN; + else + little_endian = GAIA_BIG_ENDIAN; + type = gaiaImport32( blob + 1, little_endian, endian_arch ); + if ( type == GAIA_POINTZ || type == GAIA_LINESTRINGZ + || type == GAIA_POLYGONZ + || type == GAIA_MULTIPOINTZ || type == GAIA_MULTILINESTRINGZ + || type == GAIA_MULTIPOLYGONZ || type == GAIA_GEOMETRYCOLLECTIONZ ) + dims = 3; + else if ( type == GAIA_POINTM || type == GAIA_LINESTRINGM + || type == GAIA_POLYGONM || type == GAIA_MULTIPOINTM + || type == GAIA_MULTILINESTRINGM || type == GAIA_MULTIPOLYGONM + || type == GAIA_GEOMETRYCOLLECTIONM ) + dims = 3; + else if ( type == GAIA_POINTZM || type == GAIA_LINESTRINGZM + || type == GAIA_POLYGONZM || type == GAIA_MULTIPOINTZM + || type == GAIA_MULTILINESTRINGZM || type == GAIA_MULTIPOLYGONZM + || type == GAIA_GEOMETRYCOLLECTIONZM ) + dims = 4; + else if ( type == GAIA_POINT || type == GAIA_LINESTRING + || type == GAIA_POLYGON || type == GAIA_MULTIPOINT + || type == GAIA_MULTILINESTRING || type == GAIA_MULTIPOLYGON + || type == GAIA_GEOMETRYCOLLECTION ) + dims = 2; + else + return; + + if ( dims == 2 ) + { // already 2D: simply copying is required - unsigned char *wkbGeom = new unsigned char[blob_size + 1]; - memset( wkbGeom, '\0', blob_size + 1 ); - memcpy( wkbGeom, blob, blob_size ); - *wkb = wkbGeom; - *geom_size = blob_size + 1; - return; - } - -// we need creating a 3D GEOS WKB - p_in = blob + 5; - switch ( type ) - { - // compunting the required size - case GAIA_POINTZ: - case GAIA_POINTM: - case GAIA_POINTZM: - gsize += 3 * sizeof(double); - break; - case GAIA_LINESTRINGZ: - case GAIA_LINESTRINGM: - case GAIA_LINESTRINGZM: - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - gsize += 4; - gsize += points * ( 3 * sizeof(double) ); - break; - case GAIA_POLYGONZ: - case GAIA_POLYGONM: - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gsize += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gsize += 4; - gsize += points * ( 3 * sizeof(double) ); - p_in += points * ( 3 * sizeof(double) ); - } - break; - case GAIA_POLYGONZM: - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gsize += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gsize += 4; - gsize += points * ( 3 * sizeof(double) ); - p_in += points * ( 4 * sizeof(double) ); - } - break; - default: - gsize += computeMultiWKB3Dsize( p_in, little_endian, endian_arch ); - break; - } - - unsigned char *wkbGeom = new unsigned char[gsize]; - memset( wkbGeom, '\0', gsize ); - -// building GEOS 3D WKB - *wkbGeom = 0x01; // little endian byte order - type = gaiaImport32 ( blob + 1, little_endian, endian_arch ); - switch ( type ) - { - // setting Geometry TYPE - case GAIA_POINTZ: - case GAIA_POINTM: - case GAIA_POINTZM: - gaiaExport32 ( wkbGeom + 1, GEOS_3D_POINT, 1, endian_arch); - break; - case GAIA_LINESTRINGZ: - case GAIA_LINESTRINGM: - case GAIA_LINESTRINGZM: - gaiaExport32 ( wkbGeom + 1, GEOS_3D_LINESTRING, 1, endian_arch); - break; - case GAIA_POLYGONZ: - case GAIA_POLYGONM: - case GAIA_POLYGONZM: - gaiaExport32 ( wkbGeom + 1, GEOS_3D_POLYGON, 1, endian_arch); - break; - case GAIA_MULTIPOINTZ: - case GAIA_MULTIPOINTM: - case GAIA_MULTIPOINTZM: - gaiaExport32 ( wkbGeom + 1, GEOS_3D_MULTIPOINT, 1, endian_arch); - break; - case GAIA_MULTILINESTRINGZ: - case GAIA_MULTILINESTRINGM: - case GAIA_MULTILINESTRINGZM: - gaiaExport32 ( wkbGeom + 1, GEOS_3D_MULTILINESTRING, 1, endian_arch); - break; - case GAIA_MULTIPOLYGONZ: - case GAIA_MULTIPOLYGONM: - case GAIA_MULTIPOLYGONZM: - gaiaExport32 ( wkbGeom + 1, GEOS_3D_MULTIPOLYGON, 1, endian_arch); - break; - case GAIA_GEOMETRYCOLLECTIONZ: - case GAIA_GEOMETRYCOLLECTIONM: - case GAIA_GEOMETRYCOLLECTIONZM: - gaiaExport32 ( wkbGeom + 1, GEOS_3D_GEOMETRYCOLLECTION, 1, endian_arch); - break; - } - p_in = blob + 5; - p_out = wkbGeom + 5; - switch ( type ) - { - // setting Geometry values - case GAIA_POINTM: - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - break; - case GAIA_POINTZ: - case GAIA_POINTZM: - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - if (type == GAIA_POINTZM) - p_in += sizeof(double); - break; - case GAIA_LINESTRINGM: - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - } - break; - case GAIA_LINESTRINGZ: - case GAIA_LINESTRINGZM: - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - if (type == GAIA_LINESTRINGZM) - p_in += sizeof(double); - } - break; - case GAIA_POLYGONM: - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, rings, 1, endian_arch); - p_out += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - } - } - break; - case GAIA_POLYGONZ: - case GAIA_POLYGONZM: - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, rings, 1, endian_arch); - p_out += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - if (type == GAIA_POLYGONZM) - p_in += sizeof(double); - } - } - break; - case GAIA_MULTIPOINTM: - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, entities, 1, endian_arch); - p_out += 4; - for ( ie = 0; ie < entities; ie++ ) - { - p_in += 5; - *p_out++ = 0x01; - gaiaExport32 ( p_out, GEOS_3D_POINT, 1, endian_arch); - p_out += 4; - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - } - break; - case GAIA_MULTIPOINTZ: - case GAIA_MULTIPOINTZM: - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, entities, 1, endian_arch); - p_out += 4; - for ( ie = 0; ie < entities; ie++ ) - { - p_in += 5; - *p_out++ = 0x01; - gaiaExport32 ( p_out, GEOS_3D_POINT, 1, endian_arch); - p_out += 4; - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - if (type == GAIA_MULTIPOINTZM) - p_in += sizeof(double); - } - break; - case GAIA_MULTILINESTRINGM: - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, entities, 1, endian_arch); - p_out += 4; - for ( ie = 0; ie < entities; ie++ ) - { - p_in += 5; - *p_out++ = 0x01; - gaiaExport32 ( p_out, GEOS_3D_LINESTRING, 1, endian_arch); - p_out += 4; - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - } - } - break; - case GAIA_MULTILINESTRINGZ: - case GAIA_MULTILINESTRINGZM: - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, entities, 1, endian_arch); - p_out += 4; - for ( ie = 0; ie < entities; ie++ ) - { - p_in += 5; - *p_out++ = 0x01; - gaiaExport32 ( p_out, GEOS_3D_LINESTRING, 1, endian_arch); - p_out += 4; - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - if (type == GAIA_MULTILINESTRINGZM) - p_in += sizeof(double); - } - } - break; - case GAIA_MULTIPOLYGONM: - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, entities, 1, endian_arch); - p_out += 4; - for ( ie = 0; ie < entities; ie++ ) - { - p_in += 5; - *p_out++ = 0x01; - gaiaExport32 ( p_out, GEOS_3D_POLYGON, 1, endian_arch); - p_out += 4; - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, rings, 1, endian_arch); - p_out += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - } - } - } - break; - case GAIA_MULTIPOLYGONZ: - case GAIA_MULTIPOLYGONZM: - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, entities, 1, endian_arch); - p_out += 4; - for ( ie = 0; ie < entities; ie++ ) - { - p_in += 5; - *p_out++ = 0x01; - gaiaExport32 ( p_out, GEOS_3D_POLYGON, 1, endian_arch); - p_out += 4; - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, rings, 1, endian_arch); - p_out += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - if (type == GAIA_MULTIPOLYGONZM) - p_in += sizeof(double); - } - } - } - break; - case GAIA_GEOMETRYCOLLECTIONM: - case GAIA_GEOMETRYCOLLECTIONZ: - case GAIA_GEOMETRYCOLLECTIONZM: - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, entities, 1, endian_arch ); - p_out += 4; - for ( ie = 0; ie < entities; ie++ ) - { - int type2 = gaiaImport32 ( p_in + 1, little_endian, endian_arch ); - p_in += 5; - *p_out++ = 0x01; - switch (type2) - { - case GAIA_POINTZ: - case GAIA_POINTM: - case GAIA_POINTZM: - gaiaExport32 ( p_out, GEOS_3D_POINT, 1, endian_arch); - break; - case GAIA_LINESTRINGZ: - case GAIA_LINESTRINGM: - case GAIA_LINESTRINGZM: - gaiaExport32 ( p_out, GEOS_3D_LINESTRING, 1, endian_arch); - break; - case GAIA_POLYGONZ: - case GAIA_POLYGONM: - case GAIA_POLYGONZM: - gaiaExport32 ( p_out, GEOS_3D_POLYGON, 1, endian_arch); - break; - } - p_out += 4; - switch ( type2 ) - { - // setting sub-Geometry values - case GAIA_POINTM: - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - break; - case GAIA_POINTZ: - case GAIA_POINTZM: - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - if (type2 == GAIA_POINTZM) - p_in += sizeof(double); - break; - case GAIA_LINESTRINGM: - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - } - break; - case GAIA_LINESTRINGZ: - case GAIA_LINESTRINGZM: - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - if (type2 == GAIA_LINESTRINGZM) - p_in += sizeof(double); - } - break; - case GAIA_POLYGONM: - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, rings, 1, endian_arch); - p_out += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - gaiaExport64 ( p_out, 0.0, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - } - } - break; - case GAIA_POLYGONZ: - case GAIA_POLYGONZM: - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, rings, 1, endian_arch); - p_out += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - gaiaExport32 ( p_out, points, 1, endian_arch); - p_out += 4; - for ( iv = 0; iv < points; iv++ ) - { - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // X - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Y - p_in += sizeof(double); - p_out += sizeof(double); - coord = gaiaImport64 ( p_in, little_endian, endian_arch ); - gaiaExport64 ( p_out, coord, 1, endian_arch ); // Z - p_in += sizeof(double); - p_out += sizeof(double); - if (type2 == GAIA_POLYGONZM) - p_in += sizeof(double); - } - } - break; - } - } - break; - } - + unsigned char *wkbGeom = new unsigned char[blob_size + 1]; + memset( wkbGeom, '\0', blob_size + 1 ); + memcpy( wkbGeom, blob, blob_size ); *wkb = wkbGeom; - *geom_size = gsize; + *geom_size = blob_size + 1; + return; + } + +// we need creating a 3D GEOS WKB + p_in = blob + 5; + switch ( type ) + { + // compunting the required size + case GAIA_POINTZ: + case GAIA_POINTM: + case GAIA_POINTZM: + gsize += 3 * sizeof( double ); + break; + case GAIA_LINESTRINGZ: + case GAIA_LINESTRINGM: + case GAIA_LINESTRINGZM: + points = gaiaImport32( p_in, little_endian, endian_arch ); + gsize += 4; + gsize += points * ( 3 * sizeof( double ) ); + break; + case GAIA_POLYGONZ: + case GAIA_POLYGONM: + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gsize += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gsize += 4; + gsize += points * ( 3 * sizeof( double ) ); + p_in += points * ( 3 * sizeof( double ) ); + } + break; + case GAIA_POLYGONZM: + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gsize += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gsize += 4; + gsize += points * ( 3 * sizeof( double ) ); + p_in += points * ( 4 * sizeof( double ) ); + } + break; + default: + gsize += computeMultiWKB3Dsize( p_in, little_endian, endian_arch ); + break; + } + + unsigned char *wkbGeom = new unsigned char[gsize]; + memset( wkbGeom, '\0', gsize ); + +// building GEOS 3D WKB + *wkbGeom = 0x01; // little endian byte order + type = gaiaImport32( blob + 1, little_endian, endian_arch ); + switch ( type ) + { + // setting Geometry TYPE + case GAIA_POINTZ: + case GAIA_POINTM: + case GAIA_POINTZM: + gaiaExport32( wkbGeom + 1, GEOS_3D_POINT, 1, endian_arch ); + break; + case GAIA_LINESTRINGZ: + case GAIA_LINESTRINGM: + case GAIA_LINESTRINGZM: + gaiaExport32( wkbGeom + 1, GEOS_3D_LINESTRING, 1, endian_arch ); + break; + case GAIA_POLYGONZ: + case GAIA_POLYGONM: + case GAIA_POLYGONZM: + gaiaExport32( wkbGeom + 1, GEOS_3D_POLYGON, 1, endian_arch ); + break; + case GAIA_MULTIPOINTZ: + case GAIA_MULTIPOINTM: + case GAIA_MULTIPOINTZM: + gaiaExport32( wkbGeom + 1, GEOS_3D_MULTIPOINT, 1, endian_arch ); + break; + case GAIA_MULTILINESTRINGZ: + case GAIA_MULTILINESTRINGM: + case GAIA_MULTILINESTRINGZM: + gaiaExport32( wkbGeom + 1, GEOS_3D_MULTILINESTRING, 1, endian_arch ); + break; + case GAIA_MULTIPOLYGONZ: + case GAIA_MULTIPOLYGONM: + case GAIA_MULTIPOLYGONZM: + gaiaExport32( wkbGeom + 1, GEOS_3D_MULTIPOLYGON, 1, endian_arch ); + break; + case GAIA_GEOMETRYCOLLECTIONZ: + case GAIA_GEOMETRYCOLLECTIONM: + case GAIA_GEOMETRYCOLLECTIONZM: + gaiaExport32( wkbGeom + 1, GEOS_3D_GEOMETRYCOLLECTION, 1, endian_arch ); + break; + } + p_in = blob + 5; + p_out = wkbGeom + 5; + switch ( type ) + { + // setting Geometry values + case GAIA_POINTM: + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + break; + case GAIA_POINTZ: + case GAIA_POINTZM: + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + if ( type == GAIA_POINTZM ) + p_in += sizeof( double ); + break; + case GAIA_LINESTRINGM: + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + } + break; + case GAIA_LINESTRINGZ: + case GAIA_LINESTRINGZM: + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + if ( type == GAIA_LINESTRINGZM ) + p_in += sizeof( double ); + } + break; + case GAIA_POLYGONM: + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, rings, 1, endian_arch ); + p_out += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + } + } + break; + case GAIA_POLYGONZ: + case GAIA_POLYGONZM: + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, rings, 1, endian_arch ); + p_out += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + if ( type == GAIA_POLYGONZM ) + p_in += sizeof( double ); + } + } + break; + case GAIA_MULTIPOINTM: + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, entities, 1, endian_arch ); + p_out += 4; + for ( ie = 0; ie < entities; ie++ ) + { + p_in += 5; + *p_out++ = 0x01; + gaiaExport32( p_out, GEOS_3D_POINT, 1, endian_arch ); + p_out += 4; + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + } + break; + case GAIA_MULTIPOINTZ: + case GAIA_MULTIPOINTZM: + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, entities, 1, endian_arch ); + p_out += 4; + for ( ie = 0; ie < entities; ie++ ) + { + p_in += 5; + *p_out++ = 0x01; + gaiaExport32( p_out, GEOS_3D_POINT, 1, endian_arch ); + p_out += 4; + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + if ( type == GAIA_MULTIPOINTZM ) + p_in += sizeof( double ); + } + break; + case GAIA_MULTILINESTRINGM: + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, entities, 1, endian_arch ); + p_out += 4; + for ( ie = 0; ie < entities; ie++ ) + { + p_in += 5; + *p_out++ = 0x01; + gaiaExport32( p_out, GEOS_3D_LINESTRING, 1, endian_arch ); + p_out += 4; + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + } + } + break; + case GAIA_MULTILINESTRINGZ: + case GAIA_MULTILINESTRINGZM: + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, entities, 1, endian_arch ); + p_out += 4; + for ( ie = 0; ie < entities; ie++ ) + { + p_in += 5; + *p_out++ = 0x01; + gaiaExport32( p_out, GEOS_3D_LINESTRING, 1, endian_arch ); + p_out += 4; + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + if ( type == GAIA_MULTILINESTRINGZM ) + p_in += sizeof( double ); + } + } + break; + case GAIA_MULTIPOLYGONM: + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, entities, 1, endian_arch ); + p_out += 4; + for ( ie = 0; ie < entities; ie++ ) + { + p_in += 5; + *p_out++ = 0x01; + gaiaExport32( p_out, GEOS_3D_POLYGON, 1, endian_arch ); + p_out += 4; + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, rings, 1, endian_arch ); + p_out += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + } + } + } + break; + case GAIA_MULTIPOLYGONZ: + case GAIA_MULTIPOLYGONZM: + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, entities, 1, endian_arch ); + p_out += 4; + for ( ie = 0; ie < entities; ie++ ) + { + p_in += 5; + *p_out++ = 0x01; + gaiaExport32( p_out, GEOS_3D_POLYGON, 1, endian_arch ); + p_out += 4; + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, rings, 1, endian_arch ); + p_out += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + if ( type == GAIA_MULTIPOLYGONZM ) + p_in += sizeof( double ); + } + } + } + break; + case GAIA_GEOMETRYCOLLECTIONM: + case GAIA_GEOMETRYCOLLECTIONZ: + case GAIA_GEOMETRYCOLLECTIONZM: + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, entities, 1, endian_arch ); + p_out += 4; + for ( ie = 0; ie < entities; ie++ ) + { + int type2 = gaiaImport32( p_in + 1, little_endian, endian_arch ); + p_in += 5; + *p_out++ = 0x01; + switch ( type2 ) + { + case GAIA_POINTZ: + case GAIA_POINTM: + case GAIA_POINTZM: + gaiaExport32( p_out, GEOS_3D_POINT, 1, endian_arch ); + break; + case GAIA_LINESTRINGZ: + case GAIA_LINESTRINGM: + case GAIA_LINESTRINGZM: + gaiaExport32( p_out, GEOS_3D_LINESTRING, 1, endian_arch ); + break; + case GAIA_POLYGONZ: + case GAIA_POLYGONM: + case GAIA_POLYGONZM: + gaiaExport32( p_out, GEOS_3D_POLYGON, 1, endian_arch ); + break; + } + p_out += 4; + switch ( type2 ) + { + // setting sub-Geometry values + case GAIA_POINTM: + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + break; + case GAIA_POINTZ: + case GAIA_POINTZM: + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + if ( type2 == GAIA_POINTZM ) + p_in += sizeof( double ); + break; + case GAIA_LINESTRINGM: + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + } + break; + case GAIA_LINESTRINGZ: + case GAIA_LINESTRINGZM: + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + if ( type2 == GAIA_LINESTRINGZM ) + p_in += sizeof( double ); + } + break; + case GAIA_POLYGONM: + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, rings, 1, endian_arch ); + p_out += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + gaiaExport64( p_out, 0.0, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + } + } + break; + case GAIA_POLYGONZ: + case GAIA_POLYGONZM: + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, rings, 1, endian_arch ); + p_out += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + gaiaExport32( p_out, points, 1, endian_arch ); + p_out += 4; + for ( iv = 0; iv < points; iv++ ) + { + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // X + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Y + p_in += sizeof( double ); + p_out += sizeof( double ); + coord = gaiaImport64( p_in, little_endian, endian_arch ); + gaiaExport64( p_out, coord, 1, endian_arch ); // Z + p_in += sizeof( double ); + p_out += sizeof( double ); + if ( type2 == GAIA_POLYGONZM ) + p_in += sizeof( double ); + } + } + break; + } + } + break; + } + + *wkb = wkbGeom; + *geom_size = gsize; } int QgsSpatiaLiteProvider::computeMultiWKB3Dsize( const unsigned char *p_in, int little_endian, int endian_arch ) { // computing the required size to store a GEOS 3D MultiXX - int entities; - int type; - int rings; - int points; - int ie; - int ib; - int size = 0; - - entities = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - size += 4; - for ( ie = 0; ie < entities; ie++ ) - { - type = gaiaImport32 ( p_in + 1, little_endian, endian_arch ); - p_in += 5; - size += 5; - switch ( type ) - { - // compunting the required size - case GAIA_POINTZ: - case GAIA_POINTM: - size += 3 * sizeof(double); - p_in += 3 * sizeof(double); - break; - case GAIA_POINTZM: - size += 3 * sizeof(double); - p_in += 4 * sizeof(double); - break; - case GAIA_LINESTRINGZ: - case GAIA_LINESTRINGM: - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - size += 4; - size += points * ( 3 * sizeof(double) ); - p_in += points * ( 3 * sizeof(double) ); - break; - case GAIA_LINESTRINGZM: - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - size += 4; - size += points * ( 3 * sizeof(double) ); - p_in += points * ( 4 * sizeof(double) ); - break; - case GAIA_POLYGONZ: - case GAIA_POLYGONM: - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - size += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - size += 4; - size += points * ( 3 * sizeof(double) ); - p_in += points * ( 3 * sizeof(double) ); - } - break; - case GAIA_POLYGONZM: - rings = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - size += 4; - for ( ib = 0; ib < rings; ib++ ) - { - points = gaiaImport32 ( p_in, little_endian, endian_arch ); - p_in += 4; - size += 4; - size += points * ( 3 * sizeof(double) ); - p_in += points * ( 4 * sizeof(double) ); - } - break; - } - } + int entities; + int type; + int rings; + int points; + int ie; + int ib; + int size = 0; - return size; + entities = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + size += 4; + for ( ie = 0; ie < entities; ie++ ) + { + type = gaiaImport32( p_in + 1, little_endian, endian_arch ); + p_in += 5; + size += 5; + switch ( type ) + { + // compunting the required size + case GAIA_POINTZ: + case GAIA_POINTM: + size += 3 * sizeof( double ); + p_in += 3 * sizeof( double ); + break; + case GAIA_POINTZM: + size += 3 * sizeof( double ); + p_in += 4 * sizeof( double ); + break; + case GAIA_LINESTRINGZ: + case GAIA_LINESTRINGM: + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + size += 4; + size += points * ( 3 * sizeof( double ) ); + p_in += points * ( 3 * sizeof( double ) ); + break; + case GAIA_LINESTRINGZM: + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + size += 4; + size += points * ( 3 * sizeof( double ) ); + p_in += points * ( 4 * sizeof( double ) ); + break; + case GAIA_POLYGONZ: + case GAIA_POLYGONM: + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + size += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + size += 4; + size += points * ( 3 * sizeof( double ) ); + p_in += points * ( 3 * sizeof( double ) ); + } + break; + case GAIA_POLYGONZM: + rings = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + size += 4; + for ( ib = 0; ib < rings; ib++ ) + { + points = gaiaImport32( p_in, little_endian, endian_arch ); + p_in += 4; + size += 4; + size += points * ( 3 * sizeof( double ) ); + p_in += points * ( 4 * sizeof( double ) ); + } + break; + } + } + + return size; } QString QgsSpatiaLiteProvider::subsetString() @@ -3324,13 +3324,13 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist ) // binding GEOMETRY to Prepared Statement unsigned char *wkb = NULL; size_t wkb_size; - convertFromGeosWKB ( features->geometry()->asWkb(), - features->geometry()->wkbSize(), - &wkb, &wkb_size, nDims ); - if (wkb == NULL ) - sqlite3_bind_null( stmt, 1 ); + convertFromGeosWKB( features->geometry()->asWkb(), + features->geometry()->wkbSize(), + &wkb, &wkb_size, nDims ); + if ( !wkb ) + sqlite3_bind_null( stmt, 1 ); else - sqlite3_bind_blob( stmt, 1, wkb, wkb_size, free ); + sqlite3_bind_blob( stmt, 1, wkb, wkb_size, free ); // initializing the column counter ia = 1; @@ -3690,12 +3690,12 @@ bool QgsSpatiaLiteProvider::changeGeometryValues( QgsGeometryMap & geometry_map // binding GEOMETRY to Prepared Statement unsigned char *wkb = NULL; size_t wkb_size; - convertFromGeosWKB ( iter->asWkb(), iter->wkbSize(), &wkb, &wkb_size, - nDims ); - if (wkb == NULL ) - sqlite3_bind_null( stmt, 1 ); + convertFromGeosWKB( iter->asWkb(), iter->wkbSize(), &wkb, &wkb_size, + nDims ); + if ( !wkb ) + sqlite3_bind_null( stmt, 1 ); else - sqlite3_bind_blob( stmt, 1, wkb, wkb_size, free ); + sqlite3_bind_blob( stmt, 1, wkb, wkb_size, free ); sqlite3_bind_int( stmt, 2, iter.key() ); // performing actual row update diff --git a/src/providers/spatialite/qgsspatialiteprovider.h b/src/providers/spatialite/qgsspatialiteprovider.h index 9f434ec9aca..a626fb9174e 100644 --- a/src/providers/spatialite/qgsspatialiteprovider.h +++ b/src/providers/spatialite/qgsspatialiteprovider.h @@ -380,41 +380,41 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider bool getQueryGeometryDetails(); bool getSridDetails(); bool getTableSummary(); - void convertToGeosWKB ( const unsigned char *blob, size_t blob_size, - unsigned char **wkb, size_t *geom_size ); + void convertToGeosWKB( const unsigned char *blob, size_t blob_size, + unsigned char **wkb, size_t *geom_size ); int computeSizeFromMultiWKB2D( const unsigned char *p_in, int nDims, - int little_endian, - int endian_arch ); - int computeSizeFromMultiWKB3D( const unsigned char *p_in, int nDims, int little_endian, int endian_arch ); - void convertFromGeosWKB2D( const unsigned char *blob, size_t blob_size, - unsigned char *wkb, size_t geom_size, - int nDims, int little_endian, int endian_arch ); - void convertFromGeosWKB3D( const unsigned char *blob, size_t blob_size, - unsigned char *wkb, size_t geom_size, - int nDims, int little_endian, int endian_arch ); - int computeMultiWKB3Dsize( const unsigned char *p_in, int little_endian, + int computeSizeFromMultiWKB3D( const unsigned char *p_in, int nDims, + int little_endian, + int endian_arch ); + void convertFromGeosWKB2D( const unsigned char *blob, size_t blob_size, + unsigned char *wkb, size_t geom_size, + int nDims, int little_endian, int endian_arch ); + void convertFromGeosWKB3D( const unsigned char *blob, size_t blob_size, + unsigned char *wkb, size_t geom_size, + int nDims, int little_endian, int endian_arch ); + int computeMultiWKB3Dsize( const unsigned char *p_in, int little_endian, int endian_arch ); - void convertFromGeosWKB ( const unsigned char *blob, size_t blob_size, - unsigned char **wkb, size_t *geom_size, - int dims ); - int computeSizeFromGeosWKB3D( const unsigned char *blob, size_t size, - int type, int nDims, int little_endian, + void convertFromGeosWKB( const unsigned char *blob, size_t blob_size, + unsigned char **wkb, size_t *geom_size, + int dims ); + int computeSizeFromGeosWKB3D( const unsigned char *blob, size_t size, + int type, int nDims, int little_endian, int endian_arch ); - int computeSizeFromGeosWKB2D( const unsigned char *blob, size_t size, - int type, int nDims, int little_endian, + int computeSizeFromGeosWKB2D( const unsigned char *blob, size_t size, + int type, int nDims, int little_endian, int endian_arch ); - + enum GEOS_3D { - GEOS_3D_POINT = -2147483647, - GEOS_3D_LINESTRING = -2147483646, - GEOS_3D_POLYGON = -2147483645, - GEOS_3D_MULTIPOINT = -2147483644, - GEOS_3D_MULTILINESTRING = -2147483643, - GEOS_3D_MULTIPOLYGON = -2147483642, - GEOS_3D_GEOMETRYCOLLECTION = -2147483641, + GEOS_3D_POINT = -2147483647, + GEOS_3D_LINESTRING = -2147483646, + GEOS_3D_POLYGON = -2147483645, + GEOS_3D_MULTIPOINT = -2147483644, + GEOS_3D_MULTILINESTRING = -2147483643, + GEOS_3D_MULTIPOLYGON = -2147483642, + GEOS_3D_GEOMETRYCOLLECTION = -2147483641, }; public: diff --git a/src/providers/sqlanywhere/qgssqlanywhereprovider.cpp b/src/providers/sqlanywhere/qgssqlanywhereprovider.cpp index 6e6e3ab4f77..f690571256a 100644 --- a/src/providers/sqlanywhere/qgssqlanywhereprovider.cpp +++ b/src/providers/sqlanywhere/qgssqlanywhereprovider.cpp @@ -239,7 +239,8 @@ QgsSqlAnywhereProvider::loadFields() const QgsVectorDataProvider::NativeType fieldNativeType = stmt->mapType( info.native_type ); // skip the geom column - if ( fieldName == mGeometryColumn ) continue; + if ( fieldName == mGeometryColumn ) + continue; // look for duplicates if ( fieldNames.contains( fieldName ) ) @@ -742,7 +743,8 @@ QgsSqlAnywhereProvider::featureAtId( int featureId, QgsFeature & feature, bool f + QString( "AND %1 = ? " ) .arg( quotedIdentifier( mKeyColumn ) ); - if ( mIdStmt ) { delete mIdStmt; } + if ( mIdStmt ) + delete mIdStmt; mIdStmt = mConnRO->prepare( makeSelectSql( whereClause ) ); } @@ -818,7 +820,8 @@ QgsSqlAnywhereProvider::select( QgsAttributeList fetchAttributes, QgsRectangle r .arg( mSrid ); } - if ( mStmt ) { delete mStmt; } + if ( mStmt ) + delete mStmt; mStmt = mConnRO->prepare( makeSelectSql( whereClause ) ); } diff --git a/src/providers/sqlanywhere/sqlanyconnection/sqlanyconnection.cpp b/src/providers/sqlanywhere/sqlanyconnection/sqlanyconnection.cpp index cf8b4a0fdf0..26b408fa8a6 100644 --- a/src/providers/sqlanywhere/sqlanyconnection/sqlanyconnection.cpp +++ b/src/providers/sqlanywhere/sqlanyconnection/sqlanyconnection.cpp @@ -83,7 +83,8 @@ SqlAnyConnection::~SqlAnyConnection() sApi.sqlany_disconnect( mHandle ); sApi.sqlany_free_connection( mHandle ); connCount--; - if ( !mMapKey.isEmpty() ) { connCache.remove( mMapKey ); } + if ( !mMapKey.isEmpty() ) + connCache.remove( mMapKey ); gMutex.unlock(); } @@ -168,24 +169,31 @@ SqlAnyConnection::makeUri( QString connName, QString host // begin DBNAME uri = "dbname=\""; - if ( !connName.isEmpty() ) { uri += "CON=" + connName + ";"; } + if ( !connName.isEmpty() ) + uri += "CON=" + connName + ";"; if ( !host.isEmpty() || !port.isEmpty() ) { uri += "HOST="; uri += ( host.isEmpty() ? "localhost" : host ); - if ( !port.isEmpty() ) { uri += ":" + port; } + if ( !port.isEmpty() ) + uri += ":" + port; uri += ";"; } - if ( !server.isEmpty() ) { uri += "SERVER=" + server + ";"; } - if ( !database.isEmpty() ) { uri += "DBN=" + database + ";"; } - if ( !parameters.isEmpty() ) { uri += parameters + ";"; } - if ( simpleEncrypt ) { uri += "ENC=SIMPLE;"; } + if ( !server.isEmpty() ) + uri += "SERVER=" + server + ";"; + if ( !database.isEmpty() ) + uri += "DBN=" + database + ";"; + if ( !parameters.isEmpty() ) + uri += parameters + ";"; + if ( simpleEncrypt ) + uri += "ENC=SIMPLE;"; uri += "\" "; // end DBNAME uri += "user=\"" + username + "\" "; uri += "password=\"" + password + "\" "; - if ( estimateMeta ) { uri += "estimatedmetadata=true "; } + if ( estimateMeta ) + uri += "estimatedmetadata=true "; return uri; } @@ -354,7 +362,8 @@ SqlAnyConnection::release() // use the global mutex when adjusting the reference count gMutex.lock(); mRefCount--; - if ( mRefCount == 0 ) { delete this; } + if ( mRefCount == 0 ) + delete this; gMutex.unlock(); } @@ -456,7 +465,8 @@ SqlAnyConnection::execute_immediate( QString sql, sacapi_i32 &code, char *errbuf // the connection mutex mMutex.lock(); ok = sApi.sqlany_execute_immediate( mHandle, sql.toUtf8().constData() ); - if ( !ok ) { getError( code, errbuf, size ); } + if ( !ok ) + getError( code, errbuf, size ); mMutex.unlock(); return ok != 0; diff --git a/src/providers/sqlanywhere/sqlanyconnection/sqlanystatement.cpp b/src/providers/sqlanywhere/sqlanyconnection/sqlanystatement.cpp index 53ad9c84e8e..eba89889dd8 100644 --- a/src/providers/sqlanywhere/sqlanyconnection/sqlanystatement.cpp +++ b/src/providers/sqlanywhere/sqlanyconnection/sqlanystatement.cpp @@ -35,14 +35,16 @@ SqlAnyStatement::SqlAnyStatement( SqlAnyConnection *conn ) SqlAnyStatement::~SqlAnyStatement() { - if ( isValid() ) { api()->sqlany_free_stmt( mHndl ); } + if ( isValid() ) + api()->sqlany_free_stmt( mHndl ); mConn->release(); } bool SqlAnyStatement::reset( ) { - if ( !isValid() ) return false; + if ( !isValid() ) + return false; SaDebugMsg( "Resetting statement." ); if ( !api()->sqlany_reset( mHndl ) ) { @@ -57,16 +59,19 @@ SqlAnyStatement::reset( ) sacapi_i32 SqlAnyStatement::numParams( ) { - if ( !isValid() ) return -1; + if ( !isValid() ) + return -1; sacapi_i32 retval = api()->sqlany_num_params( mHndl ); - if ( retval < 0 ) { getErrMsg(); } + if ( retval < 0 ) + getErrMsg(); return retval; } bool SqlAnyStatement::describe_bind_param( sacapi_i32 index, a_sqlany_bind_param ¶m ) { - if ( !isValid() ) return false; + if ( !isValid() ) + return false; if ( !api()->sqlany_describe_bind_param( mHndl, index, ¶m ) ) { getErrMsg(); @@ -78,7 +83,8 @@ SqlAnyStatement::describe_bind_param( sacapi_i32 index, a_sqlany_bind_param &par bool SqlAnyStatement::bind_param( sacapi_i32 index, a_sqlany_bind_param ¶m ) { - if ( !isValid() ) return false; + if ( !isValid() ) + return false; if ( !api()->sqlany_bind_param( mHndl, index, ¶m ) ) { getErrMsg(); @@ -90,7 +96,8 @@ SqlAnyStatement::bind_param( sacapi_i32 index, a_sqlany_bind_param ¶m ) bool SqlAnyStatement::execute( ) { - if ( !isValid() ) return false; + if ( !isValid() ) + return false; SaDebugMsg( "Executing prepared statement." ); if ( !api()->sqlany_execute( mHndl ) ) { @@ -106,7 +113,8 @@ SqlAnyStatement::execute( ) bool SqlAnyStatement::fetchAbsolute( sacapi_i32 rownum ) { - if ( !isValid() ) return false; + if ( !isValid() ) + return false; if ( !api()->sqlany_fetch_absolute( mHndl, rownum ) ) { getErrMsg(); @@ -118,7 +126,8 @@ SqlAnyStatement::fetchAbsolute( sacapi_i32 rownum ) bool SqlAnyStatement::fetchNext( ) { - if ( !isValid() ) return false; + if ( !isValid() ) + return false; if ( !api()->sqlany_fetch_next( mHndl ) ) { getErrMsg(); @@ -130,7 +139,8 @@ SqlAnyStatement::fetchNext( ) bool SqlAnyStatement::getColumn( sacapi_u32 col_index, a_sqlany_data_value *buffer ) { - if ( !isValid() ) return false; + if ( !isValid() ) + return false; if ( !api()->sqlany_get_column( mHndl, col_index, buffer ) ) { getErrMsg(); @@ -142,7 +152,8 @@ SqlAnyStatement::getColumn( sacapi_u32 col_index, a_sqlany_data_value *buffer ) bool SqlAnyStatement::getColumnInfo( sacapi_u32 col_index, a_sqlany_column_info *buffer ) { - if ( !isValid() ) return false; + if ( !isValid() ) + return false; if ( !api()->sqlany_get_column_info( mHndl, col_index, buffer ) ) { getErrMsg(); @@ -165,16 +176,19 @@ SqlAnyStatement::getColumnInfo( sacapi_u32 col_index, a_sqlany_column_info *buff sacapi_i32 SqlAnyStatement::getData( sacapi_u32 col_index, size_t offset, void *buffer, size_t size ) { - if ( !isValid() ) return -1; + if ( !isValid() ) + return -1; sacapi_i32 nbytes = api()->sqlany_get_data( mHndl, col_index, offset, buffer, size ); - if ( nbytes < 0 ) { getErrMsg(); } + if ( nbytes < 0 ) + getErrMsg(); return nbytes; } bool SqlAnyStatement::getDataInfo( sacapi_u32 col_index, a_sqlany_data_info *buffer ) { - if ( !isValid() ) return false; + if ( !isValid() ) + return false; if ( !api()->sqlany_get_data_info( mHndl, col_index, buffer ) ) { getErrMsg(); @@ -186,21 +200,24 @@ SqlAnyStatement::getDataInfo( sacapi_u32 col_index, a_sqlany_data_info *buffer ) sacapi_i32 SqlAnyStatement::numCols( ) { // n<0 means estimated to be |n| - if ( !isValid() ) return 0; + if ( !isValid() ) + return 0; return api()->sqlany_num_cols( mHndl ); } sacapi_i32 SqlAnyStatement::numRows( ) { // n<0 means estimated to be |n| - if ( !isValid() ) return 0; + if ( !isValid() ) + return 0; return api()->sqlany_num_rows( mHndl ); } bool SqlAnyStatement::nextResultSet( ) { - if ( !isValid() ) return false; + if ( !isValid() ) + return false; if ( !api()->sqlany_get_next_result( mHndl ) ) { getErrMsg(); diff --git a/src/providers/wms/qgswmsconnection.cpp b/src/providers/wms/qgswmsconnection.cpp index bfecbe94c68..464451c6783 100644 --- a/src/providers/wms/qgswmsconnection.cpp +++ b/src/providers/wms/qgswmsconnection.cpp @@ -52,7 +52,7 @@ #include QgsWMSConnection::QgsWMSConnection( QString theConnName ) : - mConnName ( theConnName ) + mConnName( theConnName ) { QgsDebugMsg( "theConnName = " + theConnName ); @@ -63,7 +63,7 @@ QgsWMSConnection::QgsWMSConnection( QString theConnName ) : QStringList connStringParts; - mConnectionInfo = settings.value( key + "/url" ).toString(); + mConnectionInfo = settings.value( key + "/url" ).toString(); // Check for credentials and prepend to the connection info QString username = settings.value( credentialsKey + "/username" ).toString(); @@ -111,12 +111,12 @@ QgsWMSConnection::~QgsWMSConnection() } -QString QgsWMSConnection::connectionInfo ( ) +QString QgsWMSConnection::connectionInfo( ) { return mConnectionInfo; } -QgsWmsProvider * QgsWMSConnection::provider ( ) +QgsWmsProvider * QgsWMSConnection::provider( ) { // TODO: Create and bind to data provider @@ -124,7 +124,7 @@ QgsWmsProvider * QgsWMSConnection::provider ( ) QgsProviderRegistry * pReg = QgsProviderRegistry::instance(); QgsWmsProvider *wmsProvider = - ( QgsWmsProvider* ) pReg->getProvider( "wms", mConnectionInfo ); + ( QgsWmsProvider* ) pReg->provider( "wms", mConnectionInfo ); return wmsProvider; } diff --git a/src/providers/wms/qgswmsconnection.h b/src/providers/wms/qgswmsconnection.h index 8c35997fe66..096f1207670 100644 --- a/src/providers/wms/qgswmsconnection.h +++ b/src/providers/wms/qgswmsconnection.h @@ -45,8 +45,8 @@ class QgsWMSConnection : public QObject ~QgsWMSConnection(); public: - QgsWmsProvider *provider ( ); - QString connectionInfo(); + QgsWmsProvider *provider(); + QString connectionInfo(); QString mConnName; QString mConnectionInfo; }; diff --git a/src/providers/wms/qgswmsprovider.cpp b/src/providers/wms/qgswmsprovider.cpp index fdf3bf452f5..d2898ef949d 100644 --- a/src/providers/wms/qgswmsprovider.cpp +++ b/src/providers/wms/qgswmsprovider.cpp @@ -1862,7 +1862,7 @@ void QgsWmsProvider::parseLayer( QDomElement const & e, QgsWmsLayerProperty& lay if ( !parentProperty ) { // Why clear()? I need top level access. Seems to work in standard select dialog without clear. - //layerProperty.layer.clear(); + //layerProperty.layer.clear(); layerProperty.crs.clear(); } @@ -2976,13 +2976,13 @@ QVector QgsWmsProvider::supportedFormats() QgsWmsSupportedFormat p3 = { "image/png8", "PNG8" }; // used by geoserver QgsWmsSupportedFormat p4 = { "png", "PNG" }; // used by french IGN geoportail QgsWmsSupportedFormat p5 = { "pngt", "PNGT" }; // used by french IGN geoportail - + formats << p1 << p2 << p3 << p4 << p5; } if ( supportedFormats.contains( "jpg" ) ) { - QgsWmsSupportedFormat j1 = { "image/jpeg", "JPEG" }; + QgsWmsSupportedFormat j1 = { "image/jpeg", "JPEG" }; QgsWmsSupportedFormat j2 = { "jpeg", "JPEG" }; // used by french IGN geoportail formats << j1 << j2; } @@ -2999,7 +2999,7 @@ QVector QgsWmsProvider::supportedFormats() formats << t1; } - return formats; + return formats; } void QgsWmsProvider::showMessageBox( const QString& title, const QString& text ) @@ -3046,16 +3046,17 @@ QGISEXTERN QgsWMSSourceSelect * selectWidget( QWidget * parent, Qt::WFlags fl ) return new QgsWMSSourceSelect( parent, fl ); } -QGISEXTERN int dataCapabilities () { +QGISEXTERN int dataCapabilities() +{ return QgsDataProvider::Net; } // --------------------------------------------------------------------------- -QgsWMSConnectionItem::QgsWMSConnectionItem ( QgsDataItem* parent, QString name, QString path ) - : QgsDataCollectionItem ( parent, name, path ) +QgsWMSConnectionItem::QgsWMSConnectionItem( QgsDataItem* parent, QString name, QString path ) + : QgsDataCollectionItem( parent, name, path ) { } -QgsWMSConnectionItem::~QgsWMSConnectionItem () +QgsWMSConnectionItem::~QgsWMSConnectionItem() { } @@ -3063,80 +3064,83 @@ QVector QgsWMSConnectionItem::createChildren() { QgsDebugMsg( "Entered" ); QVector children; - QgsWMSConnection connection ( mName ); - QgsWmsProvider *wmsProvider = connection.provider ( ); - if ( !wmsProvider ) return children; + QgsWMSConnection connection( mName ); + QgsWmsProvider *wmsProvider = connection.provider( ); + if ( !wmsProvider ) + return children; QString mConnInfo = connection.connectionInfo(); QgsDebugMsg( "mConnInfo = " + mConnInfo ); // Attention: supportedLayers() gives tree leafes, not top level - if ( !wmsProvider->supportedLayers( mLayerProperties ) ) return children; - - QgsWmsCapabilitiesProperty mCapabilitiesProperty = wmsProvider->capabilitiesProperty (); + if ( !wmsProvider->supportedLayers( mLayerProperties ) ) + return children; + + QgsWmsCapabilitiesProperty mCapabilitiesProperty = wmsProvider->capabilitiesProperty(); QgsWmsCapabilityProperty capabilityProperty = mCapabilitiesProperty.capability; // Top level layer is present max once // // - default maxOccurs=1 QgsWmsLayerProperty topLayerProperty = capabilityProperty.layer; - foreach ( QgsWmsLayerProperty layerProperty, topLayerProperty.layer ) + foreach( QgsWmsLayerProperty layerProperty, topLayerProperty.layer ) { // Attention, the name may be empty - QgsDebugMsg( QString::number(layerProperty.orderId ) + " " + layerProperty.name + " " + layerProperty.title ); - QString pathName = layerProperty.name.isEmpty() ? QString::number(layerProperty.orderId ) : layerProperty.name; + QgsDebugMsg( QString::number( layerProperty.orderId ) + " " + layerProperty.name + " " + layerProperty.title ); + QString pathName = layerProperty.name.isEmpty() ? QString::number( layerProperty.orderId ) : layerProperty.name; - QgsWMSLayerItem * layer = new QgsWMSLayerItem ( this, layerProperty.title, mPath+"/" + pathName, mCapabilitiesProperty, mConnInfo, layerProperty ); + QgsWMSLayerItem * layer = new QgsWMSLayerItem( this, layerProperty.title, mPath + "/" + pathName, mCapabilitiesProperty, mConnInfo, layerProperty ); - children.append ( layer ); + children.append( layer ); } return children; } -bool QgsWMSConnectionItem::equal(const QgsDataItem *other) +bool QgsWMSConnectionItem::equal( const QgsDataItem *other ) { if ( type() != other->type() ) { return false; } - const QgsWMSConnectionItem *o = dynamic_cast ( other ); + const QgsWMSConnectionItem *o = dynamic_cast( other ); return ( mPath == o->mPath && mName == o->mName && mConnInfo == o->mConnInfo ); } // --------------------------------------------------------------------------- -QgsWMSLayerItem::QgsWMSLayerItem ( QgsDataItem* parent, QString name, QString path, QgsWmsCapabilitiesProperty capabilitiesProperty, QString connInfo, QgsWmsLayerProperty layerProperty ) - : QgsLayerItem ( parent, name, path, QString(), QgsLayerItem::Raster, "wms" ), - mCapabilitiesProperty ( capabilitiesProperty ), - mConnInfo ( connInfo ), - mLayerProperty ( layerProperty ) +QgsWMSLayerItem::QgsWMSLayerItem( QgsDataItem* parent, QString name, QString path, QgsWmsCapabilitiesProperty capabilitiesProperty, QString connInfo, QgsWmsLayerProperty layerProperty ) + : QgsLayerItem( parent, name, path, QString(), QgsLayerItem::Raster, "wms" ), + mCapabilitiesProperty( capabilitiesProperty ), + mConnInfo( connInfo ), + mLayerProperty( layerProperty ) //mProviderKey ("wms"), //mLayerType ( QgsLayerItem::Raster ) { mUri = createUri(); // Populate everything, it costs nothing, all info about layers is collected - foreach ( QgsWmsLayerProperty layerProperty, mLayerProperty.layer ) + foreach( QgsWmsLayerProperty layerProperty, mLayerProperty.layer ) { // Attention, the name may be empty - QgsDebugMsg( QString::number(layerProperty.orderId ) + " " + layerProperty.name + " " + layerProperty.title ); - QString pathName = layerProperty.name.isEmpty() ? QString::number(layerProperty.orderId ) : layerProperty.name; - QgsWMSLayerItem * layer = new QgsWMSLayerItem ( this, layerProperty.title, mPath+"/" + pathName, mCapabilitiesProperty, mConnInfo, layerProperty ); + QgsDebugMsg( QString::number( layerProperty.orderId ) + " " + layerProperty.name + " " + layerProperty.title ); + QString pathName = layerProperty.name.isEmpty() ? QString::number( layerProperty.orderId ) : layerProperty.name; + QgsWMSLayerItem * layer = new QgsWMSLayerItem( this, layerProperty.title, mPath + "/" + pathName, mCapabilitiesProperty, mConnInfo, layerProperty ); mChildren.append( layer ); } if ( mChildren.size() == 0 ) { - mIcon = QIcon ( getThemePixmap ( "mIconWmsLayer.png" ) ); + mIcon = QIcon( getThemePixmap( "mIconWmsLayer.png" ) ); } - mPopulated = true; + mPopulated = true; } -QgsWMSLayerItem::~QgsWMSLayerItem () +QgsWMSLayerItem::~QgsWMSLayerItem() { } -QString QgsWMSLayerItem::createUri() +QString QgsWMSLayerItem::createUri() { QString uri; - if ( mLayerProperty.name.isEmpty() ) return uri; // layer collection + if ( mLayerProperty.name.isEmpty() ) + return uri; // layer collection QString rasterLayerPath = mConnInfo; QString baseName = mLayerProperty.name; @@ -3157,21 +3161,21 @@ QString QgsWMSLayerItem::createUri() QString format; // get first supporte by qt and server QVector formats = QgsWmsProvider::supportedFormats(); - foreach ( QgsWmsSupportedFormat f, formats ) + foreach( QgsWmsSupportedFormat f, formats ) { - if ( mCapabilitiesProperty.capability.request.getMap.format.indexOf(f.format) >= 0 ) + if ( mCapabilitiesProperty.capability.request.getMap.format.indexOf( f.format ) >= 0 ) { format = f.format; break; - } + } } QString crs; // get first known if possible QgsCoordinateReferenceSystem testCrs; - foreach ( QString c, mLayerProperty.crs ) + foreach( QString c, mLayerProperty.crs ) { - testCrs.createFromOgcWmsCrs(c); - if ( testCrs.isValid() ) + testCrs.createFromOgcWmsCrs( c ); + if ( testCrs.isValid() ) { crs = c; break; @@ -3181,21 +3185,21 @@ QString QgsWMSLayerItem::createUri() { crs = mLayerProperty.crs[0]; } - uri = rasterLayerPath + "|layers=" + layers.join(",") + "|styles=" + styles.join(",") + "|format=" + format + "|crs=" + crs; + uri = rasterLayerPath + "|layers=" + layers.join( "," ) + "|styles=" + styles.join( "," ) + "|format=" + format + "|crs=" + crs; return uri; } // --------------------------------------------------------------------------- -QgsWMSRootItem::QgsWMSRootItem ( QgsDataItem* parent, QString name, QString path ) - : QgsDataCollectionItem ( parent, name, path ) +QgsWMSRootItem::QgsWMSRootItem( QgsDataItem* parent, QString name, QString path ) + : QgsDataCollectionItem( parent, name, path ) { - mIcon = QIcon ( getThemePixmap ( "mIconWms.png" ) ); + mIcon = QIcon( getThemePixmap( "mIconWms.png" ) ); populate(); } -QgsWMSRootItem::~QgsWMSRootItem () +QgsWMSRootItem::~QgsWMSRootItem() { } @@ -3205,9 +3209,9 @@ QVectorQgsWMSRootItem::createChildren() QSettings settings; settings.beginGroup( "/Qgis/connections-wms" ); - foreach ( QString connName, settings.childGroups() ) + foreach( QString connName, settings.childGroups() ) { - QgsDataItem * conn = new QgsWMSConnectionItem ( this, connName, mPath + "/" + connName ); + QgsDataItem * conn = new QgsWMSConnectionItem( this, connName, mPath + "/" + connName ); connections.append( conn ); } return connections; @@ -3215,8 +3219,8 @@ QVectorQgsWMSRootItem::createChildren() QWidget * QgsWMSRootItem::paramWidget() { - QgsWMSSourceSelect *select = new QgsWMSSourceSelect(0,0,true,true); - connect (select, SIGNAL(connectionsChanged()), this, SLOT(connectionsChanged()) ); + QgsWMSSourceSelect *select = new QgsWMSSourceSelect( 0, 0, true, true ); + connect( select, SIGNAL( connectionsChanged() ), this, SLOT( connectionsChanged() ) ); return select; } void QgsWMSRootItem::connectionsChanged() @@ -3226,9 +3230,9 @@ void QgsWMSRootItem::connectionsChanged() // --------------------------------------------------------------------------- -QGISEXTERN QgsDataItem * dataItem ( QString thePath, QgsDataItem* parentItem ) +QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem ) { - QgsWMSRootItem * root = new QgsWMSRootItem ( parentItem, "WMS", "wms:" ); + QgsWMSRootItem * root = new QgsWMSRootItem( parentItem, "WMS", "wms:" ); return root; } diff --git a/src/providers/wms/qgswmsprovider.h b/src/providers/wms/qgswmsprovider.h index a50915a3e31..fd1073f1604 100644 --- a/src/providers/wms/qgswmsprovider.h +++ b/src/providers/wms/qgswmsprovider.h @@ -369,7 +369,7 @@ class QgsWmsProvider : public QgsRasterDataProvider //! Destructor virtual ~QgsWmsProvider(); - virtual QgsWmsCapabilitiesProperty capabilitiesProperty () { return mCapabilities; } + virtual QgsWmsCapabilitiesProperty capabilitiesProperty() { return mCapabilities; } /** * \brief Returns a list of the supported layers of the WMS server @@ -966,14 +966,14 @@ class QgsWmsProvider : public QgsRasterDataProvider QStringList mSupportedGetFeatureFormats; }; -class QgsWMSConnectionItem : public QgsDataCollectionItem +class QgsWMSConnectionItem : public QgsDataCollectionItem { - public: - QgsWMSConnectionItem (QgsDataItem* parent, QString name, QString path ); - ~QgsWMSConnectionItem(); + public: + QgsWMSConnectionItem( QgsDataItem* parent, QString name, QString path ); + ~QgsWMSConnectionItem(); QVector createChildren(); - virtual bool equal(const QgsDataItem *other); + virtual bool equal( const QgsDataItem *other ); QgsWmsCapabilitiesProperty mCapabilitiesProperty; QString mConnInfo; @@ -984,11 +984,11 @@ class QgsWMSConnectionItem : public QgsDataCollectionItem // We have to use QgsDataCollectionItem and support layer methods if necessary class QgsWMSLayerItem : public QgsLayerItem { - Q_OBJECT + Q_OBJECT public: - QgsWMSLayerItem (QgsDataItem* parent, QString name, QString path, - QgsWmsCapabilitiesProperty capabilitiesProperty, QString connInfo, QgsWmsLayerProperty layerProperties ); - ~QgsWMSLayerItem (); + QgsWMSLayerItem( QgsDataItem* parent, QString name, QString path, + QgsWmsCapabilitiesProperty capabilitiesProperty, QString connInfo, QgsWmsLayerProperty layerProperties ); + ~QgsWMSLayerItem(); QString createUri(); @@ -997,11 +997,11 @@ class QgsWMSLayerItem : public QgsLayerItem QgsWmsLayerProperty mLayerProperty; }; -class QgsWMSRootItem : public QgsDataCollectionItem +class QgsWMSRootItem : public QgsDataCollectionItem { - Q_OBJECT + Q_OBJECT public: - QgsWMSRootItem (QgsDataItem* parent, QString name, QString path ); + QgsWMSRootItem( QgsDataItem* parent, QString name, QString path ); ~QgsWMSRootItem(); QVector createChildren(); diff --git a/src/providers/wms/qgswmssourceselect.cpp b/src/providers/wms/qgswmssourceselect.cpp index 9ffeda8b942..19ef5b4bf91 100644 --- a/src/providers/wms/qgswmssourceselect.cpp +++ b/src/providers/wms/qgswmssourceselect.cpp @@ -53,26 +53,27 @@ #include #include -QgsWMSSourceSelect::QgsWMSSourceSelect( QWidget * parent, Qt::WFlags fl, bool managerMode, bool embededMode ) +QgsWMSSourceSelect::QgsWMSSourceSelect( QWidget * parent, Qt::WFlags fl, bool managerMode, bool embeddedMode ) : QDialog( parent, fl ) - , mManagerMode ( managerMode ) - , mEmbededMode( embededMode) + , mManagerMode( managerMode ) + , mEmbeddedMode( embeddedMode ) , mCurrentTileset( 0 ) { setupUi( this ); - if ( mEmbededMode ) + if ( mEmbeddedMode ) { buttonBox->button( QDialogButtonBox::Close )->hide(); } - + mAddButton = new QPushButton( tr( "&Add" ) ); mAddButton->setToolTip( tr( "Add selected layers to map" ) ); mAddButton->setEnabled( false ); - + mImageFormatGroup = new QButtonGroup; - if ( !mManagerMode ) { + if ( !mManagerMode ) + { buttonBox->addButton( mAddButton, QDialogButtonBox::ActionRole ); connect( mAddButton, SIGNAL( clicked() ), this, SLOT( addClicked() ) ); @@ -124,12 +125,12 @@ QgsWMSSourceSelect::QgsWMSSourceSelect( QWidget * parent, Qt::WFlags fl, bool ma } else { - tabServers->removeTab ( tabServers->indexOf ( tabLayerOrder ) ); - tabServers->removeTab ( tabServers->indexOf ( tabTilesets ) ); + tabServers->removeTab( tabServers->indexOf( tabLayerOrder ) ); + tabServers->removeTab( tabServers->indexOf( tabTilesets ) ); btnGrpImageEncoding->hide(); - tabLayers->layout()->removeWidget ( btnGrpImageEncoding ); + tabLayers->layout()->removeWidget( btnGrpImageEncoding ); gbCRS->hide(); - tabLayers->layout()->removeWidget ( gbCRS ); + tabLayers->layout()->removeWidget( gbCRS ); } // set up the WMS connections we already know about @@ -405,8 +406,8 @@ void QgsWMSSourceSelect::on_btnConnect_clicked() { mConnName = cmbConnections->currentText(); - QgsWMSConnection connection ( cmbConnections->currentText() ); - QgsWmsProvider *wmsProvider = connection.provider ( ); + QgsWMSConnection connection( cmbConnections->currentText() ); + QgsWmsProvider *wmsProvider = connection.provider( ); mConnectionInfo = connection.connectionInfo(); if ( wmsProvider ) @@ -483,14 +484,14 @@ void QgsWMSSourceSelect::addClicked() connInfo.prepend( connArgs + ",url=" ); } } - QgsDebugMsg ( "crs = " + crs ); + QgsDebugMsg( "crs = " + crs ); // TODO: do it without QgisApp //QgisApp::instance()->addRasterLayer( connInfo, // leLayerName->text().isEmpty() ? layers.join( "/" ) : leLayerName->text(), // "wms", layers, styles, format, crs ); emit addRasterLayer( connInfo, - leLayerName->text().isEmpty() ? layers.join( "/" ) : leLayerName->text(), + leLayerName->text().isEmpty() ? layers.join( "/" ) : leLayerName->text(), "wms", layers, styles, format, crs ); } diff --git a/src/providers/wms/qgswmssourceselect.h b/src/providers/wms/qgswmssourceselect.h index b029703e4aa..a41beecd63d 100644 --- a/src/providers/wms/qgswmssourceselect.h +++ b/src/providers/wms/qgswmssourceselect.h @@ -49,7 +49,7 @@ class QgsWMSSourceSelect : public QDialog, private Ui::QgsWMSSourceSelectBase public: //! Constructor - QgsWMSSourceSelect( QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags, bool managerMode = false, bool embededMode = false ); + QgsWMSSourceSelect( QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags, bool managerMode = false, bool embeddedMode = false ); //! Destructor ~QgsWMSSourceSelect(); @@ -126,9 +126,9 @@ class QgsWMSSourceSelect : public QDialog, private Ui::QgsWMSSourceSelectBase //! Connections manager mode bool mManagerMode; - - //! Embeded mode, without 'Close' - bool mEmbededMode; + + //! Embedded mode, without 'Close' + bool mEmbeddedMode; //! Selected CRS QString mCRS; @@ -198,12 +198,12 @@ class QgsWMSSourceSelect : public QDialog, private Ui::QgsWMSSourceSelectBase QTableWidgetItem* mCurrentTileset; signals: void addRasterLayer( QString const & rasterLayerPath, - QString const & baseName, - QString const & providerKey, - QStringList const & layers, - QStringList const & styles, - QString const & format, - QString const & crs ); + QString const & baseName, + QString const & providerKey, + QStringList const & layers, + QStringList const & styles, + QString const & format, + QString const & crs ); void connectionsChanged(); private slots: void on_btnSearch_clicked();