13.07.2013 Views

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

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

name=""<br />

# Setting table name and mode<br />

if len(table)>1:<br />

# Checking if there is schema in the table name<br />

name+=str(table[0])<br />

connstring+=" schema="+str(table[0])<br />

connstring+=’ table=’+str(table[-1])<br />

name+="."+str(table[-1])<br />

# Query <strong>for</strong> row mode<br />

connstring+=’ mode=1 where=\’rid=’ + str(rid) + ’\’’<br />

# Object rlayer will contain loaded layer<br />

rlayer=None<br />

# Retrieve a layer from <strong>PostgreSQL</strong> using the connection string<br />

rlayer = Qgs<strong>Raster</strong>Layer(connstring, name)<br />

# Try to add layer to qgis.<br />

if rlayer:<br />

if rlayer.isValid():<br />

status = QgsMapLayerRegistry.instance().addMapLayer(rlayer)<br />

self.legend.setLayerVisible(rlayer,False)<br />

# Each layer is identified by an unique layer id<br />

self.layerIds.append(rlayer.id())<br />

else:<br />

QtGui.QMessageBox.warning(self,"Error", "Could not load "+connstring)<br />

# Come back to QGIS cursor<br />

QtGui.QApplication.restoreOverrideCursor()<br />

94

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!