[mapserver-commits] r11792 - sandbox/inspire_soc2011/mapserver

svn at osgeo.org svn at osgeo.org
Tue Jun 7 13:25:07 EDT 2011


Author: stefanl
Date: 2011-06-07 10:25:07 -0700 (Tue, 07 Jun 2011)
New Revision: 11792

Modified:
   sandbox/inspire_soc2011/mapserver/README-inspire.txt
   sandbox/inspire_soc2011/mapserver/mapows.c
   sandbox/inspire_soc2011/mapserver/mapows.h
   sandbox/inspire_soc2011/mapserver/mapwms.c
Log:
just existing patch applied (adapted for msvs)

Modified: sandbox/inspire_soc2011/mapserver/README-inspire.txt
===================================================================
--- sandbox/inspire_soc2011/mapserver/README-inspire.txt	2011-06-07 15:20:50 UTC (rev 11791)
+++ sandbox/inspire_soc2011/mapserver/README-inspire.txt	2011-06-07 17:25:07 UTC (rev 11792)
@@ -1 +1,49 @@
-.
\ No newline at end of file
+INSPIRE View Service - Settings
+
+
+wms_inspire_capabilities {"url"|"embed"|""}
+    generally enable extened capabilities for the inspire view service 
+    and distinguish between use-case 1 and 2 in order to give appropriate 
+    warnings in the GetCapabilities output
+
+wms_metadataurl_href
+    existing metadata_href mapped into the inspire extension
+
+wms_metadataurl_format "application/vnd.iso.19139+xml" # fixed string ???
+    existing metadata_href mapped into the inspire extension
+
+wms_inspire_languages "eng,ger,dut,..."
+    first token is the default language; required to print the language 
+    block in the GetCapbilities output and to identify language specific
+    titles and abstracts
+
+wms_inspire_languagesubstitution ""
+    alter online_resource in the GetCapabilities output, in order that 
+    %language% may be used as variable substitution
+
+default_language "eng"
+    see run-time variable substitution; this default value must match 
+    the default language in wms_inspire_languages
+    
+language_validation_pattern "^(eng|ger)$"
+    see run-time variable substitution; the pattern must be valid for 
+    all values listed in wms_inspire_languages
+
+wms_title_eng "Example for language specific title"
+wms_title_ger "Beispiel für sprachspezifischen Titel"
+
+wms_abstract_eng "Example for language specific abstract"
+wms_abstract_ger "Beispiel für sprachspezifische Zusammenfassung"
+
+wms_rootlayer_title_eng "Example for language specific root layer title"
+wms_rootlayer_title_ger "Beispiel für sprachspezifischen Titel"
+
+wms_rootlayer_abstract_eng "Example for language specific root layer abstract"
+wms_rootlayer_abstract_ger "Beispiel für sprachspezifische Zusammenfassung"
+
+
+Examples for language specific layer properties using run-time subtsition
+     DATA "shapes/rivers_%language%.shp"
+     CONNECTION "user=... password=... dbname=rivers_%language%"
+     FILTER ("lang='%language%')
+     CLASSITEM "lang" => EXPRESSION "%language%"

Modified: sandbox/inspire_soc2011/mapserver/mapows.c
===================================================================
--- sandbox/inspire_soc2011/mapserver/mapows.c	2011-06-07 15:20:50 UTC (rev 11791)
+++ sandbox/inspire_soc2011/mapserver/mapows.c	2011-06-07 17:25:07 UTC (rev 11792)
@@ -466,7 +466,36 @@
     return value;
 }
 
