[mapserver-commits] r11160 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Tue Mar 15 15:15:37 EDT 2011
Author: sdlime
Date: 2011-03-15 12:15:37 -0700 (Tue, 15 Mar 2011)
New Revision: 11160
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/maplayer.c
trunk/mapserver/maputil.c
Log:
Allow attribute references, that is [itemname], within a TEXT string (#3736)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2011-03-15 19:11:59 UTC (rev 11159)
+++ trunk/mapserver/HISTORY.TXT 2011-03-15 19:15:37 UTC (rev 11160)
@@ -14,6 +14,8 @@
Current Version (SVN trunk):
----------------------------
+- Allow attribute references, that is [itemname], within a TEXT string (#3736)
+
- Fixed segmentation fault when parsing invalid extent arguments in shp2img (#3734)
- Make "openlayers mode" work even without OWS support (#3732)
Modified: trunk/mapserver/maplayer.c
===================================================================
--- trunk/mapserver/maplayer.c 2011-03-15 19:11:59 UTC (rev 11159)
+++ trunk/mapserver/maplayer.c 2011-03-15 19:15:37 UTC (rev 11160)
@@ -356,7 +356,7 @@
int token;
/* TODO: make sure the constants can't somehow reference invalid expression types */
- if(expression->type != MS_EXPRESSION && expression->type != MS_GEOMTRANSFORM_EXPRESSION) return MS_SUCCESS;
+ // if(expression->type != MS_EXPRESSION && expression->type != MS_GEOMTRANSFORM_EXPRESSION) return MS_SUCCESS;
msAcquireLock(TLOCK_PARSER);
msyystate = MS_TOKENIZE_EXPRESSION;
@@ -515,7 +515,7 @@
nt += layer->class[i]->label.numbindings;
- if(layer->class[i]->text.type == MS_EXPRESSION)
+ if(layer->class[i]->text.type == MS_EXPRESSION || (layer->class[i]->text.string && strchr(layer->class[i]->text.string,'[') != NULL && strchr(layer->class[i]->text.string,']') != NULL))
nt += msCountChars(layer->class[i]->text.string, '[');
}
@@ -561,9 +561,10 @@
}
/* class text and label bindings */
- if(layer->class[i]->text.type == MS_EXPRESSION) msTokenizeExpression(&(layer->class[i]->text), layer->items, &(layer->numitems));
+ if(layer->class[i]->text.type == MS_EXPRESSION || (layer->class[i]->text.string && strchr(layer->class[i]->text.string,'[') != NULL && strchr(layer->class[i]->text.string,']') != NULL))
+ msTokenizeExpression(&(layer->class[i]->text), layer->items, &(layer->numitems));
for(k=0; k<MS_LABEL_BINDING_LENGTH; k++)
- if(layer->class[i]->label.bindings[k].item) layer->class[i]->label.bindings[k].index = string2list(layer->items, &(layer->numitems), layer->class[i]->label.bindings[k].item);
+ if(layer->class[i]->label.bindings[k].item) layer->class[i]->label.bindings[k].index = string2list(layer->items, &(layer->numitems), layer->class[i]->label.bindings[k].item);
}
/* layer filter */
Modified: trunk/mapserver/maputil.c
===================================================================
--- trunk/mapserver/maputil.c 2011-03-15 19:11:59 UTC (rev 11159)
+++ trunk/mapserver/maputil.c 2011-03-15 19:15:37 UTC (rev 11160)
@@ -31,7 +31,6 @@
* DEALINGS IN THE SOFTWARE.
*****************************************************************************/
-
#include <time.h>
#include "mapserver.h"
@@ -39,7 +38,6 @@
#include "mapthread.h"
#include "mapcopy.h"
-
#if defined(_WIN32) && !defined(__CYGWIN__)
# include <windows.h>
# include <tchar.h>
@@ -546,7 +544,27 @@
if(layer->class[shape->classindex]->text.string) { /* test for global label first */
switch(layer->class[shape->classindex]->text.type) {
case(MS_STRING):
- tmpstr = msStrdup(layer->class[shape->classindex]->text.string);
+ {
+ char *target=NULL;
+ tokenListNodeObjPtr node=NULL;
+ tokenListNodeObjPtr nextNode=NULL;
+
+ tmpstr = msStrdup(layer->class[shape->classindex]->text.string);
+
+ node = layer->class[shape->classindex]->text.tokens;
+ if(node) {
+ while(node != NULL) {
+ nextNode = node->next;
+ if(node->token == MS_TOKEN_BINDING_DOUBLE || node->token == MS_TOKEN_BINDING_INTEGER || node->token == MS_TOKEN_BINDING_STRING || node->token == MS_TOKEN_BINDING_TIME) {
+ target = (char *) msSmallMalloc(strlen(node->tokenval.bindval.item) + 3);
+ sprintf(target, "[%s]", node->tokenval.bindval.item);
+ tmpstr = msReplaceSubstring(tmpstr, target, shape->values[node->tokenval.bindval.index]);
+ msFree(target);
+ }
+ node = nextNode;
+ }
+ }
+ }
break;
case(MS_EXPRESSION):
{
More information about the mapserver-commits
mailing list