Skip to content
Permalink
Browse files

Read wfs layer crs from url, not from the GetFeature output

git-svn-id: http://svn.osgeo.org/qgis/trunk@14632 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Nov 14, 2010
1 parent 2f2c1d1 commit e616bff5ab5b68331d893d346fbe89549475e141
@@ -379,15 +379,12 @@ void QgsWFSSourceSelect::addLayer()
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 )
{
@@ -33,7 +33,6 @@ const QString GML_NAMESPACE = "http://www.opengis.net/gml";
QgsWFSData::QgsWFSData(
const QString& uri,
QgsRectangle* extent,
QgsCoordinateReferenceSystem* srs,
QMap<int, QgsFeature*> &features,
QMap<int, QString > &idMap,
const QString& geometryAttribute,
@@ -42,7 +41,6 @@ QgsWFSData::QgsWFSData(
: QObject(),
mUri( uri ),
mExtent( extent ),
mSrs( srs ),
mFeatures( features ),
mIdMap( idMap ),
mGeometryAttribute( geometryAttribute ),
@@ -202,14 +200,6 @@ void QgsWFSData::startElement( const XML_Char* el, const XML_Char** attr )
{
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" )
{
@@ -38,7 +38,6 @@ class QgsWFSData: public QObject
QgsWFSData(
const QString& uri,
QgsRectangle* extent,
QgsCoordinateReferenceSystem* srs,
QMap<int, QgsFeature* > &features,
QMap<int, QString > &idMap,
const QString& geometryAttribute,
@@ -144,8 +143,6 @@ class QgsWFSData: public QObject
//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*/
@@ -284,7 +284,7 @@ bool QgsWFSProvider::addFeatures( QgsFeatureList &flist )
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 @@ bool QgsWFSProvider::deleteFeatures( const QgsFeatureIds &id )
}

//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::deleteFeatures( const QgsFeatureIds &id )
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::changeGeometryValues( QgsGeometryMap & geometry_map )
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 @@ int QgsWFSProvider::getFeatureGET( const QString& uri, const QString& geometryAt
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 @@ int QgsWFSProvider::capabilities() const
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 @@ QString QgsWFSProvider::typeNameFromUrl() const
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 @@ QDomElement QgsWFSProvider::createTransactionElement( QDomDocument& doc ) const
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 @@ void QgsWFSProvider::getLayerCapabilities()
}

//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 )
{
@@ -257,9 +257,8 @@ class QgsWFSProvider: public QgsVectorDataProvider

//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;

0 comments on commit e616bff

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