[QGIS Commit] r14632 - in trunk/qgis/src: plugins/wfs providers/wfs

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Nov 13 19:55:18 EST 2010


Author: mhugent
Date: 2010-11-13 16:55:18 -0800 (Sat, 13 Nov 2010)
New Revision: 14632

Modified:
   trunk/qgis/src/plugins/wfs/qgswfssourceselect.cpp
   trunk/qgis/src/providers/wfs/qgswfsdata.cpp
   trunk/qgis/src/providers/wfs/qgswfsdata.h
   trunk/qgis/src/providers/wfs/qgswfsprovider.cpp
   trunk/qgis/src/providers/wfs/qgswfsprovider.h
Log:
Read wfs layer crs from url, not from the GetFeature output

Modified: trunk/qgis/src/plugins/wfs/qgswfssourceselect.cpp
===================================================================
--- trunk/qgis/src/plugins/wfs/qgswfssourceselect.cpp	2010-11-14 00:52:08 UTC (rev 14631)
+++ trunk/qgis/src/plugins/wfs/qgswfssourceselect.cpp	2010-11-14 00:55:18 UTC (rev 14632)
@@ -379,15 +379,12 @@
   QgsDebugMsg( QString( "%1SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=%2" ).arg( uri ).arg( typeName ) );
 
   //get CRS
-  QString crsString;
-  if ( mProjectionSelector )
+  QString crsString = labelCoordRefSys->text();
+  if ( !crsString.isEmpty() )
   {
-    QString authid = mProjectionSelector->selectedAuthId();
-    if ( !authid.isEmpty() )
-    {
-      crsString = "&SRSNAME=" + authid;
-    }
+    crsString.prepend( "&SRSNAME=" );
   }
