MCPcopy Index your code
hub / github.com/MapServer/MapServer / msShapeGetAnnotation

Function msShapeGetAnnotation

maputil.c:569–627  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

567}
568
569char *msShapeGetAnnotation(layerObj *layer, shapeObj *shape)
570{
571 char *tmpstr=NULL;
572
573 if(layer->class[shape->classindex]->text.string) { /* test for global label first */
574 switch(layer->class[shape->classindex]->text.type) {
575 case(MS_STRING):
576 {
577 char *target=NULL;
578 tokenListNodeObjPtr node=NULL;
579 tokenListNodeObjPtr nextNode=NULL;
580
581 tmpstr = msStrdup(layer->class[shape->classindex]->text.string);
582
583 node = layer->class[shape->classindex]->text.tokens;
584 if(node) {
585 while(node != NULL) {
586 nextNode = node->next;
587 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) {
588 target = (char *) msSmallMalloc(strlen(node->tokenval.bindval.item) + 3);
589 sprintf(target, "[%s]", node->tokenval.bindval.item);
590 tmpstr = msReplaceSubstring(tmpstr, target, shape->values[node->tokenval.bindval.index]);
591 msFree(target);
592 }
593 node = nextNode;
594 }
595 }
596 }
597 break;
598 case(MS_EXPRESSION):
599 {
600 int status;
601 parseObj p;
602
603 p.shape = shape;
604 p.expr = &(layer->class[shape->classindex]->text);
605 p.expr->curtoken = p.expr->tokens; /* reset */
606 p.type = MS_PARSE_TYPE_STRING;
607
608 status = yyparse(&p);
609
610 if (status != 0) {
611 msSetError(MS_PARSEERR, "Failed to process text expression: %s", "msShapeGetAnnotation", layer->class[shape->classindex]->text.string);
612 return NULL;
613 }
614
615 tmpstr = p.result.strval;
616 break;
617 }
618 default:
619 break;
620 }
621 } else {
622 if (shape->values && layer->labelitemindex >= 0)
623 tmpstr = msStrdup(shape->values[layer->labelitemindex]);
624 }
625
626 return(tmpstr);

Callers 5

msDrawVectorLayerFunction · 0.85
msDrawQueryLayerFunction · 0.85
processFeatureTagFunction · 0.85
msOGRWriteFromQueryFunction · 0.85
msUnionLayerNextShapeFunction · 0.85

Calls 6

msStrdupFunction · 0.85
msSmallMallocFunction · 0.85
msReplaceSubstringFunction · 0.85
msFreeFunction · 0.85
yyparseFunction · 0.85
msSetErrorFunction · 0.85

Tested by

no test coverage detected