[mapserver-commits] r8791 - sandbox/graphics

svn at osgeo.org svn at osgeo.org
Sat Mar 14 04:26:18 EDT 2009


Author: tbonfort
Date: 2009-03-14 04:26:17 -0400 (Sat, 14 Mar 2009)
New Revision: 8791

Modified:
   sandbox/graphics/mapdraw.c
Log:
revert code fromatting changes


Modified: sandbox/graphics/mapdraw.c
===================================================================
--- sandbox/graphics/mapdraw.c	2009-03-13 21:32:38 UTC (rev 8790)
+++ sandbox/graphics/mapdraw.c	2009-03-14 08:26:17 UTC (rev 8791)
@@ -15,7 +15,7 @@
  * and/or sell copies of the Software, and to permit persons to whom the
  * Software is furnished to do so, subject to the following conditions:
  *
- * The above copyright notice and this permission notice shall be included in
+ * The above copyright notice and this permission notice shall be included in 
  * all copies of this Software or works derived from this Software.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
@@ -40,19 +40,19 @@
  * format type specific) which is why this function is here instead of the GD, PDF or SWF source files.
 */
 void msClearLayerPenValues(layerObj *layer) {
-  int i, j;
+  int i, j;  
 
   for(i=0; i<layer->numclasses; i++) {
     layer->class[i]->label.backgroundcolor.pen = MS_PEN_UNSET; /* set in billboardXX function */
     layer->class[i]->label.backgroundshadowcolor.pen = MS_PEN_UNSET;
     layer->class[i]->label.color.pen = MS_PEN_UNSET; /* set in MSXXDrawText function */
     layer->class[i]->label.outlinecolor.pen = MS_PEN_UNSET;
-    layer->class[i]->label.shadowcolor.pen = MS_PEN_UNSET;
+    layer->class[i]->label.shadowcolor.pen = MS_PEN_UNSET;      
 
     for(j=0; j<layer->class[i]->numstyles; j++) {
       layer->class[i]->styles[j]->backgroundcolor.pen = MS_PEN_UNSET; /* set in various symbol drawing functions */
 	  layer->class[i]->styles[j]->color.pen = MS_PEN_UNSET;
-      layer->class[i]->styles[j]->outlinecolor.pen = MS_PEN_UNSET;
+      layer->class[i]->styles[j]->outlinecolor.pen = MS_PEN_UNSET; 
     }
   }
 }
@@ -116,7 +116,7 @@
   msClearScalebarPenValues(&(map->scalebar));
   msClearReferenceMapPenValues(&(map->reference));
   msClearQueryMapPenValues(&(map->querymap));
-
+  
 }
 
 /* msPrepareImage()
@@ -127,7 +127,7 @@
  * msMapRestoreRealExtent() once they are done with the image.
  * This should be set to MS_TRUE only when called from msDrawMap(), see bug 945.
  */
-imageObj *msPrepareImage(mapObj *map, int allow_nonsquare)
+imageObj *msPrepareImage(mapObj *map, int allow_nonsquare) 
 {
     int i, status;
     imageObj *image=NULL;
@@ -162,23 +162,23 @@
 	}
     else if( MS_RENDERER_GD(map->outputformat) )
     {
-        image = msImageCreateGD(map->width, map->height, map->outputformat,
-				map->web.imagepath, map->web.imageurl);
+        image = msImageCreateGD(map->width, map->height, map->outputformat, 
+				map->web.imagepath, map->web.imageurl);        
         if( image != NULL ) msImageInitGD( image, &map->imagecolor );
         msPreAllocateColorsGD(image, map);
     }
 #ifdef USE_AGG
     else if( MS_RENDERER_AGG(map->outputformat) )
     {
-        image = msImageCreateAGG(map->width, map->height, map->outputformat,
-				map->web.imagepath, map->web.imageurl);
+        image = msImageCreateAGG(map->width, map->height, map->outputformat, 
+				map->web.imagepath, map->web.imageurl);        
         if( image != NULL ) msImageInitAGG( image, &map->imagecolor );
     }
 #endif
     else if( MS_RENDERER_IMAGEMAP(map->outputformat) )
     {
-        image = msImageCreateIM(map->width, map->height, map->outputformat,
-				map->web.imagepath, map->web.imageurl);
+        image = msImageCreateIM(map->width, map->height, map->outputformat, 
+				map->web.imagepath, map->web.imageurl);        
         if( image != NULL ) msImageInitIM( image );
     }
     else if( MS_RENDERER_RAWDATA(map->outputformat) )
@@ -212,7 +212,7 @@
     {
         image = NULL;
     }
