Skip to content
Permalink
Browse files

Merge branch 'master' into delimited_text_bug_fixes

  • Loading branch information
ccrook committed Apr 17, 2013
2 parents c396128 + 22e54b9 commit 45a1bb4843e73bc0a8fd5f5a64735ec336a37793
Showing with 253 additions and 1,170 deletions.
  1. +1 −33 python/core/raster/qgsrasterdataprovider.sip
  2. +2 −6 python/core/raster/qgsrasterinterface.sip
  3. +12 −23 python/plugins/sextante/core/SextanteLog.py
  4. +11 −6 src/app/qgsrasterlayerproperties.cpp
  5. +13 −9 src/core/raster/qgsrasterchecker.cpp
  6. +18 −187 src/core/raster/qgsrasterdataprovider.cpp
  7. +42 −129 src/core/raster/qgsrasterdataprovider.h
  8. +11 −108 src/core/raster/qgsrasterinterface.cpp
  9. +14 −88 src/core/raster/qgsrasterinterface.h
  10. +1 −1 src/core/raster/qgsrasterlayer.cpp
  11. +1 −1 src/core/raster/qgsrasterprojector.cpp
  12. +5 −98 src/core/raster/qgsrasterrendererregistry.cpp
  13. +1 −1 src/core/raster/qgsrasterresamplefilter.cpp
  14. +35 −221 src/core/symbology-ng/qgsellipsesymbollayerv2.cpp
  15. +0 −19 src/core/symbology-ng/qgsellipsesymbollayerv2.h
  16. +17 −149 src/core/symbology-ng/qgsfillsymbollayerv2.cpp
  17. +0 −14 src/core/symbology-ng/qgsfillsymbollayerv2.h
  18. +5 −4 src/gui/attributetable/qgsfeaturelistview.cpp
  19. +1 −1 src/gui/attributetable/qgsfeatureselectionmodel.cpp
  20. +3 −3 src/gui/qgsrasterlayersaveasdialog.cpp
  21. +9 −6 src/gui/qgsrasterpyramidsoptionswidget.cpp
  22. +4 −2 src/gui/raster/qgsrasterhistogramwidget.cpp
  23. +38 −26 src/providers/gdal/qgsgdalprovider.cpp
  24. +3 −12 src/providers/gdal/qgsgdalprovider.h
  25. +2 −15 src/providers/grass/qgsgrassrasterprovider.cpp
  26. +1 −6 src/providers/grass/qgsgrassrasterprovider.h
  27. +2 −2 src/providers/wcs/qgswcsprovider.cpp
  28. +1 −0 src/providers/wcs/qgswcsprovider.h
@@ -120,22 +120,8 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
virtual int ySize() const;

/** read block of data */
// TODO clarify what happens on the last block (the part outside raster)
// virtual void readBlock( int bandNo, int xBlock, int yBlock, void *data );

/** read block of data using give extent and size */
// virtual void readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, void *data );

/** read block of data using give extent and size */
// virtual void *readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS, void *data );

/** Read block of data using given extent and size. */
// virtual void *readBlock( int bandNo, QgsRectangle const & extent, int width, int height );
virtual QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height ) / Factory /;

/* Read a value from a data block at a given index. */
//virtual double readValue( void *data, int type, int index );

/* Return true if source band has no data value */
virtual bool srcHasNoDataValue( int bandNo ) const;

@@ -145,14 +131,6 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
/** \brief Set source nodata value usage */
virtual void setUseSrcNoDataValue( int bandNo, bool use );

/** value representing null data */
//virtual double noDataValue() const;

/** Value representing currentno data.
* WARNING: this value returned by this method is not constant. It may change
* for example if user disable use of source no data value. */
//virtual double noDataValue( int bandNo ) const;

/** Value representing no data value. */
virtual double srcNoDataValue( int bandNo ) const;

@@ -161,9 +139,6 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
/** Get list of user no data value ranges */
virtual QgsRasterRangeList userNoDataValue( int bandNo ) const;

virtual double minimumValue( int bandNo ) const;
virtual double maximumValue( int bandNo ) const;

virtual QList<QgsColorRampShader::ColorRampItem> colorTable( int bandNo ) const;

// Defined in parent
@@ -235,11 +210,6 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
@note: this method was added in version 1.2*/
void setDpi( int dpi );

static QStringList cStringList2Q_( char ** stringList );

static QString makeTableCell( const QString & value );
static QString makeTableCells( const QStringList & values );