+
   //add a wfs layer to the map
   if ( mIface )
   {

Modified: trunk/qgis/src/providers/wfs/qgswfsdata.cpp
===================================================================
--- trunk/qgis/src/providers/wfs/qgswfsdata.cpp	2010-11-14 00:52:08 UTC (rev 14631)
+++ trunk/qgis/src/providers/wfs/qgswfsdata.cpp	2010-11-14 00:55:18 UTC (rev 14632)
@@ -33,7 +33,6 @@
 QgsWFSData::QgsWFSData(
   const QString& uri,
   QgsRectangle* extent,
-  QgsCoordinateReferenceSystem* srs,
   QMap<int, QgsFeature*> &features,
   QMap<int, QString > &idMap,
   const QString& geometryAttribute,
@@ -42,7 +41,6 @@
     : QObject(),
     mUri( uri ),
     mExtent( extent ),
-    mSrs( srs ),
     mFeatures( features ),
     mIdMap( idMap ),
     mGeometryAttribute( geometryAttribute ),
@@ -202,14 +200,6 @@
     {
       QgsDebugMsg( "error, could not get epsg id" );
     }
-
-    if ( mSrs )
-    {
-      if ( !mSrs->createFromOgcWmsCrs( QString( "EPSG:%1" ).arg( epsgNr ) ) )
-      {
-        QgsDebugMsg( "Creation of srs from epsg failed" );
-      }
-    }
   }
   else if ( elementName == GML_NAMESPACE + NS_SEPARATOR + "Polygon" )
   {

Modified: trunk/qgis/src/providers/wfs/qgswfsdata.h
===================================================================
--- trunk/qgis/src/providers/wfs/qgswfsdata.h	2010-11-14 00:52:08 UTC (rev 14631)
+++ trunk/qgis/src/providers/wfs/qgswfsdata.h	2010-11-14 00:55:18 UTC (rev 14632)
@@ -38,7 +38,6 @@
     QgsWFSData(
       const QString& uri,
       QgsRectangle* extent,
-      QgsCoordinateReferenceSystem* srs,
       QMap<int, QgsFeature* > &features,
       QMap<int, QString > &idMap,
       const QString& geometryAttribute,
@@ -144,8 +143,6 @@
     //results are members such that handler routines are able to manipulate them
     /**Bounding box of the layer*/
     QgsRectangle* mExtent;
-    /**Source srs of the layer*/
-    QgsCoordinateReferenceSystem* mSrs;
     /**The features of the layer*/
     QMap<int, QgsFeature* > &mFeatures;
     /**Stores the relation between provider ids and WFS server ids*/

Modified: trunk/qgis/src/providers/wfs/qgswfsprovider.cpp
===================================================================
--- trunk/qgis/src/providers/wfs/qgswfsprovider.cpp	2010-11-14 00:52:08 UTC (rev 14631)
+++ trunk/qgis/src/providers/wfs/qgswfsprovider.cpp	2010-11-14 00:55:18 UTC (rev 14632)
@@ -284,7 +284,7 @@
   transactionDoc.appendChild( transactionElem );
 
   //find out typename from uri and strip namespace prefix
-  QString tname = typeNameFromUrl();
+  QString tname = parameterFromUrl( "typename" );
   if ( tname.isNull() )
   {
     return false;
@@ -375,7 +375,7 @@
   }
 
   //find out typename from uri and strip namespace prefix
-  QString tname = typeNameFromUrl();
+  QString tname = parameterFromUrl( "typename" );
   if ( tname.isNull() )
   {
     return false;
@@ -443,7 +443,7 @@
 bool QgsWFSProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
 {
   //find out typename from uri and strip namespace prefix
-  QString tname = typeNameFromUrl();
+  QString tname = parameterFromUrl( "typename" );
   if ( tname.isNull() )
   {
     return false;
@@ -530,7 +530,7 @@
 bool QgsWFSProvider::changeAttributeValues( const QgsChangedAttributesMap &attr_map )
 {
   //find out typename from uri and strip namespace prefix
-  QString tname = typeNameFromUrl();
+  QString tname = parameterFromUrl( "typename" );
   if ( tname.isNull() )
   {
     return false;
@@ -656,7 +656,18 @@
     thematicAttributes.insert( it.value().name(), qMakePair( it.key(), it.value() ) );
   }
 
-  QgsWFSData dataReader( uri, &mExtent, &mSourceCRS, mFeatures, mIdMap, geometryAttribute, thematicAttributes, &mWKBType );
+  //create mSourceCRS from url if possible
+  QString srsname = parameterFromUrl( "SRSNAME" );
+  if ( !srsname.isEmpty() )
+  {
+    QStringList epsgSplit = srsname.split( ":" );
+    if ( epsgSplit.size() > 1 )
+    {
+      mSourceCRS.createFromEpsg( epsgSplit.at( 1 ).toInt() );
+    }
+  }
+
+  QgsWFSData dataReader( uri, &mExtent, mFeatures, mIdMap, geometryAttribute, thematicAttributes, &mWKBType );
   QObject::connect( &dataReader, SIGNAL( dataProgressAndSteps( int , int ) ), this, SLOT( handleWFSProgressMessage( int, int ) ) );
 
   //also connect to statusChanged signal of qgisapp (if it exists)
@@ -1989,7 +2000,7 @@
   return mCapabilities;
 }
 
-QString QgsWFSProvider::typeNameFromUrl() const
+QString QgsWFSProvider::parameterFromUrl( const QString& name ) const
 {
   QStringList urlSplit = dataSourceUri().split( "?" );
   if ( urlSplit.size() > 1 )
@@ -1998,7 +2009,7 @@
     QStringList::const_iterator kvIt = keyValueSplit.constBegin();
     for ( ; kvIt != keyValueSplit.constEnd(); ++kvIt )
     {
-      if ( kvIt->startsWith( "typename", Qt::CaseInsensitive ) )
+      if ( kvIt->startsWith( name, Qt::CaseInsensitive ) )
       {
         QStringList equalSplit = kvIt->split( "=" );
         if ( equalSplit.size() > 1 )
@@ -2069,7 +2080,7 @@
   transactionElem.setAttribute( "xsi:schemaLocation", mWfsNamespace + " " \
                                 + dataSourceUri().replace( QString( "GetFeature" ), QString( "DescribeFeatureType" ) ) );
 
-  QString namespacePrefix = nameSpacePrefix( typeNameFromUrl() );
+  QString namespacePrefix = nameSpacePrefix( parameterFromUrl( "typename" ) );
   if ( !namespacePrefix.isEmpty() )
   {
     transactionElem.setAttribute( "xmlns:" + namespacePrefix, mWfsNamespace );
@@ -2204,7 +2215,7 @@
   }
 
   //find the <FeatureType> for this layer
-  QString thisLayerName = typeNameFromUrl();
+  QString thisLayerName = parameterFromUrl( "typename" );
   QDomNodeList featureTypeList = featureTypeListElem.elementsByTagName( "FeatureType" );
   for ( int i = 0; i < featureTypeList.size(); ++i )
   {

Modified: trunk/qgis/src/providers/wfs/qgswfsprovider.h
===================================================================
--- trunk/qgis/src/providers/wfs/qgswfsprovider.h	2010-11-14 00:52:08 UTC (rev 14631)
+++ trunk/qgis/src/providers/wfs/qgswfsprovider.h	2010-11-14 00:55:18 UTC (rev 14632)
@@ -257,9 +257,8 @@
 
     //helper methods for WFS-T
 
-    /**Extracts the typename from the providers url
-      @return typename or a null string in case of error*/
-    QString typeNameFromUrl() const;
+    /**Returns HTTP parameter value from url (or empty string if it does not exist)*/
+    QString parameterFromUrl( const QString& name ) const;
 
     /**Removes a possible namespace prefix from a typename*/
     void removeNamespacePrefix( QString& tname ) const;



More information about the QGIS-commit mailing list