[mapserver-commits] r9081 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Fri Jun 5 04:58:48 EDT 2009
Author: tbonfort
Date: 2009-06-05 04:58:48 -0400 (Fri, 05 Jun 2009)
New Revision: 9081
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapgeomtransform.c
trunk/mapserver/mapprimitive.c
trunk/mapserver/mapserver.h
Log:
add centroid geotransform
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2009-06-05 08:34:40 UTC (rev 9080)
+++ trunk/mapserver/HISTORY.TXT 2009-06-05 08:58:48 UTC (rev 9081)
@@ -13,6 +13,7 @@
Current Version (SVN trunk):
----------------------------
+- Add centroid geomtransform (#2825)
- Test database connections before using them (#2932)
Modified: trunk/mapserver/mapgeomtransform.c
===================================================================
--- trunk/mapserver/mapgeomtransform.c 2009-06-05 08:34:40 UTC (rev 9080)
+++ trunk/mapserver/mapgeomtransform.c 2009-06-05 08:58:48 UTC (rev 9081)
@@ -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,¢roid,&unused,&unused)){
+ msDrawMarkerSymbol(symbolset,image,¢roid,style,scalefactor);
+ }
+ }
default:
msSetError(MS_MISCERR, "unknown geomtransform", "msDrawTransformedShape()");
return MS_FAILURE;
Modified: trunk/mapserver/mapprimitive.c
===================================================================
--- trunk/mapserver/mapprimitive.c 2009-06-05 08:34:40 UTC (rev 9080)
+++ trunk/mapserver/mapprimitive.c 2009-06-05 08:58:48 UTC (rev 9081)
@@ -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: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h 2009-06-05 08:34:40 UTC (rev 9080)
+++ trunk/mapserver/mapserver.h 2009-06-05 08:58:48 UTC (rev 9081)
@@ -1748,7 +1748,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);
@@ -1774,6 +1774,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