Opened 18 years ago

Closed 14 years ago

Last modified 14 years ago

#1842 closed defect (fixed)

msDrawShape(): General error message. Unknown layer type

Reported by: Henrik.Stutz@… Owned by: warmerdam
Priority: normal Milestone: 6.0 release
Component: GDAL Support Version: 4.8
Severity: normal Keywords: raster query
Cc: sdlime, dmorissette, tomkralidis

Description (last modified by warmerdam)

Hi Frank,

I'm trying to set up raster querying on Mapserver 4.8.3. When
"mode=query" is enabled the following error occurs: "msDrawShape():
General error message. Unknown layer type". 

Does anyone has an idea how to solve this problem?

Cheers and thanks,
Henrik

http://localhost/cgi-bin/mapserv_483?map=%2Fvar%2Fwww%2Fhtml%2Fperl_test
%2FBalticBoundary.map&map_web_imagepath=%2Fvar%2Fwww%2Fhtml%2Ftmp%
2F&map_web_imageurl=%2Ftmp%2F&savequery=true&imgext=245990.225000
+6427447.275000+4190855.225000
+10372312.275000&layer=chlaYYMMDDsat&program=%2Fcgi-bin%
2Fmapserv_483&img.x=168&img.y=124&zoomsize=3&mode=query
                                              ^   ^
                                              |   |   
----------------mapfile----------
NAME Boundary
STATUS ON

SIZE 600 600
WEB
 IMAGEPATH "/var/www/html/perl_test/tmp/"
 IMAGEURL "/tmp/"
 TEMPLATE "template.html"

END
QUERYMAP
STATUS ON
STYLE SELECTED
END

LAYER
  NAME baltic_mask
  TYPE RASTER
  STATUS DEFAULT
  DATA /opt/MODIS/GIS/2006g6/BalticMerc07/PERMANENT/cellhd/baltic_mask
  TOLERANCE 3
  TOLERANCEUNITS PIXELS
  CLASS
    NAME "Baltic_mask"
    TEMPLATE quadtemplate.html
     OUTLINECOLOR 255 0 0
  END
END

LAYER
  NAME chlaYYMMDDsat
  TYPE RASTER
  STATUS OFF
  TRANSPARENCY 50
  DATA /opt/MODIS/GIS/2006g6/BalticMerc/T/cellhd/chlasat
  TOLERANCE 3
  TOLERANCEUNITS PIXELS
  CLASS
    NAME "Chlorophyll-a"
        OUTLINECOLOR 255 0 0
    TEMPLATE quadtemplate.html
  END
END

-------template.html-----------

<html>
  <head>
    <title>MapServer </title>
  </head>

   <form method=GET action=[program]><input type="hidden" name="map"
value="[map]">
      <input type="hidden" name="map_web_imagepath"
value="[map_web_imagepath]">
      <input type="hidden" name="map_web_imageurl"
value="[map_web_imageurl]">
      <input type="hidden" name="savequery" value="true">
      <input type="hidden" name="imgxy" value="299.5 299.5">
      <input type="hidden" name="imgext" value="[mapext]">
      <input type="hidden" name="layer" value="chlaYYMMDDsat" >

      <input type="hidden" name="program" value="[program]">

   
.
.
.
   Select quad<input type="radio" name="mode" value="query"><br>
   <!-- The map -->
   <input type="image" name="img" src="[img]" border="0" >

.
.
.

 </form>

  </body>
</html>

------quadtemplate.html----------------------------
<html>
  <head>
    <title>MapServer Test</title>
  </head>

  <body bgcolor="#ffffff">
    <br>
    <font size=+2 face=arial,helvetica>You selected the
<b>[TILE_NAME]</b> Quadrangle</font>
    <p>

    <img src="[img]">
<tr>
  <td>[lrn]</td>
  <td>[PIN]</td>
</tr>

    <p>
    <a href="javascript:history.back()">return to map...</a>

  </body>
</html>

Attachments (1)

bug1842.zip (2.1 KB ) - added by warmerdam 16 years ago.
zip of map/data/template and script needed to reproduce the problem.

Download all attachments as: .zip

Change History (13)

comment:1 by fwarmerdam, 18 years ago

Milestone: 4.10 release
Status: newassigned
I'll try and address this for 4.10. 

comment:2 by warmerdam, 17 years ago

Description: modified (diff)
Milestone: 5.0 release5.0.1 release

Well, perhaps I'll try and reproduce this for 5.0.1.

comment:3 by warmerdam, 16 years ago

Keywords: raster query added
Priority: highnormal
Severity: blockernormal

With some work I managed to reproduce the error using the materials in bug1842.zip (attached). The error gives this traceback:

#0  msSetError (code=12, message_fmt=0x547043 "Unknown layer type.", 
    routine=0x546fa9 "msDrawShape()") at maperror.c:319
#1  0x0000000000468815 in msDrawShape (map=0x67fe40, layer=0x687230, 
    shape=0x7fffffc8b120, image=0x723780, style=-1) at mapdraw.c:1644
#2  0x00000000004655ec in msDrawQueryLayer (map=0x67fe40, layer=0x687230, 
    image=0x723780) at mapdraw.c:1067
