Skip to content

Commit

Permalink
update MapServer export plugin to SIP changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Jun 3, 2013
1 parent f4657b7 commit 75cbdf6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
24 changes: 12 additions & 12 deletions python/plugins/mapserver_export/mapserverexport.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,21 @@ def run(self):
# defaults are defined in ms_export.py and set in mapserverexportdialog.py
settings = QSettings()
# map-file name and force mapfileChanged to enable/disable ok button
self.dlg.ui.txtMapFilePath.setText(settings.value("/MapserverExport/mapfileName", QVariant("")).toString ())
self.dlg.ui.txtMapFilePath.setText(settings.value("/MapserverExport/mapfileName", ""))
self.mapfileChanged(self.dlg.ui.txtMapFilePath.text())
# map width and height
if settings.contains("/MapserverExport/mapWidth"):
self.dlg.ui.txtMapWidth.setText(settings.value("/MapserverExport/mapWidth").toString ())
self.dlg.ui.txtMapWidth.setText(settings.value("/MapserverExport/mapWidth"))
if settings.contains("/MapserverExport/mapHeight"):
self.dlg.ui.txtMapHeight.setText(settings.value("/MapserverExport/mapHeight").toString ())
self.dlg.ui.txtMapHeight.setText(settings.value("/MapserverExport/mapHeight"))
# MapServer IMAGETYPE's [gif|png|jpeg|wbmp|gtiff|swf|userdefined]
self.dlg.ui.cmbMapImageType.addItems(QStringList(["agg","png","gif","jpeg","wbmp","gtiff","swf","userdefined"]))
if settings.contains("/MapserverExport/imageType"):
idx = self.dlg.ui.cmbMapImageType.findText(settings.value("/MapserverExport/imageType").toString ())
idx = self.dlg.ui.cmbMapImageType.findText(settings.value("/MapserverExport/imageType"))
self.dlg.ui.cmbMapImageType.setCurrentIndex(idx)
# MapServer URL (default value already set by dialog defaults)
if settings.contains("/MapserverExport/mapserverUrl"):
self.dlg.ui.txtMapServerUrl.setText(settings.value("/MapserverExport/mapserverUrl").toString())
self.dlg.ui.txtMapServerUrl.setText(settings.value("/MapserverExport/mapserverUrl"))
# set title or default to one if none available
title = project.title()
if title == "":
Expand Down Expand Up @@ -184,14 +184,14 @@ def saveMapFile(self):
# ok succesfull: write some setting for a next session
settings = QSettings()
# mapfile name
settings.setValue("/MapserverExport/mapfileName", QVariant(self.dlg.ui.txtMapFilePath.text()))
settings.setValue("/MapserverExport/mapfileName", self.dlg.ui.txtMapFilePath.text())
# map width and height
settings.setValue("/MapserverExport/mapWidth", QVariant(self.dlg.ui.txtMapWidth.text()))
settings.setValue("/MapserverExport/mapHeight", QVariant(self.dlg.ui.txtMapHeight.text()))
settings.setValue("/MapserverExport/mapWidth", self.dlg.ui.txtMapWidth.text())
settings.setValue("/MapserverExport/mapHeight", self.dlg.ui.txtMapHeight.text())
# mapserver url
settings.setValue("/MapserverExport/mapserverUrl", QVariant(self.dlg.ui.txtMapServerUrl.text()))
settings.setValue("/MapserverExport/mapserverUrl", self.dlg.ui.txtMapServerUrl.text())
# map ImageType
settings.setValue("/MapserverExport/imageType", QVariant(self.dlg.ui.cmbMapImageType.currentText()))
settings.setValue("/MapserverExport/imageType", self.dlg.ui.cmbMapImageType.currentText())
# show results
QMessageBox.information(self.dlg, "MapServer Export Results", result)

Expand Down Expand Up @@ -241,12 +241,12 @@ def checkCurrentProject(self, forUnload=False):
"Save QGIS Project file as...", ".",
"QGIS Project Files (*.qgs)", "Filter list for selecting files from a dialog box")
# Check that a file was selected
if saveAsFileName.size() == 0:
if len(saveAsFileName) == 0:
QMessageBox.warning(self.dlg, "Not saved!", "QGis project file not saved because no file name was given.")
# fall back to using current project if available
self.dlg.ui.txtQgisFilePath.setText(project.fileName())
else:
if not saveAsFileName.trimmed().endsWith('.qgs'):
if not saveAsFileName.strip().endswith('.qgs'):
saveAsFileName += '.qgs'
self.dlg.ui.txtQgisFilePath.setText(saveAsFileName)
project.setFileName(saveAsFileName)
Expand Down
5 changes: 2 additions & 3 deletions python/plugins/mapserver_export/ms_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from qgis.core import QgsDataSourceURI
from qgis.core import QgsMapLayerRegistry
#from qgis.core import QgsProject
from PyQt4.QtCore import QString
from PyQt4.QtCore import QVariant


Expand Down Expand Up @@ -674,13 +673,13 @@ def getPrimaryKey(self, layerId, tableName):

mlr = QgsMapLayerRegistry.instance()
layers = mlr.mapLayers()
if not QString(layerId) in layers:
if not layerId in layers:
# layerId of this postgis layer NOT in the layerlist...
# probably the project is not loaded in qgis
#raise Exception("ERROR: layer not found in project layers.... \nThis happens with postgis layers in a project which \nis not loaded in QGis.\nDid you load this project into QGis? \nIf not please load project first, and then export it to mapserver.")
return str("%" + tableName + "_id%")

layer = layers[QString(layerId)]
layer = layers[layerId]
dataProvider = layer.dataProvider()
fields = dataProvider.fields()

Expand Down

0 comments on commit 75cbdf6

Please sign in to comment.