[mapserver-commits] r8608 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Mon Feb 23 23:17:12 EST 2009


Author: sdlime
Date: 2009-02-23 23:17:12 -0500 (Mon, 23 Feb 2009)
New Revision: 8608

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapdraw.c
   trunk/mapserver/maplabel.c
   trunk/mapserver/maplegend.c
   trunk/mapserver/mapscale.c
   trunk/mapserver/mapserver.h
Log:
Fixed issue with POSITION AUTO and ANNOTATION layers... (#2770).

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2009-02-23 19:07:54 UTC (rev 8607)
+++ trunk/mapserver/HISTORY.TXT	2009-02-24 04:17:12 UTC (rev 8608)
@@ -12,6 +12,9 @@
 Current Version (SVN trunk):
 ----------------------------
 
+- Tracking original geometry type so we can make better decisions on what
+  positions to use with POSITION AUTO and annotation layers. (#2770)
+
 - Setting up the same size units between the OGR auto-style and the 
   OGR label attribute binding option (#2900)
 

Modified: trunk/mapserver/mapdraw.c
===================================================================
--- trunk/mapserver/mapdraw.c	2009-02-23 19:07:54 UTC (rev 8607)
+++ trunk/mapserver/mapdraw.c	2009-02-24 04:17:12 UTC (rev 8608)
@@ -1517,7 +1517,7 @@
           labelObj label = layer->class[c]->label;
           
           if(layer->labelcache) {
-            if(msAddLabel(map, layer->index, c, shape->index, shape->tileindex, NULL, annopath, shape->text, length, &label) != MS_SUCCESS) return(MS_FAILURE);
+            if(msAddLabel(map, layer->index, c, shape, NULL, annopath, shape->text, length, &label) != MS_SUCCESS) return(MS_FAILURE);
           } else {
             /* FIXME: Not sure how this should work with the label path yet */
             /*
@@ -1549,7 +1549,7 @@
 	  if(label.autoangle) label.angle = angle;
 
           if(layer->labelcache) {
-            if(msAddLabel(map, layer->index, c, shape->index, shape->tileindex, &annopnt, NULL, shape->text, length, &label) != MS_SUCCESS) return(MS_FAILURE);
+            if(msAddLabel(map, layer->index, c, shape, &annopnt, NULL, shape->text, length, &label) != MS_SUCCESS) return(MS_FAILURE);
 	  } else {
             if(layer->class[c]->numstyles > 0 && MS_VALID_COLOR(layer->class[c]->styles[0]->color)) {
               for(s=0; s<layer->class[c]->numstyles; s++) {
@@ -1593,7 +1593,7 @@
           label.angle -= map->gt.rotation_angle;
 
         if(layer->labelcache) {
-          if(msAddLabel(map, layer->index, c, shape->index, shape->tileindex, &annopnt, NULL, shape->text, MS_MIN(shape->bounds.maxx-shape->bounds.minx,shape->bounds.maxy-shape->bounds.miny), &label) != MS_SUCCESS) return(MS_FAILURE);
+          if(msAddLabel(map, layer->index, c, shape, &annopnt, NULL, shape->text, MS_MIN(shape->bounds.maxx-shape->bounds.minx,shape->bounds.maxy-shape->bounds.miny), &label) != MS_SUCCESS) return(MS_FAILURE);
         } else {
 	  if(layer->class[c]->numstyles > 0 && MS_VALID_COLOR(layer->class[c]->styles[0]->color)) {
         for(s=0; s<layer->class[c]->numstyles; s++) {
@@ -1630,7 +1630,7 @@
 
 	  if(shape->text) {
 	    if(layer->labelcache) {
-	      if(msAddLabel(map, layer->index, c, shape->index, shape->tileindex, point, NULL, shape->text, -1, &label) != MS_SUCCESS) return(MS_FAILURE);
+	      if(msAddLabel(map, layer->index, c, shape, point, NULL, shape->text, -1, &label) != MS_SUCCESS) return(MS_FAILURE);
 	    } else {
 	      if(layer->class[c]->numstyles > 0 && MS_VALID_COLOR(layer->class[c]->styles[0]->color)) {
             for(s=0; s<layer->class[c]->numstyles; s++) {
@@ -1690,7 +1690,7 @@
             label.angle -= map->gt.rotation_angle;
 
 	  if(layer->labelcache) {
-	    if(msAddLabel(map, layer->index, c, shape->index, shape->tileindex, point, NULL, shape->text, -1, &label) != MS_SUCCESS) return(MS_FAILURE);
+	    if(msAddLabel(map, layer->index, c, shape, point, NULL, shape->text, -1, &label) != MS_SUCCESS) return(MS_FAILURE);
 	  } else
 	    msDrawLabel(map, image, *point, shape->text, &label, layer->scalefactor);
 	}
@@ -1793,7 +1793,7 @@
           labelObj label = layer->class[c]->label;
 
           if(layer->labelcache) {
-            if(msAddLabel(map, layer->index, c, shape->index, shape->tileindex, NULL, annopath, shape->text, length, &label) != MS_SUCCESS) return(MS_FAILURE);
+            if(msAddLabel(map, layer->index, c, shape, NULL, annopath, shape->text, length, &label) != MS_SUCCESS) return(MS_FAILURE);
           } else {
             /* FIXME: need to call msDrawTextLineGD() from here eventually */
             /* msDrawLabel(image, label_line->point[0], shape->text, &label, &map->fontset, layer->scalefactor); */
@@ -1816,7 +1816,7 @@
 	if(label.autoangle) label.angle = angle;
 
 	if(layer->labelcache) {
-            if(msAddLabel(map, layer->index, c, shape->index, shape->tileindex, &annopnt, NULL, shape->text, length, &label) != MS_SUCCESS) return(MS_FAILURE);
+          if(msAddLabel(map, layer->index, c, shape, &annopnt, NULL, shape->text, length, &label) != MS_SUCCESS) return(MS_FAILURE);
 	} else
           msDrawLabel(map, image, annopnt, shape->text, &label, layer->scalefactor);
       }
@@ -1916,7 +1916,7 @@
           label.angle -= map->gt.rotation_angle;
 
 	if(layer->labelcache) {
-	  if(msAddLabel(map, layer->index, c, shape->index, shape->tileindex, &annopnt, NULL, shape->text, MS_MIN(shape->bounds.maxx-shape->bounds.minx,shape->bounds.maxy-shape->bounds.miny), &label) != MS_SUCCESS) return(MS_FAILURE);
+	  if(msAddLabel(map, layer->index, c, shape, &annopnt, NULL, shape->text, MS_MIN(shape->bounds.maxx-shape->bounds.minx,shape->bounds.maxy-shape->bounds.miny), &label) != MS_SUCCESS) return(MS_FAILURE);
 	} else
 	  msDrawLabel(map, image, annopnt, shape->text, &label, layer->scalefactor);
       }
@@ -1950,7 +1950,7 @@
     layer->project = MS_FALSE;
 #endif
   
-  /*apply wrap character and encoding to the label text*/
+  /* apply wrap character and encoding to the label text */
   if(labeltext &&(label->encoding || label->wrap || label->maxlength))
       newtext = msTransformLabelText(map,image,label,labeltext);
   else
@@ -1966,7 +1966,7 @@
 
     if(labeltext) {
       if(layer->labelcache) {
-        if(msAddLabel(map, layer->index, classindex, -1, -1, point, NULL, newtext, -1,NULL) != MS_SUCCESS) return(MS_FAILURE);
+        if(msAddLabel(map, layer->index, classindex, NULL, point, NULL, newtext, -1, NULL) != MS_SUCCESS) return(MS_FAILURE);
       } else {
 	if(theclass->numstyles > 0 && MS_VALID_COLOR(theclass->styles[0]->color)) {
       for(s=0; s<theclass->numstyles; s++) {
@@ -2005,7 +2005,7 @@
     }
     if(labeltext) {
       if(layer->labelcache) {
-        if(msAddLabel(map, layer->index, classindex, -1, -1, point, NULL, newtext, -1,NULL) != MS_SUCCESS) return(MS_FAILURE);
+        if(msAddLabel(map, layer->index, classindex, NULL, point, NULL, newtext, -1,NULL) != MS_SUCCESS) return(MS_FAILURE);
       } else
 	msDrawLabel(map, image, *point, newtext, label, layer->scalefactor);
     }
@@ -2380,10 +2380,10 @@
             if(labelPtr->position == MS_AUTO) {
               int positions[MS_POSITIONS_LENGTH], npositions=0;
 
-              if(layerPtr->type == MS_LAYER_POLYGON) {
+              if(layerPtr->type == MS_LAYER_POLYGON || (layerPtr->type == MS_LAYER_ANNOTATION && cachePtr->shapetype == MS_SHAPE_POLYGON)) {
 		positions[0]=MS_CC; positions[1]=MS_UC; positions[2]=MS_LC; positions[3]=MS_CL; positions[4]=MS_CR;
                 npositions = 5;
-              } else if(layerPtr->type == MS_LAYER_LINE) {
+              } else if(layerPtr->type == MS_LAYER_LINE || (layerPtr->type == MS_LAYER_ANNOTATION && cachePtr->shapetype == MS_SHAPE_LINE)) {
                 positions[0]=MS_UC; positions[1]=MS_LC; positions[2]=MS_CC;
                 npositions = 3;
               } else {

Modified: trunk/mapserver/maplabel.c
===================================================================
--- trunk/mapserver/maplabel.c	2009-02-23 19:07:54 UTC (rev 8607)
+++ trunk/mapserver/maplabel.c	2009-02-24 04:17:12 UTC (rev 8608)
@@ -308,7 +308,7 @@
     return newtext;
 }
 
-int msAddLabel(mapObj *map, int layerindex, int classindex, int shapeindex, int tileindex, pointObj *point, labelPathObj *labelpath, char *string, double featuresize, labelObj *label )
+int msAddLabel(mapObj *map, int layerindex, int classindex, shapeObj *shape, pointObj *point, labelPathObj *labelpath, char *string, double featuresize, labelObj *label )
 {
   int i;
   labelCacheSlotObj *cacheslot;
@@ -323,20 +323,20 @@
   classPtr = GET_LAYER(map, layerindex)->class[classindex];
 
   if( label == NULL )
-      label = &(classPtr->label);
+    label = &(classPtr->label);
 
   if(map->scaledenom > 0) {
     if((label->maxscaledenom != -1) && (map->scaledenom >= label->maxscaledenom))
-        return(MS_SUCCESS);
+      return(MS_SUCCESS);
     if((label->minscaledenom != -1) && (map->scaledenom < label->minscaledenom))
-        return(MS_SUCCESS);
+      return(MS_SUCCESS);
   }
 
   /* Validate label priority value and get ref on label cache for it */
   if (label->priority < 1)
-      label->priority = 1;
+    label->priority = 1;
   else if (label->priority > MS_MAX_LABEL_PRIORITY)
-      label->priority = MS_MAX_LABEL_PRIORITY;
+    label->priority = MS_MAX_LABEL_PRIORITY;
 
   cacheslot = &(map->labelcache.slots[label->priority-1]);
 
@@ -353,9 +353,16 @@
 
   cachePtr->layerindex = layerindex; /* so we can get back to this *raw* data if necessary */
   cachePtr->classindex = classindex;
-  cachePtr->tileindex = tileindex;
-  cachePtr->shapeindex = shapeindex;
 
+  if(shape) {
+    cachePtr->tileindex = shape->tileindex;
+    cachePtr->shapeindex = shape->index;
+    cachePtr->shapetype = shape->type;
+  } else {
+    cachePtr->tileindex = cachePtr->shapeindex = -1;    
+    cachePtr->shapetype = MS_SHAPE_POINT;
+  }
+
   /* Store the label point or the label path (Bug #1620) */
   if ( point ) {
     cachePtr->point = *point; /* the actual label point */
@@ -420,13 +427,13 @@
 
     /* TO DO: at the moment only checks the bottom style, perhaps should check all of them */
     /* #2347: after RFC-24 classPtr->styles could be NULL so we check it */
-    if (classPtr->styles != NULL) {
-	    if(msGetMarkerSize(&map->symbolset, classPtr->styles[0], &w, &h, layerPtr->scalefactor) != MS_SUCCESS)
-    	  return(MS_FAILURE);
+    if(classPtr->styles != NULL) {
+      if(msGetMarkerSize(&map->symbolset, classPtr->styles[0], &w, &h, layerPtr->scalefactor) != MS_SUCCESS) 
+        return(MS_FAILURE);
     } else {
-    	msSetError(MS_MISCERR, "msAddLabel error: missing style definition for layer '%s'", "msAddLabel()", layerPtr->name);
-		return(MS_FAILURE);
-	}
+      msSetError(MS_MISCERR, "msAddLabel error: missing style definition for layer '%s'", "msAddLabel()", layerPtr->name);
+      return(MS_FAILURE);
+    }
     rect.minx = MS_NINT(point->x - .5 * w);
     rect.miny = MS_NINT(point->y - .5 * h);
     rect.maxx = rect.minx + (w-1);
@@ -445,7 +452,6 @@
   return(MS_SUCCESS);
 }
 
-
 /* msTestLabelCacheCollisions()
 **
 ** Compares current label against labels already drawn and markers from cache and discards it

Modified: trunk/mapserver/maplegend.c
===================================================================
--- trunk/mapserver/maplegend.c	2009-02-23 19:07:54 UTC (rev 8607)
+++ trunk/mapserver/maplegend.c	2009-02-24 04:17:12 UTC (rev 8608)
@@ -495,10 +495,9 @@
   if(map->legend.postlabelcache) /* add it directly to the image */
     msDrawMarkerSymbol(&map->symbolset, img, &point, GET_LAYER(map, l)->class[0]->styles[0], 1.0);
   else
-    msAddLabel(map, l, 0, -1, -1, &point, NULL, " ", 1.0, NULL);
+    msAddLabel(map, l, 0, NULL, &point, NULL, " ", 1.0, NULL);
 
-  /* Mark layer as deleted so that it doesn't interfere with html legends or */
-  /* with saving maps */
+  /* Mark layer as deleted so that it doesn't interfere with html legends or with saving maps */
   GET_LAYER(map, l)->status = MS_DELETE;
 
   return(0);

Modified: trunk/mapserver/mapscale.c
===================================================================
--- trunk/mapserver/mapscale.c	2009-02-23 19:07:54 UTC (rev 8607)
+++ trunk/mapserver/mapscale.c	2009-02-24 04:17:12 UTC (rev 8608)
@@ -491,10 +491,9 @@
       msDrawMarkerSymbol(&map->symbolset, img, &point, GET_LAYER(map, l)->class[0]->styles[0], 1.0);
   }
   else
-    msAddLabel(map, l, 0, -1, -1, &point, NULL, " ", 1.0, NULL);
+    msAddLabel(map, l, 0, NULL, &point, NULL, " ", 1.0, NULL);
 
-  /* Mark layer as deleted so that it doesn't interfere with html legends or */
-  /* with saving maps */
+  /* Mark layer as deleted so that it doesn't interfere with html legends or with saving maps */
   GET_LAYER(map, l)->status = MS_DELETE;
 
   /* Free image (but keep the GD image which is in the symbol cache now) */

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2009-02-23 19:07:54 UTC (rev 8607)
+++ trunk/mapserver/mapserver.h	2009-02-24 04:17:12 UTC (rev 8608)
@@ -836,6 +836,8 @@
   int tileindex;
   int shapeindex;
 
+  int shapetype; /* source geometry type */
+
   pointObj point; /* label point */
   shapeObj *poly; /* label bounding box */
 
@@ -1732,7 +1734,7 @@
 MS_DLL_EXPORT int msFreeFontSet(fontSetObj *fontset);
 MS_DLL_EXPORT char *msTransformLabelText(mapObj *map, imageObj* image, labelObj *label, char *text);
 MS_DLL_EXPORT int msGetLabelSize(imageObj *img, char *string, labelObj *label, rectObj *rect, fontSetObj *fontSet, double scalefactor, int adjustBaseline,double **advances);
-MS_DLL_EXPORT int msAddLabel(mapObj *map, int layerindex, int classindex, int shapeindex, int tileindex, pointObj *point, labelPathObj *labelpath, char *string, double featuresize, labelObj *label);
+MS_DLL_EXPORT int msAddLabel(mapObj *map, int layerindex, int classindex, shapeObj *shape, pointObj *point, labelPathObj *labelpath, char *string, double featuresize, labelObj *label);
 MS_DLL_EXPORT void msTestLabelCacheCollisions(labelCacheObj *labelcache, labelObj *labelPtr, int mapwidth, int mapheight, int buffer, labelCacheMemberObj *cachePtr, int current_priority, int current_label);
 MS_DLL_EXPORT labelCacheMemberObj *msGetLabelCacheMember(labelCacheObj *labelcache, int i);
 



More information about the mapserver-commits mailing list