#3  0x00000000004633d7 in msDrawMap (map=0x67fe40, querymap=1)
    at mapdraw.c:431
#4  0x000000000041866f in msReturnTemplateQuery (msObj=0x67f1d0, 
    pszMimeType=0x682860 "text/html", papszBuffer=0x0) at maptemplate.c:200
#5  0x000000000041633d in main (argc=2, argv=0x7fffffc8bd88) at mapserv.c:1585
(gdb) 

Basically, query that result in generating a map are not supported for queries against a raster layer since there is no apparent information on how to draw raster query results. This is a known limitation though I hadn't quite connected the pieces to understand how we get to this point.

by warmerdam, 16 years ago

Attachment: bug1842.zip added

zip of map/data/template and script needed to reproduce the problem.

comment:4 by warmerdam, 16 years ago

Cc: sdlime dmorissette added

I have bolded the portion in the Raster Data Access document discussing that raster layers are not supported for drawing query maps. I have also made a change in trunk (r7132) in msDrawQueryLayer() to report the error more clearly as:

msDrawQueryLayer(): Query error. Unable to draw raster layers (such as chlaYYMMDDsat) as part of a query result.

I haven't migrated this change into 5.0 branch as I'd appreciate some review by folks familiar with this part of the code first.

comment:5 by warmerdam, 16 years ago

Milestone: 5.0.1 release5.2 release
Resolution: fixed
Status: assignedclosed

I'm not that comfortable with this fix going into 5.0.x without more vetting, so I'm going to retarget it to 5.2 and close it. The fix only improves error reporting anyways, it doesn't make something work that wasn't working.

comment:6 by warmerdam, 16 years ago

Resolution: fixed
Status: closedreopened

I have discovered this error is interfering with the operation of WMS GetFeatureInfo as tested in msautotest/wxs/tomk_workshop.map - this request:

# Generate WMS GetFeatureInfo HTML format on raster data
# RUN_PARMS: wms_get_feature_info_raster.html [MAPSERV] QUERY_STRING="map=[MAPFILE]&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=text/html&x=141&y=91&radius=10" > [RESULT]
#

I'm not exactly clear why this GetFeatureInfo results in a map being drawn. It does not appear it gets used for anything after dumping it in the tmp directory.

in reply to:  6 comment:7 by tomkralidis, 16 years ago

Replying to warmerdam:

I have discovered this error is interfering with the operation of WMS GetFeatureInfo as tested in msautotest/wxs/tomk_workshop.map - this request:

# Generate WMS GetFeatureInfo HTML format on raster data
# RUN_PARMS: wms_get_feature_info_raster.html [MAPSERV] QUERY_STRING="map=[MAPFILE]&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=text/html&x=141&y=91&radius=10" > [RESULT]
#

I'm not exactly clear why this GetFeatureInfo results in a map being drawn. It does not appear it gets used for anything after dumping it in the tmp directory.

The reason a map is being drawm is because given INFO_FORMAT=text/html, output is based on the templates (HEADER/TEMPLATE/FOOTER). In these particular templates, an image is called via HTML img tag.

comment:8 by warmerdam, 14 years ago

Ok, I'm now starting to regret just producing an error for drawing raster query maps. I have an alternate approach that instead treats the raster layer as a point layer and allows control to proceed through the query map drawing without apparent problems (though it isn't clear if the results are particularly useful). Should we consider this approach instead? I kind of hate to flip like this as such a late date.

Index: mapdraw.c
===================================================================
--- mapdraw.c   (revision 9505)
+++ mapdraw.c   (working copy)
@@ -1121,11 +1121,6 @@
 
   if(!msLayerIsVisible(map, layer)) return(MS_SUCCESS); /* not an error, just nothing to do */
 
-  if( layer->type == MS_LAYER_RASTER ) {
-    msSetError( MS_QUERYERR, "Unable to draw raster layers (such as %s) as part of a query result.", "msDrawQueryLayer()", layer->name );
-    return MS_FAILURE;
-  }
-
   /* set annotation status */
   annotate = msEvalContext(map, layer, layer->labelrequires);
   if(map->scaledenom > 0) {
@@ -1828,6 +1823,7 @@
     }
     break;  /* end MS_LAYER_ANNOTATION */
 
+  case MS_LAYER_RASTER:
   case MS_LAYER_POINT:
 
 #ifdef USE_PROJ

comment:9 by dmorissette, 14 years ago

Cc: tomkralidis added
Milestone: 5.6 release6.0 release

Let's do this in 6.0. If we can confirm that the change is safe we can always consider backporting to 5.6.x if necessary.

Tom, can you please test Frank's patch and confirm it solves your issue?

comment:10 by tomkralidis, 14 years ago

After testing, this looks like it fixes the issue (testing msautotest/wxs/tomk_workshop.map). There are some small HTML formatting issues, but the main issue is gone. I will update the msautotest/expected result once the code is committed.

comment:11 by warmerdam, 14 years ago

Resolution: fixed
Status: reopenedclosed

I have incorporated the suggested patch and confirmed that the getfeatureinfo test in msautotest now does something useful though there are some differences in the results from the expected.

comment:12 by warmerdam, 14 years ago

I should note the change is r10026 in trunk only.

Note: See TracTickets for help on using tickets.