[mapserver-commits] r11943 - sandbox/inspire_soc2011/mapserver
svn at osgeo.org
svn at osgeo.org
Fri Jul 15 12:22:24 EDT 2011
Author: stefanl
Date: 2011-07-15 09:22:24 -0700 (Fri, 15 Jul 2011)
New Revision: 11943
Modified:
sandbox/inspire_soc2011/mapserver/mapwms.c
Log:
inspire view service metadata support (scenario1+2)
Modified: sandbox/inspire_soc2011/mapserver/mapwms.c
===================================================================
--- sandbox/inspire_soc2011/mapserver/mapwms.c 2011-07-15 08:38:01 UTC (rev 11942)
+++ sandbox/inspire_soc2011/mapserver/mapwms.c 2011-07-15 16:22:24 UTC (rev 11943)
@@ -2659,20 +2659,101 @@
else
msWMSPrintScaleDenominator(" ", map->web.minscaledenom, map->web.maxscaledenom);
- if (nVersion >= OWS_1_3_0 && msOWSLookupMetadata(&(map->web.metadata), "MO", "inspire_capabilities") )
+ if (map->name && strlen(map->name) > 0 && msOWSLookupMetadata(&(map->web.metadata), "MO", "inspire_capabilities") )
{
+ char *pszEncodedName = NULL;
+ const char *styleName = NULL;
+ char *pszEncodedStyleName = NULL;
+ const char *legendURL = NULL;
+
+ pszEncodedName = msEncodeHTMLEntities(map->name);
+
+ styleName = msOWSLookupMetadata(&(map->web.metadata), "MO", "style_name");
+ if (styleName == NULL)
+ styleName = "default";
+
+ pszEncodedStyleName = msEncodeHTMLEntities(styleName);
+
msIO_fprintf(stdout, " <Style>\n");
+ msIO_fprintf(stdout, " <Name>%s</Name>\n", pszEncodedStyleName);
msOWSPrintEncodeMetadata(stdout, &(map->web.metadata), "MO",
- "inspire_style_name",
+ "style_title",
OWS_NOERR,
- " <Name>%s</Name>\n",
- "inspire_common:DEFAULT");
- msOWSPrintEncodeMetadata(stdout, &(map->web.metadata), "MO",
- "inspire_style_title",
- OWS_NOERR,
" <Title>%s</Title>\n",
- "inspire_common:DEFAULT");
+ styleName);
+
+ legendURL = msOWSLookupMetadata(&(map->web.metadata), "MO", "style_legendurl_href");
+ if (legendURL)
+ {
+ msOWSPrintURLType(stdout, &(map->web.metadata),
+ "MO", "style_legendurl",
+ OWS_NOERR, NULL,
+ "LegendURL", NULL,
+ " width=\"%s\"", " height=\"%s\"",
+ ">\n <Format>%s</Format",
+ "\n <OnlineResource "
+ "xmlns:xlink=\"http://www.w3.org/1999/xlink\""
+ " xlink:type=\"simple\" xlink:href=\"%s\"/>\n"
+ " ",
+ MS_FALSE, MS_TRUE, MS_TRUE, MS_TRUE, MS_TRUE,
+ NULL, NULL, NULL, NULL, NULL, " ");
+ }
+ else
+ {
+ int size_x=0, size_y=0;
+ size_t bufferSize = 0;
+ char *pszLegendURL = NULL;
+ char *pszMimetype = NULL;
+ char **tokens = NULL;
+ int numtokens = 0;
+ char width[10], height[10];
+ if (msLegendCalcSize(map, 1, &size_x, &size_y, NULL, 0) == MS_SUCCESS)
+ {
+ bufferSize = strlen(script_url_encoded)+200;
+ pszLegendURL = (char*)msSmallMalloc(bufferSize);
+ snprintf(width, sizeof(width), "%d", size_x);
+ snprintf(height, sizeof(height), "%d", size_y);
+
+ format_list = msOWSLookupMetadata(&(map->web.metadata), "M", "getlegendgraphic_formatlist");
+ if (format_list && strlen(format_list) > 0)
+ {
+ tokens = msStringSplit(format_list, ',', &numtokens);
+ if (tokens && numtokens > 0)
+ {
+ /*just grab the first mime type*/
+ pszMimetype = msEncodeHTMLEntities(tokens[0]);
+ msFreeCharArray(tokens, numtokens);
+ }
+ }
+ else
+ pszMimetype = msEncodeHTMLEntities("image/png; mode=24bit");
+
+ if (nVersion >= OWS_1_3_0)
+ snprintf(pszLegendURL, bufferSize, "%sversion=%s&service=WMS&request=GetLegendGraphic&sld_version=1.1.0&layer=%s&format=%s&STYLE=%s", script_url_encoded,msOWSGetVersionString(nVersion, szVersionBuf),pszEncodedName,
+ pszMimetype, pszEncodedStyleName);
+ else
+ snprintf(pszLegendURL, bufferSize, "%sversion=%s&service=WMS&request=GetLegendGraphic&layer=%s&format=%s&STYLE=%s", script_url_encoded,msOWSGetVersionString(nVersion, szVersionBuf),pszEncodedName,
+ pszMimetype, pszEncodedStyleName);
+
+ msOWSPrintURLType(stdout, NULL,
+ "O", "ttt",
+ OWS_NOERR, NULL,
+ "LegendURL", NULL,
+ " width=\"%s\"", " height=\"%s\"",
+ ">\n <Format>%s</Format",
+ "\n <OnlineResource "
+ "xmlns:xlink=\"http://www.w3.org/1999/xlink\""
+ " xlink:type=\"simple\" xlink:href=\"%s\"/>\n"
+ " ",
+ MS_FALSE, MS_FALSE, MS_FALSE, MS_FALSE, MS_FALSE,
+ NULL, width, height, pszMimetype, pszLegendURL, " ");
+ }
+ msFree(pszLegendURL);
+ msFree(pszMimetype);
+ }
msIO_fprintf(stdout, " </Style>\n");
+ msFree(pszEncodedName);
+ msFree(pszEncodedStyleName);
}
/* */
@@ -2741,84 +2822,120 @@
/*build a getlegendgraphicurl*/
if( script_url_encoded)
{
- int num_layers = 0;
- size_t bufferSize = 0;
- char width[10], height[10];
- char *name_encoded = msEncodeHTMLEntities(lp->group);
- int *group_layers = (int *)msSmallMalloc(sizeof(int)*map->numlayers);
- char *legendurl = NULL;
- int size_x=0, size_y=0;
- char *mimetype = NULL;
- char **tokens = NULL;
- int numtokens = 0;
+ if (lp->group && strlen(lp->group) > 0)
+ {
+ char *pszEncodedName = NULL;
+ const char *styleName = NULL;
+ char *pszEncodedStyleName = NULL;
+ const char *legendURL = NULL;
- for(j=i; j<map->numlayers; j++)
- if (!pabLayerProcessed[j] &&
- GET_LAYER(map, j)->group &&
- strcmp(lp->group, GET_LAYER(map, j)->group) == 0 &&
- msIntegerInArray(GET_LAYER(map, j)->index, ows_request->enabled_layers, ows_request->numlayers))
- group_layers[num_layers++] = j;
- if ( num_layers > 0)
- {
- group_layers =(int *)msSmallRealloc(group_layers, sizeof(int)*num_layers);
+ pszEncodedName = msEncodeHTMLEntities(lp->group);
- if (msLegendCalcSize(map, 1, &size_x, &size_y, group_layers , num_layers) == MS_SUCCESS)
- {
- bufferSize = strlen(script_url_encoded)+200;
- legendurl = (char*)msSmallMalloc(bufferSize);
- snprintf(width, sizeof(width), "%d", size_x);
- snprintf(height, sizeof(height), "%d", size_y);
+ styleName = msOWSLookupMetadata(&(lp->metadata), "MO", "group_style_name");
+ if (styleName == NULL)
+ styleName = "default";
- format_list = msOWSLookupMetadata(&(map->web.metadata), "M",
- "getlegendgraphic_formatlist");
- if (format_list && strlen(format_list) > 0)
- {
- tokens = msStringSplit(format_list, ',', &numtokens);
- if (tokens && numtokens > 0)
- {
- /*just grab the first mime type*/
- mimetype = msEncodeHTMLEntities(tokens[0]);
- msFreeCharArray(tokens, numtokens);
- }
- }
- else
- mimetype = msEncodeHTMLEntities("image/png; mode=24bit");
+ pszEncodedStyleName = msEncodeHTMLEntities(styleName);
- if (nVersion >= OWS_1_3_0)
-
- snprintf(legendurl, bufferSize, "%sversion=%s&service=WMS&request=GetLegendGraphic&sld_version=1.1.0&layer=%s&format=%s&STYLE=default", script_url_encoded,msOWSGetVersionString(nVersion, szVersionBuf),name_encoded,
- mimetype);
- else
- snprintf(legendurl, bufferSize, "%sversion=%s&service=WMS&request=GetLegendGraphic&layer=%s&format=%s&STYLE=default", script_url_encoded,msOWSGetVersionString(nVersion, szVersionBuf),name_encoded,
- mimetype);
- msIO_fprintf(stdout, " <Style>\n");
- msIO_fprintf(stdout, " <Name>default</Name>\n");
- msIO_fprintf(stdout, " <Title>default</Title>\n");
-
- msOWSPrintURLType(stdout, NULL,
- "O", "ttt",
- OWS_NOERR, NULL,
- "LegendURL", NULL,
- " width=\"%s\"", " height=\"%s\"",
- ">\n <Format>%s</Format",
- "\n <OnlineResource "
- "xmlns:xlink=\"http://www.w3.org/1999/xlink\""
- " xlink:type=\"simple\" xlink:href=\"%s\"/>\n"
- " ",
- MS_FALSE, MS_FALSE, MS_FALSE, MS_FALSE, MS_FALSE,
- NULL, width, height, mimetype, legendurl, " ");
-
+ msIO_fprintf(stdout, " <Style>\n");
+ msIO_fprintf(stdout, " <Name>%s</Name>\n", pszEncodedStyleName);
+ msOWSPrintEncodeMetadata(stdout, &(lp->metadata), "MO",
+ "group_style_title",
+ OWS_NOERR,
+ " <Title>%s</Title>\n",
+ styleName);
- msIO_fprintf(stdout, " </Style>\n");
- msFree(legendurl);
- msFree(mimetype);
- msFree(name_encoded);
+ legendURL = msOWSLookupMetadata(&(lp->metadata), "MO", "group_style_legendurl_href");
+ if (legendURL)
+ {
+ msOWSPrintURLType(stdout, &(lp->metadata),
+ "MO", "group_style_legendurl",
+ OWS_NOERR, NULL,
+ "LegendURL", NULL,
+ " width=\"%s\"", " height=\"%s\"",
+ ">\n <Format>%s</Format",
+ "\n <OnlineResource "
+ "xmlns:xlink=\"http://www.w3.org/1999/xlink\""
+ " xlink:type=\"simple\" xlink:href=\"%s\"/>\n"
+ " ",
+ MS_FALSE, MS_TRUE, MS_TRUE, MS_TRUE, MS_TRUE,
+ NULL, NULL, NULL, NULL, NULL, " ");
+ }
+ else
+ {
+ int num_layers = 0;
+ int *group_layers = (int *)msSmallMalloc(sizeof(int)*map->numlayers);
-
-
- }
- }
+ for(j=i; j<map->numlayers; j++)
+ if (!pabLayerProcessed[j] &&
+ GET_LAYER(map, j)->group &&
+ strcmp(lp->group, GET_LAYER(map, j)->group) == 0 &&
+ msIntegerInArray(GET_LAYER(map, j)->index, ows_request->enabled_layers, ows_request->numlayers))
+ group_layers[num_layers++] = j;
+
+ if (num_layers > 0)
+ {
+ int size_x=0, size_y=0;
+ size_t bufferSize = 0;
+ char *pszLegendURL = NULL;
+ char *pszMimetype = NULL;
+ char **tokens = NULL;
+ int numtokens = 0;
+ char width[10], height[10];
+
+ group_layers =(int *)msSmallRealloc(group_layers, sizeof(int)*num_layers);
+ if (msLegendCalcSize(map, 1, &size_x, &size_y, group_layers , num_layers) == MS_SUCCESS)
+ {
+ bufferSize = strlen(script_url_encoded)+200;
+ pszLegendURL = (char*)msSmallMalloc(bufferSize);
+ snprintf(width, sizeof(width), "%d", size_x);
+ snprintf(height, sizeof(height), "%d", size_y);
+
+ format_list = msOWSLookupMetadata(&(map->web.metadata), "M", "getlegendgraphic_formatlist");
+ if (format_list && strlen(format_list) > 0)
+ {
+ tokens = msStringSplit(format_list, ',', &numtokens);
+ if (tokens && numtokens > 0)
+ {
+ /*just grab the first mime type*/
+ pszMimetype = msEncodeHTMLEntities(tokens[0]);
+ msFreeCharArray(tokens, numtokens);
+ }
+ }
+ else
+ pszMimetype = msEncodeHTMLEntities("image/png; mode=24bit");
+
+ if (nVersion >= OWS_1_3_0)
+ snprintf(pszLegendURL, bufferSize, "%sversion=%s&service=WMS&request=GetLegendGraphic&sld_version=1.1.0&layer=%s&format=%s&STYLE=%s", script_url_encoded,msOWSGetVersionString(nVersion, szVersionBuf),pszEncodedName,
+ pszMimetype, pszEncodedStyleName);
+ else
+ snprintf(pszLegendURL, bufferSize, "%sversion=%s&service=WMS&request=GetLegendGraphic&layer=%s&format=%s&STYLE=%s", script_url_encoded,msOWSGetVersionString(nVersion, szVersionBuf),pszEncodedName,
+ pszMimetype, pszEncodedStyleName);
+
+ msOWSPrintURLType(stdout, NULL,
+ "O", "ttt",
+ OWS_NOERR, NULL,
+ "LegendURL", NULL,
+ " width=\"%s\"", " height=\"%s\"",
+ ">\n <Format>%s</Format",
+ "\n <OnlineResource "
+ "xmlns:xlink=\"http://www.w3.org/1999/xlink\""
+ " xlink:type=\"simple\" xlink:href=\"%s\"/>\n"
+ " ",
+ MS_FALSE, MS_FALSE, MS_FALSE, MS_FALSE, MS_FALSE,
+ NULL, width, height, pszMimetype, pszLegendURL, " ");
+
+ msFree(pszLegendURL);
+ msFree(pszMimetype);
+ }
+ }
+ }
+ msIO_fprintf(stdout, " </Style>\n");
+ msFree(pszEncodedName);
+ msFree(pszEncodedStyleName);
+ }
}
+
/* Dump all layers for this group */
for(j=i; j<map->numlayers; j++)
{
@@ -3774,7 +3891,8 @@
for (i=0; i<map->numlayers; i++)
{
lp = GET_LAYER(map, i);
- if ( ((lp->name && strcasecmp(lp->name, pszLayer) == 0) ||
+ if ( ((map->name && strcasecmp(map->name, pszLayer) == 0) ||
+ (lp->name && strcasecmp(lp->name, pszLayer) == 0) ||
(lp->group && strcasecmp(lp->group, pszLayer) == 0)) &&
(msIntegerInArray(lp->index, ows_request->enabled_layers, ows_request->numlayers)) )
{
More information about the mapserver-commits
mailing list