[mapserver-commits] r12592 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Wed Sep 28 10:25:10 EDT 2011
Author: aboudreault
Date: 2011-09-28 07:25:10 -0700 (Wed, 28 Sep 2011)
New Revision: 12592
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapows.h
trunk/mapserver/mapwms.c
trunk/mapserver/mapwmslayer.c
Log:
Added GetLegendGraphic Cascading support
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2011-09-27 14:22:55 UTC (rev 12591)
+++ trunk/mapserver/HISTORY.TXT 2011-09-28 14:25:10 UTC (rev 12592)
@@ -14,6 +14,9 @@
Current Version (SVN trunk, 6.1-dev, future 6.2):
-------------------------------------------------
+
+- Added GetLegendGraphic Cascading support (#3923)
+
- Rewrite postgres TIME queries to take advantage of indexes (#3374)
- Unified OWS requests and applied to WCS (defaults to version 2.0 now) (#3925)
Modified: trunk/mapserver/mapows.h
===================================================================
--- trunk/mapserver/mapows.h 2011-09-27 14:22:55 UTC (rev 12591)
+++ trunk/mapserver/mapows.h 2011-09-28 14:25:10 UTC (rev 12592)
@@ -382,6 +382,10 @@
* mapwmslayer.c
*====================================================================*/
+#define WMS_GETMAP 1
+#define WMS_GETFEATUREINFO 2
+#define WMS_GETLEGENDGRAPHIC 3
+
int msInitWmsParamsObj(wmsParamsObj *wmsparams);
void msFreeWmsParamsObj(wmsParamsObj *wmsparams);
@@ -396,8 +400,8 @@
MS_DLL_EXPORT char *msWMSGetFeatureInfoURL(mapObj *map, layerObj *lp,
int nClickX, int nClickY, int nFeatureCount,
const char *pszInfoFormat);
-int msWMSLayerFeatureInfo(mapObj *map, int nOWSLayers, int nClickX, int nClickY,
- int nFeatureCount, const char *pszInfoFormat);
+int msWMSLayerExecuteRequest(mapObj *map, int nOWSLayers, int nClickX, int nClickY,
+ int nFeatureCount, const char *pszInfoFormat, int type);
/*====================================================================
* mapwfs.c
Modified: trunk/mapserver/mapwms.c
===================================================================
--- trunk/mapserver/mapwms.c 2011-09-27 14:22:55 UTC (rev 12591)
+++ trunk/mapserver/mapwms.c 2011-09-28 14:25:10 UTC (rev 12592)
@@ -3301,7 +3301,8 @@
/* It's a valid Cascading WMS GetFeatureInfo request */
if (wms_layer)
- return msWMSLayerFeatureInfo(map, numOWSLayers, point.x, point.y, feature_count, info_format);
+ return msWMSLayerExecuteRequest(map, numOWSLayers, point.x, point.y,
+ feature_count, info_format, WMS_GETFEATUREINFO);
if( use_bbox == MS_FALSE ) {
@@ -3675,8 +3676,8 @@
/*
** msWMSGetLegendGraphic()
*/
-int msWMSGetLegendGraphic(mapObj *map, int nVersion, char **names,
- char **values, int numentries, char *wms_exception_format, owsRequestObj *ows_request)
+int msWMSLegendGraphic(mapObj *map, int nVersion, char **names,
+ char **values, int numentries, char *wms_exception_format, owsRequestObj *ows_request)
{
char *pszLayer = NULL;
char *pszFormat = NULL;
@@ -3685,10 +3686,11 @@
int iLayerIndex = -1;
outputFormatObj *psFormat = NULL;
imageObj *img=NULL;
- int i = 0;
+ int j, i = 0;
int nWidth = -1, nHeight =-1;
char *pszStyle = NULL;
char *sld_version = NULL;
+ int wms_layer = MS_FALSE;
const char *sldenabled = NULL;
const char *format_list = NULL;
layerObj *lp;
@@ -3768,6 +3770,18 @@
nLayers++;
lp->status = MS_ON;
iLayerIndex = i;
+ if (GET_LAYER(map, i)->connectiontype == MS_WMS) {
+ /* we do not cascade a wms layer if it contains at least
+ * one class with the property name set */
+ wms_layer = MS_TRUE;
+ for (j=0; j<lp->numclasses; j++)
+ {
+ if (lp->class[j]->name != NULL && strlen(lp->class[j]->name)>0) {
+ wms_layer = MS_FALSE;
+ break;
+ }
+ }
+ }
}
else
lp->status = MS_OFF;
@@ -3814,7 +3828,12 @@
}
msApplyOutputFormat(&(map->outputformat), psFormat, MS_NOOVERRIDE,
MS_NOOVERRIDE, MS_NOOVERRIDE );
-
+
+ /* It's a valid Cascading WMS GetLegendGraphic request */
+ if (wms_layer)
+ return msWMSLayerExecuteRequest(map, 1, 0, 0,
+ 0, NULL, WMS_GETLEGENDGRAPHIC);
+
/*if STYLE is set, check if it is a valid style (valid = at least one
of the classes have a the group value equals to the style */
/*style is only validated when there is only one layer #3411*/
@@ -4279,7 +4298,7 @@
return msWMSException(map, nVersion, NULL, wms_exception_format);
if (strcasecmp(request, "GetLegendGraphic") == 0)
- return msWMSGetLegendGraphic(map, nVersion, req->ParamNames, req->ParamValues, req->NumParams,
+ return msWMSLegendGraphic(map, nVersion, req->ParamNames, req->ParamValues, req->NumParams,
wms_exception_format, ows_request);
if (strcasecmp(request, "GetStyles") == 0)
Modified: trunk/mapserver/mapwmslayer.c
===================================================================
--- trunk/mapserver/mapwmslayer.c 2011-09-27 14:22:55 UTC (rev 12591)
+++ trunk/mapserver/mapwmslayer.c 2011-09-28 14:25:10 UTC (rev 12592)
@@ -454,8 +454,6 @@
* Returns a reference to a newly allocated string that should be freed
* by the caller.
**********************************************************************/
-#define WMS_GETMAP 1
-#define WMS_GETFEATUREINFO 2
static int
msBuildWMSLayerURL(mapObj *map, layerObj *lp, int nRequestType,
@@ -466,11 +464,12 @@
{
#ifdef USE_WMS_LYR
char *pszEPSG = NULL;
- const char *pszVersion, *pszTmp, *pszRequestParam, *pszExceptionsParam, *pszQueryLayers=NULL;
+ const char *pszVersion, *pszTmp, *pszRequestParam, *pszExceptionsParam,
+ *pszLayer=NULL, *pszQueryLayers=NULL;
rectObj bbox;
int bbox_width = map->width, bbox_height = map->height;
int nVersion=OWS_VERSION_NOTSET;
-
+
if (lp->connectiontype != MS_WMS)
{
msSetError(MS_WMSCONNERR, "Call supported only for CONNECTIONTYPE WMS",
@@ -549,6 +548,22 @@
}
/* ------------------------------------------------------------------
+ * For GetLegendGraphic requests, make sure LAYER is included
+ * ------------------------------------------------------------------ */
+ if (nRequestType == WMS_GETLEGENDGRAPHIC &&
+ strstr(psWMSParams->onlineresource, "LAYER=") == NULL &&
+ strstr(psWMSParams->onlineresource, "layer=") == NULL &&
+ msLookupHashTable(psWMSParams->params, "LAYER") == NULL)
+ {
+ pszLayer = msOWSLookupMetadata(&(lp->metadata), "MO", "name");
+
+ if (pszLayer == NULL) {
+ msSetError(MS_WMSCONNERR, "wms_name not set or WMS Connection String must contain the LAYER parameter to support GetLegendGraphic requests (with name in uppercase).", "msBuildWMSLayerURL()");
+ return MS_FAILURE;
+ }
+ }
+
+/* ------------------------------------------------------------------
* Figure the SRS we'll use for the request.
* - Fetch the map SRS (if it's EPSG)
* - Check if map SRS is listed in layer wms_srs metadata
@@ -849,6 +864,28 @@
}
}
+ else if (nRequestType == WMS_GETLEGENDGRAPHIC)
+ {
+ pszRequestParam = "GetLegendGraphic";
+
+ pszExceptionsParam = msOWSLookupMetadata(&(lp->metadata),
+ "MO", "exceptions_format");
+ if (pszExceptionsParam == NULL)
+ {
+ if (nVersion >= OWS_1_1_0)
+ pszExceptionsParam = "application/vnd.ogc.se_inimage";
+ else
+ pszExceptionsParam = "INIMAGE";
+ }
+
+ if (pszLayer) { /* not set in CONNECTION string */
+ msSetWMSParamString(psWMSParams, "LAYER", pszLayer, MS_FALSE);
+ }
+
+ msSetWMSParamString(psWMSParams, "REQUEST", pszRequestParam, MS_FALSE);
+ msSetWMSParamString(psWMSParams, "SRS", pszEPSG, MS_FALSE);
+
+ }
else /* if (nRequestType == WMS_GETMAP) */
{
char szBuf[100] = "";
@@ -927,7 +964,6 @@
return pszURL;
}
-
/**********************************************************************
* msPrepareWMSLayerRequest()
*
@@ -986,7 +1022,18 @@
msFreeWmsParamsObj(&sThisWMSParams);
return MS_FAILURE;
}
+ else if (nRequestType == WMS_GETLEGENDGRAPHIC &&
+ msBuildWMSLayerURL(map, lp, WMS_GETLEGENDGRAPHIC,
+ 0, 0, 0, NULL,
+ NULL, NULL, NULL,
+ &sThisWMSParams) != MS_SUCCESS )
+ {
+ /* an error was already reported. */
+ msFreeWmsParamsObj(&sThisWMSParams);
+ return MS_FAILURE;
+ }
+
/* ------------------------------------------------------------------
* Check if the request is empty, perhaps due to reprojection problems
* or wms_extents restrictions.
@@ -1336,6 +1383,7 @@
* ------------------------------------------------------------------ */
pasReqInfo[(*numRequests)].nLayerId = nLayerId;
pasReqInfo[(*numRequests)].pszGetUrl = pszURL;
+
pszURL = NULL;
pasReqInfo[(*numRequests)].pszHTTPCookieData = pszHTTPCookieData;
pszHTTPCookieData = NULL;
@@ -1365,7 +1413,7 @@
(*numRequests)++;
}
-
+
/* ------------------------------------------------------------------
* Replace contents of psLastWMSParams with sThisWMSParams
* unless bForceSeparateRequest is set in which case we make it empty
@@ -1642,8 +1690,8 @@
}
-int msWMSLayerFeatureInfo(mapObj *map, int nOWSLayers, int nClickX, int nClickY,
- int nFeatureCount, const char *pszInfoFormat)
+int msWMSLayerExecuteRequest(mapObj *map, int nOWSLayers, int nClickX, int nClickY,
+ int nFeatureCount, const char *pszInfoFormat, int type)
{
#ifdef USE_WMS_LYR
@@ -1662,7 +1710,9 @@
{
if (GET_LAYER(map,map->layerorder[i])->status == MS_ON)
{
- if (msPrepareWMSLayerRequest(map->layerorder[i], map, GET_LAYER(map,map->layerorder[i]), WMS_GETFEATUREINFO,
+ if (type == WMS_GETFEATUREINFO &&
+ msPrepareWMSLayerRequest(map->layerorder[i], map, GET_LAYER(map,map->layerorder[i]),
+ WMS_GETFEATUREINFO,
MS_WMS, &sLastWMSParams,
nClickX, nClickY, nFeatureCount, pszInfoFormat,
pasReqInfo, &numReq) == MS_FAILURE)
@@ -1671,6 +1721,16 @@
msFree(pasReqInfo);
return MS_FAILURE;
}
+ else if (msPrepareWMSLayerRequest(map->layerorder[i], map, GET_LAYER(map,map->layerorder[i]),
+ WMS_GETLEGENDGRAPHIC,
+ MS_WMS, &sLastWMSParams,
+ 0, 0, 0, NULL,
+ pasReqInfo, &numReq) == MS_FAILURE)
+ {
+ msFreeWmsParamsObj(&sLastWMSParams);
+ msFree(pasReqInfo);
+ return MS_FAILURE;
+ }
}
}
@@ -1719,7 +1779,7 @@
else
{
msSetError(MS_IOERR, "'%s'.",
- "msWMSLayerFeatureInfo()", pasReqInfo[0].pszOutputFile);
+ "msWMSLayerExecuteRequest()", pasReqInfo[0].pszOutputFile);
return MS_FAILURE;
}
}
@@ -1740,7 +1800,7 @@
* WMS CONNECTION Support not included...
* ------------------------------------------------------------------ */
msSetError(MS_WMSCONNERR, "WMS CLIENT CONNECTION support is not available.",
- "msWMSLayerFeatureInfo()");
+ "msWMSLayerExecuteRequest()");
return(MS_FAILURE);
#endif /* USE_WMS_LYR */
More information about the mapserver-commits
mailing list