Skip to content

Commit

Permalink
Allow attribute references, that is [itemname], within a TEXT string (#…
Browse files Browse the repository at this point in the history
…3736)

git-svn-id: http://svn.osgeo.org/mapserver/trunk@11160 7532c77e-422f-0410-93f4-f0b67bdd69e2
  • Loading branch information
sdlime committed Mar 15, 2011
1 parent 1c1c613 commit 3cc3a1a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
2 changes: 2 additions & 0 deletions HISTORY.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ For a complete change history, please see the Subversion log comments.
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)
Expand Down
9 changes: 5 additions & 4 deletions maplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ int msTokenizeExpression(expressionObj *expression, char **list, int *listsize)
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;
Expand Down Expand Up @@ -515,7 +515,7 @@ int msLayerWhichItems(layerObj *layer, int get_all, char *metadata)

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, '[');
}

Expand Down Expand Up @@ -561,9 +561,10 @@ int msLayerWhichItems(layerObj *layer, int get_all, char *metadata)
}

/* 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 */
Expand Down
24 changes: 21 additions & 3 deletions maputil.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@
* DEALINGS IN THE SOFTWARE.
*****************************************************************************/


#include <time.h>

#include "mapserver.h"
#include "maptime.h"
#include "mapthread.h"
#include "mapcopy.h"


#if defined(_WIN32) && !defined(__CYGWIN__)
# include <windows.h>
# include <tchar.h>
Expand Down Expand Up @@ -546,7 +544,27 @@ char *msShapeGetAnnotation(layerObj *layer, shapeObj *shape)
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):
{
Expand Down

0 comments on commit 3cc3a1a

Please sign in to comment.