Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
WFS: take into account PROPERTYNAME with OGR output format (fixes #5573)
  • Loading branch information
rouault committed Mar 27, 2018
1 parent 5c151d6 commit 563b175
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 17 deletions.
36 changes: 19 additions & 17 deletions mapwfs.c
Expand Up @@ -3825,13 +3825,25 @@ int msWFSGetFeature(mapObj *map, wfsParamsObj *paramsObj, cgiRequestObj *req,
}
}

{
int i;
for(i=0;i<map->numlayers;i++)
{
layerObj* lp = GET_LAYER(map, i);
if( papszGMLGroups[i] )
msInsertHashTable(&(lp->metadata), "GML_GROUPS", papszGMLGroups[i]);
if( papszGMLIncludeItems[i] )
msInsertHashTable(&(lp->metadata), "GML_INCLUDE_ITEMS", papszGMLIncludeItems[i]);
if( papszGMLGeometries[i] )
msInsertHashTable(&(lp->metadata), "GML_GEOMETRIES", papszGMLGeometries[i]);
}
}

/* handle case of maxfeatures = 0 */
/*internally use a start index that start with 0 as the first index*/
if( psFormat == NULL ) {
if(maxfeatures != 0 && iResultTypeHits == 0)
{
layerObj* lp;
int i;
int bWFS2MultipleFeatureCollection = MS_FALSE;

/* Would make sense for WFS 1.1.0 too ! See #3576 */
Expand All @@ -3842,24 +3854,14 @@ int msWFSGetFeature(mapObj *map, wfsParamsObj *paramsObj, cgiRequestObj *req,
else if (useurn && strcasecmp(useurn, "false") == 0)
bUseURN = 0;

for(i=0;i<map->numlayers;i++)
{
lp = GET_LAYER(map, i);
if( papszGMLGroups[i] )
msInsertHashTable(&(lp->metadata), "GML_GROUPS", papszGMLGroups[i]);
if( papszGMLIncludeItems[i] )
msInsertHashTable(&(lp->metadata), "GML_INCLUDE_ITEMS", papszGMLIncludeItems[i]);
if( papszGMLGeometries[i] )
msInsertHashTable(&(lp->metadata), "GML_GEOMETRIES", papszGMLGeometries[i]);
}

/* For WFS 2.0, when we request several types, we must present each type */
/* in its own FeatureCollection (§ 11.3.3.5 ) */
if( nWFSVersion >= OWS_2_0_0 && iResultTypeHits != 1 )
{
int i;
int nLayersWithFeatures = 0;
for(i=0; i<map->numlayers; i++) {
lp = GET_LAYER(map, i);
layerObj* lp = GET_LAYER(map, i);
if(lp->resultcache && lp->resultcache->numresults > 0)
nLayersWithFeatures ++;
}
Expand All @@ -3878,7 +3880,7 @@ int msWFSGetFeature(mapObj *map, wfsParamsObj *paramsObj, cgiRequestObj *req,
/* Save the result cache that contains the features that we want to */
/* emit in the response */
for(i=0; i<map->numlayers; i++) {
lp = GET_LAYER(map, i);
layerObj* lp = GET_LAYER(map, i);
saveResultCache[i] = lp->resultcache;
if( lp->resultcache && lp->resultcache->numresults > 0) {
iLastNonEmptyLayer = i;
Expand All @@ -3888,7 +3890,7 @@ int msWFSGetFeature(mapObj *map, wfsParamsObj *paramsObj, cgiRequestObj *req,

/* Just dump one layer at a time */
for(i=0;i<map->numlayers;i++) {
lp = GET_LAYER(map, i);
layerObj* lp = GET_LAYER(map, i);
lp->resultcache = saveResultCache[i];
if( lp->resultcache && lp->resultcache->numresults > 0) {
msIO_fprintf(stdout, " <wfs:member>\n");
Expand All @@ -3913,7 +3915,7 @@ int msWFSGetFeature(mapObj *map, wfsParamsObj *paramsObj, cgiRequestObj *req,

/* Restore for later cleanup */
for(i=0; i<map->numlayers; i++) {
lp = GET_LAYER(map, i);
layerObj* lp = GET_LAYER(map, i);
lp->resultcache = saveResultCache[i];
}
msFree(saveResultCache);
Expand Down
40 changes: 40 additions & 0 deletions msautotest/wxs/expected/wfsogr_ogroutput_propertyname.txt
@@ -0,0 +1,40 @@
Content-Type: multipart/mixed; boundary=xxOGRBoundaryxx

--xxOGRBoundaryxx
Content-Disposition: attachment; filename=road.mid
Content-Type: application/binary
Content-Transfer-Encoding: binary

""

--xxOGRBoundaryxx
Content-Disposition: attachment; filename=road.mif
Content-Type: application/binary
Content-Transfer-Encoding: binary

Version 300
Charset "Neutral"
Delimiter ","
CoordSys Earth Projection 3, 74, "m", -95, 49, 49, 77, 0, 0
Columns 1
NAME_E Char(26)
Data

Pline 14
2577257 430271.1875
2577292 420127.65625
2577297.5 418604.78125
2577491.75 417462.90625
2578069 415941.46875
2578836.5 414230.25
2579413.25 412899.1875
2580247.5 412070.84375
2580693.5 411149.46875
2580978.5 408984.375
2580750.5 407559.96875
2580066.75 405736.6875
2579326 403970.4375
2578927.5 402717.03125
Pen (1,2,0)

--xxOGRBoundaryxx--
3 changes: 3 additions & 0 deletions msautotest/wxs/wfs_ogr.map
Expand Up @@ -63,6 +63,9 @@
#
# Exception when requesting layers with different SRS
# RUN_PARMS: wfsogr_exception_not_same_srs.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=multi,withnullvalues,popplace,road" > [RESULT]
#
# PropertyName and OGR output format (#5573)
# RUN_PARMS: wfsogr_ogroutput_propertyname.txt [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WFS&VERSION=1.1.0&REQUEST=GetFeature&TYPENAME=road&PROPERTYNAME=name_e&MAXFEATURES=1&OUTPUTFORMAT=multimidmif" > [RESULT]
#
# WMS 1.1 - GetFeatureInfo
#
Expand Down

0 comments on commit 563b175

Please sign in to comment.