[mapserver-commits] r7920 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Tue Sep 23 01:17:52 EDT 2008


Author: sdlime
Date: 2008-09-23 01:17:52 -0400 (Tue, 23 Sep 2008)
New Revision: 7920

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapdraw.c
   trunk/mapserver/mapserver.h
Log:
Decoupled AUTO label positioning from the enum in mapserver.h. Added explict set of positions for POLYGON layers (POINT and LINE positioning remains as-is). (#2770)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2008-09-22 21:24:18 UTC (rev 7919)
+++ trunk/mapserver/HISTORY.TXT	2008-09-23 05:17:52 UTC (rev 7920)
@@ -12,6 +12,10 @@
 Current Version (5.3-dev, SVN trunk):
 ------------------------------------
 
+- Decoupled AUTO label placement from the positions enum in mapserver.h. Added 
+  explicit case for POLYGON layers where CC is the default and then we try UC, 
+  LC, CL and CR. (#2770)
+
 - Changed base type of styleObj size and width from int to double (#2766)
 
 - Correct allocation error in mapmssql2008.c

Modified: trunk/mapserver/mapdraw.c
===================================================================
--- trunk/mapserver/mapdraw.c	2008-09-22 21:24:18 UTC (rev 7919)
+++ trunk/mapserver/mapdraw.c	2008-09-23 05:17:52 UTC (rev 7920)
@@ -2186,21 +2186,24 @@
 	  } else {
 
             if(labelPtr->position == MS_AUTO) {
-              int first_pos, pos, last_pos;
+              int positions[MS_POSITIONS_LENGTH], npositions=0;
 
-              if(labelPtr->type == MS_LAYER_LINE) {                        
-                first_pos = MS_UC; /* There are three possible positions: UC, CC, LC */
-                last_pos = MS_CC;
+              if(layerPtr->type == MS_LAYER_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) {
+                positions[0]=MS_UC; positions[1]=MS_LC; positions[2]=MS_CC;
+                npositions = 3;
               } else {
-                first_pos = MS_UL; /* There are 8 possible outer positions: UL, LR, UR, LL, CR, CL, UC, LC */
-                last_pos = MS_LC;
+                positions[0]=MS_UL; positions[1]=MS_LR; positions[2]=MS_UR; positions[3]=MS_LL; positions[4]=MS_CR; positions[5]=MS_CL; positions[6]=MS_UC; positions[7]=MS_LC;
+                npositions = 8;
               }
 
-              for(pos = first_pos; pos <= last_pos; pos++) {
+              for(i=0; i<npositions; i++) {
                 msFreeShape(cachePtr->poly);
                 cachePtr->status = MS_TRUE; /* assume label *can* be drawn */
 
-                p = get_metrics(&(cachePtr->point), pos, r, (marker_offset_x + labelPtr->offsetx), (marker_offset_y + labelPtr->offsety), labelPtr->angle, labelPtr->buffer, cachePtr->poly);
+                p = get_metrics(&(cachePtr->point), positions[i], r, (marker_offset_x + labelPtr->offsetx), (marker_offset_y + labelPtr->offsety), labelPtr->angle, labelPtr->buffer, cachePtr->poly);
                 if(layerPtr->type == MS_LAYER_ANNOTATION && cachePtr->numstyles > 0)
                   msRectToPolygon(marker_rect, cachePtr->poly); /* save marker bounding polygon */
 
@@ -2209,7 +2212,7 @@
 
                 if(cachePtr->status) /* found a suitable place for this label */ {
                   if(MS_VALID_COLOR(labelPtr->backgroundcolor))
-                    get_metrics_line(&(cachePtr->point), pos, r, (marker_offset_x + labelPtr->offsetx), (marker_offset_y + labelPtr->offsety), labelPtr->angle, 1, billboard.line);
+                    get_metrics_line(&(cachePtr->point), positions[i], r, (marker_offset_x + labelPtr->offsetx), (marker_offset_y + labelPtr->offsety), labelPtr->angle, 1, billboard.line);
                   break; /* ...out of position loop */
                 }
 

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2008-09-22 21:24:18 UTC (rev 7919)
+++ trunk/mapserver/mapserver.h	2008-09-23 05:17:52 UTC (rev 7920)
@@ -346,7 +346,7 @@
 enum MS_FONT_TYPE {MS_TRUETYPE, MS_BITMAP};
 
 #define MS_POSITIONS_LENGTH 12
-enum MS_POSITIONS_ENUM {MS_UL=101, MS_LR, MS_UR, MS_LL, MS_CR, MS_CL, MS_UC, MS_LC, MS_CC, MS_AUTO, MS_XY, MS_FOLLOW}; /* arrangement matters for auto placement, don't change it.  Added MS_FOLLOW for bug #1620 implementation */
+enum MS_POSITIONS_ENUM {MS_UL=101, MS_LR, MS_UR, MS_LL, MS_CR, MS_CL, MS_UC, MS_LC, MS_CC, MS_AUTO, MS_XY, MS_FOLLOW}; /* Added MS_FOLLOW for bug #1620 implementation. */
 
 enum MS_BITMAP_FONT_SIZES {MS_TINY , MS_SMALL, MS_MEDIUM, MS_LARGE, MS_GIANT};
 enum MS_QUERYMAP_STYLES {MS_NORMAL, MS_HILITE, MS_SELECTED};
@@ -1732,6 +1732,7 @@
 MS_DLL_EXPORT int msAddLine(shapeObj *p, lineObj *new_line);
 MS_DLL_EXPORT int msAddLineDirectly(shapeObj *p, lineObj *new_line);
 MS_DLL_EXPORT int msAddPointToLine(lineObj *line, pointObj *point );
+MS_DLL_EXPORT double msGetPolygonArea(shapeObj *p);
 
 MS_DLL_EXPORT int msDrawRasterLayer(mapObj *map, layerObj *layer, imageObj *image); /* in mapraster.c */
 MS_DLL_EXPORT imageObj *msDrawReferenceMap(mapObj *map);



More information about the mapserver-commits mailing list