[mapserver-commits] r8286 - sandbox/graphics

svn at osgeo.org svn at osgeo.org
Fri Dec 26 04:57:37 EST 2008


Author: tbonfort
Date: 2008-12-26 04:57:37 -0500 (Fri, 26 Dec 2008)
New Revision: 8286

Modified:
   sandbox/graphics/mapcairo.c
   sandbox/graphics/maplabel.c
   sandbox/graphics/mapoutput.c
   sandbox/graphics/maprendering.c
   sandbox/graphics/mapserver.h
   sandbox/graphics/mapsymbol.c
   sandbox/graphics/mapsymbol.h
Log:
cairo plugin: support for pixmap, vector and ellipse symbols for markers and line shields

Modified: sandbox/graphics/mapcairo.c
===================================================================
--- sandbox/graphics/mapcairo.c	2008-12-26 06:42:18 UTC (rev 8285)
+++ sandbox/graphics/mapcairo.c	2008-12-26 09:57:37 UTC (rev 8286)
@@ -104,6 +104,7 @@
 	cairo_set_line_width (r->cr, width);
 	cairo_stroke (r->cr);
 	if(patternlength>0) {
+		cairo_set_dash(r->cr,cairopattern,0,0);
 		free(cairopattern);
 	}
 }
@@ -131,6 +132,94 @@
 	cairo_new_path(r->cr);
 }
 
