@@ -53,17 +53,17 @@ def __init__(self, projectFile, mapFile):
53
53
54
54
# Set the options collected from the GUI
55
55
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' )
61
61
#self.minimumScale = minscale
62
62
#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
67
67
68
68
## All real work happens here by calling methods to write the
69
69
## various sections of the map file
@@ -121,7 +121,7 @@ def writeMapFile(self):
121
121
122
122
# Write the general parts of the map section
123
123
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 " )
125
125
self .outFile .write ("# Edit this file to customize for your map interface\n " )
126
126
self .outFile .write ("# (Created with PyQgis MapServer Export plugin)\n " )
127
127
self .outFile .write ("MAP\n " )
@@ -417,10 +417,10 @@ def simpleRenderer(self, layerNode, symbolNode):
417
417
418
418
# outline color
419
419
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 "
421
421
# color
422
422
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 "
424
424
425
425
class_def += " END\n "
426
426
@@ -469,10 +469,10 @@ def graduatedRenderer(self, layerNode, symbolNode):
469
469
470
470
# outline color
471
471
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 "
473
473
# color
474
474
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 "
476
476
477
477
class_def += " END\n "
478
478
@@ -493,7 +493,7 @@ def continuousRenderer(self, layerNode, symbolNode):
493
493
classField = layerNode .getElementsByTagName ('classificationattribute' )[0 ].childNodes [0 ].nodeValue .encode ('utf-8' )
494
494
495
495
# write the rendering info for each class
496
- class_def + = " CLASS\n "
496
+ class_def = " CLASS\n "
497
497
498
498
# Class name irrelevant for color ramps since mapserver can't render their legend
499
499
#self.outFile.write(" NAME '" + classField + "'\n")
@@ -510,7 +510,7 @@ def continuousRenderer(self, layerNode, symbolNode):
510
510
class_def += " STYLE\n "
511
511
512
512
# 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 "
514
514
515
515
# The range of values over which to ramp the colors
516
516
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):
519
519
class_def += " END\n "
520
520
521
521
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 "
523
523
class_def += " END\n "
524
524
525
525
# label
@@ -577,17 +577,17 @@ def uniqueRenderer(self, layerNode, symbolNode):
577
577
# outline color
578
578
outlineNode = cls .getElementsByTagName ('outlinecolor' )[0 ]
579
579
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' ) \
583
583
+ "\n "
584
584
585
585
# color
586
586
colorNode = cls .getElementsByTagName ('fillcolor' )[0 ]
587
587
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' ) \
591
591
+ "\n "
592
592
class_def += " END\n "
593
593
0 commit comments