Skip to content

Commit

Permalink
ported mapserver export fixes from trunk (r9983)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/branches/Version-1_0@9984 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Jan 19, 2009
1 parent 45b2c23 commit 5546b66
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
18 changes: 9 additions & 9 deletions python/plugins/mapserver_export/mapserverexport.py
Expand Up @@ -78,17 +78,17 @@ def run(self):
if result == 1: if result == 1:
# get the settings from the dialog and export the map file # 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()) 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" print "Setting options"
exporter.setOptions( exporter.setOptions(
self.dlg.ui.cmbMapUnits.itemData( self.dlg.ui.cmbMapUnits.currentIndex() ).toString(), unicode(self.dlg.ui.cmbMapUnits.itemData( self.dlg.ui.cmbMapUnits.currentIndex() ).toString()),
self.dlg.ui.cmbMapImageType.currentText(), unicode(self.dlg.ui.cmbMapImageType.currentText()),
self.dlg.ui.txtMapName.text(), unicode(self.dlg.ui.txtMapName.text()),
self.dlg.ui.txtMapWidth.text(), unicode(self.dlg.ui.txtMapWidth.text()),
self.dlg.ui.txtMapHeight.text(), unicode(self.dlg.ui.txtMapHeight.text()),
self.dlg.ui.txtWebTemplate.text(), unicode(self.dlg.ui.txtWebTemplate.text()),
self.dlg.ui.txtWebFooter.text(), unicode(self.dlg.ui.txtWebFooter.text()),
self.dlg.ui.txtWebHeader.text() unicode(self.dlg.ui.txtWebHeader.text())
) )
print "Calling writeMapFile" print "Calling writeMapFile"
result = exporter.writeMapFile() result = exporter.writeMapFile()
Expand Down
46 changes: 23 additions & 23 deletions python/plugins/mapserver_export/ms_export.py
Expand Up @@ -53,17 +53,17 @@ def __init__(self, projectFile, mapFile):


# Set the options collected from the GUI # Set the options collected from the GUI
def setOptions(self, units, image, mapname, width, height, template, header, footer): def setOptions(self, units, image, mapname, width, height, template, header, footer):
self.units = units self.units = units.encode('utf-8')
self.imageType = str(image) self.imageType = image.encode('utf-8')
self.mapName = mapname self.mapName = mapname.encode('utf-8')
self.width = width self.width = width.encode('utf-8')
self.height = height self.height = height.encode('utf-8')
#self.minimumScale = minscale #self.minimumScale = minscale
#self.maximumScale = maxscale #self.maximumScale = maxscale
self.template = template self.template = template.encode('utf-8')
self.header = header self.header = header.encode('utf-8')
self.footer = footer self.footer = footer.encode('utf-8')
print units, image, mapname, width, height, template, header, footer #print units, image, mapname, width, height, template, header, footer


## All real work happens here by calling methods to write the ## All real work happens here by calling methods to write the
## various sections of the map file ## various sections of the map file
Expand Down Expand Up @@ -121,7 +121,7 @@ def writeMapFile(self):


# Write the general parts of the map section # Write the general parts of the map section
def writeMapSection(self): 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("# Edit this file to customize for your map interface\n")
self.outFile.write("# (Created with PyQgis MapServer Export plugin)\n") self.outFile.write("# (Created with PyQgis MapServer Export plugin)\n")
self.outFile.write("MAP\n") self.outFile.write("MAP\n")
Expand Down Expand Up @@ -417,10 +417,10 @@ def simpleRenderer(self, layerNode, symbolNode):


# outline color # outline color
outlineNode = symbolNode.getElementsByTagName('outlinecolor')[0] 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 # color
colorNode = symbolNode.getElementsByTagName('fillcolor')[0] 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" class_def += " END\n"


Expand Down Expand Up @@ -469,10 +469,10 @@ def graduatedRenderer(self, layerNode, symbolNode):


# outline color # outline color
outlineNode = cls.getElementsByTagName('outlinecolor')[0] 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 # color
colorNode = cls.getElementsByTagName('fillcolor')[0] 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" class_def += " END\n"


Expand All @@ -493,7 +493,7 @@ def continuousRenderer(self, layerNode, symbolNode):
classField = layerNode.getElementsByTagName('classificationattribute')[0].childNodes[0].nodeValue.encode('utf-8') classField = layerNode.getElementsByTagName('classificationattribute')[0].childNodes[0].nodeValue.encode('utf-8')


# write the rendering info for each class # 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 # Class name irrelevant for color ramps since mapserver can't render their legend
#self.outFile.write(" NAME '" + classField + "'\n") #self.outFile.write(" NAME '" + classField + "'\n")
Expand All @@ -510,7 +510,7 @@ def continuousRenderer(self, layerNode, symbolNode):
class_def += " STYLE\n" class_def += " STYLE\n"


# The first and last color of the ramp ( r g b r g b ) # 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 # 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' class_def += " DATARANGE " + lower.getElementsByTagName('lowervalue')[0].childNodes[0].nodeValue.encode('utf-8') + ' ' + upper.getElementsByTagName('lowervalue')[0].childNodes[0].nodeValue.encode('utf-8') + '\n'
Expand All @@ -519,7 +519,7 @@ def continuousRenderer(self, layerNode, symbolNode):
class_def += " END\n" class_def += " END\n"


class_def += " STYLE\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" class_def += " END\n"


# label # label
Expand Down Expand Up @@ -577,17 +577,17 @@ def uniqueRenderer(self, layerNode, symbolNode):
# outline color # outline color
outlineNode = cls.getElementsByTagName('outlinecolor')[0] outlineNode = cls.getElementsByTagName('outlinecolor')[0]
class_def += " OUTLINECOLOR " \ class_def += " OUTLINECOLOR " \
+ outlineNode.getAttribute('red') + ' ' \ + outlineNode.getAttribute('red').encode('utf-8') + ' ' \
+ outlineNode.getAttribute('green') + ' ' \ + outlineNode.getAttribute('green').encode('utf-8') + ' ' \
+ outlineNode.getAttribute('blue') \ + outlineNode.getAttribute('blue').encode('utf-8') \
+ "\n" + "\n"


# color # color
colorNode = cls.getElementsByTagName('fillcolor')[0] colorNode = cls.getElementsByTagName('fillcolor')[0]
class_def += " COLOR " \ class_def += " COLOR " \
+ colorNode.getAttribute('red') + ' ' \ + colorNode.getAttribute('red').encode('utf-8') + ' ' \
+ colorNode.getAttribute('green') + ' ' \ + colorNode.getAttribute('green').encode('utf-8') + ' ' \
+ colorNode.getAttribute('blue') \ + colorNode.getAttribute('blue').encode('utf-8') \
+ "\n" + "\n"
class_def += " END\n" class_def += " END\n"


Expand Down

0 comments on commit 5546b66

Please sign in to comment.