+cairo_surface_t *gdImgtoCairo(gdImagePtr img) {
+	int width = img->sx;
+	int height = img->sy;
+	cairo_surface_t *im = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
+	unsigned char *im_data = cairo_image_surface_get_data(im);
+	int stride = cairo_image_surface_get_stride(im);
+	int row,col;
+	for (row = 0; row < height; row++) {
+		unsigned char* rowptr = &(im_data[row*stride]);
+		for (col = 0; col < width; col++) {
+			int gdpix = gdImageGetTrueColorPixel(img, col, row);
+			//extract the alpha value from the pixel
+			int gdpixalpha = ((gdpix) & 0x7F000000) >> 24;
+
+			if (gdpixalpha == 127) {//treat the fully transparent case
+				((int*)rowptr)[col] = 0;
+			} else if (gdpixalpha == 0) {//treat the fully opaque case
+				((int*)rowptr)[col] = ((gdpix) & 0x00FFFFFF) | (255 << 24);
+			} else {
+				int alpha = 255 - (gdpixalpha << 1);
+				((int*)rowptr)[col] = ((gdpix) & 0x00FFFFFF) | (alpha << 24);
+			}
+		}
+	}
+	return im;
+}
+
+void msRenderPixmapCairo(imageObj *img, double x, double y,symbolObj *symbol,
+        double scale, double angle) {
+	cairo_renderer *r = getCairoRenderer(img);
+	cairo_surface_t *im;
+	int w,h;
+	if (symbol->renderer_cache == NULL) {
+		symbol->renderer_cache = (void*)gdImgtoCairo(symbol->img);
+	}
+	im=(cairo_surface_t*)symbol->renderer_cache;
+	w = cairo_image_surface_get_width (im);
+	h = cairo_image_surface_get_height (im);
+	cairo_save(r->cr);
+	cairo_translate (r->cr, x,y);
+	cairo_rotate (r->cr, -angle);
+	cairo_scale  (r->cr, scale,scale);
+	cairo_translate (r->cr, -0.5*w, -0.5*h);
+	cairo_set_source_surface (r->cr, im, 0, 0);
+	cairo_paint (r->cr);
+	cairo_restore(r->cr);
+}
+
+void msRenderVectorSymbolCairo(imageObj *img, double x, double y, symbolObj *symbol,
+		double scale, double angle, colorObj *c, colorObj *oc, double ow) {
+	cairo_renderer *r = getCairoRenderer(img);
+	cairo_path_t *sym;
+	if (symbol->renderer_cache == NULL) {
+		int is_new = 1,i;
+		for (i = 0; i < symbol->numpoints; i++) {
+			if ((symbol->points[i].x == -99) && (symbol->points[i].y == -99)) { // (PENUP) 
+				is_new = 1;
+			} else {
+				if (is_new) {
+					cairo_move_to(r->cr,symbol->points[i].x,symbol->points[i].y);
+					is_new = 0;
+				} else {
+					cairo_line_to(r->cr,symbol->points[i].x,symbol->points[i].y);
+				}
+			}
+		}
+		symbol->renderer_cache = (void*)cairo_copy_path(r->cr);
+		cairo_new_path(r->cr);
+	}
+	sym=(cairo_path_t*)symbol->renderer_cache;
+	cairo_save(r->cr);
+	cairo_translate(r->cr,x-0.5*symbol->sizex,y-0.5*symbol->sizey);
+	cairo_scale(r->cr,scale,scale);
+	cairo_rotate(r->cr,-angle);
+	cairo_append_path(r->cr,sym);
+	cairo_restore(r->cr);
+	if(c!=NULL && MS_VALID_COLOR(*c)) {
+		msCairoSetSourceColor(r->cr,c);
+		cairo_fill_preserve(r->cr);
+	}
+	if(oc!=NULL && MS_VALID_COLOR(*oc)) {
+		msCairoSetSourceColor(r->cr,oc);
+		cairo_set_line_width (r->cr, ow);
+		cairo_stroke_preserve(r->cr);
+	}
+	cairo_new_path(r->cr);
+}
+
 int msGetTruetypeTextBBoxCairo(imageObj *img,char *font, double size, char *string,
         		rectObj *rect, double **advances) {
 	cairo_renderer *r = getCairoRenderer(img);
@@ -145,7 +234,7 @@
 	pango_layout_set_font_description(r->layout, desc);
 	
 	baseline = pango_layout_get_baseline(r->layout)/PANGO_SCALE;
-	pango_layout_get_pixel_extents(r->layout,NULL,&prect);
+	pango_layout_get_pixel_extents(r->layout,&prect,NULL);
 	rect->minx = prect.x;
 	rect->miny = prect.y-baseline;
 	rect->maxx = prect.x+prect.width;
@@ -194,7 +283,7 @@
 	cairo_translate(r->cr,x,y);
 	cairo_rotate(r->cr, -angle);
 	cairo_translate(r->cr,0,-pango_layout_get_baseline(r->layout)/PANGO_SCALE);
-	if(MS_VALID_COLOR(*shadowcolor)) {
+	if(shadowcolor!=NULL && MS_VALID_COLOR(*shadowcolor)) {
 		cairo_save(r->cr);
 		msCairoSetSourceColor(r->cr,shadowcolor);
 		cairo_translate(r->cr,shdx,shdy);
@@ -204,7 +293,7 @@
 	}
 	pango_cairo_update_layout(r->cr, r->layout);
 	pango_cairo_layout_path(r->cr,r->layout);
-	if (MS_VALID_COLOR(*outlinecolor)) {
+	if (shadowcolor!=NULL && MS_VALID_COLOR(*outlinecolor)) {
 		cairo_save(r->cr);
 		msCairoSetSourceColor(r->cr, outlinecolor);
 		cairo_set_line_width (r->cr, outlinewidth);

Modified: sandbox/graphics/maplabel.c
===================================================================
--- sandbox/graphics/maplabel.c	2008-12-26 06:42:18 UTC (rev 8285)
+++ sandbox/graphics/maplabel.c	2008-12-26 09:57:37 UTC (rev 8286)
@@ -191,7 +191,7 @@
          * as the labelSize computing functions return integer bounding boxes. we assume
          * that the integer rounding for such a number of spaces will be negligeable
          * compared to the actual size of thoses spaces */ 
-        if(msGetLabelSize(image, "                ", label,&label_rect, 
+        if(msGetLabelSize(image, ".              .", label,&label_rect, 
                     &map->fontset, 1.0, MS_FALSE,NULL)==-1) { 
             /*error computing label size, we can't continue*/
 

Modified: sandbox/graphics/mapoutput.c
===================================================================
--- sandbox/graphics/mapoutput.c	2008-12-26 06:42:18 UTC (rev 8285)
+++ sandbox/graphics/mapoutput.c	2008-12-26 09:57:37 UTC (rev 8286)
@@ -977,6 +977,8 @@
         r->renderGlyphs=&msRenderGlyphsCairo;
         r->freeImage=&msFreeImageCairo;
         r->renderEllipse = &msRenderEllipseCairo;
+        r->renderVectorSymbol = &msRenderVectorSymbolCairo;
+        r->renderPixmap = &msRenderPixmapCairo;
         r->getTruetypeTextBBox = &msGetTruetypeTextBBoxCairo;
         return r;
 #endif

Modified: sandbox/graphics/maprendering.c
===================================================================
--- sandbox/graphics/maprendering.c	2008-12-26 06:42:18 UTC (rev 8285)
+++ sandbox/graphics/maprendering.c	2008-12-26 09:57:37 UTC (rev 8286)
@@ -1,5 +1,211 @@
 #include "mapserver.h"
 
+void msImagePolylineMarkers(imageObj *image, shapeObj *p, symbolSetObj *symbolset,
+        styleObj *style, double size) {
+	renderObj *r = image->format->r;
+    symbolObj *symbol=symbolset->symbol[style->symbol];
+    colorObj *c,*oc;
+    double gap = symbol->gap;
+    double d;
+    double outlinewidth=1;
+    int i,j;
+    if(symbol->type!= MS_SYMBOL_PIXMAP) {
+    if (!symbol->filled) {
+    	c=NULL;
+		if (MS_VALID_COLOR(style->color))
+			oc = &style->color;
+		else if (MS_VALID_COLOR(style->outlinecolor))
+			oc = &style->outlinecolor;
+		else
+			return;
+		oc->alpha = MS_NINT(style->opacity*2.55);
+	} else {
+		c = &(style->color);
+		oc = &(style->outlinecolor);
+		c->alpha = MS_NINT(style->opacity*2.55);
+		oc->alpha = c->alpha;
+	}
+    }
+    
+    
+    if(style->width!=-1)
+        outlinewidth=style->width;
+    pointObj point;
+    int rotate_symbol = gap<0;
+    if (symbol->sizey)
+    	if(symbol->type==MS_SYMBOL_VECTOR) {
+        d = size/(symbol->maxy-symbol->miny); // compute the scaling factor
+    	} else {
+    		d = size/symbol->sizey;
+    	}
+    else
+        d = 1;
+    
+    double sw;
+    if(symbol->type==MS_SYMBOL_VECTOR) {
+    	sw= MS_MAX(1,size*(symbol->maxx-symbol->minx)/(symbol->maxy-symbol->miny));
+    } else {
+    	sw = MS_MAX(1,size*(symbol->sizex)/(symbol->sizey));
+    }
+    double sh = size;
+    gap = MS_ABS(gap)*d; //TODO: original version uses scalefactor, why?
+    double symbol_width;
+    if(symbol->type==MS_SYMBOL_PIXMAP)
+        symbol_width = symbol->img->sx;
+    else
+        symbol_width=sw;
+    double angle_radians = style->angle*MS_DEG_TO_RAD;
+    for(i=0; i<p->numlines; i++) 
+    {
+        double current_length = 1+symbol_width/2.0; // initial padding for each line
+        for(j=1;j<p->line[i].numpoints;j++) 
+        {
+            double length,rx,ry,theta,angle;
+            int in;
+        	length = sqrt((pow((p->line[i].point[j].x - p->line[i].point[j-1].x),2) + pow((p->line[i].point[j].y - p->line[i].point[j-1].y),2)));
+            if(length==0)continue;
+            rx = (p->line[i].point[j].x - p->line[i].point[j-1].x)/length;
+            ry = (p->line[i].point[j].y - p->line[i].point[j-1].y)/length;  
+            theta = asin(ry);
+            if(rx < 0) {
+                if(rotate_symbol){
+                    theta += MS_PI;
+                }
+            }
+            else theta = -theta;       
+            angle=angle_radians;
+            if (rotate_symbol)
+				angle += theta;
+			in = 0;
+			while (current_length <= length) {
+				point.x = p->line[i].point[j - 1].x + current_length * rx;
+				point.y = p->line[i].point[j - 1].y + current_length * ry;
+				switch (symbol->type) {
+				case MS_SYMBOL_PIXMAP:
+					r->renderPixmap(image, point.x, point.y, symbol,d, angle);
+					break;
+				case MS_SYMBOL_ELLIPSE:
+					r->renderEllipse(image, point.x, point.y, sw, sh, angle, c,
+							oc, outlinewidth);
+					break;
+				case MS_SYMBOL_VECTOR:
+					r->renderVectorSymbol(image, point.x, point.y, symbol, d,
+							angle, c, oc, outlinewidth);
+					break;
+				case MS_SYMBOL_TRUETYPE:
+					break;
+				}
+				current_length += symbol_width + gap;
+				in = 1;
+			}
+
+			if (in)
+            {
+                current_length -= length + symbol_width/2.0;
+            }         
+            else current_length -= length;
+        }
+    }
+}
+
+
+#if 0
+void msImageShieldPolyline(symbolSetObj *symbolset, imageObj *image, shapeObj *p, styleObj *style, double scalefactor)
+{
+  int i,j;
+  double theta, length, current_length;
+  labelObj label;
+  pointObj point, label_point;
+  rectObj label_rect;
+  int label_width;
+  int  rot, position, gap, in;
+  double rx, ry, size;
+  
+  symbolObj *symbol;
+
+  AGGMapserverRenderer* ren = getAGGRenderer(image);
+  symbol = symbolset->symbol[style->symbol];
+
+  initLabel(&label);
+  rot = (symbol->gap <= 0);
+  label.type = MS_TRUETYPE;
+  label.font = symbol->font;
+  // -- rescaling symbol and gap 
+  if(style->size == -1) {
+      size = msSymbolGetDefaultSize( symbol );
+  }
+  else
+      size = style->size;
+  if(size*scalefactor > style->maxsize) scalefactor = (float)style->maxsize/(float)size;
+  if(size*scalefactor < style->minsize) scalefactor = (float)style->minsize/(float)size;
+  gap = MS_ABS(symbol->gap)* (int) scalefactor;
+  label.size = (int) (size * scalefactor);
+  // label.minsize = style->minsize; 
+  // label.maxsize = style->maxsize; 
+
+  label.color = style->color;
+  label.outlinecolor = style->outlinecolor;
+  
+  char * font = msLookupHashTable(&(symbolset->fontset->fonts), label.font);
+    if(!font) {
+        msSetError(MS_TTFERR, "Requested font (%s) not found.", "msDrawTextAGG()", label.font);
+        return;
+    }
+  if(ren->getLabelSize(symbol->character, font, label.size, &label_rect,NULL) != MS_SUCCESS)
+    return;
+
+  label_width = (int) label_rect.maxx - (int) label_rect.minx;
+  agg::rgba8 agg_color,agg_ocolor;
+  agg_color=getAGGColor(&label.color,100);
+  agg_ocolor=getAGGColor(&label.outlinecolor,100);
+  for(i=0; i<p->numlines; i++) {
+    current_length = 1+label_width/2.0; // initial padding for each line
+    
+    for(j=1;j<p->line[i].numpoints;j++) {
+      length = sqrt((pow((p->line[i].point[j].x - p->line[i].point[j-1].x),2) + pow((p->line[i].point[j].y - p->line[i].point[j-1].y),2)));
+      if(length==0)continue;
+      rx = (p->line[i].point[j].x - p->line[i].point[j-1].x)/length;
+      ry = (p->line[i].point[j].y - p->line[i].point[j-1].y)/length;  
+      theta = asin(ry);
+      position = symbol->position;
+      if(rx < 0) {
+          if(rot){
+              theta += MS_PI;
+              if((position == MS_UR)||(position == MS_UL)) position = MS_LC;
+              if((position == MS_LR)||(position == MS_LL)) position = MS_UC;
+          }else{
+              if(position == MS_UC) position = MS_LC;
+              else if(position == MS_LC) position = MS_UC;
+          }
+      }
+      else theta = -theta;
+      if((position == MS_UR)||(position == MS_UL)) position = MS_UC;
+      if((position == MS_LR)||(position == MS_LL)) position = MS_LC;
+      label.angle = style->angle ;
+      if(rot)
+          label.angle+=theta*MS_RAD_TO_DEG;
+
+      in = 0;
+      while(current_length <= length) {
+        point.x = p->line[i].point[j-1].x + current_length*rx;
+        point.y = p->line[i].point[j-1].y + current_length*ry;
+        
+        label_point = get_metrics(&point, position, label_rect, 0, 0, label.angle, 0, NULL);
+        ren->renderGlyphs(label_point.x,label_point.y,agg_color,agg_ocolor,label.size,
+                          font,symbol->character,label.angle*MS_DEG_TO_RAD,
+                          AGG_NO_COLOR,0,0,MS_NINT(style->width));
+        current_length += label_width + gap;
+        in = 1;
+      }
+
+      if(in){
+        current_length -= length + label_width/2.0;
+      } else current_length -= length;
+    }
+  }
+}
+#endif
+
 void msDrawLineSymbol(symbolSetObj *symbolset, imageObj *image, shapeObj *p, styleObj *style, double scalefactor)
 {
     if (image)
@@ -38,7 +244,13 @@
 			if(style->offsety==-99) {
 				theShape = msOffsetPolyline(p,ox,-99);
 			}
-			r->renderLine(image, theShape, &c, width, symbol->patternlength,symbol->pattern);
+			if(style->symbol == 0 || (symbol->type==MS_SYMBOL_SIMPLE)) {
+				r->renderLine(image, theShape, &c, width, symbol->patternlength,symbol->pattern);
+			}
+			else if(symbol->gap!=0) {
+		        //special function that treats any other symbol used as a marker, not a brush
+		        msImagePolylineMarkers(image,p,symbolset,style,size);
+		    }
 			if(theShape!=p)
 				msFreeShape(theShape);
 		}
@@ -161,11 +373,11 @@
        if(MS_RENDERER_PLUGIN(image->format)) {
     	   renderObj *r = image->format->r;
     	   int bRotated = MS_FALSE;
-    	   double size, angle, angle_radians, width, ox, oy,d;
+    	   double size, angle, angle_radians, width, ox, oy,scaling;
     	   symbolObj *symbol;
-    	   style->color.alpha=255;
-    	   style->outlinecolor.alpha=255;
-    	   style->backgroundcolor.alpha=255;
+    	   style->color.alpha=MS_NINT(style->opacity*2.55);
+    	   style->outlinecolor.alpha=MS_NINT(style->opacity*2.55);
+    	   style->backgroundcolor.alpha=MS_NINT(style->opacity*2.55);
 			
 			if (!p)
 				return;
@@ -186,9 +398,9 @@
 			size = MS_MAX(size, style->minsize);
 			size = MS_MIN(size, style->maxsize);
 			if (symbol->sizey)
-				d = size / symbol->sizey; /* compute the scaling factor (d) on the unrotated symbol */
+				scaling = size / symbol->sizey; /* compute the scaling factor (d) on the unrotated symbol */
 			else
-				d = 1;
+				scaling = 1;
 			width = MS_NINT(style->width * scalefactor);
 			width = MS_MAX(width, style->minwidth);
 			width = MS_MIN(width, style->maxwidth);
@@ -217,7 +429,7 @@
 			}
 				break;
 			case (MS_SYMBOL_PIXMAP): {
-				
+				r->renderPixmap(image,p->x+ox,p->y+oy,symbol,scaling,angle_radians);
 			}
 				break;
 			case (MS_SYMBOL_ELLIPSE): {
@@ -233,9 +445,9 @@
 							&(style->outlinecolor), width);
 				} else {
 					colorObj *c;
-					if (style->color.alpha)
+					if (MS_VALID_COLOR(style->color))
 						c = &style->color;
-					else if (style->outlinecolor.alpha)
+					else if (MS_VALID_COLOR(style->outlinecolor))
 						c = &style->outlinecolor;
 					else
 						return;
@@ -246,30 +458,28 @@
 			}
 				break;
 			case (MS_SYMBOL_VECTOR): {
-				if (angle != 0.0 && angle != 360.0) {
-					bRotated = MS_TRUE;
-					symbol = msRotateSymbol(symbol, angle);
-				}/*
-				agg::path_storage path = imageVectorSymbolAGG(symbol,d);
-				//center the symbol on the marker location
-				agg::trans_affine translation = agg::trans_affine_translation(
-						p->x - d*.5*symbol->sizex + ox,
-						p->y - d*.5*symbol->sizey + oy);
-				path.transform(translation);
 				if (symbol->filled) {
-					//draw an optionnally filled and/or outlined vector symbol
-					ren->renderPathSolid(path, agg_color, agg_ocolor, width);
+					//draw an optionnally filled and/or outlined ellipse
+					r->renderVectorSymbol(image, p->x + ox, p->y + oy,
+							symbol,
+							scaling,angle_radians,
+							&(style->color),
+							&(style->outlinecolor), width);
 				} else {
-					agg::rgba8 *c;
-					if (agg_color.a)
-						c = &agg_color;
-					else if (agg_ocolor.a)
-						c = &agg_ocolor;
+					colorObj *c;
+					if (style->color.alpha)
+						c = &style->color;
+					else if (style->outlinecolor.alpha)
+						c = &style->outlinecolor;
 					else
 						return;
 					//draw only the outline
-					ren->renderPathSolid(path, AGG_NO_COLOR, *c, width);
-				}*/
+					r->renderVectorSymbol(image, p->x + ox, p->y + oy,
+												symbol,
+												scaling,angle_radians,
+												NULL,
+												c, width);
+				}
 			}
 				break;
 			default:

Modified: sandbox/graphics/mapserver.h
===================================================================
--- sandbox/graphics/mapserver.h	2008-12-26 06:42:18 UTC (rev 8285)
+++ sandbox/graphics/mapserver.h	2008-12-26 09:57:37 UTC (rev 8286)
@@ -2353,6 +2353,11 @@
         		double width, double height, double angle,
         		colorObj *color, colorObj *outlinecolor,
         		double outlinewidth);
+    void msRenderVectorSymbolCairo(imageObj *img, double x, double y, symbolObj *symbol,
+    		double scale, double angle, colorObj *c, colorObj *oc, double ow);
+    void msRenderPixmapCairo(imageObj *img, double x, double y,
+            		symbolObj *symbol,
+            		double scale, double angle);
     int msGetTruetypeTextBBoxCairo(imageObj *img,char *font, double size, char *string,
         		rectObj *rect, double **advances);
     void msFreeImageCairo(imageObj *image);
@@ -2373,14 +2378,21 @@
                 double size, char *font, char *thechars, double angle,
                 colorObj *shadowcolor, double shdx, double shdy,
                 int outlinewidth);
-    void (*renderVectorSymbol)(imageObj*image, pointObj *location, 
-    		pointObj **vectorpoints, int nvectorpoints, double width,
-            colorObj *color, colorObj *outlinecolor, 
-            colorObj* backgroundcolor);
+ 
+    void (*renderVectorSymbol)(imageObj *img, double x, double y,
+    		symbolObj *symbol,
+    		double scale, double angle, 
+    		colorObj *color,
+    		colorObj *outlinecolor, double outlinewidth);
+    
+    void (*renderPixmap)(imageObj *img, double x, double y,
+        		symbolObj *symbol,
+        		double scale, double angle);
+    
     void (*renderEllipse)(imageObj *image, double x, double y, 
     		double width, double height, double angle,
-    		colorObj *color, colorObj *outlinecolor,
-    		double outlinewidth);
+    		colorObj *color,
+    		colorObj *outlinecolor, double outlinewidth);
 
     /* image i/o */
     imageObj* (*createImage)(int width, int height, outputFormatObj *format, colorObj* bg);

Modified: sandbox/graphics/mapsymbol.c
===================================================================
--- sandbox/graphics/mapsymbol.c	2008-12-26 06:42:18 UTC (rev 8285)
+++ sandbox/graphics/mapsymbol.c	2008-12-26 09:57:37 UTC (rev 8286)
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id:$
+ * $Id$
  *
  * Project:  MapServer
  * Purpose:  symbolObj related functions.
@@ -130,6 +130,10 @@
   s->patternlength = 0; /* solid line */
   s->sizex = 0;
   s->sizey = 0;
+  s->minx=99;
+  s->miny=99;
+  s->maxx=-99;
+  s->maxy=-99;
   s->filled = MS_FALSE;
   s->numpoints=0;
   s->img = NULL;
@@ -157,7 +161,7 @@
   if(s->name) free(s->name);
   if(s->img) gdImageDestroy(s->img);
 #ifdef USE_AGG
-  if(s->renderer_cache) msFreeSymbolCacheAGG(s->renderer_cache);
+  /*if(s->renderer_cache) msFreeSymbolCacheAGG(s->renderer_cache);*/
 #endif
   if(s->font) free(s->font);
   if(s->imagepath) free(s->imagepath);
@@ -324,8 +328,14 @@
 	case(MS_NUMBER):
 	  s->points[s->numpoints].x = atof(msyytext); /* grab the x */
 	  if(getDouble(&(s->points[s->numpoints].y)) == -1) return(-1); /* grab the y */
+	  if(s->points[s->numpoints].x!=-99) {
 	  s->sizex = MS_MAX(s->sizex, s->points[s->numpoints].x);
-	  s->sizey = MS_MAX(s->sizey, s->points[s->numpoints].y);	
+	  s->sizey = MS_MAX(s->sizey, s->points[s->numpoints].y);
+	  s->minx= MS_MIN(s->minx,s->points[s->numpoints].x);
+	  s->maxx = MS_MAX(s->maxx, s->points[s->numpoints].x);
+	  s->miny=MS_MIN(s->miny,s->points[s->numpoints].y);
+	  s->maxy = MS_MAX(s->maxy, s->points[s->numpoints].y);
+	  }
 	  s->numpoints++;
 	  break;
 	default:

Modified: sandbox/graphics/mapsymbol.h
===================================================================
--- sandbox/graphics/mapsymbol.h	2008-12-26 06:42:18 UTC (rev 8285)
+++ sandbox/graphics/mapsymbol.h	2008-12-26 09:57:37 UTC (rev 8286)
@@ -77,6 +77,7 @@
   ** MS_SYMBOL_VECTOR and MS_SYMBOL_ELLIPSE options
   */
   double sizex, sizey;
+  double minx,miny,maxx,maxy;
 
 #ifndef SWIG
   pointObj points[MS_MAXVECTORPOINTS];
@@ -100,7 +101,7 @@
   */
 #ifndef SWIG
   gdImagePtr img;
-  void *renderer_cache; /* AGG storage */
+  void *renderer_cache; /* Renderer storage */
 #endif /* SWIG */
 
 #ifdef SWIG



More information about the mapserver-commits mailing list