Permalink
Browse files

add metadata to optionally not emit root layer name in WMS Capabiliti…

…es XML (#5404)
  • Loading branch information...
tomkralidis committed Mar 8, 2017
1 parent 586cefe commit 478e475af6d1921ae79335fb3a8fc621a88072ad
@@ -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;
@@ -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);
@@ -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>
@@ -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>
@@ -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
Oops, something went wrong.

0 comments on commit 478e475

Please sign in to comment.