Skip to content

Commit 8063aae

Browse files
for essential WMS layers set EXCEPTIONS to XML by default
1 parent f9797d0 commit 8063aae

File tree

1 file changed

+38
-10
lines changed

1 file changed

+38
-10
lines changed

mapwmslayer.c

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,9 @@ msBuildWMSLayerURL(mapObj *map, layerObj *lp, int nRequestType,
428428
int nVersion=OWS_VERSION_NOTSET;
429429
int bUseStrictAxisOrder = MS_FALSE; /* this is the assumption up to 1.1.0 */
430430
int bFlipAxisOrder = MS_FALSE;
431-
431+
const char *pszTmp;
432+
int bIsEssential = MS_FALSE;
433+
432434
if (lp->connectiontype != MS_WMS) {
433435
msSetError(MS_WMSCONNERR, "Call supported only for CONNECTIONTYPE WMS",
434436
"msBuildWMSLayerURL()");
@@ -779,6 +781,20 @@ msBuildWMSLayerURL(mapObj *map, layerObj *lp, int nRequestType,
779781
* QUERY_LAYERS (for queryable layers only)
780782
* ------------------------------------------------------------------ */
781783

784+
/* ------------------------------------------------------------------
785+
* Sometimes a requested layer is essential for the map, so if the
786+
* request fails or an error is delivered, the map has not to be drawn
787+
* ------------------------------------------------------------------ */
788+
if ((pszTmp = msOWSLookupMetadata(&(lp->metadata),
789+
"MO", "essential")) != NULL) {
790+
if( strcasecmp(pszTmp,"true") == 0
791+
|| strcasecmp(pszTmp,"on") == 0
792+
|| strcasecmp(pszTmp,"yes") == 0 )
793+
bIsEssential = MS_TRUE;
794+
else
795+
bIsEssential = atoi(pszTmp);
796+
}
797+
782798
if (nRequestType == WMS_GETFEATUREINFO) {
783799
char szBuf[100] = "";
784800

@@ -874,11 +890,17 @@ msBuildWMSLayerURL(mapObj *map, layerObj *lp, int nRequestType,
874890

875891
pszExceptionsParam = msOWSLookupMetadata(&(lp->metadata),
876892
"MO", "exceptions_format");
877-
if (pszExceptionsParam == NULL) {
878-
if (nVersion >= OWS_1_1_0 && nVersion < OWS_1_3_0)
879-
pszExceptionsParam = "application/vnd.ogc.se_inimage";
880-
else
881-
pszExceptionsParam = "INIMAGE";
893+
894+
if (!bIsEssential) {
895+
if (pszExceptionsParam == NULL) {
896+
if (nVersion >= OWS_1_1_0 && nVersion < OWS_1_3_0)
897+
pszExceptionsParam = "application/vnd.ogc.se_inimage";
898+
else
899+
pszExceptionsParam = "INIMAGE";
900+
}
901+
} else {
902+
/* if layer is essential, do not emit EXCEPTIONS parameter (defaults to XML) */
903+
pszExceptionsParam = NULL;
882904
}
883905

884906
msSetWMSParamString(psWMSParams, "REQUEST", pszRequestParam, MS_FALSE, nVersion);
@@ -894,7 +916,9 @@ msBuildWMSLayerURL(mapObj *map, layerObj *lp, int nRequestType,
894916
bbox.minx, bbox.miny, bbox.maxx, bbox.maxy);
895917
}
896918
msSetWMSParamString(psWMSParams, "BBOX", szBuf, MS_TRUE, nVersion);
897-
msSetWMSParamString(psWMSParams, "EXCEPTIONS", pszExceptionsParam, MS_FALSE, nVersion);
919+
if( pszExceptionsParam ) {
920+
msSetWMSParamString(psWMSParams, "EXCEPTIONS", pszExceptionsParam, MS_FALSE, nVersion);
921+
}
898922
}
899923

900924
free(pszEPSG);
@@ -1279,16 +1303,20 @@ int msDrawWMSLayerLow(int nLayerId, httpRequestObj *pasReqInfo,
12791303
int numclasses;
12801304
char *mem_filename = NULL;
12811305
const char *pszTmp;
1282-
int bIsEssential;
1306+
int bIsEssential = MS_FALSE;
12831307

12841308
/* ------------------------------------------------------------------
12851309
* Sometimes a requested layer is essential for the map, so if the
12861310
* request fails or an error is delivered, the map has not to be drawn
12871311
* ------------------------------------------------------------------ */
1288-
bIsEssential = MS_FALSE;
12891312
if ((pszTmp = msOWSLookupMetadata(&(lp->metadata),
12901313
"MO", "essential")) != NULL) {
1291-
bIsEssential = atoi(pszTmp);
1314+
if( strcasecmp(pszTmp,"true") == 0
1315+
|| strcasecmp(pszTmp,"on") == 0
1316+
|| strcasecmp(pszTmp,"yes") == 0 )
1317+
bIsEssential = MS_TRUE;
1318+
else
1319+
bIsEssential = atoi(pszTmp);
12921320
}
12931321

12941322
/* ------------------------------------------------------------------

0 commit comments

Comments
 (0)