New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msDrawShape does not set labelObj annotext #4577

Closed
akrherz opened this Issue Jan 30, 2013 · 3 comments

Comments

Projects
None yet
3 participants
@akrherz
Contributor

akrherz commented Jan 30, 2013

Below is a example of rectObj->draw not placing any labels. I believe the problem is that msDrawShape does not set the labelObj's annotext, here's a suggested patch (I am not at all confident about this patch!)

diff --git a/mapdraw.c b/mapdraw.c
index acd6e4f..6acc305 100644
--- a/mapdraw.c
+++ b/mapdraw.c
@@ -1963,6 +1963,7 @@ int polygonLayerDrawShape(mapObj *map, imageObj *image, layerObj *layer,
 int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, int style, int drawmode)
 {
   int c,s,ret=MS_SUCCESS;
+  labelObj *label=NULL;
   shapeObj *anno_shape, *unclipped_shape = shape;
   int bNeedUnclippedShape = MS_FALSE;
   int bNeedUnclippedAnnoShape = MS_FALSE;
@@ -1973,6 +1974,17 @@ int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image,
   msDrawStartShape(map, layer, image, shape);
   c = shape->classindex;

+  if(shape->text && layer->class[c]->numlabels > 0) {
+    label = layer->class[c]->labels[0];
+
+    msFree(label->annotext); /* free any previously allocated annotation text */
+    if(shape->text && (label->encoding || label->wrap || label->maxlength))
+      label->annotext = msTransformLabelText(map,label,shape->text); /* apply wrap character and encoding to the label text *
+    else
+      label->annotext = msStrdup(shape->text);
+  }
+
+
   /* 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 */

rect.map

MAP

NAME base4326
STATUS ON
SIZE 640 480
EXTENT -104 37 -87 49
UNITS DD

CONFIG "MS_ERRORFILE" "/tmp/ms_error.txt"
CONFIG "CPL_DEBUG" "ON"
CONFIG "PROJ_DEBUG" "ON"
DEBUG 5

LAYER
  DEBUG 5
  NAME rect
  TYPE POLYGON
  TRANSFORM FALSE
  STATUS ON
  LABELCACHE FALSE
  CLASS
      LABEL
       OFFSET 25 25
       COLOR 0 0 0
       OUTLINECOLOR 255 255 255
       SIZE 50
       TYPE BITMAP
       SIZE LARGE
      END
      STYLE
        COLOR 255 255 255
        OUTLINECOLOR 0 0 0
      END
  END
END

END

rect.php

$map = ms_newMapObj('rect.map');

$img = $map->prepareImage();

$layer = $map->getLayerByName("rect");

$rect = ms_newRectObj();
$rect->setextent(200,200,100,100);
$bol = $rect->draw($map, $layer, $img, 0, "TEST");

header("Content-type: image/png");
$img->saveImage('');
@aboudreault

This comment has been minimized.

Show comment
Hide comment
@aboudreault

aboudreault Feb 6, 2013

Member

@akrherz I prefered to fix this in php/mapscript since it seems that all the work of setting the label should be done before msDrawShape. I think swig mapscript has the same bug. Will verify this tomorrow.

Member

aboudreault commented Feb 6, 2013

@akrherz I prefered to fix this in php/mapscript since it seems that all the work of setting the label should be done before msDrawShape. I think swig mapscript has the same bug. Will verify this tomorrow.

aboudreault pushed a commit that referenced this issue Feb 7, 2013

mkofahl pushed a commit to faegi/mapserver that referenced this issue Apr 9, 2013

mkofahl pushed a commit to faegi/mapserver that referenced this issue Apr 9, 2013

mkofahl pushed a commit to faegi/mapserver that referenced this issue Apr 9, 2013

mkofahl pushed a commit to faegi/mapserver that referenced this issue Apr 9, 2013

@tbonfort

This comment has been minimized.

Show comment
Hide comment
@tbonfort

tbonfort Apr 13, 2013

Member

@aboudreault : you first stated "I prefered to fix this in php/mapscript since it seems that all the work of setting the label should be done before msDrawShape." but your fix was to add mapscript specific workarounds in mapdraw.c, which I dislike. Re-opening until this is clarified.

Member

tbonfort commented Apr 13, 2013

@aboudreault : you first stated "I prefered to fix this in php/mapscript since it seems that all the work of setting the label should be done before msDrawShape." but your fix was to add mapscript specific workarounds in mapdraw.c, which I dislike. Re-opening until this is clarified.

@tbonfort tbonfort reopened this Apr 13, 2013

tbonfort added a commit to tbonfort/mapserver that referenced this issue Apr 18, 2013

@tbonfort

This comment has been minimized.

Show comment
Hide comment
@tbonfort

tbonfort Apr 18, 2013

Member

I have moved the fix out of libmapserver in 0fb99fc, as this issue was holding on the release of 6.2.1

@aboudreault: please, no mapscript specific workarounds inside libmapserver
@sdlime: I think we're ready to release 6.2.1 :shipit:

Member

tbonfort commented Apr 18, 2013

I have moved the fix out of libmapserver in 0fb99fc, as this issue was holding on the release of 6.2.1

@aboudreault: please, no mapscript specific workarounds inside libmapserver
@sdlime: I think we're ready to release 6.2.1 :shipit:

@tbonfort tbonfort closed this Apr 18, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment