Skip to content

Commit 55c806f

Browse files
author
wonder
committed
mapserver export: fixed i18n problems, fixed continuous color renderer export
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9983 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9caf1be commit 55c806f

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

python/plugins/mapserver_export/mapserverexport.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,17 @@ def run(self):
7878
if result == 1:
7979
# get the settings from the dialog and export the map file
8080
print "Creating exporter using %s and %s" % (self.dlg.ui.txtQgisFilePath.text(), self.dlg.ui.txtMapFilePath.text())
81-
exporter = Qgis2Map(str(self.dlg.ui.txtQgisFilePath.text()), str(self.dlg.ui.txtMapFilePath.text()))
81+
exporter = Qgis2Map(unicode(self.dlg.ui.txtQgisFilePath.text()), unicode(self.dlg.ui.txtMapFilePath.text()))
8282
print "Setting options"
8383
exporter.setOptions(
84-
self.dlg.ui.cmbMapUnits.itemData( self.dlg.ui.cmbMapUnits.currentIndex() ).toString(),
85-
self.dlg.ui.cmbMapImageType.currentText(),
86-
self.dlg.ui.txtMapName.text(),
87-
self.dlg.ui.txtMapWidth.text(),
88-
self.dlg.ui.txtMapHeight.text(),
89-
self.dlg.ui.txtWebTemplate.text(),
90-
self.dlg.ui.txtWebFooter.text(),
91-
self.dlg.ui.txtWebHeader.text()
84+
unicode(self.dlg.ui.cmbMapUnits.itemData( self.dlg.ui.cmbMapUnits.currentIndex() ).toString()),
85+
unicode(self.dlg.ui.cmbMapImageType.currentText()),
86+
unicode(self.dlg.ui.txtMapName.text()),
87+
unicode(self.dlg.ui.txtMapWidth.text()),
88+
unicode(self.dlg.ui.txtMapHeight.text()),
89+
unicode(self.dlg.ui.txtWebTemplate.text()),
90+
unicode(self.dlg.ui.txtWebFooter.text()),
91+
unicode(self.dlg.ui.txtWebHeader.text())
9292
)
9393
print "Calling writeMapFile"
9494
result = exporter.writeMapFile()

python/plugins/mapserver_export/ms_export.py

+23-23
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ def __init__(self, projectFile, mapFile):
5353

5454
# Set the options collected from the GUI
5555
def setOptions(self, units, image, mapname, width, height, template, header, footer):
56-
self.units = units
57-
self.imageType = str(image)
58-
self.mapName = mapname
59-
self.width = width
60-
self.height = height
56+
self.units = units.encode('utf-8')
57+
self.imageType = image.encode('utf-8')
58+
self.mapName = mapname.encode('utf-8')
59+
self.width = width.encode('utf-8')
60+
self.height = height.encode('utf-8')
6161
#self.minimumScale = minscale
6262
#self.maximumScale = maxscale
63-
self.template = template
64-
self.header = header
65-
self.footer = footer
66-
print units, image, mapname, width, height, template, header, footer
63+
self.template = template.encode('utf-8')
64+
self.header = header.encode('utf-8')
65+
self.footer = footer.encode('utf-8')
66+
#print units, image, mapname, width, height, template, header, footer
6767

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

122122
# Write the general parts of the map section
123123
def writeMapSection(self):
124-
self.outFile.write("# Map file created from QGIS project file " + self.project + "\n")
124+
self.outFile.write("# Map file created from QGIS project file " + self.project.encode('utf-8') + "\n")
125125
self.outFile.write("# Edit this file to customize for your map interface\n")
126126
self.outFile.write("# (Created with PyQgis MapServer Export plugin)\n")
127127
self.outFile.write("MAP\n")
@@ -417,10 +417,10 @@ def simpleRenderer(self, layerNode, symbolNode):
417417

418418
# outline color
419419
outlineNode = symbolNode.getElementsByTagName('outlinecolor')[0]
420-
class_def += " OUTLINECOLOR " + outlineNode.getAttribute('red') + ' ' + outlineNode.getAttribute('green') + ' ' + outlineNode.getAttribute('blue') + "\n"
420+
class_def += " OUTLINECOLOR " + outlineNode.getAttribute('red').encode('utf-8') + ' ' + outlineNode.getAttribute('green').encode('utf-8') + ' ' + outlineNode.getAttribute('blue').encode('utf-8') + "\n"
421421
# color
422422
colorNode = symbolNode.getElementsByTagName('fillcolor')[0]
423-
class_def += " COLOR " + colorNode.getAttribute('red') + ' ' + colorNode.getAttribute('green') + ' ' + colorNode.getAttribute('blue') + "\n"
423+
class_def += " COLOR " + colorNode.getAttribute('red').encode('utf-8') + ' ' + colorNode.getAttribute('green').encode('utf-8') + ' ' + colorNode.getAttribute('blue').encode('utf-8') + "\n"
424424

