Skip to content

Commit

Permalink
Removed GDAL dependencies where easily possible
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Dec 17, 2012
1 parent d435bfc commit b662077
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 53 deletions.
21 changes: 10 additions & 11 deletions src/core/raster/qgsrasterblock.cpp
Expand Up @@ -527,34 +527,33 @@ QByteArray QgsRasterBlock::valueBytes( QGis::DataType theDataType, double theVal
QByteArray ba;
ba.resize(( int )size );
char * data = ba.data();
unsigned char uc;
unsigned short us;
short s;
unsigned int ui;
int i;
quint8 uc;
quint16 us;
qint16 s;
quint32 ui;
qint32 i;
float f;
double d;
// TODO: define correct data types (typedef) like in GDAL
switch ( theDataType )
{
case QGis::Byte:
uc = ( unsigned char )theValue;
uc = ( quint8 )theValue;
memcpy( data, &uc, size );
break;
case QGis::UInt16:
us = ( unsigned short )theValue;
us = ( quint16 )theValue;
memcpy( data, &us, size );
break;
case QGis::Int16:
s = ( short )theValue;
s = ( qint16 )theValue;
memcpy( data, &s, size );
break;
case QGis::UInt32:
ui = ( unsigned int )theValue;
ui = ( quint32 )theValue;
memcpy( data, &ui, size );
break;
case QGis::Int32:
i = ( int )theValue;
i = ( qint32 )theValue;
memcpy( data, &i, size );
break;
case QGis::Float32:
Expand Down
22 changes: 10 additions & 12 deletions src/core/raster/qgsrasterblock.h
Expand Up @@ -24,8 +24,6 @@
#include "qgslogger.h"
#include "qgsrectangle.h"

#include "gdal.h" // only for data types for now

/** \ingroup core
* Raster data container.
*/
Expand Down Expand Up @@ -332,19 +330,19 @@ inline double QgsRasterBlock::readValue( void *data, QGis::DataType type, size_t
switch ( type )
{
case QGis::Byte:
return ( double )(( GByte * )data )[index];
return ( double )(( quint8 * )data )[index];
break;
case QGis::UInt16:
return ( double )(( GUInt16 * )data )[index];
return ( double )(( quint16 * )data )[index];
break;
case QGis::Int16:
return ( double )(( GInt16 * )data )[index];
return ( double )(( qint16 * )data )[index];
break;
case QGis::UInt32:
return ( double )(( GUInt32 * )data )[index];
return ( double )(( quint32 * )data )[index];
break;
case QGis::Int32:
return ( double )(( GInt32 * )data )[index];
return ( double )(( qint32 * )data )[index];
break;
case QGis::Float32:
return ( double )(( float * )data )[index];
Expand All @@ -369,19 +367,19 @@ inline void QgsRasterBlock::writeValue( void *data, QGis::DataType type, size_t
switch ( type )
{
case QGis::Byte:
(( GByte * )data )[index] = ( GByte ) value;
(( quint8 * )data )[index] = ( quint8 ) value;
break;
case QGis::UInt16:
(( GUInt16 * )data )[index] = ( GUInt16 ) value;
(( quint16 * )data )[index] = ( quint16 ) value;
break;
case QGis::Int16:
(( GInt16 * )data )[index] = ( GInt16 ) value;
(( qint16 * )data )[index] = ( qint16 ) value;
break;
case QGis::UInt32:
(( GUInt32 * )data )[index] = ( GUInt32 ) value;
(( quint32 * )data )[index] = ( quint32 ) value;
break;
case QGis::Int32:
(( GInt32 * )data )[index] = ( GInt32 ) value;
(( qint32 * )data )[index] = ( qint32 ) value;
break;
case QGis::Float32:
(( float * )data )[index] = ( float ) value;
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterfilewriter.cpp
Expand Up @@ -26,8 +26,6 @@
#include <QTextStream>
#include <QMessageBox>

#include "gdal.h"

QgsRasterFileWriter::QgsRasterFileWriter( const QString& outputUrl ):
mOutputUrl( outputUrl ), mOutputProviderKey( "gdal" ), mOutputFormat( "GTiff" ),
mTiledMode( false ), mMaxTileWidth( 500 ), mMaxTileHeight( 500 ),
Expand Down Expand Up @@ -726,6 +724,7 @@ void QgsRasterFileWriter::buildPyramids( const QString& filename )
}
}

#if 0
int QgsRasterFileWriter::pyramidsProgress( double dfComplete, const char *pszMessage, void* pData )
{
Q_UNUSED( pszMessage );
Expand All @@ -743,6 +742,7 @@ int QgsRasterFileWriter::pyramidsProgress( double dfComplete, const char *pszMes
}
return 1;
}
#endif

void QgsRasterFileWriter::createVRT( int xSize, int ySize, const QgsCoordinateReferenceSystem& crs, double* geoTransform )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterfilewriter.h
Expand Up @@ -116,7 +116,7 @@ class CORE_EXPORT QgsRasterFileWriter
void addToVRT( const QString& filename, int band, int xSize, int ySize, int xOffset, int yOffset );
void buildPyramids( const QString& filename );

static int pyramidsProgress( double dfComplete, const char *pszMessage, void* pData );
//static int pyramidsProgress( double dfComplete, const char *pszMessage, void* pData );

/**Create provider and datasource for a part image (vrt mode)*/
QgsRasterDataProvider* createPartProvider( const QgsRectangle& extent, int nCols, int iterCols, int iterRows,
Expand Down
2 changes: 0 additions & 2 deletions src/core/raster/qgsrasterinterface.h
Expand Up @@ -26,8 +26,6 @@
#include "qgsrasterblock.h"
#include "qgsrectangle.h"

#include "gdal.h"

/** \ingroup core
* Base class for processing modules.
*/
Expand Down
5 changes: 0 additions & 5 deletions src/gui/qgsrasterpyramidsoptionswidget.cpp
Expand Up @@ -19,11 +19,6 @@
#include "qgslogger.h"
#include "qgsdialog.h"

#include "gdal.h"
#include "cpl_string.h"
#include "cpl_conv.h"
#include "cpl_minixml.h"

#include <QSettings>
#include <QInputDialog>
#include <QMessageBox>
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/grass/qgsgrassmodule.cpp
Expand Up @@ -51,7 +51,7 @@ extern "C"
#include <grass/glocale.h>
}

#include <gdal.h> // to collect version information
//#include <gdal.h> // to collect version information

bool QgsGrassModule::mExecPathInited = 0;
QStringList QgsGrassModule::mExecPath;
Expand Down
8 changes: 8 additions & 0 deletions src/providers/wcs/qgswcsprovider.cpp
Expand Up @@ -60,6 +60,14 @@
#include "cpl_conv.h"
#include "cpl_string.h"

#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
#define TO8F(x) (x).toUtf8().constData()
#define FROM8(x) QString::fromUtf8(x)
#else
#define TO8F(x) QFile::encodeName( x ).constData()
#define FROM8(x) QString::fromLocal8Bit(x)
#endif

#define ERR(message) QGS_ERROR_MESSAGE(message,"WCS provider")
#define SRVERR(message) QGS_ERROR_MESSAGE(message,"WCS server")

Expand Down
8 changes: 0 additions & 8 deletions src/providers/wcs/qgswcsprovider.h
Expand Up @@ -45,14 +45,6 @@ class QNetworkRequest;
#define CPL_SUPRESS_CPLUSPLUS
#include <gdal.h>

#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
#define TO8F(x) (x).toUtf8().constData()
#define FROM8(x) QString::fromUtf8(x)
#else
#define TO8F(x) QFile::encodeName( x ).constData()
#define FROM8(x) QString::fromLocal8Bit(x)
#endif

/**
\brief Data provider for OGC WCS layers.
Expand Down
11 changes: 0 additions & 11 deletions src/providers/wcs/qgswcssourceselect.cpp
Expand Up @@ -27,17 +27,6 @@

#include <QWidget>

#define CPL_SUPRESS_CPLUSPLUS
#include <gdal.h>

#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
#define TO8F(x) (x).toUtf8().constData()
#define FROM8(x) QString::fromUtf8(x)
#else
#define TO8F(x) QFile::encodeName( x ).constData()
#define FROM8(x) QString::fromLocal8Bit(x)
#endif

QgsWCSSourceSelect::QgsWCSSourceSelect( QWidget * parent, Qt::WFlags fl, bool managerMode, bool embeddedMode )
: QgsOWSSourceSelect( "WCS", parent, fl, managerMode, embeddedMode )
{
Expand Down

0 comments on commit b662077

Please sign in to comment.