Skip to content
Permalink
Browse files
GRASS Direct
  • Loading branch information
blazek committed Dec 6, 2012
1 parent bfa124f commit 4dc84995ee4dec8fe4b927a650b900e7edddaad4
@@ -413,12 +413,16 @@ bool QgsRasterBlock::convert( QgsRasterBlock::DataType destDataType )
}
QgsFree( mData );
mData = data;
mDataType = destDataType;
mTypeSize = typeSize( mDataType );
}
else if ( typeIsColor( mDataType ) && typeIsColor( destDataType ) )
{
QImage::Format format = imageFormat( destDataType );
QImage image = mImage->convertToFormat( format );
*mImage = image;
mDataType = destDataType;
mTypeSize = typeSize( mDataType );
}
else
{
@@ -516,7 +520,7 @@ void * QgsRasterBlock::convert( void *srcData, QgsRasterBlock::DataType srcDataT
double value = readValue( srcData, srcDataType, i );
writeValue( destData, destDataType, i, value );
//double newValue = readValue( destData, destDataType, i );
//QgsDebugMsg( QString("convert type %1 to %2: %3 -> %4").arg(srcDataType).arg(destDataType).arg( value ).arg( newValue ) );
//QgsDebugMsg( QString("convert %1 type %2 to %3: %4 -> %5").arg(i).arg(srcDataType).arg(destDataType).arg( value ).arg( newValue ) );
}
return destData;
}
@@ -701,10 +701,10 @@ QgsRasterBlock * QgsRasterProjector::block( int bandNo, QgsRectangle const & ex
QgsRasterBlock *outputBlock = new QgsRasterBlock();
if ( !mInput )
{
QgsDebugMsg( "Input not set" );
return outputBlock;
}


if ( ! mSrcCRS.isValid() || ! mDestCRS.isValid() || mSrcCRS == mDestCRS )
{
QgsDebugMsg( "No projection necessary" );
@@ -723,6 +723,7 @@ QgsRasterBlock * QgsRasterProjector::block( int bandNo, QgsRectangle const & ex
// If we zoom out too much, projector srcRows / srcCols maybe 0, which can cause problems in providers
if ( srcRows() <= 0 || srcCols() <= 0 )
{
QgsDebugMsg( "Zero srcRows or srcCols" );
return outputBlock;
}

@@ -737,20 +738,23 @@ QgsRasterBlock * QgsRasterProjector::block( int bandNo, QgsRectangle const & ex

size_t pixelSize = QgsRasterBlock::typeSize( mInput->dataType( bandNo ) );

if ( !outputBlock->reset( QgsRasterBlock::ARGB32_Premultiplied, width, height ) )
if ( !outputBlock->reset( mInput->dataType( bandNo ), width, height ) )
{
QgsDebugMsg( "Cannot reset block" );
delete inputBlock;
return outputBlock;
}
outputBlock->setNoDataValue( mInput->noDataValue( bandNo ) );

// TODO: fill by transparent
// TODO: fill by no data or transparent

int srcRow, srcCol;
for ( int i = 0; i < height; ++i )
{
for ( int j = 0; j < width; ++j )
{
srcRowCol( i, j, &srcRow, &srcCol );
QgsDebugMsgLevel( QString( "row = %1 col = %2 srcRow = %3 srcCol = %4" ).arg( i ).arg( j ).arg( srcRow ).arg( srcCol ), 5 );
size_t srcIndex = srcRow * mSrcCols + srcCol;
size_t destIndex = i * width + j;

@@ -246,6 +246,7 @@
</section>
<section label="Create random points">
<grass name="r.random"/>
<grass name="r.random.raster"/>
<grass name="r.random.cells"/>
</section>
<section label="Generate surface">
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE qgisgrassmodule SYSTEM "http://mrcc.com/qgisgrassmodule.dtd">

<qgisgrassmodule label="Create random raster" module="r.random" direct="1">
<option key="input"/>
<option key="n" answer="1" hidden="no"/>
<option key="raster_output" />
</qgisgrassmodule>
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE qgisgrassmodule SYSTEM "http://mrcc.com/qgisgrassmodule.dtd">

<qgisgrassmodule label="Inverse distance squared weighting raster interpolation" module="r.surf.idw">
<qgisgrassmodule label="Inverse distance squared weighting raster interpolation" module="r.surf.idw" direct="1">
<option key="input" />
<option key="npoints" />
<option key="output" />
@@ -42,7 +42,7 @@ QgsGrassMapcalc::QgsGrassMapcalc(
QWidget * parent, Qt::WFlags f )
: QMainWindow( iface->mainWindow(), Qt::Dialog )
, QgsGrassMapcalcBase( )
, QgsGrassModuleOptions( tools, module, iface )
, QgsGrassModuleOptions( tools, module, iface, false )
, mTool( -1 )
, mObject( 0 )
, mConnector( 0 )

0 comments on commit 4dc8499

Please sign in to comment.