Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix error in median value calculation
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14851 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
alexbruy committed Dec 6, 2010
1 parent 2af0ca2 commit 207d377
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions python/plugins/fTools/tools/doVisual.py
Expand Up @@ -20,7 +20,7 @@ def __init__( self, iface, function ):
self.progressBar.setValue( 0 )
self.partProgressBar.setValue( 0 )
self.partProgressBar.setVisible( False )

def keyPressEvent( self, e ):
'''
Reimplemented key press event:
Expand Down Expand Up @@ -55,15 +55,15 @@ def update( self ):
# add all fields in combobox because now we can work with text fields too
for i in changedField:
self.cmbField.addItem( unicode( changedField[i].name() ) )

def accept( self ):
if self.inShape.currentText() == "":
QMessageBox.information( self, self.tr("Error!"), self.tr( "Please specify input vector layer" ) )
elif self.cmbField.isVisible() and self.cmbField.currentText() == "":
QMessageBox.information( self, self.tr("Error!"), self.tr( "Please specify input field" ) )
else:
self.visual( self.inShape.currentText(), self.cmbField.currentText(), self.useSelected.checkState() )

def manageGui( self ):
if self.myFunction == 2: # List unique values
self.setWindowTitle( self.tr( "List unique values" ) )
Expand All @@ -89,7 +89,7 @@ def manageGui( self ):
if self.myFunction == 4:
myList = ftools_utils.getLayerNames( [ QGis.Point ] )
else:
myList = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] )
myList = ftools_utils.getLayerNames( [ QGis.Point, QGis.Line, QGis.Polygon ] )
self.inShape.addItems( myList )
return

Expand Down Expand Up @@ -121,7 +121,7 @@ def cancelThread( self ):
self.testThread.stop()
QApplication.restoreOverrideCursor()
self.buttonOk.setEnabled( True )

def runFinishedFromThread( self, output ):
self.testThread.stop()
QApplication.restoreOverrideCursor()
Expand All @@ -147,28 +147,28 @@ def runFinishedFromThread( self, output ):
self.tblUnique.horizontalHeader().show()
self.tblUnique.horizontalHeader().setResizeMode( 0, QHeaderView.Stretch )
self.tblUnique.resizeRowsToContents()

self.lstCount.insert( unicode( output[ 1 ] ) )
self.cancel_close.setText( "Close" )
QObject.disconnect( self.cancel_close, SIGNAL( "clicked()" ), self.cancelThread )
return True

def runStatusFromThread( self, status ):
self.progressBar.setValue( status )

def runRangeFromThread( self, range_vals ):
self.progressBar.setRange( range_vals[ 0 ], range_vals[ 1 ] )

def runPartStatusFromThread( self, status ):
self.partProgressBar.setValue( status )
if status >= self.part_max:
self.partProgressBar.setVisible( False )

def runPartRangeFromThread( self, range_vals ):
self.part_max = range_vals[ 1 ]
self.partProgressBar.setVisible( True )
self.partProgressBar.setRange( range_vals[ 0 ], range_vals[ 1 ] )

class visualThread( QThread ):
def __init__( self, parentThread, parentObject, function, vlayer, myField, mySelection ):
QThread.__init__( self, parentThread )
Expand Down Expand Up @@ -359,7 +359,7 @@ def basic_statistics( self, vlayer, myField ):
if ( nVal % 2 ) == 0:
medianVal = 0.5 * ( lstVal[ int( ( nVal - 1 ) / 2 ) ] + lstVal[ int( ( nVal ) / 2 ) ] )
else:
medianVal = lstVal[ int( ( nVal + 1 ) / 2 ) ]
medianVal = lstVal[ int( ( nVal + 1 ) / 2 - 1 ) ]
lstStats = []
lstStats.append( self.tr( "Mean:" ) + unicode( meanVal ) )
lstStats.append( self.tr( "StdDev:" ) + unicode( stdVal ) )
Expand Down

0 comments on commit 207d377

Please sign in to comment.