[mapserver-commits] r9611 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Wed Dec 9 16:43:43 EST 2009


Author: aboudreault
Date: 2009-12-09 16:43:42 -0500 (Wed, 09 Dec 2009)
New Revision: 9611

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapogcsld.c
   trunk/mapserver/mapogcsld.h
Log:
Fixed ogc sld functions to return proper values (#2165)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2009-12-09 18:08:52 UTC (rev 9610)
+++ trunk/mapserver/HISTORY.TXT	2009-12-09 21:43:42 UTC (rev 9611)
@@ -14,6 +14,8 @@
 Current Version (SVN trunk):
 ----------------------------
 
+- Fixed ogc sld functions to return proper values (#2165)
+
 - MAP EXTENT truncates GetFeature requests for data outside bounds (#1287)
 
 - Added msStringSplitComplex function (#471)

Modified: trunk/mapserver/mapogcsld.c
===================================================================
--- trunk/mapserver/mapogcsld.c	2009-12-09 18:08:52 UTC (rev 9610)
+++ trunk/mapserver/mapogcsld.c	2009-12-09 21:43:42 UTC (rev 9611)
@@ -712,7 +712,7 @@
 /*                                                                      */
 /*      Parse NamedLayer root.                                          */
 /************************************************************************/
-void msSLDParseNamedLayer(CPLXMLNode *psRoot, layerObj *psLayer)
+int msSLDParseNamedLayer(CPLXMLNode *psRoot, layerObj *psLayer)
 {
     CPLXMLNode *psFeatureTypeStyle, *psRule, *psUserStyle; 
     CPLXMLNode *psSLDName = NULL, *psNamedStyle=NULL;
@@ -728,8 +728,9 @@
     int j=0;
 
 
-    if (psRoot && psLayer)
-    {
+    if (!psRoot || !psLayer)
+        return MS_FAILURE;
+
         psUserStyle = CPLGetXMLNode(psRoot, "UserStyle");
         if (psUserStyle)
         {
@@ -902,7 +903,8 @@
                   psLayer->classgroup = strdup(psSLDName->psChild->pszValue);
             }
         }
-    }
+
+        return MS_SUCCESS;
 }
 
 
@@ -911,7 +913,7 @@
 /*                                                                      */
 /*      Parse a Rule node into classes for a spcific layer.             */
 /************************************************************************/
-void msSLDParseRule(CPLXMLNode *psRoot, layerObj *psLayer)
+int msSLDParseRule(CPLXMLNode *psRoot, layerObj *psLayer)
 {
     CPLXMLNode *psLineSymbolizer = NULL;
     CPLXMLNode *psPolygonSymbolizer = NULL;
@@ -922,8 +924,9 @@
     int bSymbolizer = 0;
     int bNewClass=0, nSymbolizer=0;
 
-    if (psRoot && psLayer)
-    {
+    if (!psRoot || !psLayer)
+        return MS_FAILURE;
+
         /* TODO : parse name of the rule */
 /* -------------------------------------------------------------------- */
 /*      The SLD specs assumes here that a certain FeatureType can only have*/
@@ -1049,7 +1052,8 @@
             psRasterSymbolizer = psRasterSymbolizer->psNext;
             psLayer->type = MS_LAYER_RASTER;
         } 
-    }
+
+        return MS_SUCCESS;
 }
 
 
@@ -1098,22 +1102,23 @@
 /*      </Rule>                                                         */
 /*       ...                                                            */
 /************************************************************************/
-void msSLDParseLineSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer,
+int msSLDParseLineSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer,
                               int bNewClass)
 {
     int nClassId = 0;
     CPLXMLNode *psStroke=NULL, *psOffset=NULL;
     int iStyle = 0;
 
-    if (psRoot && psLayer)
-    {
+    if (!psRoot || !psLayer)
+        return MS_FAILURE;
+
         psStroke =  CPLGetXMLNode(psRoot, "Stroke");
         if (psStroke)
         {
             if (bNewClass || psLayer->numclasses <= 0)
             {
         	if (msGrowLayerClasses(psLayer) == NULL)
-                    return; /* MS_FAILURE */
+                    return MS_FAILURE;
                 initClass(psLayer->class[psLayer->numclasses]);
                 nClassId = psLayer->numclasses;
                 psLayer->numclasses++;
@@ -1135,7 +1140,8 @@
               psLayer->class[nClassId]->styles[iStyle]->offsety = psLayer->class[nClassId]->styles[iStyle]->offsetx;
             }
         }
-    }
+
+    return MS_SUCCESS;
 }
 
 
@@ -1151,8 +1157,8 @@
 /*        1 : outlinecolor                                              */
 /*        2 : backgroundcolor                                           */
 /************************************************************************/
-void msSLDParseStroke(CPLXMLNode *psStroke, styleObj *psStyle,
-                      mapObj *map, int iColorParam)
+int msSLDParseStroke(CPLXMLNode *psStroke, styleObj *psStyle,
+                     mapObj *map, int iColorParam)
 {
     CPLXMLNode *psCssParam = NULL, *psGraphicFill=NULL;
     char *psStrkName = NULL;
@@ -1160,8 +1166,9 @@
     int nLength = 0;
     char *pszDashValue = NULL;
 
-    if (psStroke && psStyle)
-    {
+    if (!psStroke || !psStyle)
+        return MS_FAILURE;
+
         /* parse css parameters */
         psCssParam =  CPLGetXMLNode(psStroke, "CssParameter");
         /*sld 1.1 used SvgParameter*/ 
@@ -1273,7 +1280,8 @@
 
         if (pszDashValue)
           free(pszDashValue);
-    }
+
+        return MS_SUCCESS;
 }
 
 
@@ -1354,7 +1362,7 @@
 /*      marks may be made solid or hollow depending on Fill and Stroke elements.*/
 /*                                                                      */
 /************************************************************************/
-void msSLDParsePolygonSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer, 
+int msSLDParsePolygonSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer, 
                                  int bNewClass)
 {
     CPLXMLNode *psFill, *psStroke;
@@ -1362,8 +1370,9 @@
     CPLXMLNode *psDisplacement=NULL, *psDisplacementX=NULL, *psDisplacementY=NULL;
     int nOffsetX=-1, nOffsetY=-1;
 
-    if (psRoot && psLayer)
-    {
+    if (!psRoot || !psLayer)
+        return MS_FAILURE;
+
         /*parse displacement for SLD 1.1.0*/
         psDisplacement = CPLGetXMLNode(psRoot, "Displacement");
         if (psDisplacement)
@@ -1389,7 +1398,7 @@
             if (bNewClass || psLayer->numclasses <= 0)
             {
         	if (msGrowLayerClasses(psLayer) == NULL)
-                    return; /* MS_FAILURE */
+                    return MS_FAILURE;
                 initClass(psLayer->class[psLayer->numclasses]);
                 nClassId = psLayer->numclasses;
                 psLayer->numclasses++;
@@ -1429,7 +1438,7 @@
                 if (bNewClass || psLayer->numclasses <= 0)
                 {
         	    if (msGrowLayerClasses(psLayer) == NULL)
-                        return; /* MS_FAILURE */
+                        return MS_FAILURE;
                     initClass(psLayer->class[psLayer->numclasses]);
                     nClassId = psLayer->numclasses;
                     psLayer->numclasses++;
@@ -1450,7 +1459,8 @@
                 psLayer->class[nClassId]->styles[iStyle]->offsety = nOffsetY;  
             }
         }
-    }
+
+        return MS_SUCCESS;
 }
   
 
