Skip to content

Commit 08ead81

Browse files
committedJun 10, 2016
[WFS provider] Use EPSG:XXXX format for SRSNAME= parameter for servers that adverize SRS in GetCapabilities response in that format. And also append srsname to value of BBOX parameter
1 parent 734a3a5 commit 08ead81

File tree

5 files changed

+29
-14
lines changed

5 files changed

+29
-14
lines changed
 

‎src/providers/wfs/qgswfscapabilities.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ void QgsWFSCapabilities::Capabilities::clear()
7272
setAllTypenames.clear();
7373
mapUnprefixedTypenameToPrefixedTypename.clear();
7474
setAmbiguousUnprefixedTypename.clear();
75+
useEPSGColumnFormat = false;
7576
}
7677

7778
QString QgsWFSCapabilities::Capabilities::addPrefixIfNeeded( const QString& name ) const
@@ -283,7 +284,11 @@ void QgsWFSCapabilities::capabilitiesReplyFinished()
283284
defaultCRSList = featureTypeElem.elementsByTagName( "DefaultCRS" );
284285
if ( defaultCRSList.length() > 0 )
285286
{
286-
featureType.crslist.append( NormalizeSRSName( defaultCRSList.at( 0 ).toElement().text() ) );
287+
QString srsname( defaultCRSList.at( 0 ).toElement().text() );
288+
// Some servers like Geomedia advertize EPSG:XXXX even in WFS 1.1 or 2.0
289+
if ( srsname.startsWith( "EPSG:" ) )
290+
mCaps.useEPSGColumnFormat = true;
291+
featureType.crslist.append( NormalizeSRSName( srsname ) );
287292
}
288293

289294
//OtherSRS

