[mapserver-commits] r7166 - in
sandbox/hobu/ms5_integration/mapserver: . mapscript/php3
mapscript/swiginc
svn at osgeo.org
svn at osgeo.org
Wed Dec 12 01:58:52 EST 2007
Author: hobu
Date: 2007-12-12 01:58:52 -0500 (Wed, 12 Dec 2007)
New Revision: 7166
Modified:
sandbox/hobu/ms5_integration/mapserver/HISTORY.TXT
sandbox/hobu/ms5_integration/mapserver/mapgd.c
sandbox/hobu/ms5_integration/mapserver/maplegend.c
sandbox/hobu/ms5_integration/mapserver/mapscript/php3/mapscript_i.c
sandbox/hobu/ms5_integration/mapserver/mapscript/php3/php_mapscript.c
sandbox/hobu/ms5_integration/mapserver/mapscript/php3/php_mapscript.h
sandbox/hobu/ms5_integration/mapserver/mapscript/swiginc/class.i
sandbox/hobu/ms5_integration/mapserver/mapserver.h
Log:
merge the 5.0 branch in and r6934
Modified: sandbox/hobu/ms5_integration/mapserver/HISTORY.TXT
===================================================================
--- sandbox/hobu/ms5_integration/mapserver/HISTORY.TXT 2007-12-12 06:58:11 UTC (rev 7165)
+++ sandbox/hobu/ms5_integration/mapserver/HISTORY.TXT 2007-12-12 06:58:52 UTC (rev 7166)
@@ -13,6 +13,9 @@
Current Version (5.1-dev, SVN trunk):
-------------------------------------
+- use a renderer agnostic legend icon drawing function which switches
+ to the GD or AGG specific one depending on the outputformat (#2348)
+
- AGG: switch alpha buffer when drawing query layer
- Fixed legend icons not drawing when using maxscaledenom
@@ -2064,3 +2067,4 @@
- No Revision history before version 3.5
+
Modified: sandbox/hobu/ms5_integration/mapserver/mapgd.c
===================================================================
--- sandbox/hobu/ms5_integration/mapserver/mapgd.c 2007-12-12 06:58:11 UTC (rev 7165)
+++ sandbox/hobu/ms5_integration/mapserver/mapgd.c 2007-12-12 06:58:52 UTC (rev 7166)
@@ -3363,7 +3363,123 @@
return(0);
}
+int msDrawLegendIconGD(mapObj *map, layerObj *lp, classObj *class, int width, int height, gdImagePtr img, int dstX, int dstY)
+{
+ int i, type;
+ shapeObj box, zigzag;
+ pointObj marker;
+ char szPath[MS_MAXPATHLEN];
+ imageObj *image = NULL;
+ styleObj outline_style;
+ /* if drawing an outline (below) we need to set clipping to keep symbols withing the outline */
+ if(MS_VALID_COLOR(map->legend.outlinecolor))
+ gdImageSetClip(img, dstX, dstY, dstX + width - 1, dstY + height - 1);
+
+ /* initialize the box used for polygons and for outlines */
+ box.line = (lineObj *)malloc(sizeof(lineObj));
+ box.numlines = 1;
+ box.line[0].point = (pointObj *)malloc(sizeof(pointObj)*5);
+ box.line[0].numpoints = 5;
+
+ box.line[0].point[0].x = dstX;
+ box.line[0].point[0].y = dstY;
+ box.line[0].point[1].x = dstX + width - 1;
+ box.line[0].point[1].y = dstY;
+ box.line[0].point[2].x = dstX + width - 1;
+ box.line[0].point[2].y = dstY + height - 1;
+ box.line[0].point[3].x = dstX;
+ box.line[0].point[3].y = dstY + height - 1;
+ box.line[0].point[4].x = box.line[0].point[0].x;
+ box.line[0].point[4].y = box.line[0].point[0].y;
+ box.line[0].numpoints = 5;
+
+ /* if the class has a keyimage then load it, scale it and we're done */
+ if(class->keyimage != NULL) {
+ image = msImageLoadGD(msBuildPath(szPath, map->mappath, class->keyimage));
+ if(!image) return(MS_FAILURE);
+
+ /* TO DO: we may want to handle this differently depending on the relative size of the keyimage */
+ gdImageCopyResampled(img, image->img.gd, dstX, dstY, 0, 0, width, height, image->img.gd->sx, image->img.gd->sy);
+ } else {
+ /* some polygon layers may be better drawn using zigzag if there is no fill */
+ type = lp->type;
+ if(type == MS_LAYER_POLYGON) {
+ type = MS_LAYER_LINE;
+ for(i=0; i<class->numstyles; i++) {
+ if(MS_VALID_COLOR(class->styles[i]->color)) { /* there is a fill */
+ type = MS_LAYER_POLYGON;
+ break;
+ }
+ }
+ }
+
+ /*
+ ** now draw the appropriate color/symbol/size combination
+ */
+
+ /* Bug 490 - switch alpha blending on for a layer that requires it */
+ if(lp->opacity == MS_GD_ALPHA)
+ gdImageAlphaBlending(img, 1);
+
+ switch(type) {
+ case MS_LAYER_ANNOTATION:
+ case MS_LAYER_POINT:
+ marker.x = dstX + MS_NINT(width / 2.0);
+ marker.y = dstY + MS_NINT(height / 2.0);
+
+ for(i=0; i<class->numstyles; i++)
+ msDrawMarkerSymbolGD(&map->symbolset, img, &marker, class->styles[i], lp->scalefactor);
+ break;
+ case MS_LAYER_LINE:
+ zigzag.line = (lineObj *)malloc(sizeof(lineObj));
+ zigzag.numlines = 1;
+ zigzag.line[0].point = (pointObj *)malloc(sizeof(pointObj)*4);
+ zigzag.line[0].numpoints = 4;
+
+ zigzag.line[0].point[0].x = dstX;
+ zigzag.line[0].point[0].y = dstY + height - 1;
+ zigzag.line[0].point[1].x = dstX + MS_NINT(width / 3.0) - 1;
+ zigzag.line[0].point[1].y = dstY;
+ zigzag.line[0].point[2].x = dstX + MS_NINT(2.0 * width / 3.0) - 1;
+ zigzag.line[0].point[2].y = dstY + height - 1;
+ zigzag.line[0].point[3].x = dstX + width - 1;
+ zigzag.line[0].point[3].y = dstY;
+ zigzag.line[0].numpoints = 4;
+
+ for(i=0; i<class->numstyles; i++)
+ msDrawLineSymbolGD(&map->symbolset, img, &zigzag, class->styles[i], lp->scalefactor);
+
+ free(zigzag.line[0].point);
+ free(zigzag.line);
+ break;
+ case MS_LAYER_CIRCLE:
+ case MS_LAYER_RASTER:
+ case MS_LAYER_CHART:
+ case MS_LAYER_POLYGON:
+ for(i=0; i<class->numstyles; i++)
+ msDrawShadeSymbolGD(&map->symbolset, img, &box, class->styles[i], lp->scalefactor);
+ break;
+ default:
+ return MS_FAILURE;
+ break;
+ } /* end symbol drawing */
+ }
+
+ /* handle an outline if necessary */
+ if(MS_VALID_COLOR(map->legend.outlinecolor)) {
+ initStyle(&outline_style);
+ outline_style.color = map->legend.outlinecolor;
+ msDrawLineSymbolGD(&map->symbolset, img, &box, &outline_style, 1.0);
+ gdImageSetClip(img, 0, 0, img->sx - 1, img->sy - 1); /* undo any clipping settings */
+ }
+
+ free(box.line[0].point);
+ free(box.line);
+
+ return MS_SUCCESS;
+}
+
static int msImageCopyForcePaletteGD(gdImagePtr src, gdImagePtr dst)
{
int x, y;
@@ -4007,3 +4123,4 @@
+
Modified: sandbox/hobu/ms5_integration/mapserver/maplegend.c
===================================================================
--- sandbox/hobu/ms5_integration/mapserver/maplegend.c 2007-12-12 06:58:11 UTC (rev 7165)
+++ sandbox/hobu/ms5_integration/mapserver/maplegend.c 2007-12-12 06:58:52 UTC (rev 7166)
@@ -34,121 +34,20 @@
#define VMARGIN 5 /* margin at top and bottom of legend graphic */
#define HMARGIN 5 /* margin at left and right of legend graphic */
-int msDrawLegendIcon(mapObj *map, layerObj *lp, classObj *class, int width, int height, gdImagePtr img, int dstX, int dstY)
+/*
+ * generic function for drawing a legend icon. (added for bug #2348)
+ * renderer specific drawing functions shouldn't be called directly, but through
+ * this function
+ */
+int msDrawLegendIcon(mapObj *map, layerObj *lp, classObj *class, int width, int height, imageObj *img, int dstX, int dstY)
{
- int i, type;
- shapeObj box, zigzag;
- pointObj marker;
- char szPath[MS_MAXPATHLEN];
- imageObj *image = NULL;
- styleObj outline_style;
-
- /* if drawing an outline (below) we need to set clipping to keep symbols withing the outline */
- if(MS_VALID_COLOR(map->legend.outlinecolor))
- gdImageSetClip(img, dstX, dstY, dstX + width - 1, dstY + height - 1);
-
- /* initialize the box used for polygons and for outlines */
- box.line = (lineObj *)malloc(sizeof(lineObj));
- box.numlines = 1;
- box.line[0].point = (pointObj *)malloc(sizeof(pointObj)*5);
- box.line[0].numpoints = 5;
-
- box.line[0].point[0].x = dstX;
- box.line[0].point[0].y = dstY;
- box.line[0].point[1].x = dstX + width - 1;
- box.line[0].point[1].y = dstY;
- box.line[0].point[2].x = dstX + width - 1;
- box.line[0].point[2].y = dstY + height - 1;
- box.line[0].point[3].x = dstX;
- box.line[0].point[3].y = dstY + height - 1;
- box.line[0].point[4].x = box.line[0].point[0].x;
- box.line[0].point[4].y = box.line[0].point[0].y;
- box.line[0].numpoints = 5;
-
- /* if the class has a keyimage then load it, scale it and we're done */
- if(class->keyimage != NULL) {
- image = msImageLoadGD(msBuildPath(szPath, map->mappath, class->keyimage));
- if(!image) return(MS_FAILURE);
-
- /* TO DO: we may want to handle this differently depending on the relative size of the keyimage */
- gdImageCopyResampled(img, image->img.gd, dstX, dstY, 0, 0, width, height, image->img.gd->sx, image->img.gd->sy);
- } else {
- /* some polygon layers may be better drawn using zigzag if there is no fill */
- type = lp->type;
- if(type == MS_LAYER_POLYGON) {
- type = MS_LAYER_LINE;
- for(i=0; i<class->numstyles; i++) {
- if(MS_VALID_COLOR(class->styles[i]->color)) { /* there is a fill */
- type = MS_LAYER_POLYGON;
- break;
- }
- }
- }
-
- /*
- ** now draw the appropriate color/symbol/size combination
- */
-
- /* Bug 490 - switch alpha blending on for a layer that requires it */
- if(lp->opacity == MS_GD_ALPHA)
- gdImageAlphaBlending(img, 1);
-
- switch(type) {
- case MS_LAYER_ANNOTATION:
- case MS_LAYER_POINT:
- marker.x = dstX + MS_NINT(width / 2.0);
- marker.y = dstY + MS_NINT(height / 2.0);
-
- for(i=0; i<class->numstyles; i++)
- msDrawMarkerSymbolGD(&map->symbolset, img, &marker, class->styles[i], lp->scalefactor);
- break;
- case MS_LAYER_LINE:
- zigzag.line = (lineObj *)malloc(sizeof(lineObj));
- zigzag.numlines = 1;
- zigzag.line[0].point = (pointObj *)malloc(sizeof(pointObj)*4);
- zigzag.line[0].numpoints = 4;
-
- zigzag.line[0].point[0].x = dstX;
- zigzag.line[0].point[0].y = dstY + height - 1;
- zigzag.line[0].point[1].x = dstX + MS_NINT(width / 3.0) - 1;
- zigzag.line[0].point[1].y = dstY;
- zigzag.line[0].point[2].x = dstX + MS_NINT(2.0 * width / 3.0) - 1;
- zigzag.line[0].point[2].y = dstY + height - 1;
- zigzag.line[0].point[3].x = dstX + width - 1;
- zigzag.line[0].point[3].y = dstY;
- zigzag.line[0].numpoints = 4;
-
- for(i=0; i<class->numstyles; i++)
- msDrawLineSymbolGD(&map->symbolset, img, &zigzag, class->styles[i], lp->scalefactor);
-
- free(zigzag.line[0].point);
- free(zigzag.line);
- break;
- case MS_LAYER_CIRCLE:
- case MS_LAYER_RASTER:
- case MS_LAYER_CHART:
- case MS_LAYER_POLYGON:
- for(i=0; i<class->numstyles; i++)
- msDrawShadeSymbolGD(&map->symbolset, img, &box, class->styles[i], lp->scalefactor);
- break;
- default:
- return MS_FAILURE;
- break;
- } /* end symbol drawing */
- }
-
- /* handle an outline if necessary */
- if(MS_VALID_COLOR(map->legend.outlinecolor)) {
- initStyle(&outline_style);
- outline_style.color = map->legend.outlinecolor;
- msDrawLineSymbolGD(&map->symbolset, img, &box, &outline_style, 1.0);
- gdImageSetClip(img, 0, 0, img->sx - 1, img->sy - 1); /* undo any clipping settings */
- }
-
- free(box.line[0].point);
- free(box.line);
-
- return MS_SUCCESS;
+#ifdef USE_AGG
+ if(MS_RENDERER_AGG(map->outputformat))
+ return msDrawLegendIconAGG(map,lp,class,width,height,img,dstX,dstY);
+ else
+#endif
+ /*default is to draw with GD*/
+ return msDrawLegendIconGD(map,lp,class,width,height,img->img.gd,dstX,dstY);
}
imageObj *msCreateLegendIcon(mapObj* map, layerObj* lp, classObj* class, int width, int height)
@@ -158,7 +57,7 @@
int i = 0;
if(!map->outputformat || (!MS_RENDERER_GD(map->outputformat) && !MS_RENDERER_AGG(map->outputformat) )) {
- msSetError(MS_GDERR, "Map outputformat must be set to a GD format!", "msCreateLegendIcon()");
+ msSetError(MS_GDERR, "Map outputformat must be set to a GD or AGG format!", "msCreateLegendIcon()");
return(NULL);
}
@@ -196,10 +95,10 @@
if (lp) {
msClearLayerPenValues(lp); /* just in case the mapfile has already been processed */
if (class) {
- msDrawLegendIcon(map, lp, class, width, height, image->img.gd, 0, 0);
+ msDrawLegendIcon(map, lp, class, width, height, image, 0, 0);
} else {
for (i=0; i<lp->numclasses; i++) {
- msDrawLegendIcon(map, lp, lp->class[i], width, height, image->img.gd, 0, 0);
+ msDrawLegendIcon(map, lp, lp->class[i], width, height, image, 0, 0);
}
}
}
@@ -329,21 +228,15 @@
}
/* Set background */
- if(image != NULL) {
#ifdef USE_AGG
- if( MS_RENDERER_AGG(map->outputformat) )
- msImageInitAGG( image, &(map->legend.imagecolor));
- else
+ if( MS_RENDERER_AGG(map->outputformat) )
+ msImageInitAGG( image, &(map->legend.imagecolor));
+ else
#endif
- msImageInitGD(image, &(map->legend.imagecolor));
- }
+ msImageInitGD(image, &(map->legend.imagecolor));
- msClearPenValues(map); /* just in case the mapfile has already been processed */
-#ifdef USE_AGG
- if(MS_RENDERER_AGG(map->outputformat))
- msAlphaGD2AGG(image);
-#endif
+ msClearPenValues(map); /* just in case the mapfile has already been processed */
pnt.y = VMARGIN;
/* for(i=0; i<map->numlayers; i++) { */
@@ -378,15 +271,7 @@
pnt.x = HMARGIN + map->legend.keysizex + map->legend.keyspacingx;
- /* TODO */
-#ifdef USE_AGG
- if(MS_RENDERER_AGG(map->outputformat)) {
- if(msDrawLegendIconAGG(map, lp, lp->class[j], map->legend.keysizex, map->legend.keysizey, image, HMARGIN, (int) pnt.y) != MS_SUCCESS)
- return NULL;
- }
- else
-#endif
- if(msDrawLegendIcon(map, lp, lp->class[j], map->legend.keysizex, map->legend.keysizey, image->img.gd, HMARGIN, (int) pnt.y) != MS_SUCCESS)
+ if(msDrawLegendIcon(map, lp, lp->class[j], map->legend.keysizex, map->legend.keysizey, image, HMARGIN, (int) pnt.y) != MS_SUCCESS)
return NULL;
pnt.y += MS_MAX(map->legend.keysizey, maxheight);
@@ -525,3 +410,4 @@
+
Modified: sandbox/hobu/ms5_integration/mapserver/mapscript/php3/mapscript_i.c
===================================================================
--- sandbox/hobu/ms5_integration/mapserver/mapscript/php3/mapscript_i.c 2007-12-12 06:58:11 UTC (rev 7165)
+++ sandbox/hobu/ms5_integration/mapserver/mapscript/php3/mapscript_i.c 2007-12-12 06:58:52 UTC (rev 7166)
@@ -618,7 +618,7 @@
return msGetExpressionString(&(self->text));
}
-int classObj_drawLegendIcon(classObj *self, mapObj *map, layerObj *layer, int width, int height, gdImagePtr dstImg, int dstX, int dstY) {
+int classObj_drawLegendIcon(classObj *self, mapObj *map, layerObj *layer, int width, int height, imageObj *dstImg, int dstX, int dstY) {
msClearLayerPenValues(layer); // just in case the mapfile has already been processed
return msDrawLegendIcon(map, layer, self, width, height, dstImg, dstX, dstY);
}
Modified: sandbox/hobu/ms5_integration/mapserver/mapscript/php3/php_mapscript.c
===================================================================
--- sandbox/hobu/ms5_integration/mapserver/mapscript/php3/php_mapscript.c 2007-12-12 06:58:11 UTC (rev 7165)
+++ sandbox/hobu/ms5_integration/mapserver/mapscript/php3/php_mapscript.c 2007-12-12 06:58:52 UTC (rev 7166)
@@ -9170,10 +9170,10 @@
parent_map = (mapObj*)_phpms_fetch_property_handle(pThis, "_map_handle_",
PHPMS_GLOBAL(le_msmap),
list TSRMLS_CC, E_ERROR);
- if (im != NULL && !MS_DRIVER_GD(im->format))
+ if (im != NULL && !(MS_DRIVER_GD(im->format)||MS_DRIVER_AGG(im->format)))
{
_phpms_report_mapserver_error(E_WARNING);
- php3_error(E_WARNING, "DrawLegendicon function is only available for GD dirvers");
+ php3_error(E_WARNING, "DrawLegendicon function is only available for GD and AGG drivers");
RETURN_FALSE;
}
if (self == NULL || parent_map == NULL || parent_layer == NULL ||
@@ -9181,7 +9181,7 @@
parent_map,
parent_layer,
pWidth->value.lval, pHeight->value.lval,
- im->img.gd,
+ im,
pDstX->value.lval, pDstY->value.lval)) == -1)
{
_phpms_report_mapserver_error(E_WARNING);
Modified: sandbox/hobu/ms5_integration/mapserver/mapscript/php3/php_mapscript.h
===================================================================
--- sandbox/hobu/ms5_integration/mapserver/mapscript/php3/php_mapscript.h 2007-12-12 06:58:11 UTC (rev 7165)
+++ sandbox/hobu/ms5_integration/mapserver/mapscript/php3/php_mapscript.h 2007-12-12 06:58:52 UTC (rev 7166)
@@ -182,7 +182,7 @@
mapObj *map,
layerObj *layer,
int width, int height,
- gdImagePtr im,
+ imageObj *im,
int dstX, int dstY);
imageObj *classObj_createLegendIcon(classObj *self,
mapObj *map,
Modified: sandbox/hobu/ms5_integration/mapserver/mapscript/swiginc/class.i
===================================================================
--- sandbox/hobu/ms5_integration/mapserver/mapscript/swiginc/class.i 2007-12-12 06:58:11 UTC (rev 7165)
+++ sandbox/hobu/ms5_integration/mapserver/mapscript/swiginc/class.i 2007-12-12 06:58:52 UTC (rev 7166)
@@ -172,7 +172,7 @@
}
int drawLegendIcon(mapObj *map, layerObj *layer, int width, int height, imageObj *dstImage, int dstX, int dstY) {
- return msDrawLegendIcon(map, layer, self, width, height, dstImage->img.gd, dstX, dstY);
+ return msDrawLegendIcon(map, layer, self, width, height, dstImage, dstX, dstY);
}
%newobject createLegendIcon;
Modified: sandbox/hobu/ms5_integration/mapserver/mapserver.h
===================================================================
--- sandbox/hobu/ms5_integration/mapserver/mapserver.h 2007-12-12 06:58:11 UTC (rev 7165)
+++ sandbox/hobu/ms5_integration/mapserver/mapserver.h 2007-12-12 06:58:52 UTC (rev 7166)
@@ -1519,7 +1519,7 @@
MS_DLL_EXPORT imageObj *msDrawLegend(mapObj *map, int scale_independent); /* in maplegend.c */
MS_DLL_EXPORT int msEmbedLegend(mapObj *map, imageObj *img);
-MS_DLL_EXPORT int msDrawLegendIcon(mapObj* map, layerObj* lp, classObj* myClass, int width, int height, gdImagePtr img, int dstX, int dstY);
+MS_DLL_EXPORT int msDrawLegendIcon(mapObj* map, layerObj* lp, classObj* myClass, int width, int height, imageObj *img, int dstX, int dstY);
MS_DLL_EXPORT imageObj *msCreateLegendIcon(mapObj* map, layerObj* lp, classObj* myClass, int width, int height);
MS_DLL_EXPORT int msLoadFontSet(fontSetObj *fontSet, mapObj *map); /* in maplabel.c */
@@ -1744,6 +1744,7 @@
MS_DLL_EXPORT int msDrawTextGD(gdImagePtr img, pointObj labelPnt, char *string, labelObj *label, fontSetObj *fontset, double scalefactor);
MS_DLL_EXPORT int msDrawTextLineGD(gdImagePtr img, char *string, labelObj *label, labelPathObj *labelpath, fontSetObj *fontset, double scalefactor);
MS_DLL_EXPORT int msDrawLabelCacheGD(gdImagePtr img, mapObj *map);
+MS_DLL_EXPORT int msDrawLegendIconGD(mapObj *map, layerObj *lp, classObj *theclass, int width, int height, gdImagePtr img, int dstX, int dstY);
MS_DLL_EXPORT void msImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct);
MS_DLL_EXPORT void msImageCopyMergeNoAlpha (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct, colorObj *transparent);
More information about the mapserver-commits
mailing list