@@ -1460,15 +1470,16 @@
 /*                                                                      */
 /*      Parse the Fill node for a polygon into a style.                 */
 /************************************************************************/
-void msSLDParsePolygonFill(CPLXMLNode *psFill, styleObj *psStyle,
-                           mapObj *map)
+int msSLDParsePolygonFill(CPLXMLNode *psFill, styleObj *psStyle,
+                          mapObj *map)
 {
     CPLXMLNode *psCssParam, *psGraphicFill;
     char *psColor=NULL, *psFillName=NULL;
     int nLength = 0;
 
-    if (psFill && psStyle && map)
-    {
+    if (!psFill || !psStyle || !map)
+        return MS_FAILURE;
+
         /* sets the default fill color defined in the spec #808080 */
         psStyle->color.red = 128;
         psStyle->color.green = 128;
@@ -1529,7 +1540,7 @@
           msSLDParseGraphicFillOrStroke(psGraphicFill, NULL, psStyle, map, 0);
 
         
-    }
+        return MS_SUCCESS;
 }
 
 
@@ -1539,7 +1550,7 @@
 /*      Parse the GraphicFill Or GraphicStroke node : look for a        */
 /*      Marker symbol and set the style for that symbol.                */
 /************************************************************************/
-void msSLDParseGraphicFillOrStroke(CPLXMLNode *psRoot, 
+int msSLDParseGraphicFillOrStroke(CPLXMLNode *psRoot, 
                                    char *pszDashValue,
                                    styleObj *psStyle, mapObj *map,
                                    int bPointLayer)
@@ -1555,8 +1566,8 @@
     
     bPointLayer=0;
 
-    if (psRoot && psStyle && map)
-    {
+    if (!psRoot || !psStyle || !map)
+        return MS_FAILURE;
 /* ==================================================================== */
 /*      This a definition taken from the specification (11.3.2) :       */
 /*      Graphics can either be referenced from an external URL in a common format (such as*/
@@ -1749,7 +1760,8 @@
                   msSLDParseExternalGraphic(psExternalGraphic, psStyle, map);
             }
         }