+
 /*
+** msOWSLookupMetadataWithLanguage()
+**
+** Attempts to lookup a given metadata name in multiple OWS namespaces
+** for a specific language.
+*/
+const char *msOWSLookupMetadataWithLanguage(hashTableObj *metadata, 
+                                const char *namespaces, const char *name, const char* validated_language)
+{
+    const char *value = NULL;
+    char * name2=NULL;
+    size_t bufferSize = 0;
+
+    bufferSize = strlen(name)+(validated_language ? strlen(validated_language) : 0)+2;
+    name2 = (char *) msSmallMalloc( bufferSize );
+
+    if ( validated_language && name2 )
+       snprintf(name2, bufferSize, "%s_%s", name, validated_language);
+    else
+       snprintf(name2, bufferSize, "%s", name);
+
+    value = msOWSLookupMetadata(metadata, namespaces, name2);
+
+    msFree( name2 );
+
+    return value;
+}
+
+/*
 ** msOWSLookupMetadata2()
 **
 ** Attempts to lookup a given metadata name in multiple hashTables, and
@@ -726,6 +755,32 @@
 }
 
 
+/*
+** msOWSGetOnlineResource()
+**
+** Return the online resource for this service and add language parameter.
+**
+** Returns a newly allocated string that should be freed by the caller or
+** NULL in case of error.
+*/
+char * msOWSGetOnlineResource2(mapObj *map, const char *namespaces, const char *metadata_name, 
+                              cgiRequestObj *req, const char* validated_language)
+{
+    char *online_resource = msOWSGetOnlineResource(map, namespaces, metadata_name, req);
+
+    if ( online_resource && validated_language &&
+        msOWSLookupMetadata(&(map->web.metadata), namespaces, "inspire_languagesubstitution") ) {
+        /* online_resource is already terminated, so we can simply add language=...& */
+    	/* but first we need to make sure that online_resource has enough capacity */
+    	online_resource = (char *)msSmallRealloc(online_resource, strlen(online_resource) + strlen(validated_language) +  11);
+        strcat(online_resource, "language=");
+        strcat(online_resource, validated_language);
+        strcat(online_resource, "&");
+    }
+
+    return online_resource;
+}
+
 /* msOWSGetSchemasLocation()
 **
 ** schemas location is the root of the web tree where all WFS-related 
@@ -775,6 +830,162 @@
     return language;
 }
 
+/* msOWSGetInspireLanguageList
+**
+** Returns the list of INSPIRE languages that this service supports
+**
+** Use value of "inspire_languages" metadata (comma-separated list),
+** or NULL if not set
+**
+** Returns a malloced char** of length numitems which must be freed
+** by the caller, or NULL (with numitems = 0)
+*/
+char **msOWSGetInspireLanguageList(mapObj *map, const char *namespaces, int *numitems) {
+
+  const char *inspire_languages = NULL;
+
+  if (!msOWSLookupMetadata(&(map->web.metadata), "MO", "inspire_capabilities")) {
+	  *numitems = 0;
+	  return NULL;
+  }
+
+  inspire_languages = msOWSLookupMetadata(&(map->web.metadata), namespaces, "inspire_languages");
+  if (inspire_languages && strlen(inspire_languages) > 0) {
+	  return msStringSplit(inspire_languages, ',', numitems);
+  } else {
+	  *numitems = 0;
+	  return NULL;
+  }
+}
+
+/* msOWSGetInspireLanguage
+**
+** Returns an INSPIRE languae according to the language requested
+** by the client
+**
+** If the requested language is in the inspire_languages metadata then
+** use it, otherwise ignore the request and use the defaul language,
+** which is the first entry the metadata list. Calling
+** with a NULL requested_langauge therefore returns this default language.
+**
+** If the metadata list is not defined then we assume that this is a
+** non-INSPIRE service and the language is therefore NULL
+**
+** Returns a malloced char* which must be freed by the caller, or NULL
+*/
+char *msOWSGetInspireLanguage(mapObj *map, const char *namespaces, const char *requested_language) {
+  int num_items = 0;
+  char **inspire_languages = msOWSGetInspireLanguageList(map, namespaces, &num_items);
+  char *language = NULL;
+
+  if( inspire_languages && num_items > 0 ) {
+	if ( !requested_language || !msStringInArray( requested_language, inspire_languages, num_items) ) {
+	  language = msStrdup(inspire_languages[0]);
+	} else {
+	  language = msStrdup(requested_language);
+	}
+  }
+  msFreeCharArray(inspire_languages, num_items);
+
+  return language;
+}
+
+/* msOWSPrintInspireCommonExtendedCapabilities
+**
+** Output INSPIRE common extended capabilities items to stream
+** The currently supported items are metadata and languages
+**
+** tag_name is the name (including ns prefix) of the tag to include the whole
+** extended capabilities block in
+**
+** service is currently included for future compatibility when differing
+** extended capabilities elements are included for different service types
+**
+** Returns a status code; MS_NOERR if all ok, action_if_not_found otherwise
+*/
+int msOWSPrintInspireCommonExtendedCapabilities(FILE *stream, mapObj *map, const char *namespaces,
+		                                        int action_if_not_found, const char *tag_name,
+		                                        const char *validated_language, const int service) {
+
+    int metadataStatus = 0; 
+    int languageStatus = 0;
+
+	msIO_fprintf(stream, "  <%s>\n", tag_name);
+
+	metadataStatus = msOWSPrintInspireCommonMetadata(stream, map, namespaces, action_if_not_found);
+	languageStatus = msOWSPrintInspireCommonLanguages(stream, map, namespaces, action_if_not_found, validated_language);
+
+	msIO_fprintf(stream, "  </%s>\n", tag_name);
+
+	return (metadataStatus != MS_NOERR) ? metadataStatus : languageStatus;
+}
+
+/* msOWSPrintInspireCommonMetadata
+**
+** Output INSPIRE common metadata items to a stream
+**
+** Returns a status code; MS_NOERR if all OK, action_if_not_found otherwise
+*/
+int msOWSPrintInspireCommonMetadata(FILE *stream, mapObj *map, const char *namespaces,
+                                       int action_if_not_found) {
+	int status = MS_NOERR;
+
+    /* Referencing a CSW only is the solution known as Scenario 1 */
+    if ( msOWSLookupMetadata(&(map->web.metadata), namespaces, "metadataurl_href") ) {
+      msIO_fprintf(stream, "    <inspire_common:MetadataUrl xsi:type=\"inspire_common:resourceLocatorType\">\n");
+      msOWSPrintEncodeMetadata(stream, &(map->web.metadata), namespaces, "metadataurl_href", OWS_WARN, "      <inspire_common:URL>%s</inspire_common:URL>\n", "");
+      msOWSPrintEncodeMetadata(stream, &(map->web.metadata), namespaces, "metadataurl_format", OWS_WARN, "      <inspire_common:MediaType>%s</inspire_common:MediaType>\n", "");
+      msIO_fprintf(stream, "    </inspire_common:MetadataUrl>\n");
+    } else if ( "embed" != msOWSLookupMetadata(&(map->web.metadata), namespaces, "inspire_capabilities") ) {
+      status = action_if_not_found;
+      if (OWS_WARN == action_if_not_found) {
+        msIO_fprintf(stream, "<!-- WARNING: Mandatory metadata '%s%s' was missing in this context. -->\n", (namespaces?"..._":""), "metadataurl_href");
+      }
+    }
+
+    /* Including all required extension metadata is known as Scenario 2 */
+    /* TODO */
+
+    return status;
+}
+
+/* msOWSPrintInspireCommonLanguages
+**
+** Output INSPIRE supported languages block to stream
+**
+** Returns a status code; MS_NOERR if all OK; action_if_not_found otherwise
+*/
+int msOWSPrintInspireCommonLanguages(FILE *stream, mapObj *map, const char *namespaces,
+							   int action_if_not_found, const char *validated_language) {
+	char *buffer = NULL; /* temp variable for malloced strings that will need freeing */
+	int status = MS_NOERR;
+
+	char *default_language = msOWSGetInspireLanguage(map, namespaces, NULL);
+
+    if(validated_language && default_language) {
+      msIO_fprintf(stream, "    <inspire_common:SupportedLanguages>\n");
+      msIO_fprintf(stream, "      <inspire_common:DefaultLanguage><inspire_common:Language>%s"
+                           "</inspire_common:Language></inspire_common:DefaultLanguage>\n",
+                           buffer = msEncodeHTMLEntities(default_language));
+      msFree(buffer);
+      msOWSPrintEncodeMetadataList(stream, &(map->web.metadata), namespaces, "inspire_languages", NULL, NULL,
+                                   "      <inspire_common:SupportedLanguage><inspire_common:Language>%s"
+                                   "</inspire_common:Language></inspire_common:SupportedLanguage>\n", NULL);
+      msIO_fprintf(stream, "    </inspire_common:SupportedLanguages>\n");
+      msIO_fprintf(stream, "    <inspire_common:ResponseLanguage><inspire_common:Language>%s"
+                           "</inspire_common:Language></inspire_common:ResponseLanguage>\n", validated_language);
+    } else {
+      status = action_if_not_found;
+      if (OWS_WARN == action_if_not_found) {
+    	msIO_fprintf(stream, "<!-- WARNING: Mandatory metadata '%s%s' was missing in this context. -->\n", (namespaces?"..._":""), "inspire_languages");
+      }
+    }
+
+    msFree(default_language);
+
+    return status;
+}
+
 /*
 ** msOWSPrintMetadata()
 **
@@ -827,11 +1038,27 @@
                              int action_if_not_found, 
                              const char *format, const char *default_value) 
 {
+    return msOWSPrintEncodeMetadata2(stream, metadata, namespaces, name, action_if_not_found, format, default_value, NULL);
+}
+
+
+/*
+** msOWSPrintEncodeMetadata2()
+**
+** Attempt to output a capability item in the requested language.
+** Fallback using no language parameter.
+*/
+int msOWSPrintEncodeMetadata2(FILE *stream, hashTableObj *metadata, 
+                              const char *namespaces, const char *name, 
+                              int action_if_not_found, 
+                              const char *format, const char *default_value, 
+                              const char *language) 
+{
     const char *value;
     char * pszEncodedValue=NULL;
     int status = MS_NOERR;
 
-    if((value = msOWSLookupMetadata(metadata, namespaces, name)))
+    if((value = msOWSLookupMetadataWithLanguage(metadata, namespaces, name, language)))
     {
         pszEncodedValue = msEncodeHTMLEntities(value);
         msIO_fprintf(stream, format, pszEncodedValue);
@@ -841,7 +1068,7 @@
     {
         if (action_if_not_found == OWS_WARN)
         {
-            msIO_fprintf(stream, "<!-- WARNING: Mandatory metadata '%s%s' was missing in this context. -->\n", (namespaces?"..._":""), name);
+            msIO_fprintf(stream, "<!-- WARNING: Mandatory metadata '%s%s%s%s' was missing in this context. -->\n", (namespaces?"..._":""), name, (language?"_":""), (language?language:""));
             status = action_if_not_found;
         }
 

Modified: sandbox/inspire_soc2011/mapserver/mapows.h
===================================================================
--- sandbox/inspire_soc2011/mapserver/mapows.h	2011-06-07 15:20:50 UTC (rev 11791)
+++ sandbox/inspire_soc2011/mapserver/mapows.h	2011-06-07 17:25:07 UTC (rev 11792)
@@ -115,6 +115,8 @@
 
 MS_DLL_EXPORT const char * msOWSLookupMetadata(hashTableObj *metadata, 
                                     const char *namespaces, const char *name);
+MS_DLL_EXPORT const char * msOWSLookupMetadataWithLanguage(hashTableObj *metadata, 
+                                    const char *namespaces, const char *name, const char *validated_language);
 MS_DLL_EXPORT const char * msOWSLookupMetadata2(hashTableObj *pri,
                                                 hashTableObj *sec,
                                                 const char *namespaces,
@@ -154,8 +156,11 @@
 MS_DLL_EXPORT int msOWSNegotiateVersion(int requested_version, int supported_versions[], int num_supported_versions);
 MS_DLL_EXPORT char *msOWSTerminateOnlineResource(const char *src_url);
 MS_DLL_EXPORT char *msOWSGetOnlineResource(mapObj *map, const char *namespaces, const char *metadata_name, cgiRequestObj *req);
+MS_DLL_EXPORT char *msOWSGetOnlineResource2(mapObj *map, const char *namespaces, const char *metadata_name, cgiRequestObj *req, const char *validated_language);
 MS_DLL_EXPORT const char *msOWSGetSchemasLocation(mapObj *map);
 MS_DLL_EXPORT const char *msOWSGetLanguage(mapObj *map, const char *context);
+MS_DLL_EXPORT char **msOWSGetInspireLanguageList(mapObj *map, const char *namespaces, int *numitems);
+MS_DLL_EXPORT char *msOWSGetInspireLanguage(mapObj *map, const char *namespaces, const char *requested_language);
 
 
 /* OWS_NOERR and OWS_WARN passed as action_if_not_found to printMetadata() */
@@ -167,6 +172,14 @@
 #define OWS_WMS     1
 #define OWS_WFS     2
 
+MS_DLL_EXPORT int msOWSPrintInspireCommonExtendedCapabilities(FILE *stream, mapObj *map, const char *namespaces,
+		                                        const int action_if_not_found, const char *tag_name,
+		                                        const char *validated_language, const int service);
+int msOWSPrintInspireCommonMetadata(FILE *stream, mapObj *map, const char *namespaces,
+                                       int action_if_not_found);
+int msOWSPrintInspireCommonLanguages(FILE *stream, mapObj *map, const char *namespaces,
+							   int action_if_not_found, const char *validated_language);
+
 MS_DLL_EXPORT int msOWSPrintMetadata(FILE *stream, hashTableObj *metadata, 
                        const char *namespaces, const char *name, 
                        int action_if_not_found, const char *format, 
@@ -175,6 +188,11 @@
                              const char *namespaces, const char *name, 
                              int action_if_not_found, 
                              const char *format, const char *default_value) ;
+int msOWSPrintEncodeMetadata2(FILE *stream, hashTableObj *metadata, 
+                             const char *namespaces, const char *name, 
+                             int action_if_not_found, 
+                             const char *format, const char *default_value,
+                             const char *validated_language);
 char *msOWSGetEncodeMetadata(hashTableObj *metadata, 
                              const char *namespaces, const char *name, 
                              const char *default_value);

Modified: sandbox/inspire_soc2011/mapserver/mapwms.c
===================================================================
--- sandbox/inspire_soc2011/mapserver/mapwms.c	2011-06-07 15:20:50 UTC (rev 11791)
+++ sandbox/inspire_soc2011/mapserver/mapwms.c	2011-06-07 17:25:07 UTC (rev 11792)
@@ -1396,7 +1396,7 @@
 /*
 ** msDumpLayer()
 */
-int msDumpLayer(mapObj *map, layerObj *lp, int nVersion, const char *script_url_encoded, const char *indent)
+int msDumpLayer(mapObj *map, layerObj *lp, int nVersion, const char *script_url_encoded, const char *indent, const char *validated_language)
 {
    rectObj ext;
    const char *value;
@@ -1439,11 +1439,11 @@
                          "        <Name>%s</Name>\n", NULL);
 
    /* the majority of this section is dependent on appropriately named metadata in the LAYER object */
-   msOWSPrintEncodeMetadata(stdout, &(lp->metadata), "MO", "title",
-                            OWS_WARN, "        <Title>%s</Title>\n", lp->name);
+   msOWSPrintEncodeMetadata2(stdout, &(lp->metadata), "MO", "title",
+                            OWS_WARN, "        <Title>%s</Title>\n", lp->name, validated_language);
 
-   msOWSPrintEncodeMetadata(stdout, &(lp->metadata), "MO", "abstract",
-                         OWS_NOERR, "        <Abstract>%s</Abstract>\n", NULL);
+   msOWSPrintEncodeMetadata2(stdout, &(lp->metadata), "MO", "abstract",
+                         OWS_NOERR, "        <Abstract>%s</Abstract>\n", NULL, validated_language);
 
    if (nVersion == OWS_1_0_0)
    {
@@ -1947,14 +1947,14 @@
  * -numNestedGroups: This array holds the number of nested groups for each layer   *
  ***********************************************************************************/
 void msWMSPrintNestedGroups(mapObj* map, int nVersion, char* pabLayerProcessed, 
-	int index, int level, char*** nestedGroups, int* numNestedGroups, const char *script_url_encoded)
+	int index, int level, char*** nestedGroups, int* numNestedGroups, const char *script_url_encoded, const char *validated_language)
 {
    int j;
 
    if (numNestedGroups[index] <= level) /* no more subgroups */
    {
       /* we are at the deepest level of the group branchings, so add layer now. */
-      msDumpLayer(map, GET_LAYER(map, index), nVersion, script_url_encoded, "");
+      msDumpLayer(map, GET_LAYER(map, index), nVersion, script_url_encoded, "", validated_language);
       pabLayerProcessed[index] = 1; /* done */
    }
    else /* not yet there, we have to deal with this group and possible subgroups and layers. */
@@ -1968,7 +1968,7 @@
       {
          msWMSPrintNestedGroups(map, nVersion, pabLayerProcessed,
                                 index, level + 1, nestedGroups, 
-                                numNestedGroups, script_url_encoded);
+                                numNestedGroups, script_url_encoded, validated_language);
       }
 
       /* look for subgroups in other layers. */
@@ -1980,7 +1980,7 @@
             {
                msWMSPrintNestedGroups(map, nVersion, pabLayerProcessed,
                                       j, level + 1, nestedGroups, 
-                                      numNestedGroups, script_url_encoded);
+                                      numNestedGroups, script_url_encoded, validated_language);
             }
          }
          else
@@ -2000,7 +2000,7 @@
 ** msWMSGetCapabilities()
 */
 int msWMSGetCapabilities(mapObj *map, int nVersion, cgiRequestObj *req, owsRequestObj *ows_request, 
-                         const char *requested_updatesequence, char *wms_exception_format)
+                         const char *requested_updatesequence, char *wms_exception_format, const char *requested_language)
 {
   char *dtd_url = NULL;
   char *script_url=NULL, *script_url_encoded=NULL;
@@ -2016,6 +2016,7 @@
   const char *format_list=NULL;
   char **tokens = NULL;
   int numtokens = 0;
+  char *validated_language = NULL;
    
   updatesequence = msOWSLookupMetadata(&(map->web.metadata), "MO", "updatesequence");
 
@@ -2072,13 +2073,17 @@
   else
      nVersion = OWS_1_3_0;
 
+  /* This function owns validated_language, so remember to free it later*/
+  validated_language = msOWSGetInspireLanguage(map, "MO", requested_language);
+
   /* We need this server's onlineresource. */
   /* Default to use the value of the "onlineresource" metadata, and if not */
   /* set then build it: "http://$(SERVER_NAME):$(SERVER_PORT)$(SCRIPT_NAME)?" */
   /* the returned string should be freed once we're done with it. */
-  if ((script_url=msOWSGetOnlineResource(map, "MO", "onlineresource", req)) == NULL ||
+  if ((script_url=msOWSGetOnlineResource2(map, "MO", "onlineresource", req, validated_language)) == NULL ||
       (script_url_encoded = msEncodeHTMLEntities(script_url)) == NULL)
   {
+	  msFree(validated_language);
       return msWMSException(map, nVersion, NULL, wms_exception_format);
   }
 
@@ -2126,11 +2131,24 @@
       msIO_printf("  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 %s/wms/%s/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 %sservice=WMS&amp;version=1.3.0&amp;request=GetSchemaExtension\"",
-         msOWSGetSchemasLocation(map), msOWSGetVersionString(nVersion, szVersionBuf), script_url_encoded);
+                  "   xmlns:ms=\"http://mapserver.gis.umn.edu/mapserver\"");
+
+      if ( msOWSLookupMetadata(&(map->web.metadata), "MO", "inspire_capabilities") ) {
+        msIO_printf("   xmlns:inspire_common=\"http://inspire.ec.europa.eu/schemas/common/1.0\""
+                    "   xmlns:inspire_vs=\"http://inspire.ec.europa.eu/schemas/inspire_vs/1.0\"" );
+      }
+
+      msIO_printf("   xsi:schemaLocation=\"http://www.opengis.net/wms %s/wms/%s/capabilities_1_3_0.xsd "
+                  " http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd ",
+         msOWSGetSchemasLocation(map), msOWSGetVersionString(nVersion, szVersionBuf));
+
+      if ( msOWSLookupMetadata(&(map->web.metadata), "MO", "inspire_capabilities") ) {
+        msIO_printf(" http://inspire.ec.europa.eu/schemas/inspire_vs/1.0 "
+                    " http://inspire.ec.europa.eu/schemas/inspire_vs/1.0/inspire_vs.xsd");
+      }
+
+      msIO_printf(" http://mapserver.gis.umn.edu/mapserver %sservice=WMS&amp;version=1.3.0&amp;request=GetSchemaExtension\"",
+         script_url_encoded);
   }
 
   msIO_printf(">\n");
@@ -2153,10 +2171,10 @@
   
 
   /* the majority of this section is dependent on appropriately named metadata in the WEB object */
-  msOWSPrintEncodeMetadata(stdout, &(map->web.metadata), "MO", "title",
-                           OWS_WARN, "  <Title>%s</Title>\n", map->name);
-  msOWSPrintEncodeMetadata(stdout, &(map->web.metadata), "MO", "abstract",
-                           OWS_NOERR, "  <Abstract>%s</Abstract>\n", NULL);
+  msOWSPrintEncodeMetadata2(stdout, &(map->web.metadata), "MO", "title",
+                           OWS_WARN, "  <Title>%s</Title>\n", map->name, validated_language);
+  msOWSPrintEncodeMetadata2(stdout, &(map->web.metadata), "MO", "abstract",
+                           OWS_NOERR, "  <Abstract>%s</Abstract>\n", NULL, validated_language);
 
   if (nVersion == OWS_1_0_0)
   {
@@ -2424,6 +2442,11 @@
     }
   }
 
