Skip to content

Commit f9b05a4

Browse files
committed
add configuration, use correct DIM_* KVP for WMS
1 parent 26ea399 commit f9b05a4

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

lib/configuration_xml.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ void parseDimensions(mapcache_context *ctx, ezxml_t node, mapcache_tileset *tile
9696
char *name = (char*)ezxml_attr(dimension_node,"name");
9797
char *type = (char*)ezxml_attr(dimension_node,"type");
9898
char *unit = (char*)ezxml_attr(dimension_node,"unit");
99+
char *skip_validation = (char*)ezxml_attr(dimension_node,"skip_validation");
99100
char *default_value = (char*)ezxml_attr(dimension_node,"default");
100101

101102
mapcache_dimension *dimension = NULL;
@@ -112,6 +113,8 @@ void parseDimensions(mapcache_context *ctx, ezxml_t node, mapcache_tileset *tile
112113
dimension = mapcache_dimension_regex_create(ctx->pool);
113114
} else if(!strcmp(type,"intervals")) {
114115
dimension = mapcache_dimension_intervals_create(ctx->pool);
116+
} else if(!strcmp(type,"sqlite")) {
117+
dimension = mapcache_dimension_sqlite_create(ctx->pool);
115118
} else if(!strcmp(type,"time")) {
116119
ctx->set_error(ctx,501,"time dimension type not implemented yet");
117120
return;
@@ -130,6 +133,10 @@ void parseDimensions(mapcache_context *ctx, ezxml_t node, mapcache_tileset *tile
130133
if(unit && *unit) {
131134
dimension->unit = apr_pstrdup(ctx->pool,unit);
132135
}
136+
137+
if(skip_validation && !strcmp(skip_validation,"true")) {
138+
dimension->skip_validation = MAPCACHE_TRUE;
139+
}
133140

134141
if(default_value && *default_value) {
135142
dimension->default_value = apr_pstrdup(ctx->pool,default_value);

lib/service_wms.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -639,17 +639,28 @@ void _mapcache_service_wms_parse_request(mapcache_context *ctx, mapcache_service
639639
const char *value;
640640
if(tileset->dimensions) {
641641
for(i=0; i<tileset->dimensions->nelts; i++) {
642+
char *dim_name;
642643
mapcache_dimension *dimension = APR_ARRAY_IDX(tileset->dimensions,i,mapcache_dimension*);
643-
if((value = (char*)apr_table_get(params,dimension->name)) != NULL) {
644+
if(!strcasecmp(dimension->name,"TIME") || !strcasecmp(dimension->name,"ELEVATION")) {
645+
dim_name = dimension->name;
646+
} else {
647+
dim_name = apr_pstrcat(ctx->pool, "dim_", dimension->name, NULL);
648+
}
649+
if((value = (char*)apr_table_get(params,dim_name)) != NULL) {
644650
char *tmpval = apr_pstrdup(ctx->pool,value);
645-
int ok = dimension->validate(ctx,dimension,&tmpval);
646-
GC_CHECK_ERROR(ctx);
651+
int ok;
652+
if(dimension->skip_validation) {
653+
ok = MAPCACHE_SUCCESS;
654+
} else {
655+
ok = dimension->validate(ctx,dimension,&tmpval);
656+
GC_CHECK_ERROR(ctx);
657+
}
647658
if(ok == MAPCACHE_SUCCESS)
648659
apr_table_setn(dimtable,dimension->name,tmpval);
649660
else {
650661
errcode = 400;
651662
errmsg = apr_psprintf(ctx->pool, "dimension \"%s\" value \"%s\" fails to validate",
652-
dimension->name, value);
663+
dim_name, value);
653664
goto proxies;
654665
}
655666
}

lib/service_wmts.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -780,19 +780,20 @@ void _mapcache_service_wmts_parse_request(mapcache_context *ctx, mapcache_servic
780780
for(i=0; i<tileset->dimensions->nelts; i++) {
781781
char *tmpval;
782782
int ok;
783+
const char *value;
783784
mapcache_dimension *dimension = APR_ARRAY_IDX(tileset->dimensions,i,mapcache_dimension*);
784-
const char *value = apr_table_get(dimtable,dimension->name);
785+
if(dimension->skip_validation) continue;
786+
value = apr_table_get(dimtable,dimension->name);
785787
if(value) {
786788
tmpval = apr_pstrdup(ctx->pool,value);
787789
ok = dimension->validate(ctx,dimension,&tmpval);
788790
GC_CHECK_ERROR(ctx);
789791
if(ok != MAPCACHE_SUCCESS) {
790792
ctx->set_error(ctx,404,"dimension \"%s\" value \"%s\" fails to validate",
791-
dimension->name, value);
793+
dimension->name, value);
792794
if(kvp) ctx->set_exception(ctx,"InvalidParameterValue","%s",dimension->name);
793795
return;
794796
}
795-
796797
/* re-set the eventually modified value in the dimension table */
797798
apr_table_set(dimtable,dimension->name,tmpval);
798799
}

0 commit comments

Comments
 (0)