Skip to content

Commit

Permalink
Fix rectObj/shapeObj draw function rendering when setting text proper…
Browse files Browse the repository at this point in the history
…ty in mapscript (closes #4577)
  • Loading branch information
Alan Boudreault committed Feb 7, 2013
1 parent ecf401d commit 44cfa83
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 8 additions & 0 deletions mapdraw.c
Expand Up @@ -1973,6 +1973,14 @@ int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image,
msDrawStartShape(map, layer, image, shape);
c = shape->classindex;

/* When creating a shape in mapscript and setting the shape.text directly, the
text rendering fails without this #4577. If annotext of the first label is
not null, msShapeGetAnnotation has already been called: do nothing */
if(layer->class[c]->numlabels > 0 && shape->text &&
(layer->class[c]->labels[0] && layer->class[c]->labels[0]->annotext==NULL)) {
msShapeGetAnnotation(layer, shape);
}

/* Before we do anything else, we will check for a rangeitem.
If its there, we need to change the style's color to map
the range to the shape */
Expand Down
4 changes: 1 addition & 3 deletions mapscript/php/mapscript_i.c
Expand Up @@ -1478,10 +1478,8 @@ int rectObj_draw(rectObj *self, mapObj *map, layerObj *layer,
msRectToPolygon(*self, &shape);
shape.classindex = classindex;

if (text) {
if (text)
shape.text = strdup(text);
msShapeGetAnnotation(layer, &shape);
}

msDrawShape(map, layer, &shape, img, -1, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS);

Expand Down
2 changes: 1 addition & 1 deletion mapscript/swiginc/rect.i
Expand Up @@ -91,7 +91,7 @@
msRectToPolygon(*self, &shape);
shape.classindex = classindex;
shape.text = strdup(text);

msDrawShape(map, layer, &shape, image, -1, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS);

msFreeShape(&shape);
Expand Down

0 comments on commit 44cfa83

Please sign in to comment.