Permalink
Browse files

Fix rectObj/shapeObj draw function rendering when setting text proper…

…ty in mapscript (closes #4577)
  • Loading branch information...
1 parent ecf401d commit 44cfa8308e5930a435c0864c37325043eee02010 Alan Boudreault committed Feb 7, 2013
Showing with 10 additions and 4 deletions.
  1. +8 −0 mapdraw.c
  2. +1 −3 mapscript/php/mapscript_i.c
  3. +1 −1 mapscript/swiginc/rect.i
View
@@ -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 */
@@ -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);
@@ -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);

0 comments on commit 44cfa83

Please sign in to comment.