Skip to content

Commit 1a9cc04

Browse files
author
gsherman
committed
Fix for bug #636 in MapServer export script
Enhanced the text_export.py script. git-svn-id: http://svn.osgeo.org/qgis/trunk@7429 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent a5dfe88 commit 1a9cc04

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

tools/mapserver_export/ms_export.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,11 @@ def uniqueRenderer(self, layerNode, symbolNode):
559559
for cls in classes:
560560
self.outFile.write(" CLASS\n")
561561

562-
lower = cls.getElementsByTagName('lowervalue')[0].childNodes[0].nodeValue.encode('utf-8')
562+
try:
563+
lower = cls.getElementsByTagName('lowervalue')[0].childNodes[0].nodeValue.encode('utf-8')
564+
except IndexError:
565+
# set to blank in the case where the field used for rendering has no value
566+
lower = ""
563567

564568
# If there's a label use it, otherwise autogenerate one
565569
try:

tools/mapserver_export/test_export.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,17 @@
1515
#***************************************************************************/
1616

1717

18-
# test script to export a sample QGIS project file to mapserver
18+
# Test script to export a sample QGIS project file to mapserver
19+
# No template of header/footer information is included in the map file
20+
# To change units, image type, name, and dimensions, modify the ex.setOptions line
21+
#
22+
import sys
1923
import ms_export
20-
ex = ms_export.Qgis2Map('./test1.qgs', './test1.map')
21-
ex.setOptions( 'Meters', 'JPEG', 'TestMap', '800', '600', '', '', '')
22-
23-
ex.writeMapFile()
24+
if len(sys.argv) == 3:
25+
ex = ms_export.Qgis2Map('/home/gsherman/town_test.qgs', './town_test.map')
26+
ex.setOptions( 'Meters', 'JPEG', 'TestMap', '800', '600', '', '', '')
27+
ex.writeMapFile()
28+
else:
29+
print "Test script to export a QGIS project file to a MapServer map file"
30+
print "Specify the QGIS project file and a file name for the map file to be created:"
31+
print " text_export.py my_qgis_project.qgs my_output_map.map"

0 commit comments

Comments
 (0)