Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mapserver export: fixed i18n problems, fixed continuous color rendere…
…r export

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9983 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Jan 19, 2009
1 parent 9caf1be commit 55c806f
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:
# 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()
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
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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand All @@ -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")
Expand All @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -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"

Expand Down

0 comments on commit 55c806f

Please sign in to comment.