Opened 19 years ago

Closed 19 years ago

#1118 closed defect (fixed)

WMS layers with connectiontype MS_WMS are overridden to MS_RASTER

Reported by: hobu Owned by: warmerdam
Priority: high Milestone:
Component: WMS Server Version: 4.5
Severity: normal Keywords:
Cc: bartvde@…

Description

line 169 of maplayer.c sets the connectiontype to MS_RASTER if the layer's type
is  set to MS_LAYER_RASTER.  This causes a problem for WMS layers that have
their connectiontype set to MS_WMS already.

  if(layer->type == MS_LAYER_RASTER )
    layer->connectiontype = MS_RASTER;

I provoked this by trying to change the projection of a mapObj in mapscript from
Albers to UTM zone 15 *after* the mapObj had been opened in mapscript.  

My WMS layer is defined as such:
LAYER
   NAME ortho
   METADATA
     "wms_title" "USGS Digital Ortho-Quadrangles"
     "wms_srs"   "EPSG:4326" 
     "wms_connectiontimeout" "45"
   END
   STATUS ON
   TYPE RASTER
   CONNECTIONTYPE WMS
   CONNECTION
"http://terraservice.net/ogcmap.ashx?VERSION=1.1.1&SERVICE=wms&LAYERS=DOQ&FORMAT=jpeg&styles="
   PROJECTION
     "init=epsg:4326" 
   END
END

In mapscript, I query for the object I want, calculate a UTM zone for it and set
the wms_srs and projection objects of this layer to EPSG:26915 and
init=epsg:26915, repectively.  At first, I didn't attempt to monkey with the
mapObj's projection.  Later, I tried to also change the projection of the mapObj
and provoked the error.  My mapObj was initialized with this PROJECTION block:
  PROJECTION
   "proj=aea"
   "ellps=GRS80"
   "datum=NAD83"
   "lat_1=29.5"
   "lat_2=45.5"
   "lat_0=23.0"
   "lon_0=-96"
   "x_0=0"
   "y_0=0"
  END

and I *also* set it with mapscript to be "init=epsg:26915", which then provokes
the "Attempt to open a RASTER layer, but this is only supported after a raster
query." error.  This is because the WMS layer's layerinfo is NULL (a WMS layer
does not have a layerinfo).

Change History (4)

comment:1 by fwarmerdam, 19 years ago

Status: newassigned

comment:2 by hobu, 19 years ago

ok. What's going on is it's trying to read the extent of the layer in
msOWSGetLayerExtent, which is provoking it to open the layer. If an extent is
defined for the layer via wms_extent, then it skips this step and doesn't try to
open the layer

I'm seeing an effect, now that I get this to reproject, where one of my layers
is swallowed up and not drawn. If I make a copy of it and give it a different
name, the copy draws ok. If I do not do the reprojection, it draws fine. 

comment:3 by bartvde@…, 19 years ago

Cc: bartvde@… added

comment:4 by fwarmerdam, 19 years ago

Resolution: fixed
Status: assignedclosed
It turns out that shp2img on pretty much any map with a WMS layer does
produce this error, it is just supressed.  MapScript is sensitive to "set 
errors" and reports it to the user where shp2img does not.  Breaking in
msSetError() in shp2img is helpful. 

MAP
  NAME "Testing"
  EXTENT -0.5 50.977222 0.5 51.977222
  IMAGETYPE PNG
  IMAGECOLOR 255 255 255
  STATUS ON
  SIZE 200 200
  FONTSET "fonts.txt"
  SYMBOLSET "symbols.txt"

  WEB
    IMAGEPATH "/tmp"
  END

  LAYER
    NAME "WMS_RASTER"
    TYPE RASTER
    PROJECTION
      "init=epsg:4326"
    END
    #EXTENT -0.5 50.977222 0.5 51.977222
    CONNECTIONTYPE WMS
    CONNECTION "http://wms.jpl.nasa.gov/wms.cgi?"
    METADATA
      wms_srs "EPSG:4326"
      wms_server_version "1.1.1"
      wms_name "global_mosaic"
      wms_style "visual"
      wms_format "image/jpeg"
    END
    STATUS DEFAULT
  END

END


My "fix" is to avoid calling msLayerGetExtent() for layers of type
MS_LAYER_RASTER.  For a regular raster layer, or a WMS layer, the
whole layer API does not provide a constructive access to layer extents. 
I am a bit concerned that this will prevent use of raster tile indexes
to get extents even though that might be a very effective way of collecting
the extent.  But for now I'm going to disregard that possibility. 

BTW, the getextents is being called from msGDALGetGeoTransform() which
tries msOWSGetLayerExtent() as a way of checking for metadata extents if
nothing else is available.   

I will apply the following change in 4.5 and 4.4.x. 

  else if( lp->type != MS_LAYER_RASTER )
  {
      return msLayerGetExtent(lp, ext);
  }
Note: See TracTickets for help on using tickets.