-    }
+
+        return MS_SUCCESS;
 }
   
 /************************************************************************/
@@ -2235,18 +2247,19 @@
 /*      </xs:complexType>                                               */
 /*      </xs:element>                                                   */
 /************************************************************************/
-void msSLDParsePointSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer,
+int msSLDParsePointSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer,
                                int bNewClass)
 {
     int nClassId = 0;
     int iStyle = 0;
 
-    if (psRoot && psLayer)
-    {
+    if (!psRoot || !psLayer)
+        return MS_FAILURE;
+
         if (bNewClass || psLayer->numclasses <= 0)
         {
             if (msGrowLayerClasses(psLayer) == NULL)
-                return; /* MS_FAILURE */
+                return MS_FAILURE;
             initClass(psLayer->class[psLayer->numclasses]);
             nClassId = psLayer->numclasses;
             psLayer->numclasses++;
@@ -2261,7 +2274,8 @@
         msSLDParseGraphicFillOrStroke(psRoot, NULL,
                                       psLayer->class[nClassId]->styles[iStyle],
                                       psLayer->map, 1);
-    }
+
+        return MS_SUCCESS;
 }
 
 
@@ -2272,7 +2286,7 @@
 /*      by the URL and create a PIXMAP inmap symbol. Only GIF and       */
 /*      PNG are supported.                                              */
 /************************************************************************/
-void msSLDParseExternalGraphic(CPLXMLNode *psExternalGraphic, 
+int msSLDParseExternalGraphic(CPLXMLNode *psExternalGraphic, 
                                styleObj *psStyle,  mapObj *map)
 {
 /* needed for libcurl function msHTTPGetFile in maphttp.c */
@@ -2284,8 +2298,9 @@
     int status;
 
 
-    if (psExternalGraphic && psStyle && map)
-    {
+    if (!psExternalGraphic || !psStyle || !map)
+        return MS_FAILURE;
+
         psFormat = CPLGetXMLNode(psExternalGraphic, "Format");
         if (psFormat && psFormat->psChild && psFormat->psChild->pszValue)
           pszFormat = psFormat->psChild->pszValue;
@@ -2367,7 +2382,8 @@
                 }
             }
         }
-    }
+        
+        return MS_SUCCESS;
 #endif
 }
 
@@ -2464,17 +2480,18 @@
 /*      </xs:complexType>                                               */
 /*      </xs:element>                                                   */
 /************************************************************************/
-void msSLDParseTextSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer,
+int msSLDParseTextSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer,
                               int bOtherSymboliser)
 {
     int nStyleId=0, nClassId=0;
 
-    if (psRoot && psLayer)
-    {
+    if (!psRoot || !psLayer)
+        return MS_FAILURE;
+
         if (!bOtherSymboliser)
         {	
             if (msGrowLayerClasses(psLayer) == NULL)
-                return; /* MS_FAILURE */
+                return MS_FAILURE;
             initClass(psLayer->class[psLayer->numclasses]);
             nClassId = psLayer->numclasses;
             psLayer->numclasses++;
@@ -2491,7 +2508,8 @@
         if (nStyleId >= 0 && nClassId >= 0) /* should always be true */
           msSLDParseTextParams(psRoot, psLayer,
                                psLayer->class[nClassId]);
-    }
+
+        return MS_SUCCESS;
 }
 
 
@@ -2588,7 +2606,7 @@
 /*      </xsd:simpleType>                                               */
 /*                                                                      */
 /************************************************************************/
-void msSLDParseRasterSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer)
+int msSLDParseRasterSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer)
 {
     CPLXMLNode  *psColorMap = NULL, *psColorEntry = NULL, *psOpacity=NULL;
     char *pszColor=NULL, *pszQuantity=NULL;
@@ -2608,7 +2626,7 @@
     int i,nMaxValues= 100, nMaxThreshold=100;
 
     if (!psRoot || !psLayer)
-      return;
+      return MS_FAILURE;
 
 /* ==================================================================== */
 /*      The default opacity value is 0 : we set it here to -1           */
@@ -2630,6 +2648,7 @@
         else
         {
             msSetError(MS_WMSERR, "Invalid opacity value. Values should be between 0.0 and 1.0", "msSLDParseRasterSymbolizer()");
+            return MS_FAILURE;
         }
     }
     psColorMap = CPLGetXMLNode(psRoot, "ColorMap");