+  /* INSPIRE extended capabilities */
+  if (nVersion >= OWS_1_3_0 && msOWSLookupMetadata(&(map->web.metadata), "MO", "inspire_capabilities") ) {
+    msOWSPrintInspireCommonExtendedCapabilities(stdout, map, "MO", OWS_WARN, "inspire_vs:ExtendedCapabilities", validated_language, OWS_WMS);
+  }
+
   /* Top-level layer with map extents and SRS, encloses all map layers */
   msIO_printf("  <Layer>\n");
 
@@ -2436,16 +2459,16 @@
   msOWSPrintEncodeParam(stdout, "MAP.NAME", map->name, OWS_NOERR,
                         "    <Name>%s</Name>\n", NULL);
 
-  if (msOWSLookupMetadata(&(map->web.metadata), "MO", "rootlayer_title"))
-    msOWSPrintEncodeMetadata(stdout, &(map->web.metadata), "MO", "rootlayer_title", OWS_WARN, "    <Title>%s</Title>\n", map->name);
+  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);
 
   else 
-    msOWSPrintEncodeMetadata(stdout, &(map->web.metadata), "MO", "title", OWS_WARN, "    <Title>%s</Title>\n", map->name);
+    msOWSPrintEncodeMetadata2(stdout, &(map->web.metadata), "MO", "title", OWS_WARN, "    <Title>%s</Title>\n", map->name, validated_language);
 
