PostGIS Raster : Extending PostgreSQL for The Support of ... - CoDE
PostGIS Raster : Extending PostgreSQL for The Support of ... - CoDE
PostGIS Raster : Extending PostgreSQL for The Support of ... - CoDE
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
eturn "Version 0.1"<br />
def qgisMinimumVersion():<br />
return "1.0"<br />
def authorName():<br />
return "Developer"<br />
def classFactory(iface):<br />
# Load TestPlugin class from file testplugin.py<br />
from testplugin import TestPlugin<br />
return TestPlugin(iface)<br />
<strong>The</strong> classFactory() function is called when the plugin is loaded into QGIS. It receives reference<br />
to instance <strong>of</strong> QgisInterface and return instance <strong>of</strong> TestPlugin plugin (the TestPlugin class will be<br />
described later in plugin.py file).<br />
def category():<br />
return "<strong>Raster</strong>"<br />
Normally, user-created plugins are placed into Plugins menu but from QGIS 1.9.90, they can also<br />
be placed into Vector, <strong>Raster</strong>, Database or Web menus using category entry. For example, the above<br />
plugin will be available from <strong>Raster</strong> menus.<br />
B.2.2 Plugin.py<br />
from PyQt4.QtCore import *<br />
from PyQt4.QtGui import *<br />
from qgis.core import *<br />
# initialize Qt resources from file resouces.py<br />
import resources<br />
class TestPlugin:<br />
def __init__(self, iface):<br />
# Save reference to the QGIS interface<br />
self.iface = iface<br />
def initGui(self):<br />
# Create action that triggers plugin<br />
self.action = QAction(QIcon(":/plugins/testplug/icon.png"), "Test plugin", self.iface.ma<br />
# Code in function run will be executed<br />
QObject.connect(self.action, SIGNAL("triggered()"), self.run)<br />
# Check if <strong>Raster</strong> menu available<br />
if hasattr(self.iface, "addPluginTo<strong>Raster</strong>Menu"):<br />
# <strong>Raster</strong> menu and toolbar available<br />
# Add action to toolbar and menu item<br />
self.iface.add<strong>Raster</strong>ToolBarIcon(self.action)<br />
self.iface.addPluginTo<strong>Raster</strong>Menu("\&Test plugins", self.action)<br />
else:<br />
# <strong>The</strong>re is no <strong>Raster</strong> menu, place plugin under Plugins menu as usual<br />
self.iface.addToolBarIcon(self.action)<br />
self.iface.addPluginToMenu("\&Test plugins", self.action)<br />
def unload(self):<br />
# Check if <strong>Raster</strong> menu available<br />
90