/** Time stamp of data source in the moment when data/metadata were loaded by provider */
virtual QDateTime timestamp() const;

@@ -273,9 +243,7 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
virtual bool remove();

/** Returns a list of pyramid resampling method names for given provider */
static QStringList pyramidResamplingMethods( QString providerKey = "gdal" );
/** Returns the pyramid resampling argument that corresponds to a given method */
static QString pyramidResamplingArg( QString method, QString providerKey = "gdal" );
static QList<QPair<QString,QString> > pyramidResamplingMethods( QString providerKey );

/** Validates creation options for a specific dataset and destination format.
* @note used by GDAL provider only
@@ -44,15 +44,11 @@ class QgsRasterInterface
enum Capability
{
NoCapabilities,
Identify,
ExactMinimumMaximum,
ExactResolution,
EstimatedMinimumMaximum,
BuildPyramids,
Histogram,
Size,
Create,
Remove,
BuildPyramids,
Identify,
IdentifyValue,
IdentifyText,
IdentifyHtml,
@@ -23,35 +23,37 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import datetime
import os
from sextante.core.SextanteUtils import SextanteUtils
from sextante.core.SextanteConfig import SextanteConfig
import codecs
import datetime
from PyQt4 import QtGui

from sextante.core.SextanteUtils import SextanteUtils
from sextante.core.SextanteConfig import SextanteConfig

class SextanteLog():

LOG_ERROR = "ERROR"
LOG_INFO = "INFO"
LOG_WARNING = "WARNING"
LOG_ALGORITHM = "ALGORITHM"
DATE_FORMAT = u"%a %b %d %Y %H:%M:%S".encode("utf-8")
recentAlgs = []

@staticmethod
def startLogging():
if os.path.isfile(SextanteLog.logFilename()):
logfile = open(SextanteLog.logFilename(), "a")
logfile = codecs.open(SextanteLog.logFilename(), "a", encoding="utf-8")
else:
logfile = open(SextanteLog.logFilename(), "w")
logfile.write("Started logging at " + datetime.datetime.now().strftime("%a %b %d %Y %H:%M:%S") + "\n")
logfile = codecs.open(SextanteLog.logFilename(), "w", encoding="utf-8")
logfile.write("Started logging at " + datetime.datetime.now().strftime(SextanteLog.DATE_FORMAT).decode("utf-8") + "\n")
logfile.close()

@staticmethod
def logFilename():
batchfile = SextanteUtils.userFolder() + os.sep + "sextante_qgis.log"
return batchfile


@staticmethod
def addToLog(msgtype, msg):
try: #it seems that this fails sometimes depending on the msg added:
@@ -63,8 +65,8 @@ def addToLog(msgtype, msg):
text = a
else:
text = msg.replace("\n", "|")
line = msgtype + "|" + datetime.datetime.now().strftime("%a %b %d %Y %H:%M:%S") + "|" + text + "\n"
logfile = open(SextanteLog.logFilename(), "a")
line = msgtype + "|" + datetime.datetime.now().strftime(SextanteLog.DATE_FORMAT).decode("utf-8") + "|" + text + "\n"
logfile = codecs.open(SextanteLog.logFilename(), "a", encoding="utf-8")
#logfile = codecs.open(SextanteLog.logFilename(), "a", encoding='utf-8')
logfile.write(line)
logfile.close()
@@ -78,7 +80,6 @@ def addToLog(msgtype, msg):
except:
pass


@staticmethod
def getLogEntries():
entries={}
@@ -115,7 +116,6 @@ def getLogEntries():
entries[SextanteLog.LOG_WARNING] = warnings
return entries


@staticmethod
def getRecentAlgorithms():
recentAlgsSetting = SextanteConfig.getSetting(SextanteConfig.RECENT_ALGORITHMS)
@@ -125,14 +125,11 @@ def getRecentAlgorithms():
pass
return SextanteLog.recentAlgs


@staticmethod
def clearLog():
os.unlink(SextanteLog.logFilename())
SextanteLog.startLogging()



class LogEntry():
def __init__(self, date, text):
self.date = date
@@ -141,8 +138,6 @@ def __init__(self, date, text):
import re
import time



#===============================================================================

#this code has been take from pytailer
@@ -173,7 +168,7 @@ class Tailer(object):

def __init__(self, filename, read_size=1024, end=False):
self.read_size = read_size
self.file = open(filename)
self.file = codecs.open(filename, encoding="utf-8")
self.start_pos = self.file.tell()
if end:
self.seek_end()
@@ -259,8 +254,6 @@ def tail(self, lines=10):
else:
return []



def __iter__(self):
return self.follow()

@@ -269,7 +262,3 @@ def close(self):

def tail(file, lines=200):
return Tailer(file).tail(lines)




@@ -164,9 +164,11 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
{
// initialize resampling methods
cboResamplingMethod->clear();
foreach ( QString method, QgsRasterDataProvider::pyramidResamplingMethods( mRasterLayer->providerType() ) )
cboResamplingMethod->addItem( method );

QPair<QString, QString> method;
foreach ( method, QgsRasterDataProvider::pyramidResamplingMethods( mRasterLayer->providerType() ) )
{
cboResamplingMethod->addItem( method.second, method.first );
}
// build pyramid list
QList< QgsRasterPyramid > myPyramidList = provider->buildPyramidList();
QList< QgsRasterPyramid >::iterator myRasterPyramidIterator;
@@ -195,7 +197,10 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
mOptsPage_Pyramids->setEnabled( false );
}

if ( !( provider->capabilities() & QgsRasterDataProvider::Histogram ) )
// We can calculate histogram for all data sources but estimated only if
// size is unknown - could also be enabled if well supported (estimated histogram
// and and let user know that it is estimated)
if ( !( provider->capabilities() & QgsRasterDataProvider::Size ) )
{
// disable Histogram tab completely
mOptsPage_Histogram->setEnabled( false );
@@ -572,7 +577,7 @@ void QgsRasterLayerProperties::sync()
}
}

if ( !( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Histogram ) )
if ( !( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Size ) )
{
if ( mOptsPage_Histogram != NULL )
{
@@ -933,7 +938,7 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
QApplication::setOverrideCursor( Qt::WaitCursor );
QString res = provider->buildPyramids(
myPyramidList,
cboResamplingMethod->currentText(),
cboResamplingMethod->itemData( cboResamplingMethod->currentIndex() ).toString(),
( QgsRasterDataProvider::RasterPyramidsFormat ) cbxPyramidsFormat->currentIndex() );
QApplication::restoreOverrideCursor();
mPyramidProgress->setValue( 0 );
@@ -145,12 +145,16 @@ bool QgsRasterChecker::runTest( QString theVerifiedKey, QString theVerifiedUri,

int width = expectedProvider->xSize();
int height = expectedProvider->ySize();
int blockSize = width * height * QgsRasterBlock::typeSize( expectedProvider->dataType( band ) ) ;
void * expectedData = malloc( blockSize );
void * verifiedData = malloc( blockSize );
QgsRasterBlock *expectedBlock = expectedProvider->block( band, expectedProvider->extent(), width, height );
QgsRasterBlock *verifiedBlock = verifiedProvider->block( band, expectedProvider->extent(), width, height );

expectedProvider->readBlock( band, expectedProvider->extent(), width, height, expectedData );
verifiedProvider->readBlock( band, expectedProvider->extent(), width, height, verifiedData );
if ( !expectedBlock || !expectedBlock->isValid() ||
!verifiedBlock || !verifiedBlock->isValid() )
{
allOk = false;
mReport += "cannot read raster block";
continue;
}

// compare data values
QString htmlTable = QString( "<table style='%1'>" ).arg( mTabStyle );
@@ -160,8 +164,8 @@ bool QgsRasterChecker::runTest( QString theVerifiedKey, QString theVerifiedUri,
for ( int col = 0; col < width; col ++ )
{
bool cellOk = true;
double verifiedVal = QgsRasterBlock::readValue( verifiedData, verifiedProvider->dataType( band ), row * width + col );
double expectedVal = QgsRasterBlock::readValue( expectedData, expectedProvider->dataType( band ), row * width + col );
double verifiedVal = verifiedBlock->value( row, col );
double expectedVal = expectedBlock->value( row, col );

QString valStr;
if ( compare( verifiedVal, expectedVal, 0 ) )
@@ -182,8 +186,8 @@ bool QgsRasterChecker::runTest( QString theVerifiedKey, QString theVerifiedUri,

mReport += htmlTable;

free( expectedData );
free( verifiedData );
delete expectedBlock;
delete verifiedBlock;
}
delete verifiedProvider;
delete expectedProvider;

0 comments on commit 45a1bb4

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