‎src/providers/wfs/qgswfscapabilities.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class QgsWFSCapabilities : public QgsWFSRequest
3535
//! description of a vector layer
3636
struct FeatureType
3737
{
38+
//! Default constructor
39+
FeatureType() : insertCap( false ), updateCap( false ), deleteCap( false ) {}
40+
3841
QString name;
3942
QString title;
4043
QString abstract;
@@ -92,6 +95,7 @@ class QgsWFSCapabilities : public QgsWFSRequest
9295
QList<FeatureType> featureTypes;
9396
QList<Function> spatialPredicatesList;
9497
QList<Function> functionList;
98+
bool useEPSGColumnFormat; // whether to use EPSG:XXXX srsname
9599

96100
QSet< QString > setAllTypenames;
97101
QMap< QString, QString> mapUnprefixedTypenameToPrefixedTypename;

‎src/providers/wfs/qgswfsfeatureiterator.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,15 @@ QUrl QgsWFSFeatureDownloader::buildURL( int startIndex, int maxFeatures, bool fo
302302
{
303303
invertAxis = !invertAxis;
304304
}
305-
getFeatureUrl.addQueryItem( "BBOX", QString(( invertAxis ) ? "%2,%1,%4,%3" : "%1,%2,%3,%4" )
306-
.arg( qgsDoubleToString( mShared->mRect.xMinimum() ),
307-
qgsDoubleToString( mShared->mRect.yMinimum() ),
308-
qgsDoubleToString( mShared->mRect.xMaximum() ),
309-
qgsDoubleToString( mShared->mRect.yMaximum() ) ) );
305+
QString bbox( QString(( invertAxis ) ? "%2,%1,%4,%3" : "%1,%2,%3,%4" )
306+
.arg( qgsDoubleToString( mShared->mRect.xMinimum() ),
307+
qgsDoubleToString( mShared->mRect.yMinimum() ),
308+
qgsDoubleToString( mShared->mRect.xMaximum() ),
309+
qgsDoubleToString( mShared->mRect.yMaximum() ) ) );
310+
// Some servers like Geomedia need the srsname to be explictly appended
311+
// otherwise they are confused and do not interpret it properly
312+
bbox += "," + mShared->srsName();
313+
getFeatureUrl.addQueryItem( "BBOX", bbox );
310314
}
311315
else if ( !mShared->mWFSFilter.isEmpty() )
312316
{

‎src/providers/wfs/qgswfsshareddata.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ QString QgsWFSSharedData::srsName() const
7070
if ( !mSourceCRS.authid().isEmpty() )
7171
{
7272
if ( mWFSVersion.startsWith( "1.0" ) ||
73-
!mSourceCRS.authid().startsWith( "EPSG:" ) )
73+
!mSourceCRS.authid().startsWith( "EPSG:" ) ||
74+
// For servers like Geomedia that advertize EPSG:XXXX in capabilities even in WFS 1.1 or 2.0
75+
mCaps.useEPSGColumnFormat )
7476
{
7577
srsName = mSourceCRS.authid();
7678
}

‎tests/src/python/test_provider_wfs.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ def testWFSGetOnlyFeaturesInViewExtent(self):
842842
assert vl.isValid()
843843
self.assertEqual(vl.wkbType(), QgsWKBTypes.Point)
844844

845-
last_url = sanitize(endpoint, '?SERVICE=WFS&REQUEST=GetFeature&VERSION=1.1.0&TYPENAME=my:typename&MAXFEATURES=2&SRSNAME=urn:ogc:def:crs:EPSG::4326&BBOX=60,-70,80,-60')
845+
last_url = sanitize(endpoint, '?SERVICE=WFS&REQUEST=GetFeature&VERSION=1.1.0&TYPENAME=my:typename&MAXFEATURES=2&SRSNAME=urn:ogc:def:crs:EPSG::4326&BBOX=60,-70,80,-60,urn:ogc:def:crs:EPSG::4326')
846846
with open(last_url, 'wb') as f:
847847
f.write("""
848848
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs"
@@ -883,7 +883,7 @@ def testWFSGetOnlyFeaturesInViewExtent(self):
883883
self.assertEqual(values, [2])
884884

885885
# Move to a neighbouring area, and reach the download limit
886-
last_url = sanitize(endpoint, '?SERVICE=WFS&REQUEST=GetFeature&VERSION=1.1.0&TYPENAME=my:typename&MAXFEATURES=2&SRSNAME=urn:ogc:def:crs:EPSG::4326&BBOX=65,-70,90,-60')
886+
last_url = sanitize(endpoint, '?SERVICE=WFS&REQUEST=GetFeature&VERSION=1.1.0&TYPENAME=my:typename&MAXFEATURES=2&SRSNAME=urn:ogc:def:crs:EPSG::4326&BBOX=65,-70,90,-60,urn:ogc:def:crs:EPSG::4326')
887887
with open(last_url, 'wb') as f:
888888
f.write("""
889889
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs"
@@ -908,7 +908,7 @@ def testWFSGetOnlyFeaturesInViewExtent(self):
908908
self.assertEqual(values, [2, 3])
909909

910910
# Zoom-in again, and bring more features
911-
last_url = sanitize(endpoint, '?SERVICE=WFS&REQUEST=GetFeature&VERSION=1.1.0&TYPENAME=my:typename&MAXFEATURES=2&SRSNAME=urn:ogc:def:crs:EPSG::4326&BBOX=66,-69,89,-61')
911+
last_url = sanitize(endpoint, '?SERVICE=WFS&REQUEST=GetFeature&VERSION=1.1.0&TYPENAME=my:typename&MAXFEATURES=2&SRSNAME=urn:ogc:def:crs:EPSG::4326&BBOX=66,-69,89,-61,urn:ogc:def:crs:EPSG::4326')
912912
with open(last_url, 'wb') as f:
913913
f.write("""
914914
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs"
@@ -1823,7 +1823,7 @@ def testWrongCapabilityExtent(self):
18231823
assert vl.isValid()
18241824

18251825
# First request that will be attempted
1826-
with open(sanitize(endpoint, """?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=my:typename&SRSNAME=urn:ogc:def:crs:EPSG::4326&BBOX=-0.125,-0.125,1.125,1.125"""), 'wb') as f:
1826+
with open(sanitize(endpoint, """?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=my:typename&SRSNAME=urn:ogc:def:crs:EPSG::4326&BBOX=-0.125,-0.125,1.125,1.125,urn:ogc:def:crs:EPSG::4326"""), 'wb') as f:
18271827
f.write("""
18281828
<wfs:FeatureCollection
18291829
xmlns:wfs="http://www.opengis.net/wfs/2.0"
@@ -1868,7 +1868,7 @@ def testGeomedia(self):
18681868
<Name>my:typename</Name>
18691869
<Title>Title</Title>
18701870
<Abstract>Abstract</Abstract>
1871-
<DefaultCRS>urn:ogc:def:crs:EPSG::32631</DefaultCRS>
1871+
<DefaultCRS>EPSG:32631</DefaultCRS>
18721872
<ows:WGS84BoundingBox>
18731873
<ows:LowerCorner>0 40</ows:LowerCorner>
18741874
<ows:UpperCorner>15 50</ows:UpperCorner>
@@ -1895,7 +1895,7 @@ def testGeomedia(self):
18951895
</xsd:schema>
18961896
""".encode('UTF-8'))
18971897

1898-
with open(sanitize(endpoint, """?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=my:typename&SRSNAME=urn:ogc:def:crs:EPSG::32631"""), 'wb') as f:
1898+
with open(sanitize(endpoint, """?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=my:typename&SRSNAME=EPSG:32631"""), 'wb') as f:
18991899
f.write("""
19001900
<wfs:FeatureCollection
19011901
xmlns:wfs="http://www.opengis.net/wfs/2.0"
@@ -1904,7 +1904,7 @@ def testGeomedia(self):
19041904
<wfs:member>
19051905
<my:typename gml:id="typename.0">
19061906
<my:intfield>1</my:intfield>
1907-
<my:geometryProperty><gml:Polygon srsName="urn:ogc:def:crs:EPSG::32631" gml:id="typename.geom.0"><gml:exterior><gml:LinearRing><gml:posList>500000 4500000 500000 4510000 510000 4510000 510000 4500000 500000 4500000</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></my:geometryProperty>
1907+
<my:geometryProperty><gml:Polygon srsName="EPSG:32631" gml:id="typename.geom.0"><gml:exterior><gml:LinearRing><gml:posList>500000 4500000 500000 4510000 510000 4510000 510000 4500000 500000 4500000</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></my:geometryProperty>
19081908
</my:typename>
19091909
</wfs:member>
19101910
</wfs:FeatureCollection>""".encode('UTF-8'))

0 commit comments

Comments
 (0)
Please sign in to comment.