Skip to content
Permalink
Browse files

Merge branch 'master' of github.com:qgis/Quantum-GIS

  • Loading branch information
timlinux committed May 23, 2012
2 parents 4d3cf1a + c367a35 commit b982fdc275b6295649e778aa499bca2a6c5c498c
@@ -5,7 +5,7 @@
/*! \mainpage Quantum GIS

\section index_intro Introduction
\htmlonly<img src="http://download.qgis.org/qgis-icon-60x60.png" alt="QGIS"
\htmlonly<img src="http://hub.qgis.org/projects/quantum-gis/repository/revisions/master/entry/images/icons/qgis-icon-60x60.png" alt="QGIS"
align="left"><a href="http://qgis.org">Quantum GIS</a>\endhtmlonly\latexonly
Quantum GIS \endlatexonly (QGIS) is a user friendly Open Source Geographic
Information System (GIS) that runs on Linux, Unix, Mac OSX, and Windows. QGIS
@@ -223,7 +223,7 @@ def registerAction(self, action, menuName, callback=None):
# get the placeholder's position to insert before it
pos = 0
for pos in range(len(menuActions)):
if menuActions[pos].isSeparator() and menuActions[pos].text() == "placeholder":
if menuActions[pos].isSeparator() and menuActions[pos].objectName().endsWith("_placeholder"):
menuActions[pos].setVisible(True)
break

@@ -301,7 +301,7 @@ def unregisterAction(self, action, menuName):
# hide the placeholder if there're no other registered actions
if len(self._registeredDbActions[menuName]) <= 0:
for i in range(len(menuActions)):
if menuActions[i].isSeparator() and menuActions[i].text() == "placeholder":
if menuActions[i].isSeparator() and menuActions[i].objectName().endsWith("_placeholder"):
menuActions[i].setVisible(False)
break

@@ -369,18 +369,18 @@ def setupUi(self):
# create menus' actions

# menu DATABASE
sep = self.menuDb.addAction("placeholder"); sep.setSeparator(True); sep.setVisible(False)
sep = self.menuDb.addSeparator(); sep.setObjectName("DB_Manager_DbMenu_placeholder"); sep.setVisible(False)
self.actionRefresh = self.menuDb.addAction( QIcon(":/db_manager/actions/refresh"), "&Refresh", self.refreshActionSlot, QKeySequence("F5") )
self.actionSqlWindow = self.menuDb.addAction( QIcon(":/db_manager/actions/sql_window"), "&SQL window", self.runSqlWindow, QKeySequence("F2") )
self.menuDb.addSeparator()
self.actionClose = self.menuDb.addAction( QIcon(), "&Exit", self.close, QKeySequence("CTRL+Q") )

# menu SCHEMA
sep = self.menuSchema.addAction("placeholder"); sep.setSeparator(True); sep.setVisible(False)
sep = self.menuSchema.addSeparator(); sep.setObjectName("DB_Manager_SchemaMenu_placeholder"); sep.setVisible(False)
actionMenuSchema.setVisible(False)

# menu TABLE
sep = self.menuTable.addAction("placeholder"); sep.setSeparator(True); sep.setVisible(False)
sep = self.menuTable.addSeparator(); sep.setObjectName("DB_Manager_TableMenu_placeholder"); sep.setVisible(False)
actionMenuTable.setVisible(False)
self.actionShowSystemTables = self.menuTable.addAction("Show system tables/views", self.showSystemTables)
self.actionShowSystemTables.setCheckable(True)
@@ -60,13 +60,13 @@ def hasTableColumnEditingSupport(self):
return False


def execution_error_types():
def execution_error_types(self):
raise Exception("DBConnector.execution_error_types() is an abstract method")

def connection_error_types():
def connection_error_types(self):
raise Exception("DBConnector.connection_error_types() is an abstract method")

def error_types():
def error_types(self):
return self.connection_error_types() + self.execution_error_types()

def _execute(self, cursor, sql):
@@ -67,7 +67,12 @@ def setDirty(self, val=True):

def _clear(self):
if self.item is not None:
self.disconnect(self.item, SIGNAL('aboutToChange'), self.setDirty)
try:
self.disconnect(self.item, SIGNAL('aboutToChange'), self.setDirty)
except:
# do not raise any error if self.item was deleted
pass

self.item = None
self.dirty = False

@@ -83,11 +88,13 @@ def _loadTableData(self, table):
self.setModel( table.tableDataModel(self) )

except DbError, e:
QApplication.restoreOverrideCursor()
DlgDbError.showError(e, self)
return

else:
self.update()

finally:
QApplication.restoreOverrideCursor()


@@ -944,7 +944,7 @@ def intersect( self ):
if geom.intersects( tmpGeom ):
atMapB = inFeatB.attributeMap()
int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
if int_geom.wkbType() == 7:
if int_geom.wkbType() == 0:
int_com = geom.combine( tmpGeom )
int_sym = geom.symDifference( tmpGeom )
int_geom = QgsGeometry( int_com.difference( int_sym ) )
@@ -973,7 +973,7 @@ def intersect( self ):
if geom.intersects( tmpGeom ):
atMapB = inFeatB.attributeMap()
int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
if int_geom.wkbType() == 7:
if int_geom.wkbType() == 0:
int_com = geom.combine( tmpGeom )
int_sym = geom.symDifference( tmpGeom )
int_geom = QgsGeometry( int_com.difference( int_sym ) )
@@ -1010,7 +1010,7 @@ def intersect( self ):
if geom.intersects( tmpGeom ):
atMapB = inFeatB.attributeMap()
int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
if int_geom.wkbType() == 7:
if int_geom.wkbType() == 0:
int_com = geom.combine( tmpGeom )
int_sym = geom.symDifference( tmpGeom )
int_geom = QgsGeometry( int_com.difference( int_sym ) )
@@ -1039,7 +1039,7 @@ def intersect( self ):
if geom.intersects( tmpGeom ):
atMapB = inFeatB.attributeMap()
int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
if int_geom.wkbType() == 7:
if int_geom.wkbType() == 0:
int_com = geom.combine( tmpGeom )
int_sym = geom.symDifference( tmpGeom )
int_geom = QgsGeometry( int_com.difference( int_sym ) )
@@ -1143,17 +1143,24 @@ def union( self ):
diff_geom = QgsGeometry(diff_geom)

if int_geom.wkbType() == 0:
# intersection produced different geomety types
# intersection produced different geometry types
temp_list = int_geom.asGeometryCollection()
for i in temp_list:
if i.type() == geom.type():
int_geom = QgsGeometry( i )
try:
outFeat.setGeometry( int_geom )
outFeat.setAttributeMap( ftools_utils.combineVectorAttributes( atMapA, atMapB ) )
writer.addFeature( outFeat )
except Exception, err:
FEATURE_EXCEPT = False
int_geom = QgsGeometry( i )
try:
outFeat.setGeometry( int_geom )
outFeat.setAttributeMap( ftools_utils.combineVectorAttributes( atMapA, atMapB ) )
writer.addFeature( outFeat )
except Exception, err:
FEATURE_EXCEPT = False
else:
try:
outFeat.setGeometry( int_geom )
outFeat.setAttributeMap( ftools_utils.combineVectorAttributes( atMapA, atMapB ) )
writer.addFeature( outFeat )
except Exception, err:
FEATURE_EXCEPT = False
else:
# this only happends if the bounding box
# intersects, but the geometry doesn't
@@ -1390,7 +1397,7 @@ def clip( self ):
try:
cur_geom = QgsGeometry( outFeat.geometry() )
new_geom = QgsGeometry( geom.intersection( cur_geom ) )
if new_geom.wkbType() == 7:
if new_geom.wkbType() == 0:
int_com = QgsGeometry( geom.combine( cur_geom ) )
int_sym = QgsGeometry( geom.symDifference( cur_geom ) )
new_geom = QgsGeometry( int_com.difference( int_sym ) )
@@ -1434,7 +1441,7 @@ def clip( self ):
try:
cur_geom = QgsGeometry( outFeat.geometry() )
new_geom = QgsGeometry( geom.intersection( cur_geom ) )
if new_geom.wkbType() == 7:
if new_geom.wkbType() == 0:
int_com = QgsGeometry( geom.combine( cur_geom ) )
int_sym = QgsGeometry( geom.symDifference( cur_geom ) )
new_geom = QgsGeometry( int_com.difference( int_sym ) )
@@ -1485,7 +1492,7 @@ def clip( self ):
try:
cur_geom = QgsGeometry( outFeat.geometry() )
new_geom = QgsGeometry( geom.intersection( cur_geom ) )
if new_geom.wkbType() == 7:
if new_geom.wkbType() == 0:
int_com = QgsGeometry( geom.combine( cur_geom ) )
int_sym = QgsGeometry( geom.symDifference( cur_geom ) )
new_geom = QgsGeometry( int_com.difference( int_sym ) )
@@ -1530,7 +1537,7 @@ def clip( self ):
try:
cur_geom = QgsGeometry( outFeat.geometry() )
new_geom = QgsGeometry( geom.intersection( cur_geom ) )
if new_geom.wkbType() == 7:
if new_geom.wkbType() == 0:
int_com = QgsGeometry( geom.combine( cur_geom ) )
int_sym = QgsGeometry( geom.symDifference( cur_geom ) )
new_geom = QgsGeometry( int_com.difference( int_sym ) )
@@ -50,12 +50,12 @@ def __init__(self, iface):

def populateLayers( self ):
layers = ftools_utils.getLayerNames([QGis.Polygon, "Raster"])
QObject.disconnect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
self.inShape.blockSignals(True)
self.inShape.clear()
self.inShape.blockSignals(False)
self.inShape.addItems(layers)
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)

# If input layer is changed, update field list
# If input layer is changed, update field list
def update(self, inputLayer):
self.cmbField.clear()
changedLayer = ftools_utils.getMapLayerByName(unicode(inputLayer))
@@ -67,6 +67,7 @@ def update(self, inputLayer):
changedLayer = ftools_utils.getVectorLayerByName(inputLayer)
changedFields = ftools_utils.getFieldList(changedLayer)
for i in changedFields:
if changedFields[i].typeName() == "Integer":
self.cmbField.addItem(unicode(changedFields[i].name()))
else:
self.rdoUnstratified.setChecked(True)
@@ -78,7 +79,7 @@ def update(self, inputLayer):
self.cmbField.setEnabled(False)
self.label_4.setEnabled(False)

# when 'OK' button is pressed, gather required inputs, and initiate random points generation
# when 'OK' button is pressed, gather required inputs, and initiate random points generation
def accept(self):
self.buttonOk.setEnabled( False )
if self.inShape.currentText() == "":
@@ -99,7 +100,7 @@ def accept(self):
self.progressBar.setValue(5)
mLayer = ftools_utils.getMapLayerByName(unicode(inName))
if mLayer.type() == mLayer.VectorLayer:
inLayer = QgsVectorLayer(unicode(mLayer.source()), unicode(mLayer.name()), unicode(mLayer.dataProvider().name()))
inLayer = ftools_utils.getVectorLayerByName(unicode(inName))
if self.rdoUnstratified.isChecked():
design = self.tr("unstratified")
value = self.spnUnstratified.value()
@@ -113,7 +114,7 @@ def accept(self):
design = self.tr("field")
value = unicode(self.cmbField.currentText())
elif mLayer.type() == mLayer.RasterLayer:
inLayer = QgsRasterLayer(unicode(mLayer.source()), unicode(mLayer.name()))
inLayer = ftools_utils.getRasterLayerByName(unicode(inName))
design = self.tr("unstratified")
value = self.spnUnstratified.value()
else:
@@ -153,7 +153,7 @@ def accept(self):
self.buttonOk.setEnabled( True )

def compute( self, bound, xOffset, yOffset, polygon ):
crs = self.iface.mapCanvas().mapRenderer().destinationSrs()
crs = ftools_utils.getMapLayerByName(unicode(self.inShape.currentText())).crs()
if not crs.isValid(): crs = None
if polygon:
fields = {0:QgsField("ID", QVariant.Int), 1:QgsField("XMIN", QVariant.Double), 2:QgsField("XMAX", QVariant.Double),
@@ -163,15 +163,13 @@ def compute( self, bound, xOffset, yOffset, polygon ):
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
return
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fields, QGis.WKBPolygon, crs)
#writer = QgsVectorFileWriter(outPath, "CP1250", fields, QGis.WKBPolygon, None)
else:
fields = {0:QgsField("ID", QVariant.Int), 1:QgsField("COORD", QVariant.Double)}
check = QFile(self.shapefileName)
if check.exists():
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
return
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fields, QGis.WKBLineString, crs)
#writer = QgsVectorFileWriter(unicode(outPath), "CP1250", fields, QGis.WKBLineString, None)
outFeat = QgsFeature()
outGeom = QgsGeometry()
idVar = 0
@@ -279,16 +277,16 @@ def getClosestPixel(self, startVal, targetVal, step, isMin ):
while foundVal is None:
if tmpVal <= targetVal:
if backOneStep:
tmpVal -= step
tmpVal -= step
foundVal = tmpVal
tmpVal += step
else:
backOneStep = isMin
while foundVal is None:
if tmpVal >= targetVal:
if backOneStep:
tmpVal -= step
tmpVal -= step
foundVal = tmpVal
tmpVal += step
return foundVal
return foundVal

@@ -206,6 +206,16 @@ def getVectorLayerByName( myName ):
else:
return None

# Return QgsRasterLayer from a layer name ( as string )
def getRasterLayerByName( myName ):
layermap = QgsMapLayerRegistry.instance().mapLayers()
for name, layer in layermap.iteritems():
if layer.type() == QgsMapLayer.RasterLayer and layer.name() == myName:
if layer.isValid():
return layer
else:
return None

# Return QgsMapLayer from a layer name ( as string )
def getMapLayerByName( myName ):
layermap = QgsMapLayerRegistry.instance().mapLayers()

0 comments on commit b982fdc

Please sign in to comment.
You can’t perform that action at this time.