@@ -2685,7 +2704,7 @@
 
 
                             if (msGrowLayerClasses(psLayer) == NULL)
-                              return/* MS_FAILURE */;
+                              return MS_FAILURE;
                             else
                             {
                                 initClass(psLayer->class[psLayer->numclasses]);
@@ -2724,6 +2743,7 @@
                             msSetError(MS_WMSERR, 
                                        "Invalid ColorMap Entry.", 
                                        "msSLDParseRasterSymbolizer()");
+                            return MS_FAILURE;
                         }
 
                     }
@@ -2753,7 +2773,7 @@
                     }
 
                     if (msGrowLayerClasses(psLayer) == NULL)
-                      return/* MS_FAILURE */;
+                      return MS_FAILURE;
                     else
                     {
                         initClass(psLayer->class[psLayer->numclasses]);
@@ -2893,20 +2913,23 @@
             free(papszThresholds);
 
             
-        }
+        } 
         else
         {
             msSetError(MS_WMSERR, "Invalid SLD document. msSLDParseRaster", "");
+            return MS_FAILURE;
         }
     }
+
+    return MS_SUCCESS;
 }
 /************************************************************************/
 /*                           msSLDParseTextParams                       */
 /*                                                                      */
 /*      Parse text paramaters like font, placement and color.           */
 /************************************************************************/
-void msSLDParseTextParams(CPLXMLNode *psRoot, layerObj *psLayer, 
-                          classObj *psClass)
+int msSLDParseTextParams(CPLXMLNode *psRoot, layerObj *psLayer, 
+                         classObj *psClass)
 {
     char szFontName[100];
     double  dfFontSize = 10;
@@ -2927,8 +2950,9 @@
 
     szFontName[0]='\0';
 
-    if (psRoot && psClass && psLayer)
-    {
+    if (!psRoot || !psClass || !psLayer)
+        return MS_FAILURE;
+    
         /*set the angle by default to auto. the angle can be
           modified Label Placement #2806*/
         psClass->label.autoangle = MS_TRUE;
@@ -3181,7 +3205,7 @@
             }/* labelitem */
         }
 
-    }
+        return MS_SUCCESS;
 }
 
 /************************************************************************/
@@ -3189,7 +3213,7 @@
 /*                                                                      */
 /*      point placement node for the text symbolizer.                  */
 /************************************************************************/
-void ParseTextPointPlacement(CPLXMLNode *psRoot, classObj *psClass)
+int ParseTextPointPlacement(CPLXMLNode *psRoot, classObj *psClass)
 {
     CPLXMLNode *psAnchor, *psAnchorX, *psAnchorY;
     double dfAnchorX=0, dfAnchorY=0;
@@ -3197,8 +3221,9 @@
     CPLXMLNode *psRotation=NULL, *psPropertyName=NULL;
     char szTmp[100];
 
-    if (psRoot && psClass)
-    {
+    if (!psRoot || !psClass)
+        return MS_FAILURE;
+
         /* init the label with the default position */
         psClass->label.position = MS_CL;
 
@@ -3289,7 +3314,8 @@
                   psClass->label.angle = atof(psRotation->psChild->pszValue);
             }
         }
-    }   
+        
+        return MS_SUCCESS;
 }
 
 /************************************************************************/
@@ -3297,11 +3323,13 @@
 /*                                                                      */
 /*      Lineplacement node fro the text symbolizer.                     */
 /************************************************************************/
-void ParseTextLinePlacement(CPLXMLNode *psRoot, classObj *psClass)
+int ParseTextLinePlacement(CPLXMLNode *psRoot, classObj *psClass)
 {
   CPLXMLNode *psOffset = NULL, *psAligned=NULL;
-    if (psRoot && psClass)
-    {
+
+  if (!psRoot || !psClass)
+      return MS_FAILURE;
+
         /*if there is a line placement, we will assume that the 
           best setting for mapserver would be for the text to follow
           the line #2806*/
@@ -3333,8 +3361,8 @@
                 psClass->label.autofollow = MS_FALSE; 
             }
         }
-    }
-            
+
+        return MS_SUCCESS;
 }
 
 
