Skip to content

Commit

Permalink
Merge pull request #5405 from tomkralidis/issue-5404
Browse files Browse the repository at this point in the history
add metadata to optionally not emit root layer name in WMS Capabilities
  • Loading branch information
tomkralidis committed Mar 18, 2017
2 parents 1ec4d65 + 478e475 commit bbe192c
Show file tree
Hide file tree
Showing 5 changed files with 466 additions and 2 deletions.
17 changes: 15 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=NULL;
char *pszTmp=NULL;
int i;
const char *format_list=NULL;
Expand Down Expand Up @@ -3100,8 +3101,20 @@ 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 = msOWSLookupMetadata(&(map->web.metadata), "MO", "rootlayer_name");

if (rootlayer_name) {
if (strlen(rootlayer_name) > 0) {
msOWSPrintEncodeMetadata(stdout, &(map->web.metadata), "MO", "rootlayer_name",
OWS_NOERR, " <Name>%s</Name>\n",
NULL);
}
}
else {
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
103 changes: 103 additions & 0 deletions msautotest/wxs/expected/ows_wms_rootlayer_name_capabilities.xml
@@ -0,0 +1,103 @@
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>
<Name>foo</Name>
<!-- 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>
102 changes: 102 additions & 0 deletions msautotest/wxs/expected/ows_wms_rootlayer_name_empty_capabilities.xml
@@ -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>
123 changes: 123 additions & 0 deletions msautotest/wxs/ows_wms_rootlayer_name.map
@@ -0,0 +1,123 @@

# Test WMS rootlayer_name
#
# 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_capabilities.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WMS&REQUEST=GetCapabilities" > [RESULT_DEVERSION]

# Results expected
# getcapabilities: root <Layer> element emits <Name>foo</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" "foo"
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 bbe192c

Please sign in to comment.