-  if (msOWSLookupMetadata(&(map->web.metadata), "MO", "rootlayer_abstract"))
-    msOWSPrintEncodeMetadata(stdout, &(map->web.metadata), "MO", "rootlayer_abstract", OWS_NOERR, "    <Abstract>%s</Abstract>\n", map->name);
+  if (msOWSLookupMetadataWithLanguage(&(map->web.metadata), "MO", "rootlayer_abstract", validated_language))
+    msOWSPrintEncodeMetadata2(stdout, &(map->web.metadata), "MO", "rootlayer_abstract", OWS_NOERR, "    <Abstract>%s</Abstract>\n", map->name, validated_language);
   else
-    msOWSPrintEncodeMetadata(stdout, &(map->web.metadata), "MO", "abstract", OWS_NOERR, "    <Abstract>%s</Abstract>\n", map->name);
+    msOWSPrintEncodeMetadata2(stdout, &(map->web.metadata), "MO", "abstract", OWS_NOERR, "    <Abstract>%s</Abstract>\n", map->name, validated_language);
 
 
   if (msOWSLookupMetadata(&(map->web.metadata), "MO", "rootlayer_keywordlist"))
@@ -2564,12 +2587,12 @@
             /* Has nested groups.  */
              msWMSPrintNestedGroups(map, nVersion, pabLayerProcessed, i, 0, 
                                     nestedGroups, numNestedGroups, 
-                                    script_url_encoded);
+                                    script_url_encoded, validated_language);
          }
          else if (lp->group == NULL || strlen(lp->group) == 0)
          {
              /* This layer is not part of a group... dump it directly */
-             msDumpLayer(map, lp, nVersion, script_url_encoded, "");
+             msDumpLayer(map, lp, nVersion, script_url_encoded, "", validated_language);
              pabLayerProcessed[i] = 1;
          }
          else
