Skip to content

Commit

Permalink
add metadata to optionally not emit root layer name in WMS Capabiliti…
Browse files Browse the repository at this point in the history
…es XML (MapServer#5404)
  • Loading branch information
tomkralidis committed Mar 8, 2017
1 parent 586cefe commit 3f5b2ea
Show file tree
Hide file tree
Showing 5 changed files with 269 additions and 21 deletions.
30 changes: 30 additions & 0 deletions mapscript/python/setup.py
@@ -1,3 +1,33 @@
###############################################################################
#
# Project: MapServer
# Purpose: MapScript setup
# Author: The MapServer team.
#
##############################################################################
#
# Copyright (c) 1996-2016 Regents of the University of Minnesota.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies of this Software or works derived from this Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
###############################################################################

# $Id$
#
# setup.py file for MapScript
Expand Down
10 changes: 8 additions & 2 deletions mapwms.c
Expand Up @@ -2686,6 +2686,7 @@ int msWMSGetCapabilities(mapObj *map, int nVersion, cgiRequestObj *req, owsReque
const char *updatesequence=NULL;
const char *sldenabled=NULL;
const char *layerlimit=NULL;
const char *rootlayer_name_enabled=NULL;
char *pszTmp=NULL;
int i;
const char *format_list=NULL;
Expand Down Expand Up @@ -3100,8 +3101,13 @@ int msWMSGetCapabilities(mapObj *map, int nVersion, cgiRequestObj *req, owsReque
msIO_fprintf(stdout, "<!-- WARNING: The layer name '%s' might contain spaces or "
"invalid characters or may start with a number. This could lead to potential problems. -->\n",
map->name);
msOWSPrintEncodeParam(stdout, "MAP.NAME", map->name, OWS_NOERR,
" <Name>%s</Name>\n", NULL);

rootlayer_name_enabled = msOWSLookupMetadata(&(map->web.metadata), "MO", "rootlayer_name_enabled");

if (!rootlayer_name_enabled || strcmp(rootlayer_name_enabled, "true") == 0) {
msOWSPrintEncodeParam(stdout, "MAP.NAME", map->name, OWS_NOERR,
" <Name>%s</Name>\n", NULL);
}

if (msOWSLookupMetadataWithLanguage(&(map->web.metadata), "MO", "rootlayer_title", validated_language))
msOWSPrintEncodeMetadata2(stdout, &(map->web.metadata), "MO", "rootlayer_title", OWS_WARN, " <Title>%s</Title>\n", map->name, validated_language);
Expand Down
@@ -0,0 +1,102 @@
Content-Type: text/xml; charset=UTF-8

<?xml version='1.0' encoding="UTF-8" standalone="no" ?>
<WMS_Capabilities version="1.3.0" xmlns="http://www.opengis.net/wms" xmlns:sld="http://www.opengis.net/sld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ms="http://mapserver.gis.umn.edu/mapserver" xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd http://mapserver.gis.umn.edu/mapserver http://localhost/path/to/ows?service=WMS&amp;version=1.3.0&amp;request=GetSchemaExtension">

<Service>
<Name>WMS</Name>
<!-- WARNING: Mandatory metadata '..._title' was missing in this context. -->
<Title>WMS_TEST</Title>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/ows?"/>
<ContactInformation>
</ContactInformation>
<MaxWidth>4096</MaxWidth>
<MaxHeight>4096</MaxHeight>
</Service>

<Capability>
<Request>
<GetCapabilities>
<Format>text/xml</Format>
<DCPType>
<HTTP>
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/ows?"/></Get>
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/ows?"/></Post>
</HTTP>
</DCPType>
</GetCapabilities>
<GetMap>
<Format>image/png</Format>
<Format>image/jpeg</Format>
<Format>image/png; mode=8bit</Format>
<Format>image/vnd.jpeg-png</Format>
<Format>image/vnd.jpeg-png8</Format>
<Format>application/x-pdf</Format>
<Format>image/svg+xml</Format>
<Format>image/tiff</Format>
<Format>application/vnd.google-earth.kml+xml</Format>
<Format>application/vnd.google-earth.kmz</Format>
<DCPType>
<HTTP>
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/ows?"/></Get>
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/ows?"/></Post>
</HTTP>
</DCPType>
</GetMap>
<sld:DescribeLayer>
<Format>text/xml</Format>
<DCPType>
<HTTP>
<Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/ows?"/></Get>
<Post><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://localhost/path/to/ows?"/></Post>
</HTTP>
</DCPType>
</sld:DescribeLayer>
</Request>
<Exception>
<Format>XML</Format>
<Format>INIMAGE</Format>
<Format>BLANK</Format>
</Exception>
<sld:UserDefinedSymbolization SupportSLD="1" UserLayer="0" UserStyle="1" RemoteWFS="0" InlineFeature="0" RemoteWCS="0"/>
<Layer>
<!-- WARNING: Mandatory metadata '..._title' was missing in this context. -->
<Title>WMS_TEST</Title>
<Abstract>WMS_TEST</Abstract>
<CRS>EPSG:4326</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>-1</westBoundLongitude>
<eastBoundLongitude>-1</eastBoundLongitude>
<southBoundLatitude>-1</southBoundLatitude>
<northBoundLatitude>-1</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="EPSG:4326"
minx="-1" miny="-1" maxx="-1" maxy="-1" />
<Layer>
<Title>roadgroup</Title>
<Layer queryable="1" opaque="0" cascaded="0">
<Name>road2</Name>
<Title>road</Title>
<CRS>EPSG:43204</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>-66.6333</westBoundLongitude>
<eastBoundLongitude>-59.2921</eastBoundLongitude>
<southBoundLatitude>42.3821</southBoundLatitude>
<northBoundLatitude>48.2955</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="EPSG:43204"
minx="2.25898e+06" miny="-70747.9" maxx="2.61535e+06" maxy="495481" />
<Style>
<Name>default</Name>
<Title>default</Title>
<LegendURL width="71" height="20">
<Format>image/png</Format>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://localhost/path/to/ows?version=1.3.0&amp;service=WMS&amp;request=GetLegendGraphic&amp;sld_version=1.1.0&amp;layer=road2&amp;format=image/png&amp;STYLE=default"/>
</LegendURL>
</Style>
<MinScaleDenominator>1500</MinScaleDenominator>
</Layer>
</Layer>
</Layer>
</Capability>
</WMS_Capabilities>
25 changes: 6 additions & 19 deletions msautotest/wxs/ows_wms.map
@@ -1,30 +1,16 @@
#
# Test WMS enabling/disabling

# Test WMS rootlayer_name_enabled
#
# REQUIRES: SUPPORTS=WMS
#
# The following tests exists primarily to test the ability of enabling/disabling
# WMS service (see RFC 67).
# WMS service (see https://github.com/mapserver/mapserver/issues/5404).
#

# RUN_PARMS: ows_wms_capabilities.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&REQUEST=GetCapabilities" > [RESULT_DEVERSION]
# RUN_PARMS: ows_wms_getfeatureinfo.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&CRS=EPSG%3A4326&BBOX=35.18749999863387,-141.0000000021858,90.81250000136613,-51.99999999781419&WIDTH=560&HEIGHT=350&LAYERS=road&STYLES=&FORMAT=image%2Fpng&BGCOLOR=0xFFFFFF&TRANSPARENT=FALSE&QUERY_LAYERS=road&I=483&J=291&FEATURE_COUNT=5" > [RESULT_DEVERSION]
# RUN_PARMS: ows_wms_getfeatureinfo_plain.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&CRS=EPSG%3A4326&BBOX=35.18749999863387,-141.0000000021858,90.81250000136613,-51.99999999781419&WIDTH=560&HEIGHT=350&LAYERS=road&STYLES=&FORMAT=image%2Fpng&BGCOLOR=0xFFFFFF&TRANSPARENT=FALSE&QUERY_LAYERS=road&INFO_FORMAT=text%2Fplain&I=483&J=291&FEATURE_COUNT=5" > [RESULT_DEVERSION]
# RUN_PARMS: ows_wms_getfeatureinfo_gml.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&CRS=EPSG%3A4326&BBOX=35.18749999863387,-141.0000000021858,90.81250000136613,-51.99999999781419&WIDTH=560&HEIGHT=350&LAYERS=road&STYLES=&FORMAT=image%2Fpng&BGCOLOR=0xFFFFFF&TRANSPARENT=FALSE&QUERY_LAYERS=road&INFO_FORMAT=application%2Fvnd.ogc.gml&I=483&J=291&FEATURE_COUNT=5" > [RESULT_DEVERSION]
# RUN_PARMS: ows_wms_getfeatureinfo_plain_alias.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&CRS=EPSG%3A4326&BBOX=35.18749999863387,-141.0000000021858,90.81250000136613,-51.99999999781419&WIDTH=560&HEIGHT=350&LAYERS=road2&STYLES=&FORMAT=image%2Fpng&BGCOLOR=0xFFFFFF&TRANSPARENT=FALSE&QUERY_LAYERS=road2&INFO_FORMAT=text%2Fplain&I=483&J=291&FEATURE_COUNT=5" > [RESULT_DEVERSION]
# RUN_PARMS: ows_wms_getfeatureinfo_gml_alias.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&CRS=EPSG%3A4326&BBOX=35.18749999863387,-141.0000000021858,90.81250000136613,-51.99999999781419&WIDTH=560&HEIGHT=350&LAYERS=road2&STYLES=&FORMAT=image%2Fpng&BGCOLOR=0xFFFFFF&TRANSPARENT=FALSE&QUERY_LAYERS=road2&INFO_FORMAT=application%2Fvnd.ogc.gml&I=483&J=291&FEATURE_COUNT=5" > [RESULT_DEVERSION]
# RUN_PARMS: ows_wms_getmap.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&VERSION=1.1.0&REQUEST=GetMap&SRS=EPSG:4326&BBOX=-67.5725,42.3683,-58.9275,48.13&FORMAT=image/png&WIDTH=300&HEIGHT=200&STYLES=&LAYERS=road" > [RESULT_DEVERSION]
# RUN_PARMS: ows_wms_describelayer.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&VERSION=1.3.0&REQUEST=DescribeLayer&layers=road&sld_version=1.1.0&WIDTH=600&HEIGHT=600" > [RESULT_DEVERSION]
# RUN_PARMS: ows_wms_getlegendgraphic.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&x=500&y=300&LAYER=popplace&FORMAT=agg/png&VERSION=1.1.1&REQUEST=GetLegendGraphic&STYLES=&EXCEPTIONS=application%252Fvnd.ogc.se_inimage&SRS=EPSG:42304&BBOX=-2200000,-712631,3072800,3840000&WIDTH=600&HEIGHT=600" > [RESULT_DEVERSION]
# RUN_PARMS: ows_wms_getmap_exception.png [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&REQUEST=GetMap&VERSION=1.3.0&LAYERS=road&CRS=EPSG%3A4326&BBOX=35.18749999863387,-141.0000000021858,90.81250000136613,-51.99999999781419&WIDTH=560&HEIGHT=350&STYLES=&FORMAT=image%2Fpng&BGCOLOR=0xFFFFFF&TRANSPARENT=FALSE&EXCEPTIONS=INIMAGE" > [RESULT_DEVERSION] [RESULT_DEMIME]
# RUN_PARMS: ows_wms_getmap_valid.png [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&REQUEST=GetMap&VERSION=1.3.0&LAYERS=road3&CRS=EPSG%3A4326&BBOX=35.18749999863387,-141.0000000021858,90.81250000136613,-51.99999999781419&WIDTH=560&HEIGHT=350&STYLES=&FORMAT=image%2Fpng&BGCOLOR=0xFFFFFF&TRANSPARENT=FALSE&EXCEPTIONS=INIMAGE" > [RESULT_DEVERSION] [RESULT_DEMIME]
# RUN_PARMS: ows_wms_capabilities_rootlayer_name_enabled.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&REQUEST=GetCapabilities" > [RESULT_DEVERSION]

# Results expected
# getcapabilities: enabled at layer level but only for layer road2
# getfeatureinfo: enabled at layer level
# getmap: disabled at layer level for layer road and enabled for layer road3
# describelayer: enabled at map level
# other requests: disabled
# getcapabilities: root <Layer> element does not emit <Name> element

MAP

Expand All @@ -36,6 +22,7 @@ WEB
"wms_onlineresource" "http://localhost/path/to/ows?"
"ows_enable_request" "DescribeLayer"
"wms_enable_request" "!GetCapabilities !GetFeatureInfo GetMap"
"wms_rootlayer_name_enabled" "false"
END
END

Expand Down
123 changes: 123 additions & 0 deletions msautotest/wxs/ows_wms_rootlayer_name_enabled.map
@@ -0,0 +1,123 @@

# Test WMS rootlayer_name_enabled
#
# REQUIRES: SUPPORTS=WMS
#
# The following tests exists primarily to test the ability of enabling/disabling
# WMS service (see https://github.com/mapserver/mapserver/issues/5404).
#

# RUN_PARMS: ows_wms_rootlayer_name_enabled_capabilities.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&REQUEST=GetCapabilities" > [RESULT_DEVERSION]

# Results expected
# getcapabilities: root <Layer> element does not emit <Name> element

MAP

NAME WMS_TEST
SHAPEPATH ./data

WEB
METADATA
"wms_onlineresource" "http://localhost/path/to/ows?"
"ows_enable_request" "DescribeLayer"
"wms_enable_request" "!GetCapabilities !GetFeatureInfo GetMap"
"wms_rootlayer_name_enabled" "false"
END
END

PROJECTION
"init=epsg:4326"
END

LAYER
NAME road
DATA road
TEMPLATE "ttt"
METADATA
"wms_title" "road"
"wms_description" "Roads of I.P.E."
"wms_srs" "EPSG:43204"
"wms_include_items" "all"
"wms_ROAD_ID_alias" "ROAD_NAME"
"ows_enable_request" "GetFeatureInfo"
"wms_enable_request" "!GetCapabilities !GetMap"
"wms_layer_group" "/roadgroup"
END
TYPE LINE
STATUS ON
PROJECTION
"init=./data/epsg2:42304"
END

DUMP TRUE

CLASSITEM "Name_e"
CLASS
NAME "Roads"
SYMBOL 0
COLOR 220 0 0
END
END # Layer

LAYER
NAME road2
DATA road
TEMPLATE "ttt"
METADATA
"wms_title" "road"
"wms_description" "Roads of I.P.E."
"wms_srs" "EPSG:43204"
"wms_include_items" "all"
"gml_ROAD_ID_alias" "ROAD_NAME"
"ows_enable_request" "GetFeatureInfo"
"wms_enable_request" "GetCapabilities !GetMap"
"wms_layer_group" "/roadgroup"
END
MINSCALEDENOM 1500
TYPE LINE
STATUS ON
PROJECTION
"init=./data/epsg2:42304"
END

DUMP TRUE

CLASSITEM "Name_e"
CLASS
NAME "Roads"
SYMBOL 0
COLOR 220 0 0
END
END # Layer

LAYER
NAME road3
DATA road
TEMPLATE "ttt"
METADATA
"wms_title" "road"
"wms_description" "Roads of I.P.E."
"wms_srs" "EPSG:43204"
"gml_include_items" "all"
"ows_enable_request" "GetFeatureInfo"
"wms_enable_request" "!GetCapabilities GetMap"
"wms_layer_group" "/roadgroup"
END
TYPE LINE
STATUS ON
PROJECTION
"init=./data/epsg2:42304"
END

DUMP TRUE

CLASSITEM "Name_e"
CLASS
NAME "Roads"
SYMBOL 0
COLOR 220 0 0
END
END # Layer

END # Map File

0 comments on commit 3f5b2ea

Please sign in to comment.