[Mapserver-users] WMS Problems...

Frank Warmerdam warmerdam at pobox.com
Wed Mar 3 10:06:28 PST 2004


Steve Lime wrote:
> Note that the MapServer version is 4.1 (a week or two old) and not 4.0.
> 
> Anyway, I've created 2 stripped down versions of the mapfile. One with
> output formats:
> 
>  OUTPUTFORMAT
>     NAME geotiff_24bit
>     MIMETYPE "image/tiff"
>     DRIVER "GDAL/GTiff"
>     IMAGEMODE RGB
>   END
> 
>   OUTPUTFORMAT
>     NAME geotiff_8bit
>     MIMETYPE "image/tiff"
>     DRIVER "GDAL/GTiff"
>     IMAGEMODE PC256
>   END
> 
> and one without. Here are the links to the capabilties (switch to your
> favorite version):
> 
> http://maps.dnr.state.mn.us/cgi-bin/mapserv40?map=/usr/local/www/docs/deli/mapserver/wms_test_outputformat.map&version=1.0.0&request=GetCapabilities
> 
> http://maps.dnr.state.mn.us/cgi-bin/mapserv40?map=/usr/local/www/docs/deli/mapserver/wms_test_no_outputformat.map&version=1.0.0&request=GetCapabilities
> 
> With WMS 1.0.0 tiff never shows up as an output format. With WMS 1.1.x
> tiff is always always there.

Steve,

OK, looking in the code I see the following logic. Basically, because the
WMS 1.0.0 format names are ideosyncratic I guess someone (perhaps me?) made
the decision to just hardcode and support a few formats.   While for later
versions of the protocol the formats are actually determined from the
declared (internally or via .map file) OUTPUTFORMATs.

   if (strcasecmp(wmtver, "1.0.7") <= 0)
   {
     // WMS 1.0.0 to 1.0.7 - We don't try to use outputformats list here for now
     msWMSPrintRequestCap(wmtver, "Map", script_url_encoded, ""
#ifdef USE_GD_GIF
                       "<GIF />"
#endif
#ifdef USE_GD_PNG
                       "<PNG />"
#endif
#ifdef USE_GD_JPEG
                       "<JPEG />"
#endif
#ifdef USE_GD_WBMP
                       "<WBMP />"
#endif
                       , NULL);
     msWMSPrintRequestCap(wmtver, "Capabilities", script_url_encoded, "<WMS_XML />", NULL);
     msWMSPrintRequestCap(wmtver, "FeatureInfo", script_url_encoded, "<MIME /><GML.1 />", NULL);
   }
   else
   {
     char *mime_list[20];
     // WMS 1.0.8, 1.1.0 and later
     // Note changes to the request names, their ordering, and to the formats

     msWMSPrintRequestCap(wmtver, "GetCapabilities", script_url_encoded,
                     "application/vnd.ogc.wms_xml",
                     NULL);

     msGetOutputFormatMimeList(map,mime_list,sizeof(mime_list)/sizeof(char*));
     msWMSPrintRequestCap(wmtver, "GetMap", script_url_encoded,
                     mime_list[0], mime_list[1], mime_list[2], mime_list[3],
                     mime_list[4], mime_list[5], mime_list[6], mime_list[7],
                     mime_list[8], mime_list[9], mime_list[10], mime_list[11],
                     mime_list[12], mime_list[13], mime_list[14], mime_list[15],
                     mime_list[16], mime_list[17], mime_list[18], mime_list[19],
                     NULL );

     pszMimeType = msLookupHashTable(map->web.metadata, "WMS_FEATURE_INFO_MIME_TYPE");
     if (pszMimeType && strcasecmp(pszMimeType, "NONE") == 0)
        msWMSPrintRequestCap(wmtver, "GetFeatureInfo", script_url_encoded,
                        "text/plain",
                        "application/vnd.ogc.gml",
                        NULL);
     else
     if (pszMimeType)
        msWMSPrintRequestCap(wmtver, "GetFeatureInfo", script_url_encoded,
                        "text/plain",
                        pszMimeType,
                        "application/vnd.ogc.gml",
                        NULL);
     else
        msWMSPrintRequestCap(wmtver, "GetFeatureInfo", script_url_encoded,
                        "text/plain",
                        "text/html",
                        "application/vnd.ogc.gml",
                        NULL);


   }

There are a couple of issues here.

One is, should we fix 1.0.0 WMS support to emit entries for all
declared formats?  Perhaps using the name of the outputformat
converted to upper case?  This would give us the "well known" names
for the default GIF, PNG and JPEG formats and would allow arbitrary
other formats to be listed.

The other issue is that there is currently no way to prevent the various
internally declared formats from appearing.  Basically, all the standard
formats (if built in) will appear regardless of what output formats are
declared in the map file.  The predefined ones are listed here (from
mapoutput.c):


/************************************************************************/
/*                    msApplyDefaultOutputFormats()                     */
/************************************************************************/

void msApplyDefaultOutputFormats( mapObj *map )

{
     char *saved_imagetype;

     if( map->imagetype == NULL )
         saved_imagetype = NULL;
     else
         saved_imagetype = strdup(map->imagetype);

     if( msSelectOutputFormat( map, "gif" ) == NULL )
         msCreateDefaultOutputFormat( map, "GD/GIF" );

     if( msSelectOutputFormat( map, "png" ) == NULL )
         msCreateDefaultOutputFormat( map, "GD/PNG" );

     if( msSelectOutputFormat( map, "png24" ) == NULL )
         msCreateDefaultOutputFormat( map, "GD/PNG24" );

     if( msSelectOutputFormat( map, "jpeg" ) == NULL )
         msCreateDefaultOutputFormat( map, "GD/JPEG" );

     if( msSelectOutputFormat( map, "wbmp" ) == NULL )
         msCreateDefaultOutputFormat( map, "GD/WBMP" );

     if( msSelectOutputFormat( map, "swf" ) == NULL )
         msCreateDefaultOutputFormat( map, "swf" );

     if( msSelectOutputFormat( map, "imagemap" ) == NULL )
         msCreateDefaultOutputFormat( map, "imagemap" );

     if( msSelectOutputFormat( map, "pdf" ) == NULL )
         msCreateDefaultOutputFormat( map, "pdf" );

     if( msSelectOutputFormat( map, "GTiff" ) == NULL )
         msCreateDefaultOutputFormat( map, "GDAL/GTiff" );

     if( map->imagetype != NULL )
         free( map->imagetype );
     map->imagetype = saved_imagetype;
}

These built-ins can be overridden with a new definition by using
the same name in an outputformat declaration in the .map file,
but they can't be deleted (if you only wanted GeoTIFF support
for instance).  This was something that flipflopped a bit during
development.  Originally, I had the logic that declaring any output
formats in the .map file would stop the pre-defined ones from being
declared at all.  However, later that was changed around to
"postdefine" any builtin output formats not declared (under the same
name) by the user in an outputformat block.

If you are concerned about the WMS 1.0.0 formats list being hardcoded,
then file a bug and assign it to me.  I will fix this up.

If you see a need for being able to avoid pre-defined formats from
showing up in the list in the capabilities then file another bug
about this, but I think we should talk a bit about how to accomplish
it without too much disruption.

By the way, I assume that we will need a somewhat similar ability to
return formats in the WCS capabilities.  Presumably some of the same
issues exist with the exception of the whole versioning problem.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the MapServer-users mailing list