[mapserver-commits] r12247 - in trunk/mapserver/mapcache: . include
src
svn at osgeo.org
svn at osgeo.org
Fri Aug 26 07:10:43 EDT 2011
Author: tbonfort
Date: 2011-08-26 04:10:43 -0700 (Fri, 26 Aug 2011)
New Revision: 12247
Modified:
trunk/mapserver/mapcache/geocache.xml
trunk/mapserver/mapcache/include/geocache.h
trunk/mapserver/mapcache/src/configuration.c
trunk/mapserver/mapcache/src/dimension.c
trunk/mapserver/mapcache/src/service_wms.c
trunk/mapserver/mapcache/src/service_wmts.c
Log:
typo
thomas.bonfort | 2011-01-13 17:21:12 +0100 (Thu, 13 Jan 2011)
Modified: trunk/mapserver/mapcache/geocache.xml
===================================================================
--- trunk/mapserver/mapcache/geocache.xml 2011-08-26 11:10:36 UTC (rev 12246)
+++ trunk/mapserver/mapcache/geocache.xml 2011-08-26 11:10:43 UTC (rev 12247)
@@ -303,8 +303,8 @@
are currently used to populate the GetCapabilities document.
-->
<metadata>
- <title>osm mapserver served map of midi-pyrénées</title>
- <abstract>see http://mapserver-utils.googlecode.com</abstract>
+ <title>vmap0 map</title>
+ <abstract>blabla</abstract>
</metadata>
<!-- watermark
@@ -378,6 +378,10 @@
-->
<values>foobar,foobarbaz,foo,bar</values>
</dimension>
+ <dimension name="ELEVATION">
+ <default>0</default>
+ <values>0,1000,2000,3000,4000</values>
+ </dimension>
</dimensions>
</tileset>
<tileset name="test2">
Modified: trunk/mapserver/mapcache/include/geocache.h
===================================================================
--- trunk/mapserver/mapcache/include/geocache.h 2011-08-26 11:10:36 UTC (rev 12246)
+++ trunk/mapserver/mapcache/include/geocache.h 2011-08-26 11:10:43 UTC (rev 12247)
@@ -1012,37 +1012,18 @@
/** @} */
-typedef enum {
- GEOCACHE_DIMENSION_VALUES,
- GEOCACHE_DIMENSION_INTERVAL,
- GEOCACHE_DIMENSION_REGEX
-} geocache_dimension_type;
-
-typedef struct geocache_dimension_entry geocache_dimension_entry;
-
struct geocache_dimension {
- geocache_dimension_type type;
char *name;
+ char *unit;
apr_table_t *metadata;
char *default_value;
- int (*validate)(geocache_context *context, geocache_dimension *dimension, const char *value);
-};
-typedef struct geocache_dimension_values geocache_dimension_values;
-
-struct geocache_dimension_values {
- geocache_dimension dimension;
int nvalues;
char **values;
+ int (*validate)(geocache_context *context, geocache_dimension *dimension, const char *value);
};
-geocache_dimension_values* geocache_dimension_values_create(apr_pool_t *pool);
+geocache_dimension* geocache_dimension_create(apr_pool_t *pool);
-typedef struct geocache_dimension_regexp geocache_dimension_regexp;
-
-struct geocache_dimension_regexp {
- geocache_dimension dimension;
- regex_t *regex;
-};
#endif /* GEOCACHE_H_ */
/* vim: ai ts=3 sts=3 et sw=3
*/
Modified: trunk/mapserver/mapcache/src/configuration.c
===================================================================
--- trunk/mapserver/mapcache/src/configuration.c 2011-08-26 11:10:36 UTC (rev 12246)
+++ trunk/mapserver/mapcache/src/configuration.c 2011-08-26 11:10:43 UTC (rev 12247)
@@ -215,21 +215,28 @@
apr_array_header_t *dimensions = apr_array_make(ctx->pool,1,sizeof(geocache_dimension*));
for(dimension_node = ezxml_child(node,"dimension"); dimension_node; dimension_node = dimension_node->next) {
char *name = (char*)ezxml_attr(dimension_node,"name");
- char *default_value, *values, *key, *last;
+ char *key, *last, *values;
int count = 1;
+ geocache_dimension *dimension = geocache_dimension_create(ctx->pool);
ezxml_t dchild_node;
if(!name || !strlen(name)) {
ctx->set_error(ctx, GEOCACHE_PARSE_ERROR, "mandatory attribute \"name\" not found in <dimension>");
return;
}
- name = apr_pstrdup(ctx->pool,name);
+ dimension->name = apr_pstrdup(ctx->pool,name);
+
+ dchild_node = ezxml_child(dimension_node,"unit");
+ if(dchild_node && dchild_node->txt) {
+ dimension->unit = apr_pstrdup(ctx->pool,dchild_node->txt);
+ }
+
dchild_node = ezxml_child(dimension_node,"default");
if(!dchild_node || !dchild_node->txt) {
ctx->set_error(ctx, GEOCACHE_PARSE_ERROR, "<dimension> \"%s\" has no default value",name);
return;
}
- default_value = apr_pstrdup(ctx->pool,dchild_node->txt);
+ dimension->default_value = apr_pstrdup(ctx->pool,dchild_node->txt);
dchild_node = ezxml_child(dimension_node,"values");
if(!dchild_node || !dchild_node->txt) {
@@ -237,9 +244,6 @@
return;
}
values = apr_pstrdup(ctx->pool,dchild_node->txt);
- geocache_dimension_values *dimension = geocache_dimension_values_create(ctx->pool);
- dimension->dimension.name = name;
- dimension->dimension.default_value = default_value;
for(key=values;*key;key++) if(*key == ',') count++;
dimension->values = (char**)apr_pcalloc(ctx->pool,count*sizeof(char*));
@@ -253,7 +257,7 @@
ctx->set_error(ctx, GEOCACHE_PARSE_ERROR, "<dimension> \"%s\" has no values",name);
return;
}
- APR_ARRAY_PUSH(dimensions,geocache_dimension*) = (geocache_dimension*)dimension;
+ APR_ARRAY_PUSH(dimensions,geocache_dimension*) = dimension;
}
if(apr_is_empty_array(dimensions)) {
ctx->set_error(ctx, GEOCACHE_PARSE_ERROR, "<dimensions> for tileset \"%s\" has no dimensions defined (expecting <dimension> children)",tileset->name);
Modified: trunk/mapserver/mapcache/src/dimension.c
===================================================================
--- trunk/mapserver/mapcache/src/dimension.c 2011-08-26 11:10:36 UTC (rev 12246)
+++ trunk/mapserver/mapcache/src/dimension.c 2011-08-26 11:10:43 UTC (rev 12247)
@@ -16,27 +16,31 @@
#include "geocache.h"
-
-int _geocache_dimension_values_validate(geocache_context *ctx, geocache_dimension *dimension, const char *value) {
+int _geocache_dimension_validate(geocache_context *ctx, geocache_dimension *dim, const char *value) {
int i;
- geocache_dimension_values *dim = (geocache_dimension_values*)dimension;
-#ifdef DEBUG
- if(dimension->type != GEOCACHE_DIMENSION_VALUES) {
- ctx->set_error(ctx, GEOCACHE_ERROR, "##### BUG ###### dimension values 1");
- return;
+ if(dim->unit && !strcmp(dim->unit,"ISO8601")) {
+ for(i=0;i<dim->nvalues;i++) {
+ if(!strcmp(value,dim->values[i]))
+ return GEOCACHE_SUCCESS;
+ }
+ } else if(dim->unit && !strcmp(dim->unit,"m")) {
+ for(i=0;i<dim->nvalues;i++) {
+ if(!strcmp(value,dim->values[i]))
+ return GEOCACHE_SUCCESS;
+ }
+ } else {
+ for(i=0;i<dim->nvalues;i++) {
+ if(!strcmp(value,dim->values[i]))
+ return GEOCACHE_SUCCESS;
+ }
}
-#endif
- for(i=0;i<dim->nvalues;i++) {
- if(!strcmp(value,dim->values[i]))
- return GEOCACHE_SUCCESS;
- }
return GEOCACHE_FAILURE;
}
-geocache_dimension_values* geocache_dimension_values_create(apr_pool_t *pool) {
- geocache_dimension_values *dimension = apr_pcalloc(pool, sizeof(geocache_dimension_values));
- dimension->dimension.type = GEOCACHE_DIMENSION_VALUES;
+
+geocache_dimension* geocache_dimension_create(apr_pool_t *pool) {
+ geocache_dimension *dimension = apr_pcalloc(pool, sizeof(geocache_dimension));
dimension->nvalues = 0;
- dimension->dimension.validate = _geocache_dimension_values_validate;
+ dimension->validate = _geocache_dimension_validate;
return dimension;
}
Modified: trunk/mapserver/mapcache/src/service_wms.c
===================================================================
--- trunk/mapserver/mapcache/src/service_wms.c 2011-08-26 11:10:36 UTC (rev 12246)
+++ trunk/mapserver/mapcache/src/service_wms.c 2011-08-26 11:10:43 UTC (rev 12247)
@@ -21,7 +21,7 @@
/** @{ */
-static char *wms_capabilities_preamble = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"no\" ?>\n"
+static char *wms_capabilities_preamble = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n"
"<!DOCTYPE WMT_MS_Capabilities SYSTEM\n"
"\"http://schemas.opengeospatial.net/wms/1.1.1/WMS_MS_Capabilities.dtd\" [\n"
"<!ELEMENT VendorSpecificCapabilities (TileSet*) >\n"
@@ -79,6 +79,7 @@
"<Title>%s</Title>\n"
"<Abstract>%s</Abstract>\n"
"<SRS>%s</SRS>\n"
+ "%s"
"<BoundingBox srs=\"%s\" minx=\"%f\" miny=\"%f\" maxx=\"%f\" maxy=\"%f\" />\n"
"</Layer>\n";
@@ -108,6 +109,7 @@
const void *key; apr_ssize_t keylen;
apr_hash_this(tileindex_index,&key,&keylen,(void**)&tileset);
char *resolutions="";
+
int i;
for(i=0;i<tileset->grid->levels;i++) {
resolutions = apr_psprintf(ctx->pool,"%s%.20f ",resolutions,tileset->grid->resolutions[i]);
@@ -145,11 +147,34 @@
if(!abstract) {
abstract = "no abstract set, add some in metadata";
}
+ char *dimensions = "";
+ if(tileset->dimensions) {
+ int i;
+ for(i=0;i<tileset->dimensions->nelts;i++) {
+ geocache_dimension *dimension = APR_ARRAY_IDX(tileset->dimensions,i,geocache_dimension*);
+ dimensions = apr_psprintf(ctx->pool,"%s"
+ "<Dimension name=\"%s\" default=\"%s\"",
+ dimensions,
+ dimension->name,
+ dimension->default_value);
+ if(dimension->unit) {
+ dimensions = apr_pstrcat(ctx->pool,dimensions,
+ " units=\"%s\"",dimension->unit,NULL);
+ }
+ dimensions = apr_pstrcat(ctx->pool,dimensions,">",dimension->values[0],NULL);
+ int j;
+ for(j=1;j<dimension->nvalues;j++) {
+ dimensions = apr_pstrcat(ctx->pool,dimensions,",",dimension->values[j],NULL);
+ }
+ dimensions = apr_pstrcat(ctx->pool,dimensions,"</Dimension>\n",NULL);
+ }
+ }
char *layercaps = apr_psprintf(ctx->pool,wms_layer,
tileset->name,
title,
abstract,
tileset->grid->srs,
+ dimensions,
tileset->grid->srs,
tileset->grid->extents[0][0],
tileset->grid->extents[0][1],
Modified: trunk/mapserver/mapcache/src/service_wmts.c
===================================================================
--- trunk/mapserver/mapcache/src/service_wmts.c 2011-08-26 11:10:36 UTC (rev 12246)
+++ trunk/mapserver/mapcache/src/service_wmts.c 2011-08-26 11:10:43 UTC (rev 12247)
@@ -180,6 +180,30 @@
if(!abstract) {
abstract = "no abstract set, add some in metadata";
}
+
+ char *dimensions="";
+ if(tileset->dimensions) {
+ int i;
+ for(i=0;i<tileset->dimensions->nelts;i++) {
+ geocache_dimension *dimension = APR_ARRAY_IDX(tileset->dimensions,i,geocache_dimension*);
+ dimensions = apr_psprintf(ctx->pool,"%s"
+ " <Dimension>\n"
+ " <ows:Identifier>%s</ows:Identifier>\n"
+ " <Default>%s</Default>\n",
+ dimensions,
+ dimension->name,
+ dimension->default_value);
+ if(dimension->unit) {
+ dimension = apr_pstrcat(ctx->pool,dimension,
+ " <UOM>",dimension->unit,"</UOM>\n",NULL);
+ }
+ int i = dimension->nvalues;
+ while(i--) {
+ dimensions = apr_pstrcat(ctx->pool,dimensions," <Value>",dimension->values[i],"</Value>\n",NULL);
+ }
+ dimensions = apr_pstrcat(ctx->pool,dimensions," </Dimension>\n",NULL);
+ }
+ }
caps = apr_psprintf(ctx->pool,"%s"
" <Layer>\n"
@@ -193,12 +217,13 @@
" <Style isDefault=\"true\">\n"
" <ows:Identifier>_null</ows:Identifier>\n"
" </Style>\n"
+ "%s" /*dimensions*/
" <Format>%s</Format>\n"
" <TileMatrixSetLink>\n"
" <TileMatrixSet>%s</TileMatrixSet>\n"
" </TileMatrixSetLink>\n"
- " </Layer>",caps,title,abstract,
- tileset->name,tileset->format->mime_type,tileset->grid->name);
+ " </Layer>\n",caps,title,abstract,
+ tileset->name,dimensions,tileset->format->mime_type,tileset->grid->name);
layer_index = apr_hash_next(layer_index);
}
caps = apr_pstrcat(ctx->pool,caps,"</Contents>\n</Capabilities>\n",NULL);
@@ -357,6 +382,28 @@
row = matrixheight-row-1;
+ /*look for dimensions*/
+ if(tileset->dimensions) {
+ int i;
+ req->tiles[0]->dimensions = apr_table_make(ctx->pool,tileset->dimensions->nelts);
+ for(i=0;i<tileset->dimensions->nelts;i++) {
+ geocache_dimension *dimension = APR_ARRAY_IDX(tileset->dimensions,i,geocache_dimension*);
+ const char *value;
+ if((value = apr_table_get(params,dimension->name)) != NULL) {
+ int ok = dimension->validate(ctx,dimension,value);
+ GC_CHECK_ERROR(ctx);
+ if(ok == GEOCACHE_SUCCESS)
+ apr_table_setn(req->tiles[0]->dimensions,dimension->name,value);
+ else {
+ ctx->set_error(ctx,GEOCACHE_REQUEST_ERROR,"dimension \"%s\" value \"%s\" fails to validate",
+ dimension->name, value);
+ return;
+ }
+ } else {
+ apr_table_setn(req->tiles[0]->dimensions,dimension->name,dimension->default_value);
+ }
+ }
+ }
req->tiles[0]->x = col;
More information about the mapserver-commits
mailing list