QgsWFSProvider::QgsWFSProvider( const QString& uri, const QgsWFSCapabilities::Capabilities &caps ) : QgsVectorDataProvider( uri ) , mShared( new QgsWFSSharedData( uri ) ) , mWKBType( QGis::WKBUnknown ) , mValid( true ) , mCapabilities( 0 ) { mShared->mCaps = caps; connect( mShared.data(), SIGNAL( raiseError( const QString& ) ), this, SLOT( pushErrorSlot( const QString& ) ) ); if ( uri.isEmpty() ) { mValid = false; return; } //create mSourceCRS from url if possible [WBC 111221] refactored from GetFeatureGET() QString srsname = mShared->mURI.SRSName(); if ( !srsname.isEmpty() ) { if ( srsname == "EPSG:900913" ) mShared->mSourceCRS.createFromOgcWmsCrs( "EPSG:3857" ); else mShared->mSourceCRS.createFromOgcWmsCrs( srsname ); } // Must be called first to establish the version, in case we are in auto-detection if ( !getCapabilities() ) { mValid = false; return; } if ( !mShared->mURI.sql().isEmpty() ) { if ( !processSQL( mShared->mURI.sql(), mProcessSQLErrorMsg ) ) { QgsMessageLog::logMessage( mProcessSQLErrorMsg, tr( "WFS" ) ); mValid = false; return; } mSubsetString = mShared->mURI.sql(); } else { mSubsetString = mShared->mURI.filter(); //fetch attributes of layer and type of its geometry attribute //WBC 111221: extracting geometry type here instead of getFeature allows successful //layer creation even when no features are retrieved (due to, e.g., BBOX or FILTER) if ( !describeFeatureType( mShared->mGeometryAttribute, mShared->mFields, mWKBType ) ) { mValid = false; return; } mThisTypenameFields = mShared->mFields; } if ( !mShared->computeFilter( mProcessSQLErrorMsg ) ) { QgsMessageLog::logMessage( mProcessSQLErrorMsg, tr( "WFS" ) ); mValid = false; return; } //Failed to detect feature type from describeFeatureType -> get first feature from layer to detect type if ( mWKBType == QGis::WKBUnknown ) { QgsWFSFeatureDownloader downloader( mShared.data() ); connect( &downloader, SIGNAL( featureReceived( QVector<QgsWFSFeatureGmlIdPair> ) ), this, SLOT( featureReceivedAnalyzeOneFeature( QVector<QgsWFSFeatureGmlIdPair> ) ) ); downloader.run( false, /* serialize features */ 1 /* maxfeatures */ ); } qRegisterMetaType<QgsRectangle>( "QgsRectangle" ); }
void sqlimport::process_line(QString sqlLine) { QString lineData; lineData = cleanLine(sqlLine); if (!lineData.isEmpty()) { if ((lineData.left(13) == "CREATE TABLE") || (lineData.left(12) == "CREATE TABLE")) { SQLStatement.clear(); collectSQL = false; if (lineData.lastIndexOf(";") >= 0) { SQLStatement << lineData; if (isSemiColonInsideSingleQuote() == false) { collectSQL = false; processSQL(SQLStatement); SQLStatement.clear(); } else { collectSQL = true; } } else { SQLStatement << lineData; collectSQL = true; } } else { if ((lineData.left(12) == "INSERT INTO") || (lineData.left(11) == "INSERT INTO")) { //qDebug() << lineData.left(11); SQLStatement.clear(); collectSQL = false; if (lineData.lastIndexOf(";") >= 0) { SQLStatement << lineData; if (isSemiColonInsideSingleQuote() == false) { collectSQL = false; processSQL(SQLStatement); SQLStatement.clear(); } else { collectSQL = true; } } else { SQLStatement << lineData; collectSQL = true; } } else { if (lineData.lastIndexOf(";") >= 0) { SQLStatement << lineData; if (isSemiColonInsideSingleQuote() == false) { collectSQL = false; processSQL(SQLStatement); SQLStatement.clear(); } else { //qDebug() << "Why!"; collectSQL = true; } } else { if (collectSQL) { SQLStatement << lineData; } else { lineData = lineData + "\n"; //outfile.write(lineData.toAscii()); writeToFile(lineData.toAscii()); //outStream << lineData; } } } } } }