[mapserver-commits] r9119 - branches/branch-5-4/mapserver

svn at osgeo.org svn at osgeo.org
Thu Jun 25 12:35:19 EDT 2009


Author: tbonfort
Date: 2009-06-25 12:35:17 -0400 (Thu, 25 Jun 2009)
New Revision: 9119

Modified:
   branches/branch-5-4/mapserver/HISTORY.TXT
   branches/branch-5-4/mapserver/mapgeomtransform.c
   branches/branch-5-4/mapserver/mapprimitive.c
   branches/branch-5-4/mapserver/mapserver.h
Log:
add centroid to geomtransform (#2825)


Modified: branches/branch-5-4/mapserver/HISTORY.TXT
===================================================================
--- branches/branch-5-4/mapserver/HISTORY.TXT	2009-06-23 10:01:19 UTC (rev 9118)
+++ branches/branch-5-4/mapserver/HISTORY.TXT	2009-06-25 16:35:17 UTC (rev 9119)
@@ -13,6 +13,7 @@
 
 Current Version:
 ----------------
+- Add centroid geomtransform (#2825)
 
 - Save ALIGN parameter if it is set to CENTER or RIGHT (#3057)
 

Modified: branches/branch-5-4/mapserver/mapgeomtransform.c
===================================================================
--- branches/branch-5-4/mapserver/mapgeomtransform.c	2009-06-23 10:01:19 UTC (rev 9118)
+++ branches/branch-5-4/mapserver/mapgeomtransform.c	2009-06-25 16:35:17 UTC (rev 9119)
@@ -44,6 +44,9 @@
   else if(!strncasecmp("bbox",transform,4)) {
     s->_geomtransform = MS_GEOMTRANSFORM_BBOX;
   }
+  else if(!strncasecmp("centroid",transform,8)) {
+    s->_geomtransform = MS_GEOMTRANSFORM_CENTROID;
+  }
   else {
     s->_geomtransform = MS_GEOMTRANSFORM_NONE;
     msSetError(MS_MISCERR,"unknown transform expression","msStyleSetGeomTransform()");
@@ -159,6 +162,14 @@
   	    msDrawShadeSymbol(symbolset, image, &bbox, style, scalefactor);
       }
       break;
+    case MS_GEOMTRANSFORM_CENTROID:
+      {
+        double unused; /*used by centroid function*/
+        pointObj centroid;
+        if(MS_SUCCESS == msGetPolygonCentroid(shape,&centroid,&unused,&unused)){
+          msDrawMarkerSymbol(symbolset,image,&centroid,style,scalefactor);
+        }
+      }
     default:
      msSetError(MS_MISCERR, "unknown geomtransform", "msDrawTransformedShape()");
      return MS_FAILURE;

Modified: branches/branch-5-4/mapserver/mapprimitive.c
===================================================================
--- branches/branch-5-4/mapserver/mapprimitive.c	2009-06-23 10:01:19 UTC (rev 9118)
+++ branches/branch-5-4/mapserver/mapprimitive.c	2009-06-25 16:35:17 UTC (rev 9119)
@@ -1034,7 +1034,7 @@
   return MS_SUCCESS;
 }
 
-static int getPolygonCentroid(shapeObj *p, pointObj *lp, double *miny, double *maxy)
+int msGetPolygonCentroid(shapeObj *p, pointObj *lp, double *miny, double *maxy)
 {
   int i,j;
   double cent_weight_x=0.0, cent_weight_y=0.0;
@@ -1097,7 +1097,7 @@
     lp->y = cp.y;
     break;
   case 1: /* centroid */
-    if(getPolygonCentroid(p, lp, &miny, &maxy) != MS_SUCCESS) return(MS_FAILURE);  
+    if(msGetPolygonCentroid(p, lp, &miny, &maxy) != MS_SUCCESS) return(MS_FAILURE);  
     break;
   case 2: /* center of gravity */
     if(getPolygonCenterOfGravity(p, lp) != MS_SUCCESS) return(MS_FAILURE);

Modified: branches/branch-5-4/mapserver/mapserver.h
===================================================================
--- branches/branch-5-4/mapserver/mapserver.h	2009-06-23 10:01:19 UTC (rev 9118)
+++ branches/branch-5-4/mapserver/mapserver.h	2009-06-25 16:35:17 UTC (rev 9119)
@@ -1743,7 +1743,7 @@
 MS_DLL_EXPORT int msImageTruetypePolyline(symbolSetObj *symbolset, gdImagePtr img, shapeObj *p, styleObj *style, double scalefactor);
 MS_DLL_EXPORT int msImageTruetypeArrow(symbolSetObj *symbolset, gdImagePtr img, shapeObj *p, styleObj *style, double scalefactor);
 
-MS_DLL_EXPORT void msFreeShape(shapeObj *shape); /* in mapprimative.c */
+MS_DLL_EXPORT void msFreeShape(shapeObj *shape); /* in mapprimitive.c */
 MS_DLL_EXPORT void msFreeLabelPathObj(labelPathObj *path);
 MS_DLL_EXPORT shapeObj *msShapeFromWKT(const char *string);
 MS_DLL_EXPORT char *msShapeToWKT(shapeObj *shape);
@@ -1769,6 +1769,7 @@
 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 msGetPolygonCentroid(shapeObj *p, pointObj *lp, double *miny, double *maxy);
 
 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