@@ -2679,7 +2702,7 @@
                      GET_LAYER(map, j)->group &&
                      strcmp(lp->group, GET_LAYER(map, j)->group) == 0 )
                  {
-                     msDumpLayer(map, (GET_LAYER(map, j)), nVersion, script_url_encoded, "  ");
+                     msDumpLayer(map, (GET_LAYER(map, j)), nVersion, script_url_encoded, "  ", validated_language);
                      pabLayerProcessed[j] = 1;
                  }
              }
@@ -2713,6 +2736,8 @@
   else
     msIO_printf("</WMT_MS_Capabilities>\n");
 
+  msFree(validated_language);
+
   free(script_url);
   free(script_url_encoded);
 
@@ -3900,7 +3925,7 @@
 {
 #ifdef USE_WMS_SVR
   int i, status, nVersion=OWS_VERSION_NOTSET;
-  const char *version=NULL, *request=NULL, *service=NULL, *format=NULL, *updatesequence=NULL;
+  const char *version=NULL, *request=NULL, *service=NULL, *format=NULL, *updatesequence=NULL, *language=NULL;
   const char * encoding;
   char *wms_exception_format = NULL;
   
@@ -3925,6 +3950,8 @@
         service = req->ParamValues[i];
       else if (strcasecmp(req->ParamNames[i], "FORMAT") == 0)
         format = req->ParamValues[i];
+      else if (strcasecmp(req->ParamNames[i], "LANGUAGE") == 0 && msOWSLookupMetadata(&(map->web.metadata), "MO", "inspire_capabilities"))
+        language = req->ParamValues[i];
   }
 
   /* If SERVICE is specified then it MUST be "WMS" */
@@ -3983,7 +4010,7 @@
           msSetError(MS_WMSERR, "WMS request not enabled. Check wms/ows_enable_request settings.", "msWMSGetCapabilities()");
           return msWMSException(map, nVersion, NULL, wms_exception_format);
       }
-      return msWMSGetCapabilities(map, nVersion, req, ows_request, updatesequence, wms_exception_format);
+      return msWMSGetCapabilities(map, nVersion, req, ows_request, updatesequence, wms_exception_format, language);
   }
   else if (request && (strcasecmp(request, "context") == 0 ||
                        strcasecmp(request, "GetContext") == 0) )



More information about the mapserver-commits mailing list