Skip to content
Permalink
Browse files

Merge pull request #730 from palmerj/wfs_client_fixes

WFS client fixes
  • Loading branch information
jef-n committed Jul 15, 2013
2 parents 133398b + b54c981 commit d0c3f4fc4c4e95c7b3543542b0288cf49a78d58a
@@ -85,7 +85,16 @@ int QgsGml::getFeatures( const QString& uri, QGis::WkbType* wkbType, QgsRectangl

//find out if there is a QGIS main window. If yes, display a progress dialog
QProgressDialog* progressDialog = 0;
QWidget* mainWindow = qApp->activeWindow();
QWidget* mainWindow = 0;
QWidgetList topLevelWidgets = qApp->topLevelWidgets();
for ( QWidgetList::iterator it = topLevelWidgets.begin(); it != topLevelWidgets.end(); ++it )
{
if (( *it )->objectName() == "QgisApp" )
{
mainWindow = *it;
break;
}
}
if ( mainWindow )
{
progressDialog = new QProgressDialog( tr( "Loading GML data\n%1" ).arg( mTypeName ), tr( "Abort" ), 0, 0, mainWindow );
@@ -119,9 +128,22 @@ int QgsGml::getFeatures( const QString& uri, QGis::WkbType* wkbType, QgsRectangl
QCoreApplication::processEvents();
}

QNetworkReply::NetworkError replyError = reply->error();
QString replyErrorString = reply->errorString();

delete reply;
delete progressDialog;

if ( replyError )
{
QgsMessageLog::logMessage(
tr( "GML Getfeature network request failed with error: %1" ).arg( replyErrorString ),
tr( "Network" ),
QgsMessageLog::CRITICAL
);
return 1;
}

if ( *mWkbType != QGis::WKBNoGeometry )
{
if ( mExtent.isEmpty() )
@@ -12,6 +12,8 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include <QStringList>

#include "qgsmimedatautils.h"

#include "qgsdataitem.h"
@@ -39,20 +41,50 @@ QgsMimeDataUtils::Uri::Uri( QgsLayerItem* layerItem )

QgsMimeDataUtils::Uri::Uri( QString& encData )
{
QRegExp rx( "^([^:]+):([^:]+):([^:]+):(.+)" );
if ( rx.indexIn( encData ) != -1 )
QStringList parts;
QChar split = ':';
QChar escape = '\\';
QString part;
bool inEscape = false;
for (int i = 0; i < encData.length(); ++i)
{
if (encData.at(i) == escape && !inEscape)
{
inEscape = true;
}
else if (encData.at(i) == split && !inEscape)
{
parts << part;
part = "";
}
else
{
part += encData.at(i);
inEscape = false;
}
}
if (!part.isEmpty())
{
parts << part;
}

if ( parts.size() == 4 )
{
layerType = rx.cap( 1 );
providerKey = rx.cap( 2 );
name = rx.cap( 3 );
uri = rx.cap( 4 );
layerType = parts[0];
providerKey = parts[1];
name = parts[2];
uri = parts[3];
QgsDebugMsg( "type: " + layerType + " key: " + providerKey + " name: " + name + " uri: " + uri );
}
}

QString QgsMimeDataUtils::Uri::data() const
{
return layerType + ":" + providerKey + ":" + name + ":" + uri;
QString escapedName = name;
QString escapeUri = uri;
escapedName.replace(":", "\\:");
escapeUri.replace(":", "\\:");
return layerType + ":" + providerKey + ":" + escapedName + ":" + escapeUri;
}

// -----
@@ -24,10 +24,10 @@
#include <QCoreApplication>


QgsWFSLayerItem::QgsWFSLayerItem( QgsDataItem* parent, QString name, QgsDataSourceURI uri, QString featureType, QString title )
QgsWFSLayerItem::QgsWFSLayerItem( QgsDataItem* parent, QString name, QgsDataSourceURI uri, QString featureType, QString title, QString crsString )
: QgsLayerItem( parent, title, parent->path() + "/" + name, QString(), QgsLayerItem::Vector, "WFS" )
{
mUri = QgsWFSCapabilities( uri.encodedUri() ).uriGetFeature( featureType );
mUri = QgsWFSCapabilities( uri.encodedUri() ).uriGetFeature( featureType, crsString );
mPopulated = true;
mIcon = QgsApplication::getThemeIcon( "mIconWfs.svg" );
}
@@ -74,7 +74,7 @@ QVector<QgsDataItem*> QgsWFSConnectionItem::createChildren()
foreach ( const QgsWFSCapabilities::FeatureType& featureType, caps.featureTypes )
{
//QgsWFSLayerItem* layer = new QgsWFSLayerItem( this, mName, featureType.name, featureType.title );
QgsWFSLayerItem* layer = new QgsWFSLayerItem( this, mName, uri, featureType.name, featureType.title );
QgsWFSLayerItem* layer = new QgsWFSLayerItem( this, mName, uri, featureType.name, featureType.title, featureType.crslist.first() );
layers.append( layer );
}
}
@@ -69,7 +69,7 @@ class QgsWFSConnectionItem : public QgsDataCollectionItem
class QgsWFSLayerItem : public QgsLayerItem
{
public:
QgsWFSLayerItem( QgsDataItem* parent, QString name, QgsDataSourceURI uri, QString featureType, QString title );
QgsWFSLayerItem( QgsDataItem* parent, QString name, QgsDataSourceURI uri, QString featureType, QString title, QString crsString );
~QgsWFSLayerItem();

};
@@ -207,6 +207,8 @@ void QgsWFSSourceSelect::capabilitiesReplyFinished()
}
// handle errors
QMessageBox::critical( 0, title, mCapabilities->errorMessage() );

mAddButton->setEnabled( false );
return;
}

@@ -60,7 +60,6 @@ class QgsWFSSourceSelect: public QDialog, private Ui::QgsWFSSourceSelectBase
The first string is the typename, the corresponding list
stores the CRS for the typename in the form 'EPSG:XXXX'*/
std::map<QString, std::list<QString> > mAvailableCRS;
QAbstractButton* btnAdd;
QgsWFSCapabilities* mCapabilities;
QString mUri; // data source URI
QgsWFSItemDelegate* mItemDelegate;

0 comments on commit d0c3f4f

Please sign in to comment.
You can’t perform that action at this time.