Skip to content

Commit

Permalink
Fix BBOX CRS in WFS GetFeature
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-morvan committed Apr 25, 2018
1 parent 72bd89e commit 60dc78a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
22 changes: 17 additions & 5 deletions src/server/services/wfs/qgswfsgetfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,6 @@ namespace QgsWfs
requestPrecision = QgsServerProjectUtils::wfsLayerPrecision( *project, vlayer->id() );
}

if ( onlyOneLayer && !featureRequest.filterRect().isEmpty() )
{
requestRect = featureRequest.filterRect();
}

if ( aRequest.maxFeatures > 0 )
{
featureRequest.setLimit( aRequest.maxFeatures + aRequest.startIndex - sentFeatures );
Expand All @@ -363,6 +358,23 @@ namespace QgsWfs
outputCrs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( query.srsName );
}

if ( onlyOneLayer && !featureRequest.filterRect().isEmpty() )
{
Q_NOWARN_DEPRECATED_PUSH
QgsCoordinateTransform transform( outputCrs, requestCrs );
Q_NOWARN_DEPRECATED_POP
try
{
featureRequest.setFilterRect( transform.transform( featureRequest.filterRect() ) );
}
catch ( QgsException &cse )
{
Q_UNUSED( cse );
}

requestRect = featureRequest.filterRect();
}

// Iterate through features
QgsFeatureIterator fit = vlayer->getFeatures( featureRequest );

Expand Down
9 changes: 7 additions & 2 deletions tests/src/python/test_qgsserver_wfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ def test_getfeature_post(self):
<ogc:BBOX>
<ogc:PropertyName>geometry</ogc:PropertyName>
<gml:Envelope xmlns:gml="http://www.opengis.net/gml">
<gml:lowerCorner>8 44</gml:lowerCorner>
<gml:upperCorner>9 45</gml:upperCorner>
<gml:lowerCorner>890555.92634619 5465442.18332275</gml:lowerCorner>
<gml:upperCorner>1001875.41713946 5621521.48619207</gml:upperCorner>
</gml:Envelope>
</ogc:BBOX>
</ogc:Filter>
Expand Down Expand Up @@ -268,6 +268,11 @@ def test_getFeatureBBOX(self):
self.wfs_request_compare("GetFeature", '1.1.0', "SRSNAME=EPSG:4326&TYPENAME=testlayer&RESULTTYPE=hits&BBOX=913144,5605992,913303,5606048,EPSG:3857", 'wfs_getFeature_1_1_0_epsgbbox_3_feature_3857')
self.wfs_request_compare("GetFeature", '1.1.0', "SRSNAME=EPSG:4326&TYPENAME=testlayer&RESULTTYPE=hits&BBOX=913206,5606024,913213,5606026,EPSG:3857", 'wfs_getFeature_1_1_0_epsgbbox_1_feature_3857')

self.wfs_request_compare("GetFeature", '1.0.0', "SRSNAME=EPSG:3857&TYPENAME=testlayer&RESULTTYPE=hits&BBOX=913144,5605992,913303,5606048,EPSG:3857", 'wfs_getFeature_1_0_0_epsgbbox_3_feature_3857')
self.wfs_request_compare("GetFeature", '1.0.0', "SRSNAME=EPSG:3857&TYPENAME=testlayer&RESULTTYPE=hits&BBOX=913206,5606024,913213,5606026,EPSG:3857", 'wfs_getFeature_1_0_0_epsgbbox_1_feature_3857')
self.wfs_request_compare("GetFeature", '1.1.0', "SRSNAME=EPSG:3857&TYPENAME=testlayer&RESULTTYPE=hits&BBOX=913144,5605992,913303,5606048,EPSG:3857", 'wfs_getFeature_1_1_0_epsgbbox_3_feature_3857')
self.wfs_request_compare("GetFeature", '1.1.0', "SRSNAME=EPSG:3857&TYPENAME=testlayer&RESULTTYPE=hits&BBOX=913206,5606024,913213,5606026,EPSG:3857", 'wfs_getFeature_1_1_0_epsgbbox_1_feature_3857')

def test_getFeatureFeatureId(self):
"""Test GetFeature with featureid"""
self.wfs_request_compare("GetFeature", '1.0.0', "SRSNAME=EPSG:4326&TYPENAME=testlayer&FEATUREID=testlayer.0", 'wfs_getFeature_1_0_0_featureid_0')
Expand Down

0 comments on commit 60dc78a

Please sign in to comment.