Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#3168 closed defect (fixed)

raster queries: WMS GetFeatureInfo with FEATURE_COUNT not respected

Reported by: bartvde Owned by: warmerdam
Priority: normal Milestone: 5.6 release
Component: WMS Server Version: svn-trunk (development)
Severity: normal Keywords:
Cc: aboudreault, assefa

Description

Attachments (1)

ticket3168.patch (2.0 KB ) - added by bartvde 15 years ago.
patch to fix this issue

Download all attachments as: .zip

Change History (14)

by bartvde, 15 years ago

Attachment: ticket3168.patch added

patch to fix this issue

comment:1 by bartvde, 15 years ago

Patch contains 3 files, but Trac preview only shows 2 of them (not my change to mapquery.c)

comment:2 by dmorissette, 15 years ago

Milestone: 5.6 release
Owner: changed from mapserverbugs to dmorissette
Status: newassigned

I'm having a hard time reproducing. Can you please tell me how you setup your layer to return raster results in GML format?

comment:3 by dmorissette, 15 years ago

Cc: assefa added

comment:4 by tomkralidis, 15 years ago

I can reproduce this error. To reproduce

$ cd msautotest/wxs
$ ../../mapserver/mapserv QUERY_STRING="map=tomk_workshop.map&version=1.1.1&service=WMS&request=GetFeatureInfo&srs=EPSG:4326&bbox=-180,-90,180,90&format=image/png&layers=land_shallow_topo_2048,rivers&styles=,&transparent=true&width=500&height=300&query_layers=land_shallow_topo_2048&info_format=application/vnd.ogc.gml&x=141&y=91&radius=10&feature_count=1"

The above is a variation on the wms_get_feature_info_raster.gml test in tomk_workshop.map. The above will return 1 record.

Running:

$ ../../mapserver/mapserv QUERY_STRING="map=tomk_workshop.map&version=1.1.1&service=WMS&request=GetFeatureInfo&srs=EPSG:4326&bbox=-180,-90,180,90&format=image/png&layers=land_shallow_topo_2048,rivers&styles=,&transparent=true&width=500&height=300&query_layers=land_shallow_topo_2048&info_format=application/vnd.ogc.gml&x=141&y=91&radius=10&feature_count=2"

and you'll see that > 2 records are returned.

comment:5 by dmorissette, 15 years ago

Owner: changed from dmorissette to aboudreault
Status: assignednew

Assigning to Alan, unless someone else wants to grab it.

comment:6 by tomkralidis, 15 years ago

Hi: here's a patch based on r9462:

Index: maprasterquery.c
===================================================================
--- maprasterquery.c    (revision 9462)
+++ maprasterquery.c    (working copy)
@@ -909,7 +909,7 @@
 /************************************************************************/
 
 int msRasterQueryByPoint(mapObj *map, layerObj *layer, int mode, pointObj p, 
-                         double buffer)
+                         double buffer, int maxresults)
 {
 #ifndef USE_GDAL
     msSetError( MS_IMGERR, 
@@ -918,6 +918,7 @@
     return MS_FAILURE;
 #else
     int result;
+    int previous_maxresults;
     double layer_tolerance;
     rectObj bufferRect;
     rasterLayerInfo *rlinfo = NULL;
@@ -980,8 +981,11 @@
         pointRect.maxy = p.y;
 
         rlinfo->range_mode = MS_SINGLE;
+        previous_maxresults = rlinfo->query_result_hard_max;
+        rlinfo->query_result_hard_max = maxresults;
         result = msRasterQueryByRect( map, layer, pointRect );
 
+        rlinfo->query_result_hard_max = previous_maxresults;
         if( rlinfo->query_results > 0 )
             return result;
     }
Index: mapquery.c
===================================================================
--- mapquery.c  (revision 9462)
+++ mapquery.c  (working copy)
@@ -1113,7 +1113,7 @@
 
     /* Raster layers are handled specially.  */
     if( lp->type == MS_LAYER_RASTER ) {
-      if( msRasterQueryByPoint( map, lp, map->query.mode, map->query.point, map->query.buffer ) == MS_FAILURE )
+      if( msRasterQueryByPoint( map, lp, map->query.mode, map->query.point, map->query.buffer, map->query.maxresults ) == MS_FAILURE )
         return MS_FAILURE;
       continue;
     }
Index: mapserver.h
===================================================================
--- mapserver.h (revision 9462)
+++ mapserver.h (working copy)
@@ -1742,7 +1742,7 @@
 MS_DLL_EXPORT void msQueryFree(mapObj *map, int qlayer); /* todo: rename */
 MS_DLL_EXPORT int msRasterQueryByShape(mapObj *map, layerObj *layer, shapeObj *selectshape);
 MS_DLL_EXPORT int msRasterQueryByRect(mapObj *map, layerObj *layer, rectObj queryRect);
-MS_DLL_EXPORT int msRasterQueryByPoint(mapObj *map, layerObj *layer, int mode, pointObj p, double buffer );
+MS_DLL_EXPORT int msRasterQueryByPoint(mapObj *map, layerObj *layer, int mode, pointObj p, double buffer, int maxresults );
 
 /* in mapstring.c */
 MS_DLL_EXPORT void msStringTrim(char *str); 


Running the resulting patch aganist the tests per comment:4, yields the same result.

comment:7 by warmerdam, 15 years ago

This approach looks ok to me.

in reply to:  7 comment:8 by tomkralidis, 15 years ago

Replying to warmerdam:

This approach looks ok to me.

To clarify, I'm still getting erroneous results, even with this patch:

  • feature_count=0: 380 features
  • feature_count=1: 1 feature
  • feature_count=2: 380 features

Anything higher than feature_count=1 returns 380 records.

I wonder whether the issue is in maprasterquery.c/msRasterQueryByPoint logic.

comment:9 by warmerdam, 15 years ago

Cc: aboudreault added; warmerdam removed
Owner: changed from aboudreault to warmerdam

Seizing this ticket. I'll see if I can figure out the behavior Tom is seeing.

comment:10 by warmerdam, 15 years ago

Resolution: fixed
Status: newclosed

Corrected in trunk (r9464), I think in time for beta4.

in reply to:  10 comment:11 by tomkralidis, 15 years ago

Replying to warmerdam:

Corrected in trunk (r9464), I think in time for beta4.

Thanks Frank. Added msautotest in r9465.

comment:12 by bartvde, 15 years ago

Great work guys, thanks!

comment:13 by warmerdam, 15 years ago

In r9502 a few fixes to the maxresults handling were incorporated for the default case where maxresults is zero which should mean unlimited.

Note: See TracTickets for help on using tickets.