425425
class_def += " END\n"
426426

@@ -469,10 +469,10 @@ def graduatedRenderer(self, layerNode, symbolNode):
469469

470470
# outline color
471471
outlineNode = cls.getElementsByTagName('outlinecolor')[0]
472-
class_def += " OUTLINECOLOR " + outlineNode.getAttribute('red') + ' ' + outlineNode.getAttribute('green') + ' ' + outlineNode.getAttribute('blue') + "\n"
472+
class_def += " OUTLINECOLOR " + outlineNode.getAttribute('red').encode('utf-8') + ' ' + outlineNode.getAttribute('green').encode('utf-8') + ' ' + outlineNode.getAttribute('blue').encode('utf-8') + "\n"
473473
# color
474474
colorNode = cls.getElementsByTagName('fillcolor')[0]
475-
class_def += " COLOR " + colorNode.getAttribute('red') + ' ' + colorNode.getAttribute('green') + ' ' + colorNode.getAttribute('blue') + "\n"
475+
class_def += " COLOR " + colorNode.getAttribute('red').encode('utf-8') + ' ' + colorNode.getAttribute('green').encode('utf-8') + ' ' + colorNode.getAttribute('blue').encode('utf-8') + "\n"
476476

477477
class_def += " END\n"
478478

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

495495
# write the rendering info for each class
496-
class_def += " CLASS\n"
496+
class_def = " CLASS\n"
497497

498498
# Class name irrelevant for color ramps since mapserver can't render their legend
499499
#self.outFile.write(" NAME '" + classField + "'\n")
@@ -510,7 +510,7 @@ def continuousRenderer(self, layerNode, symbolNode):
510510
class_def += " STYLE\n"
511511

512512
# The first and last color of the ramp ( r g b r g b )
513-
class_def += " COLORRANGE " + lowerColor.getAttribute('red') + " " + lowerColor.getAttribute('green') + " " + lowerColor.getAttribute('blue') + " " + upperColor.getAttribute('red') + " " + upperColor.getAttribute('green') + " " + upperColor.getAttribute('blue') + "\n"
513+
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"
514514

515515
# The range of values over which to ramp the colors
516516
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):
519519
class_def += " END\n"
520520

521521
class_def += " STYLE\n"
522-
class_def += " OUTLINECOLOR " + outlineNode.getAttribute('red') + " " + outlineNode.getAttribute('green') + " " + outlineNode.getAttribute('blue') + "\n"
522+
class_def += " OUTLINECOLOR " + outlineNode.getAttribute('red').encode('utf-8') + " " + outlineNode.getAttribute('green').encode('utf-8') + " " + outlineNode.getAttribute('blue').encode('utf-8') + "\n"
523523
class_def += " END\n"
524524

525525
# label
@@ -577,17 +577,17 @@ def uniqueRenderer(self, layerNode, symbolNode):
577577
# outline color
578578
outlineNode = cls.getElementsByTagName('outlinecolor')[0]
579579
class_def += " OUTLINECOLOR " \
580-
+ outlineNode.getAttribute('red') + ' ' \
581-
+ outlineNode.getAttribute('green') + ' ' \
582-
+ outlineNode.getAttribute('blue') \
580+
+ outlineNode.getAttribute('red').encode('utf-8') + ' ' \
581+
+ outlineNode.getAttribute('green').encode('utf-8') + ' ' \
582+
+ outlineNode.getAttribute('blue').encode('utf-8') \
583583
+ "\n"
584584

585585
# color
586586
colorNode = cls.getElementsByTagName('fillcolor')[0]
587587
class_def += " COLOR " \
588-
+ colorNode.getAttribute('red') + ' ' \
589-
+ colorNode.getAttribute('green') + ' ' \
590-
+ colorNode.getAttribute('blue') \
588+
+ colorNode.getAttribute('red').encode('utf-8') + ' ' \
589+
+ colorNode.getAttribute('green').encode('utf-8') + ' ' \
590+
+ colorNode.getAttribute('blue').encode('utf-8') \
591591
+ "\n"
592592
class_def += " END\n"
593593

0 commit comments

Comments
 (0)