@@ -3346,7 +3374,7 @@
 /*      color string (format is : #aaff08) and set it in the color      */
 /*      object.                                                         */
 /************************************************************************/
-void msSLDSetColorObject(char *psHexColor, colorObj *psColor)
+int msSLDSetColorObject(char *psHexColor, colorObj *psColor)
 {
     if (psHexColor && psColor && strlen(psHexColor)== 7 && 
         psHexColor[0] == '#')
@@ -3356,6 +3384,8 @@
         psColor->green = msHexToInt(psHexColor+3);
         psColor->blue= msHexToInt(psHexColor+5);
     }
+
+    return MS_SUCCESS;
 }   
 
 #endif

Modified: trunk/mapserver/mapogcsld.h
===================================================================
--- trunk/mapserver/mapogcsld.h	2009-12-09 18:08:52 UTC (rev 9610)
+++ trunk/mapserver/mapogcsld.h	2009-12-09 21:43:42 UTC (rev 9611)
@@ -44,27 +44,27 @@
 /*      prototypes.                                                     */
 /* -------------------------------------------------------------------- */
 layerObj  *msSLDParseSLD(mapObj *map, char *psSLDXML, int *pnLayers);
-void msSLDParseNamedLayer(CPLXMLNode *psRoot, layerObj *layer);
-void msSLDParseRule(CPLXMLNode *psRoot, layerObj *psLayer);
-void msSLDParseStroke(CPLXMLNode *psStroke, styleObj *psStyle,
-                      mapObj *map, int iColorParam);
-void msSLDParsePolygonFill(CPLXMLNode *psFill, styleObj *psStyle,
+int msSLDParseNamedLayer(CPLXMLNode *psRoot, layerObj *layer);
+int msSLDParseRule(CPLXMLNode *psRoot, layerObj *psLayer);
+int msSLDParseStroke(CPLXMLNode *psStroke, styleObj *psStyle,
+                     mapObj *map, int iColorParam);
+int msSLDParsePolygonFill(CPLXMLNode *psFill, styleObj *psStyle,
                            mapObj *map);
 
-void msSLDParseLineSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer,  
+int msSLDParseLineSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer,  
+                             int bNewClass);
+int msSLDParsePolygonSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer,
+                                int bNewClass);
+int msSLDParsePointSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer, 
                               int bNewClass);
-void msSLDParsePolygonSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer,
-                                  int bNewClass);
-void msSLDParsePointSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer, 
-                               int bNewClass);
-void msSLDParseTextSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer,
+int msSLDParseTextSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer,
                               int bOtherSymboliser);
-void msSLDParseRasterSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer);
+int msSLDParseRasterSymbolizer(CPLXMLNode *psRoot, layerObj *psLayer);
 
-void msSLDParseGraphicFillOrStroke(CPLXMLNode *psGraphicFill,
-                                   char *pszDashValue,
-                                   styleObj *psStyle, mapObj *map, int bPointLayer);
-void msSLDParseExternalGraphic(CPLXMLNode *psExternalGraphic, styleObj *psStyle, 
+int msSLDParseGraphicFillOrStroke(CPLXMLNode *psGraphicFill,
+                                  char *pszDashValue,
+                                  styleObj *psStyle, mapObj *map, int bPointLayer);
+int msSLDParseExternalGraphic(CPLXMLNode *psExternalGraphic, styleObj *psStyle, 
                               mapObj *map);
 
 int msSLDGetLineSymbol(mapObj *map);
@@ -73,11 +73,11 @@
                        char *pszDashValue);
 int msSLDGetGraphicSymbol(mapObj *map, char *pszFileName, char *extGraphicName, int nGap);
 
-void msSLDSetColorObject(char *psHexColor, colorObj *psColor);
+int msSLDSetColorObject(char *psHexColor, colorObj *psColor);
 
-void msSLDParseTextParams(CPLXMLNode *psRoot, layerObj *psLayer, classObj *psClass);
-void ParseTextPointPlacement(CPLXMLNode *psRoot, classObj *psClass);
-void ParseTextLinePlacement(CPLXMLNode *psRoot, classObj *psClass);
+int msSLDParseTextParams(CPLXMLNode *psRoot, layerObj *psLayer, classObj *psClass);
+int ParseTextPointPlacement(CPLXMLNode *psRoot, classObj *psClass);
+int ParseTextLinePlacement(CPLXMLNode *psRoot, classObj *psClass);
 
 char *msSLDGenerateSLDLayer(layerObj *psLayer, int nVersion);
 



More information about the mapserver-commits mailing list