-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New MapServer export plugin implemented in Python. This is a
core plugin and installed with QGIS. The old exporter (C++/SWIG/Python) has been removed from the build and the code will be removed following complete testing of the new plugin. git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7898 c8812cc2-4d05-0410-92ff-de0c093fc19c
- Loading branch information
gsherman
committed
Jan 10, 2008
1 parent
5e2eb4a
commit 9564d38
Showing
13 changed files
with
2,045 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
SUBDIRS(plugin_installer) | ||
SUBDIRS(plugin_installer mapserver_export) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
""" | ||
/*************************************************************************** | ||
MapServerExport - A QGIS plugin to export a saved project file | ||
to a MapServer map file | ||
------------------- | ||
begin : 2008-01-07 | ||
copyright : (C) 2008 by Gary E.Sherman | ||
email : sherman at mrcc.com | ||
***************************************************************************/ | ||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
This script initializes the plugin, making it known to QGIS. | ||
""" | ||
# load MapServerExport class from file mapserverexport.py | ||
from mapserverexport import MapServerExport | ||
def name(): | ||
return "MapServer Export" | ||
def description(): | ||
return "Export a saved QGIS project file to a MapServer map file" | ||
def version(): | ||
return "Version 0.1" | ||
def classFactory(iface): | ||
return MapServerExport(iface) | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
""" | ||
/*************************************************************************** | ||
MapServerExport - A QGIS plugin to export a saved project file | ||
to a MapServer map file | ||
------------------- | ||
begin : 2008-01-07 | ||
copyright : (C) 2008 by Gary E.Sherman | ||
email : sherman at mrcc.com | ||
***************************************************************************/ | ||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
""" | ||
# Import the PyQt and QGIS libraries | ||
from PyQt4.QtCore import * | ||
from PyQt4.QtGui import * | ||
from qgis.core import * | ||
# Initialize Qt resources from file resources.py | ||
import resources | ||
# Import the code for the dialog | ||
from mapserverexportdialog import MapServerExportDialog | ||
# Import the ms_export script that does the real work | ||
from ms_export import * | ||
|
||
class MapServerExport: | ||
|
||
def __init__(self, iface): | ||
# Save reference to the QGIS interface | ||
self.iface = iface | ||
|
||
def initGui(self): | ||
# Create action that will start plugin configuration | ||
self.action = QAction(QIcon(":/plugins/mapserver_export/icon.png"), \ | ||
"MapServer Export", self.iface.getMainWindow()) | ||
#self.action.setWhatsThis("Configuration for Zoom To Point plugin") | ||
# connect the action to the run method | ||
QObject.connect(self.action, SIGNAL("activated()"), self.run) | ||
|
||
# Add toolbar button and menu item | ||
self.iface.addToolBarIcon(self.action) | ||
self.iface.addPluginMenu("&MapServer Export...", self.action) | ||
|
||
def unload(self): | ||
# Remove the plugin menu item and icon | ||
self.iface.removePluginMenu("&Zoom to Point...",self.action) | ||
self.iface.removeToolBarIcon(self.action) | ||
|
||
# run method that performs all the real work | ||
def run(self): | ||
# create and show the MapServerExport dialog | ||
self.dlg = MapServerExportDialog() | ||
#dlg.setupUi(self) | ||
# fetch the last used values from settings and intialize the | ||
# dialog with them | ||
#settings = QSettings("MicroResources", "ZoomToPoint") | ||
#xValue = settings.value("coordinate/x") | ||
#dlg.ui.xCoord.setText(str(xValue.toString())) | ||
#yValue = settings.value("coordinate/y") | ||
#dlg.ui.yCoord.setText(str(yValue.toString())) | ||
#scale = settings.value("zoom/scale", QVariant(4)) | ||
#dlg.ui.spinBoxScale.setValue(scale.toInt()[0]) | ||
QObject.connect(self.dlg.ui.btnChooseFile, SIGNAL("clicked()"), self.setSaveFile) | ||
QObject.connect(self.dlg.ui.btnChooseProjectFile, SIGNAL("clicked()"), self.setProjectFile) | ||
QObject.connect(self.dlg.ui.chkExpLayersOnly, SIGNAL("clicked(bool)"), self.toggleLayersOnly) | ||
QObject.connect(self.dlg.ui.btnChooseFooterFile, SIGNAL("clicked()"), self.setFooterFile) | ||
QObject.connect(self.dlg.ui.btnChooseHeaderFile, SIGNAL("clicked()"), self.setHeaderFile) | ||
QObject.connect(self.dlg.ui.btnChooseTemplateFile, SIGNAL("clicked()"), self.setTemplateFile) | ||
|
||
self.dlg.show() | ||
result = self.dlg.exec_() | ||
# See if OK was pressed | ||
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(self.dlg.ui.txtQgisFilePath.text(), self.dlg.ui.txtMapFilePath.text()) | ||
print "Setting options" | ||
exporter.setOptions( | ||
self.dlg.ui.cmbMapUnits.currentText(), | ||
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() | ||
) | ||
print "Calling writeMapFile" | ||
result = exporter.writeMapFile() | ||
QMessageBox.information(None, "MapServer Export Results", result) | ||
|
||
def setSaveFile(self): | ||
mapFile = QFileDialog.getSaveFileName(self.dlg, "Name for the map file", \ | ||
".", "MapServer map files (*.map);;All files (*.*)","Filter list for selecting files from a dialog box") | ||
self.dlg.ui.txtMapFilePath.setText(mapFile) | ||
|
||
def setProjectFile(self): | ||
qgisProjectFile = QFileDialog.getOpenFileName(self.dlg, "Choose the QGIS Project file", \ | ||
".", "QGIS Project Files (*.qgs);;All files (*.*)", "Filter list for selecting files from a dialog box") | ||
self.dlg.ui.txtQgisFilePath.setText(qgisProjectFile) | ||
|
||
def setTemplateFile(self): | ||
templateFile = QFileDialog.getOpenFileName(self.dlg, | ||
"Choose the MapServer template file", | ||
".", | ||
"All files (*.*)", | ||
"Filter list for selecting files from a dialog box") | ||
self.dlg.ui.txtWebTemplate.setText(templateFile) | ||
|
||
def setHeaderFile(self): | ||
headerFile = QFileDialog.getOpenFileName(self.dlg, | ||
"Choose the MapServer header file", | ||
".", | ||
"All files (*.*)", | ||
"Filter list for selecting files from a dialog box") | ||
self.dlg.ui.txtWebHeader.setText(headerFile) | ||
|
||
def setFooterFile(self): | ||
footerFile = QFileDialog.getOpenFileName(self.dlg, | ||
"Choose the MapServer footer file", | ||
".", | ||
"All files (*.*)", | ||
"Filter list for selecting files from a dialog box") | ||
self.dlg.ui.txtWebFooter.setText(footerFile) | ||
|
||
def apply(self): | ||
# create the map file | ||
foo = 'bar' | ||
|
||
def toggleLayersOnly(self, isChecked): | ||
# disable other sections if only layer export is desired | ||
self.dlg.ui.txtMapName.setEnabled(not isChecked) | ||
self.dlg.ui.txtMapWidth.setEnabled(not isChecked) | ||
self.dlg.ui.txtMapHeight.setEnabled(not isChecked) | ||
self.dlg.ui.cmbMapUnits.setEnabled(not isChecked) | ||
self.dlg.ui.cmbMapImageType.setEnabled(not isChecked) | ||
self.dlg.ui.txtWebTemplate.setEnabled(not isChecked) | ||
self.dlg.ui.txtWebHeader.setEnabled(not isChecked) | ||
self.dlg.ui.txtWebFooter.setEnabled(not isChecked) | ||
self.dlg.ui.btnChooseFooterFile.setEnabled(not isChecked) | ||
self.dlg.ui.btnChooseHeaderFile.setEnabled(not isChecked) | ||
self.dlg.ui.btnChooseTemplateFile.setEnabled(not isChecked) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
/*************************************************************************** | ||
MapServerExport - A QGIS plugin to export a saved project file | ||
to a MapServer map file | ||
------------------- | ||
begin : 2008-01-07 | ||
copyright : (C) 2007 by Gary E.Sherman | ||
email : sherman at mrcc.com | ||
***************************************************************************/ | ||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
""" | ||
from PyQt4 import QtCore, QtGui | ||
from ui_mapserverexport import Ui_QgsMapserverExportBase | ||
# create the dialog for mapserver export | ||
class MapServerExportDialog(QtGui.QDialog): | ||
def __init__(self): | ||
QtGui.QDialog.__init__(self) | ||
# Set up the user interface from Designer. | ||
self.ui = Ui_QgsMapserverExportBase() | ||
self.ui.setupUi(self) | ||
|
Oops, something went wrong.