-
+  
     if(!image) {
         msSetError(MS_GDERR, "Unable to initialize image.", "msPrepareImage()");
         return(NULL);
@@ -231,7 +231,7 @@
         double cellsize_x = (map->extent.maxx - map->extent.minx)/map->width;
         double cellsize_y = (map->extent.maxy - map->extent.miny)/map->height;
 
-        if( cellsize_y != 0.0
+        if( cellsize_y != 0.0 
             && (fabs(cellsize_x/cellsize_y) > 1.00001
                 || fabs(cellsize_x/cellsize_y) < 0.99999) )
         {
@@ -269,7 +269,7 @@
 
         geo_cellsize = sqrt(cellsize_x*cellsize_x + cellsize_y*cellsize_y)
             / sqrt(2.0);
-    }
+    } 
 
     /* compute layer scale factors now */
     for(i=0;i<map->numlayers; i++) {
@@ -290,7 +290,7 @@
  * The type of the image created is based on the imagetype parameter in the map file.
  *
  * mapObj *map - map object loaded in MapScript or via a mapfile to use
- * int querymap - is this map the result of a query operation, MS_TRUE|MS_FALSE
+ * int querymap - is this map the result of a query operation, MS_TRUE|MS_FALSE 
 */
 imageObj *msDrawMap(mapObj *map, int querymap)
 {
@@ -328,12 +328,12 @@
 #if defined(USE_WMS_LYR) || defined(USE_WFS_LYR)
   /* How many OWS (WMS/WFS) layers do we have to draw?
    * Note: numOWSLayers is the number of actual layers and numOWSRequests is
-   * the number of HTTP requests which could be lower if multiple layers
+   * the number of HTTP requests which could be lower if multiple layers 
    * are merged into the same request.
    */
   numOWSLayers=0;
   for(i=0; i<map->numlayers; i++) {
-    if(map->layerorder[i] != -1 &&
+    if(map->layerorder[i] != -1 && 
        msLayerIsVisible(map, GET_LAYER(map,map->layerorder[i])))
         numOWSLayers++;
   }
@@ -408,14 +408,14 @@
       if(!msLayerIsVisible(map, lp)) continue;
 
       if(lp->connectiontype == MS_WMS) {
-#ifdef USE_WMS_LYR
+#ifdef USE_WMS_LYR 
         if(MS_RENDERER_GD(image->format) || MS_RENDERER_RAWDATA(image->format))
           status = msDrawWMSLayerLow(map->layerorder[i], pasOWSReqInfo, numOWSRequests,  map, lp, image);
 #ifdef USE_AGG
         else if(MS_RENDERER_AGG(image->format))
           status = msDrawWMSLayerLow(map->layerorder[i], pasOWSReqInfo, numOWSRequests, map, lp, image);
 #endif
-#ifdef USE_MING_FLASH
+#ifdef USE_MING_FLASH                
         else if(MS_RENDERER_SWF(image->format))
           status = msDrawWMSLayerSWF(map->layerorder[i], pasOWSReqInfo, numOWSRequests, map, lp, image);
 #endif
@@ -427,9 +427,9 @@
           msSetError(MS_WMSCONNERR, "Output format '%s' doesn't support WMS layers.", "msDrawMap()", image->format->name);
           status = MS_FAILURE;
         }
-
+                
         if(status == MS_FAILURE) {
-          msSetError(MS_WMSCONNERR,
+          msSetError(MS_WMSCONNERR, 
                      "Failed to draw WMS layer named '%s'. This most likely happened because "
                      "the remote WMS server returned an invalid image, and XML exception "
                      "or another unexpected result in response to the GetMap request. Also check "
@@ -468,7 +468,7 @@
 
     if(map->debug >= MS_DEBUGLEVEL_TUNING || lp->debug >= MS_DEBUGLEVEL_TUNING) {
       msGettimeofday(&endtime, NULL);
-      msDebug("msDrawMap(): Layer %d (%s), %.3fs\n",
+      msDebug("msDrawMap(): Layer %d (%s), %.3fs\n", 
               map->layerorder[i], lp->name?lp->name:"(null)",
               (endtime.tv_sec+endtime.tv_usec/1.0e6)-
               (starttime.tv_sec+starttime.tv_usec/1.0e6) );
@@ -513,7 +513,7 @@
 
   if(map->debug >= MS_DEBUGLEVEL_TUNING) {
     msGettimeofday(&endtime, NULL);
-    msDebug("msDrawMap(): Drawing Label Cache, %.3fs\n",
+    msDebug("msDrawMap(): Drawing Label Cache, %.3fs\n", 
             (endtime.tv_sec+endtime.tv_usec/1.0e6)-
             (starttime.tv_sec+starttime.tv_usec/1.0e6) );
   }
@@ -528,10 +528,10 @@
     if(map->debug >= MS_DEBUGLEVEL_TUNING || lp->debug >= MS_DEBUGLEVEL_TUNING) msGettimeofday(&starttime, NULL);
 
     if(lp->connectiontype == MS_WMS) {
-#ifdef USE_WMS_LYR
+#ifdef USE_WMS_LYR 
       if(MS_RENDERER_GD(image->format) || MS_RENDERER_RAWDATA(image->format))
         status = msDrawWMSLayerLow(map->layerorder[i], pasOWSReqInfo, numOWSRequests, map, lp, image);
-#ifdef USE_AGG
+#ifdef USE_AGG               
       else if(MS_RENDERER_AGG(image->format))
         status = msDrawWMSLayerLow(map->layerorder[i], pasOWSReqInfo, numOWSRequests, map, lp, image);
 #endif
@@ -567,14 +567,14 @@
 
     if(map->debug >= MS_DEBUGLEVEL_TUNING || lp->debug >= MS_DEBUGLEVEL_TUNING) {
       msGettimeofday(&endtime, NULL);
-      msDebug("msDrawMap(): Layer %d (%s), %.3fs\n",
+      msDebug("msDrawMap(): Layer %d (%s), %.3fs\n", 
               map->layerorder[i], lp->name?lp->name:"(null)",
               (endtime.tv_sec+endtime.tv_usec/1.0e6)-
               (starttime.tv_sec+starttime.tv_usec/1.0e6) );
     }
 
   }
-
+  
   /* Do we need to fake out stuff for rotated support? */
   /* This really needs to be done on every preceeding exit point too... */
   if(map->gt.need_geotransform)
@@ -605,7 +605,7 @@
 
   if(map->debug >= MS_DEBUGLEVEL_TUNING) {
     msGettimeofday(&mapendtime, NULL);
-    msDebug("msDrawMap() total time: %.3fs\n",
+    msDebug("msDrawMap() total time: %.3fs\n", 
             (mapendtime.tv_sec+mapendtime.tv_usec/1.0e6)-
             (mapstarttime.tv_sec+mapstarttime.tv_usec/1.0e6) );
   }
@@ -615,7 +615,7 @@
 
 /*
  * Test whether a layer should be drawn or not in the current map view and
- * at the current scale.
+ * at the current scale.  
  * Returns TRUE if layer is visible, FALSE if not.
 */
 int msLayerIsVisible(mapObj *map, layerObj *layer)
@@ -630,7 +630,7 @@
   if(msEvalContext(map, layer, layer->requires) == MS_FALSE) return(MS_FALSE);
 
   if(map->scaledenom > 0) {
-
+    
     /* layer scale boundaries should be checked first */
     if((layer->maxscaledenom > 0) && (map->scaledenom > layer->maxscaledenom)) return(MS_FALSE);
     if((layer->minscaledenom > 0) && (map->scaledenom <= layer->minscaledenom)) return(MS_FALSE);
@@ -644,7 +644,7 @@
           continue; /* can skip this one, next class */
 
         break; /* can't skip this class (or layer for that matter) */
-      }
+      } 
       if(i == layer->numclasses) return(MS_FALSE);
     }
 
@@ -668,7 +668,7 @@
   int oldAlphaBlending=0;  /* allow toggling of gd alpha blending (bug 490) */
 
   if(!msLayerIsVisible(map, layer))
-    return MS_SUCCESS;
+    return MS_SUCCESS;  
 
   if(layer->opacity == 0) return MS_SUCCESS; /* layer is completely transparent, skip it */
 
@@ -681,19 +681,19 @@
 
   if(MS_RENDERER_GD(image_draw->format)) {
 
-    /*
+    /* 
     ** for layer-level opacity we render to a temp image
     */
     if(layer->opacity > 0 && layer->opacity < 100) {
       msApplyOutputFormat(&transFormat, image->format, MS_TRUE, MS_NOOVERRIDE, MS_NOOVERRIDE);
-
+      
       image_draw = msImageCreateGD( image->width, image->height, transFormat, image->imagepath, image->imageurl );
       if(!image_draw) {
         msSetError(MS_GDERR, "Unable to initialize image.", "msDrawLayer()");
         return(MS_FAILURE);
       }
       msImageInitGD(image_draw, &map->imagecolor);
-
+      
       if(image_draw->format->imagemode == MS_IMAGEMODE_PC256) /* gdImageCopyMerge() needs this later */
         gdImageColorTransparent(image_draw->img.gd, 0);
     }
@@ -717,14 +717,14 @@
 					return (MS_FAILURE);
 				}
 			} else {
-				image_draw->format->r->startNewLayer(image_draw, layer->opacity);
+				image_draw->format->r->startNewLayer(image_draw,layer->opacity);
 			}
-		}
+		} 
   }
 #ifdef USE_AGG
   else if(MS_RENDERER_AGG(image_draw->format)) {
-
-    /*
+    
+    /* 
     ** for layer-level opacity we render to a temp image
     */
     if(layer->opacity > 0 && layer->opacity < 100) {
@@ -740,8 +740,8 @@
   }
 #endif
 
-  /*
-  ** redirect procesing of some layer types.
+  /* 
+  ** redirect procesing of some layer types. 
   */
   if(layer->connectiontype == MS_WMS) {
 #ifdef USE_WMS_LYR
@@ -750,7 +750,7 @@
           msAlphaAGG2GD(image_draw);
 #endif
     retcode = msDrawWMSLayer(map, layer, image_draw);
-#else
+#else  
     retcode = MS_FAILURE;
 #endif
   } else if(layer->type == MS_LAYER_RASTER) {
@@ -788,9 +788,9 @@
   }
   else if( MS_RENDERER_PLUGIN(image_draw->format) && layer->opacity > 0 && layer->opacity < 100 ) {
 	  if (!image_draw->format->r->supports_transparent_layers) {
-		  image_draw->format->r->mergeImages(image,image_draw,100,0,0);
+		  image_draw->format->r->mergeImages(image,image_draw,100,0,0);  
 		  image_draw->format->r->freeImage( image_draw );
-
+	
 		  /* deref and possibly free temporary transparent output format.  */
 		  msApplyOutputFormat( &transFormat, NULL, MS_NOOVERRIDE, MS_NOOVERRIDE, MS_NOOVERRIDE );
 	  } else {
@@ -842,13 +842,13 @@
   {
     if ((msLookupHashTable(&(layer->metadata), "SWFOUTPUT") &&
         strcasecmp(msLookupHashTable(&(layer->metadata), "SWFOUTPUT"),"RASTER")==0) ||
-        strcasecmp(msGetOutputFormatOption(image->format,"OUTPUT_MOVIE", ""),
+        strcasecmp(msGetOutputFormatOption(image->format,"OUTPUT_MOVIE", ""),  
                    "MULTIPLE") != 0)
     return msDrawVectorLayerAsRasterSWF(map, layer, image);
   }
 #endif
+  
 
-
 /* ==================================================================== */
 /*      For PDF if the output_type is set to raster, draw the vector    */
 /*      into a gd image.                                                */
@@ -856,7 +856,7 @@
 #ifdef USE_PDF
   if(image &&  MS_RENDERER_PDF(image->format))
   {
-    if (strcasecmp(msGetOutputFormatOption(image->format,"OUTPUT_TYPE", ""),
+    if (strcasecmp(msGetOutputFormatOption(image->format,"OUTPUT_TYPE", ""),  
                    "RASTER") == 0)
     return msDrawVectorLayerAsRasterPDF(map, layer, image);
   }
@@ -870,11 +870,11 @@
 
   /* reset layer pen values just in case the map has been previously processed */
   msClearLayerPenValues(layer);
-
+  
   /* open this layer */
   status = msLayerOpen(layer);
   if(status != MS_SUCCESS) return MS_FAILURE;
-
+  
   /* build item list */
 /* ==================================================================== */
 /*      For Flash, we use a metadata called SWFDUMPATTRIBUTES that      */
@@ -882,15 +882,15 @@
 /*      flash movie for query purpose.                                  */
 /* ==================================================================== */
   if(image && MS_RENDERER_SWF(image->format))
-    status = msLayerWhichItems(layer, MS_TRUE, annotate, msLookupHashTable(&(layer->metadata), "SWFDUMPATTRIBUTES"));
-  else
+    status = msLayerWhichItems(layer, MS_TRUE, annotate, msLookupHashTable(&(layer->metadata), "SWFDUMPATTRIBUTES"));                                
+  else        
     status = msLayerWhichItems(layer, MS_TRUE, annotate, NULL);
 
   if(status != MS_SUCCESS) {
     msLayerClose(layer);
     return MS_FAILURE;
   }
-
+  
   /* identify target shapes */
   if(layer->transform == MS_TRUE)
     searchrect = map->extent;
@@ -899,12 +899,12 @@
     searchrect.maxx = map->width-1;
     searchrect.maxy = map->height-1;
   }
-
+  
 #ifdef USE_PROJ
   if((map->projection.numargs > 0) && (layer->projection.numargs > 0))
     msProjectRect(&map->projection, &layer->projection, &searchrect); /* project the searchrect to source coords */
 #endif
-
+    
   status = msLayerWhichShapes(layer, searchrect);
   if(status == MS_DONE) { /* no overlap */
     msLayerClose(layer);
@@ -913,10 +913,10 @@
     msLayerClose(layer);
     return MS_FAILURE;
   }
-
+  
   /* step through the target shapes */
   msInitShape(&shape);
-
+  
   nclasses = 0;
   classgroup = NULL;
   if (layer->classgroup && layer->numclasses > 0)
@@ -929,12 +929,11 @@
        msFreeShape(&shape);
        continue;
     }
-
+  
     cache = MS_FALSE;
-    if(layer->type == MS_LAYER_LINE && (layer->class[shape.classindex]->numstyles > 1 || 
-        (layer->class[shape.classindex]->numstyles == 1 && layer->class[shape.classindex]->styles[0]->outlinewidth>0)))
+    if(layer->type == MS_LAYER_LINE && (layer->class[shape.classindex]->numstyles > 1||layer->class[shape.classindex]->styles[0]->outlinewidth>0))
       cache = MS_TRUE; /* only line layers with multiple styles need be cached (I don't think POLYLINE layers need caching - SDL) */
-
+         
     /* With 'STYLEITEM AUTO', we will have the datasource fill the class' */
     /* style parameters for this shape. */
     if(layer->styleitem && strcasecmp(layer->styleitem, "AUTO") == 0) {
@@ -942,59 +941,43 @@
         retcode = MS_FAILURE;
         break;
       }
-
+                  
       /* __TODO__ For now, we can't cache features with 'AUTO' style */
       cache = MS_FALSE;
     }
-
+  
     if(annotate && (layer->class[shape.classindex]->text.string || layer->labelitem) && layer->class[shape.classindex]->label.size != -1)
       shape.text = msShapeGetAnnotation(layer, &shape);
 
-    if (cache) {
+    if(cache) {
         int i;
-        for (i = 0; i < layer->class[shape.classindex]->numstyles; i++) {
-            styleObj *pStyle = layer->class[shape.classindex]->styles[i];
-            colorObj tmp;
-            if (pStyle->outlinewidth > 0) {
-                /* 
-                 * RFC 49 implementation
-                 * if an outlinewidth is used:
-                 *  - augment the style's width to account for the outline width
-                 *  - swap the style color and outlinecolor
-                 *  - draw the shape (the outline) in the first pass of the
-                 *    caching mechanism
-                 */
-                
-                /* adapt width (must take scalefactor into account) */
-                pStyle->width += (pStyle->outlinewidth / layer->scalefactor) * 2;
-                pStyle->minwidth += pStyle->outlinewidth * 2;
-                pStyle->maxwidth += pStyle->outlinewidth * 2;
-                
-                /*swap color and outlinecolor*/
-                tmp = pStyle->color;
-                pStyle->color = pStyle->outlinecolor;
-                pStyle->outlinecolor = tmp;
+        for(i=0;i<layer->class[shape.classindex]->numstyles;i++) {
+            if(layer->class[shape.classindex]->styles[i]->outlinewidth>0) {
+                colorObj tmp;
+                styleObj *styleTmp = layer->class[shape.classindex]->styles[i];
+                //msDebug("layer width before:%f\n",styleTmp->width);
+                styleTmp->width+=styleTmp->outlinewidth/layer->scalefactor*2;
+                //msDebug("layer width after:%f\n",styleTmp->width);
+                styleTmp->minwidth+=styleTmp->outlinewidth*2;
+                styleTmp->maxwidth+=styleTmp->outlinewidth*2;
+                tmp = styleTmp->color;
+                styleTmp->color=styleTmp->outlinecolor;
+                styleTmp->outlinecolor=tmp;
+                //layer->class[shape.classindex]->styles[i]->width+=layer->class[shape.classindex]->styles[i]->outlinewidth;
             }
-            if (i == 0 || pStyle->outlinewidth > 0) {
-                status = msDrawShape(map, layer, &shape, image, i, MS_TRUE); /* draw a single style */
+        }
+        status = msDrawShape(map, layer, &shape, image, 0,MS_TRUE); /* draw only the first style */
+        for(i=0;i<layer->class[shape.classindex]->numstyles;i++) {
+            if(layer->class[shape.classindex]->styles[i]->outlinewidth>0) {
+                colorObj tmp;
+                styleObj *styleTmp = layer->class[shape.classindex]->styles[i];
+                styleTmp->width-=styleTmp->outlinewidth/layer->scalefactor*2;
+                styleTmp->minwidth-=styleTmp->outlinewidth*2;
+                styleTmp->maxwidth-=styleTmp->outlinewidth*2;
+                tmp = styleTmp->color;
+                styleTmp->color=styleTmp->outlinecolor;
+                styleTmp->outlinecolor=tmp;
             }
-            if (pStyle->outlinewidth > 0) {
-                /*
-                 * RFC 49 implementation: switch back the styleobj to its
-                 * original state, so the line fill will be drawn in the
-                 * second pass of the caching mechanism
-                 */
-                
-                /* reset widths to original state */
-                pStyle->width -= (pStyle->outlinewidth / layer->scalefactor) * 2;
-                pStyle->minwidth -= pStyle->outlinewidth * 2;
-                pStyle->maxwidth -= pStyle->outlinewidth * 2;
-                
-                /*reswap colors to original state*/
-                tmp = pStyle->color;
-                pStyle->color = pStyle->outlinecolor;
-                pStyle->outlinecolor = tmp;
-            }
         }
     }
 
@@ -1010,18 +993,18 @@
       msFreeShape(&shape);
       continue;
     }
-
+  
     if(cache) {
       if(insertFeatureList(&shpcache, &shape) == NULL) {
         retcode = MS_FAILURE; /* problem adding to the cache */
         break;
       }
-    }
+    }  
 
     maxnumstyles = MS_MAX(maxnumstyles, layer->class[shape.classindex]->numstyles);
     msFreeShape(&shape);
   }
-
+    
   if (classgroup)
     msFree(classgroup);
 
@@ -1029,36 +1012,36 @@
     msLayerClose(layer);
     return MS_FAILURE;
   }
-
+  
   if(shpcache) {
     int s;
     for(s=0; s<maxnumstyles; s++) {
       for(current=shpcache; current; current=current->next) {
         if(layer->class[current->shape.classindex]->numstyles > s) {
-          styleObj *pStyle = layer->class[current->shape.classindex]->styles[s];
-          if(pStyle->_geomtransform!=MS_GEOMTRANSFORM_NONE)
+          styleObj *curStyle = layer->class[current->shape.classindex]->styles[s];
+          if(curStyle->_geomtransform!=MS_GEOMTRANSFORM_NONE)
         	continue; /*skip this as it has already been rendered*/
           if(map->scaledenom > 0) {
-            if((pStyle->maxscaledenom != -1) && (map->scaledenom >= pStyle->maxscaledenom))
+            if((curStyle->maxscaledenom != -1) && (map->scaledenom >= curStyle->maxscaledenom))
               continue;
-            if((pStyle->minscaledenom != -1) && (map->scaledenom < pStyle->minscaledenom))
+            if((curStyle->minscaledenom != -1) && (map->scaledenom < curStyle->minscaledenom))
               continue;
           }
-          if(s==0 && pStyle->outlinewidth>0 && MS_VALID_COLOR(pStyle->color)) {
-            msDrawLineSymbol(&map->symbolset, image, &current->shape, pStyle, layer->scalefactor);  
+          if(s==0 && curStyle->outlinewidth>0 && MS_VALID_COLOR(curStyle->color)) {
+            msDrawLineSymbol(&map->symbolset, image, &current->shape, curStyle, layer->scalefactor);  
           } else if(s>0)
-            msDrawLineSymbol(&map->symbolset, image, &current->shape, pStyle, layer->scalefactor);
+            msDrawLineSymbol(&map->symbolset, image, &current->shape, curStyle, layer->scalefactor);
         }
       }
     }
-
+    
     freeFeatureList(shpcache);
-    shpcache = NULL;
+    shpcache = NULL;  
   }
 
-  msLayerClose(layer);
+  msLayerClose(layer);  
   return MS_SUCCESS;
-
+  
 }
 
 /*
@@ -1079,11 +1062,11 @@
   if(!layer->resultcache || map->querymap.style == MS_NORMAL)
     return(msDrawLayer(map, layer, image));
 
-  if(!layer->data && !layer->tileindex && !layer->connection && !layer->features)
+  if(!layer->data && !layer->tileindex && !layer->connection && !layer->features) 
    return(MS_SUCCESS); /* no data associated with this layer, not an error since layer may be used as a template from MapScript */
 
   if(layer->type == MS_LAYER_QUERY || layer->type == MS_LAYER_TILEINDEX) return(MS_SUCCESS); /* query and tileindex layers simply can't be drawn, not an error */
-
+  
   if( layer->type == MS_LAYER_RASTER ) {
       msSetError( MS_QUERYERR, "Unable to draw raster layers (such as %s) as part of a query result.", "msDrawQueryLayer()", layer->name );
       return MS_FAILURE;
@@ -1130,10 +1113,6 @@
 
     for(i=0; i<layer->numclasses; i++) {
       if(layer->type == MS_LAYER_POLYGON) { /* alter BOTTOM style since that's almost always the fill */
-	if (layer->class[i]->styles == NULL) {
-           msSetError(MS_MISCERR, "Don't know how to draw class %s of layer %s without a style definition.", "msDrawQueryLayer()", layer->class[i]->name, layer->name);
-           return(MS_FAILURE);
-	}
         if(MS_VALID_COLOR(layer->class[i]->styles[0]->color)) {
           colorbuffer[i] = layer->class[i]->styles[0]->color; /* save the color from the BOTTOM style */
           layer->class[i]->styles[0]->color = map->querymap.color;
@@ -1189,12 +1168,12 @@
     shape.classindex = layer->resultcache->results[i].classindex;
     /* classindex may be -1 here if there was a template at the top level
      * in this layer and the current shape selected even if it didn't
-     * match any class
+     * match any class 
      *
-     * FrankW: classindex is also sometimes 0 even if there are no classes, so
+     * FrankW: classindex is also sometimes 0 even if there are no classes, so 
      * we are careful not to use out of range class values as an index.
      */
-    if(shape.classindex==-1
+    if(shape.classindex==-1 
        || shape.classindex >= layer->numclasses
        || layer->class[shape.classindex]->status == MS_OFF) {
       msFreeShape(&shape);
@@ -1202,7 +1181,7 @@
     }
 
     cache = MS_FALSE;
-    if(layer->type == MS_LAYER_LINE && layer->class[shape.classindex]->numstyles > 1)
+    if(layer->type == MS_LAYER_LINE && layer->class[shape.classindex]->numstyles > 1) 
       cache = MS_TRUE; /* only line layers with multiple styles need be cached (I don't think POLYLINE layers need caching - SDL) */
 
     if(annotate && (layer->class[shape.classindex]->text.string || layer->labelitem) && layer->class[shape.classindex]->label.size != -1)
@@ -1234,7 +1213,7 @@
 
   if(shpcache) {
     int s;
-
+  
     for(s=1; s<maxnumstyles; s++) {
       for(current=shpcache; current; current=current->next) {        
         if(layer->class[current->shape.classindex]->numstyles > s) {
@@ -1249,9 +1228,9 @@
         }
       }
     }
-
+    
     freeFeatureList(shpcache);
-    shpcache = NULL;
+    shpcache = NULL;  
   }
 
   /* if MS_HILITE, restore color and mindistance values */
@@ -1264,11 +1243,11 @@
           layer->class[i]->styles[0]->outlinecolor = colorbuffer[i]; /* if no color, restore outlinecolor for the BOTTOM style */
       } else {
         if(MS_VALID_COLOR(layer->class[i]->styles[layer->class[i]->numstyles-1]->color))
-          layer->class[i]->styles[layer->class[i]->numstyles-1]->color = colorbuffer[i];
+          layer->class[i]->styles[layer->class[i]->numstyles-1]->color = colorbuffer[i];        
         else if(MS_VALID_COLOR(layer->class[i]->styles[layer->class[i]->numstyles-1]->outlinecolor))
 	  layer->class[i]->styles[layer->class[i]->numstyles-1]->outlinecolor = colorbuffer[i]; /* if no color, restore outlinecolor for the TOP style */
       }
-
+    
       layer->class[i]->label.mindistance = mindistancebuffer[i];
     }
 
@@ -1284,7 +1263,7 @@
 /**
  * Generic function to render raster layers.
  */
-int msDrawRasterLayer(mapObj *map, layerObj *layer, imageObj *image)
+int msDrawRasterLayer(mapObj *map, layerObj *layer, imageObj *image) 
 {
     if (image && map && layer)
     {
@@ -1315,7 +1294,7 @@
 /**
  * msDrawWMSLayer()
  *
- * Draw a single WMS layer.
+ * Draw a single WMS layer.  
  * Multiple WMS layers in a map are preloaded and then drawn using
  * msDrawWMSLayerLow()
  */
@@ -1358,7 +1337,7 @@
             nStatus = msDrawWMSLayerLow(1, asReqInfo, numReq,
                                         map, layer, image) ;
 
-#ifdef USE_MING_FLASH
+#ifdef USE_MING_FLASH                
         else if( MS_RENDERER_SWF(image->format) )
             nStatus = msDrawWMSLayerSWF(1, asReqInfo, numReq,
                                         map, layer, image);
@@ -1367,7 +1346,7 @@
 /* PDF doesn't support WMS yet so return failure
         else if( MS_RENDERER_PDF(image->format) )
         {
-            nReturnVal = msDrawWMSLayerPDF(image, labelPnt, string, label,
+            nReturnVal = msDrawWMSLayerPDF(image, labelPnt, string, label, 
                                       fontset, scalefactor);
 			nStatus = MS_FAILURE;
 		}
@@ -1375,8 +1354,8 @@
 #endif
         else
         {
-            msSetError(MS_WMSCONNERR,
-                       "Output format '%s' doesn't support WMS layers.",
+            msSetError(MS_WMSCONNERR, 
+                       "Output format '%s' doesn't support WMS layers.", 
                        "msDrawWMSLayer()", image->format->name);
             nStatus = MS_SUCCESS; /* Should we fail if output doesn't support WMS? */
         }
@@ -1392,7 +1371,7 @@
 /*
 ** Function to render an individual shape, the style variable enables/disables the drawing of a single style
 ** versus a single style. This is necessary when drawing entire layers as proper overlay can only be achived
-** through caching. "querymapMode" parameter is used to tell msBindLayerToShape to not override the
+** through caching. "querymapMode" parameter is used to tell msBindLayerToShape to not override the 
 ** QUERYMAP HILITE color.
 */
 int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, int style, int querymapMode)
@@ -1403,22 +1382,22 @@
   double angle, length = 0.0;
   int bLabelNoClip = MS_FALSE;
   int annocallret = MS_FAILURE; /* Retvals for find-label-pnt calls */
-
+  
   int hasGeomTransform = MS_FALSE;
   shapeObj nonClippedShape;
-
+  
   pointObj center; /* circle origin */
   double r; /* circle radius */
   int csz; /* clip over size */
   double buffer;
   int status = MS_FAILURE;
-
+  
   labelPathObj *annopath = NULL; /* Curved label path. Bug #1620 implementation */
 
 
   /* set clipping rectangle just a bit larger than the map extent */
-/* Steve's original code
-  cliprect.minx = map->extent.minx - 2*map->cellsize;
+/* Steve's original code 
+  cliprect.minx = map->extent.minx - 2*map->cellsize; 
   cliprect.miny = map->extent.miny - 2*map->cellsize;
   cliprect.maxx = map->extent.maxx + 2*map->cellsize;
   cliprect.maxy = map->extent.maxy + 2*map->cellsize;
@@ -1435,7 +1414,7 @@
     if(layer->class[c]->styles[s]->rangeitem !=  NULL)
       msShapeToRange((layer->class[c]->styles[s]), shape);
   }
-
+  
   /* changed when Tomas added CARTOLINE symbols
    * adjust the clipping rectangle so that clipped polygon shapes with thick lines
    * do not enter the image */
@@ -1458,10 +1437,11 @@
 
   if(msBindLayerToShape(layer, shape, querymapMode) != MS_SUCCESS)
     return MS_FAILURE; /* error message is set in msBindLayerToShape() */
-
+  
   if(shape->text && (layer->class[c]->label.encoding || layer->class[c]->label.wrap
           ||layer->class[c]->label.maxlength)) {
       char *newtext=msTransformLabelText(map,image,&(layer->class[c]->label),shape->text);
+      //if(!newtext) return MS_FAILURE;
       free(shape->text);
       shape->text = newtext;
   }
@@ -1485,7 +1465,7 @@
     if(layer->transform == MS_TRUE) {
       center.x = MS_MAP2IMAGE_X(center.x, map->extent.minx, map->cellsize);
       center.y = MS_MAP2IMAGE_Y(center.y, map->extent.maxy, map->cellsize);
-      r /= map->cellsize;
+      r /= map->cellsize;      
     } else
       msOffsetPointRelativeTo(&center, layer);
 
@@ -1536,7 +1516,7 @@
 
         msFreeShape(&annoshape);
       }
-
+    
       if(layer->transform == MS_TRUE) {
         msClipPolylineRect(shape, cliprect);
         if(shape->numlines == 0) return(MS_SUCCESS);
@@ -1554,7 +1534,7 @@
 
         if( annopath ) {
           labelObj label = layer->class[c]->label;
-
+          
           if(layer->labelcache) {
             if(msAddLabel(map, layer->index, c, shape->index, shape->tileindex, NULL, annopath, shape->text, length, &label) != MS_SUCCESS) return(MS_FAILURE);
           } else {
@@ -1580,7 +1560,7 @@
         /* succesfully calculated it previously                                */
         if ((bLabelNoClip == MS_TRUE && annocallret == MS_SUCCESS) || (msPolylineLabelPoint(shape, &annopnt, layer->class[c]->label.minfeaturesize, &angle, &length) == MS_SUCCESS)) {
           labelObj label = layer->class[c]->label;
-
+          
           if(label.angle != 0)
             label.angle -= map->gt.rotation_angle;
 
@@ -1737,7 +1717,7 @@
     }
     break; /* end MS_LAYER_POINT */
 
-  case MS_LAYER_LINE:
+  case MS_LAYER_LINE:    
     if(shape->type != MS_SHAPE_POLYGON && shape->type != MS_SHAPE_LINE) {
       msSetError(MS_MISCERR, "Only polygon or line shapes can be drawn using a line layer definition.", "msDrawShape()");
       return(MS_FAILURE);
@@ -1786,7 +1766,7 @@
       msClipPolylineRect(shape, cliprect);
       if(shape->numlines == 0) {
         if(hasGeomTransform)
-          msFreeShape(&nonClippedShape);
+          msFreeShape(&nonClippedShape);   
         return(MS_SUCCESS);
       }
       msTransformShape(shape, map->extent, map->cellsize, image);
@@ -1795,7 +1775,7 @@
     } else {
       msOffsetShapeRelativeTo(shape, layer);
     }
-
+    
 	if(hasGeomTransform)
       msOffsetShapeRelativeTo(&nonClippedShape, layer);
 	
@@ -1814,11 +1794,11 @@
       else if(style==-1 || s==style)
         msDrawLineSymbol(&map->symbolset, image, shape, curStyle, layer->scalefactor);
     }
-
+    
     /*RFC48: free non clipped shape if it was previously alloced/used*/
     if(hasGeomTransform)
       msFreeShape(&nonClippedShape);
-
+    
     if(shape->text) {
 
       /* Bug #1620 implementation */
@@ -1836,7 +1816,7 @@
           } else {
             /* FIXME: need to call msDrawTextLineGD() from here eventually */
             /* msDrawLabel(image, label_line->point[0], shape->text, &label, &map->fontset, layer->scalefactor); */
-
+            
             msFreeLabelPathObj(annopath);
           }
         }
@@ -1845,7 +1825,7 @@
       /* Use regular label algorithm if angle is AUTO or a number, or if ANGLE FOLLOW failed */
       if ( layer->class[c]->label.autofollow == MS_FALSE || (!annopath && status != MS_FAILURE) ) {
 
-      if((bLabelNoClip == MS_TRUE && annocallret == MS_SUCCESS) ||
+      if((bLabelNoClip == MS_TRUE && annocallret == MS_SUCCESS) || 
          (msPolylineLabelPoint(shape, &annopnt, layer->class[c]->label.minfeaturesize, &angle, &length) == MS_SUCCESS)) {
         labelObj label = layer->class[c]->label;
 
@@ -1872,7 +1852,7 @@
 #ifdef USE_PROJ
     if(layer->project && msProjectionsDiffer(&(layer->projection), &(map->projection))) {
       if(msProjectShape(&layer->projection, &map->projection, shape) == MS_FAILURE ) {
-#ifdef notdef
+#ifdef notdef 
         msSetError(MS_PROJERR, "Reprojecting a shape failed.", "msDrawShape()" );
         return MS_FAILURE;
 #else
@@ -1918,7 +1898,7 @@
       msClipPolygonRect(shape, cliprect);
       if(shape->numlines == 0) {
         if(hasGeomTransform)
-          msFreeShape(&nonClippedShape);
+          msFreeShape(&nonClippedShape);   
         return(MS_SUCCESS);
       }
       msTransformShape(shape, map->extent, map->cellsize, image);
@@ -1974,21 +1954,21 @@
 ** Function to render an individual point, used as a helper function for mapscript only. Since a point
 ** can't carry attributes you can't do attribute based font size or angle.
 */
-int msDrawPoint(mapObj *map, layerObj *layer, pointObj *point, imageObj *image,
+int msDrawPoint(mapObj *map, layerObj *layer, pointObj *point, imageObj *image, 
                 int classindex, char *labeltext)
 {
   int s;
   char *newtext;
   classObj *theclass=layer->class[classindex];
   labelObj *label=&(theclass->label);
-
+ 
 #ifdef USE_PROJ
   if(layer->project && msProjectionsDiffer(&(layer->projection), &(map->projection)))
     msProjectPoint(&layer->projection, &map->projection, point);
   else
     layer->project = MS_FALSE;
 #endif
-
+  
   /*apply wrap character and encoding to the label text*/
   if(labeltext &&(label->encoding || label->wrap || label->maxlength))
       newtext = msTransformLabelText(map,image,label,labeltext);
@@ -2052,7 +2032,7 @@
   default:
     break; /* don't do anything with layer of other types */
   }
-
+  
   if(newtext!=labeltext) /*free the transformed text if necessary*/
     free(newtext);
 
@@ -2154,7 +2134,7 @@
 {
   int nReturnVal = MS_SUCCESS;
   if(image) {
-    if(MS_RENDERER_PLUGIN(image->format) || MS_RENDERER_GD(image->format) || MS_RENDERER_AGG(image->format)) {
+    if(MS_RENDERER_PLUGIN(image->format) || MS_RENDERER_GD(image->format) || MS_RENDERER_AGG(image->format)) {          
       pointObj p;
       int i, l, priority;
       int oldAlphaBlending=0;
@@ -2175,7 +2155,7 @@
       const char *value;
 
 #ifdef USE_AGG
-      if(MS_RENDERER_AGG(image->format))
+      if(MS_RENDERER_AGG(image->format)) 
         msAlphaGD2AGG(image);
       else
 #endif
@@ -2226,12 +2206,12 @@
               return(-1);
 
             marker_offset_x = MS_NINT(marker_width/2.0);
-            marker_offset_y = MS_NINT(marker_height/2.0);
+            marker_offset_y = MS_NINT(marker_height/2.0);      
 
             marker_rect.minx = MS_NINT(cachePtr->point.x - .5 * marker_width);
             marker_rect.miny = MS_NINT(cachePtr->point.y - .5 * marker_height);
             marker_rect.maxx = marker_rect.minx + (marker_width-1);
-            marker_rect.maxy = marker_rect.miny + (marker_height-1);
+            marker_rect.maxy = marker_rect.miny + (marker_height-1); 
           }
 
           /* handle path following labels first (position does not matter) */
@@ -2305,7 +2285,7 @@
                 if(MS_VALID_COLOR(labelPtr->backgroundcolor))
                   get_metrics_line(&(cachePtr->point), labelPtr->position, r, (marker_offset_x + labelPtr->offsetx), (marker_offset_y + labelPtr->offsety), labelPtr->angle, 1, billboard.line);
               }
-
+  
               if(layerPtr->type == MS_LAYER_ANNOTATION && cachePtr->numstyles > 0)
                 msRectToPolygon(marker_rect, cachePtr->poly); /* save marker bounding polygon, part of overlap tests */
 
@@ -2330,7 +2310,7 @@
           if(!cachePtr->labelpath && MS_VALID_COLOR(labelPtr->backgroundcolor)) {
             styleObj style;
 
-            initStyle(&style);
+            initStyle(&style);                    
             if(MS_VALID_COLOR(labelPtr->backgroundshadowcolor)) {
               MS_COPYCOLOR(&(style.color),&(labelPtr->backgroundshadowcolor));
               style.offsetx = labelPtr->backgroundshadowsizex;
@@ -2376,7 +2356,7 @@
 }
 
 /**
- * Generic function to tell the underline device that layer
+ * Generic function to tell the underline device that layer 
  * drawing is stating
  */
 
@@ -2392,7 +2372,7 @@
 #endif
 #ifdef USE_PDF
         if( MS_RENDERER_PDF(image->format) )
-            msImageStartLayerPDF(map, layer, image);
+            msImageStartLayerPDF(map, layer, image); 
 #endif
         if( MS_RENDERER_SVG(image->format) )
             msImageStartLayerSVG(map, layer, image);
@@ -2401,7 +2381,7 @@
 
 
 /**
- * Generic function to tell the underline device that layer
+ * Generic function to tell the underline device that layer 
  * drawing is ending
  */
 
@@ -2410,7 +2390,7 @@
 }
 
 /**
- * Generic function to tell the underline device that shape
+ * Generic function to tell the underline device that shape 
  * drawing is stating
  */
 
@@ -2428,22 +2408,22 @@
         if( MS_RENDERER_PDF(map->outputformat) )
             msDrawStartShapePDF(map, layer, image, shape);
 #endif
-
+               
     }
 }
 
 
 /**
- * Generic function to tell the underline device that shape
+ * Generic function to tell the underline device that shape 
  * drawing is ending
  */
 
-void msDrawEndShape(mapObj *map, layerObj *layer, imageObj *image,
+void msDrawEndShape(mapObj *map, layerObj *layer, imageObj *image, 
                     shapeObj *shape)
 {
 }
 /**
- * take the value from the shape and use it to change the
+ * take the value from the shape and use it to change the 
  * color in the style to match the range map
  */
 int msShapeToRange(styleObj *style, shapeObj *shape)
@@ -2465,8 +2445,8 @@
 }
 
 /**
- * Allow direct mapping of a value so that mapscript can use the
- * Ranges.  The styls passed in is updated to reflect the right color
+ * Allow direct mapping of a value so that mapscript can use the 
+ * Ranges.  The styls passed in is updated to reflect the right color 
  * based on the fieldVal
  */
 int msValueToRange(styleObj *style, double fieldVal)
@@ -2476,7 +2456,7 @@
 
   range = style->maxvalue - style->minvalue;
   scaledVal = (fieldVal - style->minvalue)/range;
-
+  
   /*At this point, we know where on the range we need to be*/
   /*However, we don't know how to map it yet, since RGB(A) can */
   /*Go up or down*/



More information about the mapserver-commits mailing list