From 5546b665d71cd08ffd8b0e386227a5f300579a5c Mon Sep 17 00:00:00 2001 From: wonder Date: Mon, 19 Jan 2009 20:39:02 +0000 Subject: [PATCH] ported mapserver export fixes from trunk (r9983) git-svn-id: http://svn.osgeo.org/qgis/branches/Version-1_0@9984 c8812cc2-4d05-0410-92ff-de0c093fc19c --- .../mapserver_export/mapserverexport.py | 18 ++++---- python/plugins/mapserver_export/ms_export.py | 46 +++++++++---------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/python/plugins/mapserver_export/mapserverexport.py b/python/plugins/mapserver_export/mapserverexport.py index 5e47159f7a20..39ced7aa18e2 100644 --- a/python/plugins/mapserver_export/mapserverexport.py +++ b/python/plugins/mapserver_export/mapserverexport.py @@ -78,17 +78,17 @@ def run(self): if result == 1: # get the settings from the dialog and export the map file print "Creating exporter using %s and %s" % (self.dlg.ui.txtQgisFilePath.text(), self.dlg.ui.txtMapFilePath.text()) - exporter = Qgis2Map(str(self.dlg.ui.txtQgisFilePath.text()), str(self.dlg.ui.txtMapFilePath.text())) + exporter = Qgis2Map(unicode(self.dlg.ui.txtQgisFilePath.text()), unicode(self.dlg.ui.txtMapFilePath.text())) print "Setting options" exporter.setOptions( - self.dlg.ui.cmbMapUnits.itemData( self.dlg.ui.cmbMapUnits.currentIndex() ).toString(), - self.dlg.ui.cmbMapImageType.currentText(), - self.dlg.ui.txtMapName.text(), - self.dlg.ui.txtMapWidth.text(), - self.dlg.ui.txtMapHeight.text(), - self.dlg.ui.txtWebTemplate.text(), - self.dlg.ui.txtWebFooter.text(), - self.dlg.ui.txtWebHeader.text() + unicode(self.dlg.ui.cmbMapUnits.itemData( self.dlg.ui.cmbMapUnits.currentIndex() ).toString()), + unicode(self.dlg.ui.cmbMapImageType.currentText()), + unicode(self.dlg.ui.txtMapName.text()), + unicode(self.dlg.ui.txtMapWidth.text()), + unicode(self.dlg.ui.txtMapHeight.text()), + unicode(self.dlg.ui.txtWebTemplate.text()), + unicode(self.dlg.ui.txtWebFooter.text()), + unicode(self.dlg.ui.txtWebHeader.text()) ) print "Calling writeMapFile" result = exporter.writeMapFile() diff --git a/python/plugins/mapserver_export/ms_export.py b/python/plugins/mapserver_export/ms_export.py index 3e67d9081690..8451ae6663a7 100644 --- a/python/plugins/mapserver_export/ms_export.py +++ b/python/plugins/mapserver_export/ms_export.py @@ -53,17 +53,17 @@ def __init__(self, projectFile, mapFile): # Set the options collected from the GUI def setOptions(self, units, image, mapname, width, height, template, header, footer): - self.units = units - self.imageType = str(image) - self.mapName = mapname - self.width = width - self.height = height + self.units = units.encode('utf-8') + self.imageType = image.encode('utf-8') + self.mapName = mapname.encode('utf-8') + self.width = width.encode('utf-8') + self.height = height.encode('utf-8') #self.minimumScale = minscale #self.maximumScale = maxscale - self.template = template - self.header = header - self.footer = footer - print units, image, mapname, width, height, template, header, footer + self.template = template.encode('utf-8') + self.header = header.encode('utf-8') + self.footer = footer.encode('utf-8') + #print units, image, mapname, width, height, template, header, footer ## All real work happens here by calling methods to write the ## various sections of the map file @@ -121,7 +121,7 @@ def writeMapFile(self): # Write the general parts of the map section def writeMapSection(self): - self.outFile.write("# Map file created from QGIS project file " + self.project + "\n") + self.outFile.write("# Map file created from QGIS project file " + self.project.encode('utf-8') + "\n") self.outFile.write("# Edit this file to customize for your map interface\n") self.outFile.write("# (Created with PyQgis MapServer Export plugin)\n") self.outFile.write("MAP\n") @@ -417,10 +417,10 @@ def simpleRenderer(self, layerNode, symbolNode): # outline color outlineNode = symbolNode.getElementsByTagName('outlinecolor')[0] - class_def += " OUTLINECOLOR " + outlineNode.getAttribute('red') + ' ' + outlineNode.getAttribute('green') + ' ' + outlineNode.getAttribute('blue') + "\n" + class_def += " OUTLINECOLOR " + outlineNode.getAttribute('red').encode('utf-8') + ' ' + outlineNode.getAttribute('green').encode('utf-8') + ' ' + outlineNode.getAttribute('blue').encode('utf-8') + "\n" # color colorNode = symbolNode.getElementsByTagName('fillcolor')[0] - class_def += " COLOR " + colorNode.getAttribute('red') + ' ' + colorNode.getAttribute('green') + ' ' + colorNode.getAttribute('blue') + "\n" + class_def += " COLOR " + colorNode.getAttribute('red').encode('utf-8') + ' ' + colorNode.getAttribute('green').encode('utf-8') + ' ' + colorNode.getAttribute('blue').encode('utf-8') + "\n" class_def += " END\n" @@ -469,10 +469,10 @@ def graduatedRenderer(self, layerNode, symbolNode): # outline color outlineNode = cls.getElementsByTagName('outlinecolor')[0] - class_def += " OUTLINECOLOR " + outlineNode.getAttribute('red') + ' ' + outlineNode.getAttribute('green') + ' ' + outlineNode.getAttribute('blue') + "\n" + class_def += " OUTLINECOLOR " + outlineNode.getAttribute('red').encode('utf-8') + ' ' + outlineNode.getAttribute('green').encode('utf-8') + ' ' + outlineNode.getAttribute('blue').encode('utf-8') + "\n" # color colorNode = cls.getElementsByTagName('fillcolor')[0] - class_def += " COLOR " + colorNode.getAttribute('red') + ' ' + colorNode.getAttribute('green') + ' ' + colorNode.getAttribute('blue') + "\n" + class_def += " COLOR " + colorNode.getAttribute('red').encode('utf-8') + ' ' + colorNode.getAttribute('green').encode('utf-8') + ' ' + colorNode.getAttribute('blue').encode('utf-8') + "\n" class_def += " END\n" @@ -493,7 +493,7 @@ def continuousRenderer(self, layerNode, symbolNode): classField = layerNode.getElementsByTagName('classificationattribute')[0].childNodes[0].nodeValue.encode('utf-8') # write the rendering info for each class - class_def += " CLASS\n" + class_def = " CLASS\n" # Class name irrelevant for color ramps since mapserver can't render their legend #self.outFile.write(" NAME '" + classField + "'\n") @@ -510,7 +510,7 @@ def continuousRenderer(self, layerNode, symbolNode): class_def += " STYLE\n" # The first and last color of the ramp ( r g b r g b ) - class_def += " COLORRANGE " + lowerColor.getAttribute('red') + " " + lowerColor.getAttribute('green') + " " + lowerColor.getAttribute('blue') + " " + upperColor.getAttribute('red') + " " + upperColor.getAttribute('green') + " " + upperColor.getAttribute('blue') + "\n" + class_def += " COLORRANGE " + lowerColor.getAttribute('red').encode('utf-8') + " " + lowerColor.getAttribute('green').encode('utf-8') + " " + lowerColor.getAttribute('blue').encode('utf-8') + " " + upperColor.getAttribute('red').encode('utf-8') + " " + upperColor.getAttribute('green').encode('utf-8') + " " + upperColor.getAttribute('blue').encode('utf-8') + "\n" # The range of values over which to ramp the colors class_def += " DATARANGE " + lower.getElementsByTagName('lowervalue')[0].childNodes[0].nodeValue.encode('utf-8') + ' ' + upper.getElementsByTagName('lowervalue')[0].childNodes[0].nodeValue.encode('utf-8') + '\n' @@ -519,7 +519,7 @@ def continuousRenderer(self, layerNode, symbolNode): class_def += " END\n" class_def += " STYLE\n" - class_def += " OUTLINECOLOR " + outlineNode.getAttribute('red') + " " + outlineNode.getAttribute('green') + " " + outlineNode.getAttribute('blue') + "\n" + class_def += " OUTLINECOLOR " + outlineNode.getAttribute('red').encode('utf-8') + " " + outlineNode.getAttribute('green').encode('utf-8') + " " + outlineNode.getAttribute('blue').encode('utf-8') + "\n" class_def += " END\n" # label @@ -577,17 +577,17 @@ def uniqueRenderer(self, layerNode, symbolNode): # outline color outlineNode = cls.getElementsByTagName('outlinecolor')[0] class_def += " OUTLINECOLOR " \ - + outlineNode.getAttribute('red') + ' ' \ - + outlineNode.getAttribute('green') + ' ' \ - + outlineNode.getAttribute('blue') \ + + outlineNode.getAttribute('red').encode('utf-8') + ' ' \ + + outlineNode.getAttribute('green').encode('utf-8') + ' ' \ + + outlineNode.getAttribute('blue').encode('utf-8') \ + "\n" # color colorNode = cls.getElementsByTagName('fillcolor')[0] class_def += " COLOR " \ - + colorNode.getAttribute('red') + ' ' \ - + colorNode.getAttribute('green') + ' ' \ - + colorNode.getAttribute('blue') \ + + colorNode.getAttribute('red').encode('utf-8') + ' ' \ + + colorNode.getAttribute('green').encode('utf-8') + ' ' \ + + colorNode.getAttribute('blue').encode('utf-8') \ + "\n" class_def += " END\n"