[QGIS Commit] r8321 - trunk/qgis/python/plugins/mapserver_export

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Apr 6 23:22:57 EDT 2008


Author: gsherman
Date: 2008-04-06 23:22:56 -0400 (Sun, 06 Apr 2008)
New Revision: 8321

Modified:
   trunk/qgis/python/plugins/mapserver_export/ms_export.py
Log:
Fix for condition where layer name is blank in the legend


Modified: trunk/qgis/python/plugins/mapserver_export/ms_export.py
===================================================================
--- trunk/qgis/python/plugins/mapserver_export/ms_export.py	2008-04-06 10:49:26 UTC (rev 8320)
+++ trunk/qgis/python/plugins/mapserver_export/ms_export.py	2008-04-07 03:22:56 UTC (rev 8321)
@@ -280,7 +280,11 @@
 
       self.outFile.write("  LAYER\n")
       # write the name of the layer
-      self.outFile.write("    NAME '" + lyr.getElementsByTagName("layername")[0].childNodes[0].nodeValue.encode('utf-8').replace("\"", "") + "'\n")
+      # first check to see if there is a name
+      if len(lyr.getElementsByTagName("layername")[0].childNodes) > 0:
+        self.outFile.write("    NAME '" + lyr.getElementsByTagName("layername")[0].childNodes[0].nodeValue.encode('utf-8').replace("\"", "") + "'\n")
+      else:
+        self.outFile.write("    NAME 'LAYER%s'\n" % count)
       if lyr.getAttribute("type").encode('utf-8') == 'vector':  
         self.outFile.write("    TYPE " + lyr.getAttribute("geometry").encode('utf-8').upper() + "\n")
       elif lyr.getAttribute("type").encode('utf-8') == 'raster':  
@@ -348,8 +352,12 @@
       
       # WMS settings for all layers
       self.outFile.write("    METADATA\n")
-      self.outFile.write("      'wms_title' '" 
+      if len(lyr.getElementsByTagName("layername")[0].childNodes) > 0:
+        self.outFile.write("      'wms_title' '" 
            + lyr.getElementsByTagName("layername")[0].childNodes[0].nodeValue.encode('utf-8').replace("\"", "") + "'\n")
+      else:
+        self.outFile.write("      'wms_title' 'LAYER%s'\n"  % count)
+
       self.outFile.write("    END\n")
 
       self.outFile.write("    STATUS DEFAULT\n")



More information about the QGIS-commit mailing list