Skip to content
Permalink
Browse files
Fix for condition where layer name is blank in the legend
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8321 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
gsherman committed Apr 7, 2008
1 parent 361856a commit d5ed5abb7e46fc8d14d144bbacfc17cba58bc273
Showing with 10 additions and 2 deletions.
  1. +10 −2 python/plugins/mapserver_export/ms_export.py
@@ -280,7 +280,11 @@ def writeMapLayers(self):

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 @@ def writeMapLayers(self):

# 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")

0 comments on commit d5ed5ab

Please sign in to comment.