MapServer / MapServer-import

3 stars 2 forks source link

msDrawShape(): General error message. Unknown layer type #1842

Open tbonfort opened 12 years ago

tbonfort commented 12 years ago

Reporter: Henrik.Stutz@fimr.fi Date: 2006/07/25 - 08:00

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>
tbonfort commented 12 years ago

Author: fwarmerdam Date: 2006/08/16 - 21:57

I'll try and address this for 4.10. 
tbonfort commented 12 years ago

Author: warmerdam Date: 2007/09/05 - 22:11 Well, perhaps I'll try and reproduce this for 5.0.1.

tbonfort commented 12 years ago

Author: warmerdam Date: 2007/12/01 - 04:50 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.

tbonfort commented 12 years ago

Author: warmerdam Date: 2007/12/01 - 05:09 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 (6895f9d5054d79888c6599e9c8ed9c7e5aaa7564 (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.

tbonfort commented 12 years ago

Author: warmerdam Date: 2008/01/04 - 17:38 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.

tbonfort commented 12 years ago

Author: warmerdam Date: 2008/01/23 - 05:21 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.

tbonfort commented 12 years ago

Author: tomkralidis Date: 2008/02/09 - 03:32 Replying to [comment:6 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.

tbonfort commented 12 years ago

Author: warmerdam Date: 2009/10/24 - 02:38 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
tbonfort commented 12 years ago

Author: dmorissette Date: 2009/11/25 - 04:42 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?

tbonfort commented 12 years ago

Author: tomkralidis Date: 2009/11/25 - 19:58 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.

tbonfort commented 12 years ago

Author: warmerdam Date: 2010/03/29 - 16:15 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.

tbonfort commented 12 years ago

Author: warmerdam Date: 2010/03/29 - 16:16 I should note the change is 89ff7736e38f3a4cb734f96216b4e49c4de6e206 (r10026) in trunk only.