Ok, perfect, now it's clear.<div><br></div><div>giovanni<br><br><div class="gmail_quote">2012/12/11 Radim Blazek <span dir="ltr"><<a href="mailto:radim.blazek@gmail.com" target="_blank">radim.blazek@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Tue, Dec 11, 2012 at 2:23 PM, G. Allegri <<a href="mailto:giohappy@gmail.com">giohappy@gmail.com</a>> wrote:<br>
>><br>
>> Yes, you are right. Any class inheriting from QgsRasterInterface may<br>
>> be plugged into the QgsRasterPipe but all interfaces will be in a<br>
>> single line, no forks.<br>
><br>
><br>
> Ok, Radim, I'm sorry if I insist on this, it's just to understand it<br>
> correctly.<br>
> To add a QgsRasterInterface in a QgsRasterPipe I would use<br>
> QgsRasterPipe.insert(idx,QgsRasterInterface), but what is the<br>
> QgsRasterInterface.setInput(QgsRasterInterface ) for?<br>
<br>
</div>QgsRasterInterface.setInput(QgsRasterInterface ) is used to set input,<br>
but you dont have to call it if you are using QgsRasterPipe because<br>
it is called by QgsRasterPipe.insert(idx,QgsRasterInterface).<br>
<div class="im"><br>
> If I set a QgsRasterInterface, which will have its own input, as the input<br>
> for another QgsRasterInterface, I'm creating a chain of<br>
> QgsRasterInterfaces...<br>
<br>
</div>Yes, QgsRasterPipe just helps you to manage such chain. It will<br>
automatically connect the interfaces. QgsRasterPipe represents a chain<br>
of interfaces.<br>
<span class="HOEnZb"><font color="#888888"><br>
Radim<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> Help me to understand it...<br>
><br>
> giovanni<br>
><br>
>><br>
>><br>
>> BTW, you should always test if QgsRasterPipe::insert() was successful,<br>
>> because if connection of interfaces fails, the interface is not<br>
>> inserted. Only compatible interfaces may be connected. For example, it<br>
>> is not possible to connect QgsSingleBandGrayRenderer to an interface<br>
>> of ARGB32 type, because it needs numerical data as input.<br>
>> QgsRasterResampleFilter only works with ARGB32 as input etc.<br>
>><br>
>> Radim<br>
>><br>
>><br>
>> > [1]<br>
>> ><br>
>> > <a href="https://github.com/qgis/Quantum-GIS/blob/master/src/core/raster/qgsrasterinterface.h#L108" target="_blank">https://github.com/qgis/Quantum-GIS/blob/master/src/core/raster/qgsrasterinterface.h#L108</a><br>
>> ><br>
>> >><br>
>> >><br>
>> >> Radim<br>
>> >><br>
>> >><br>
>> >> > giovanni<br>
>> >> ><br>
>> >> ><br>
>> >> > 2012/12/11 Radim Blazek <<a href="mailto:radim.blazek@gmail.com">radim.blazek@gmail.com</a>><br>
>> >> >><br>
>> >> >> On Tue, Dec 11, 2012 at 10:52 AM, G. Allegri <<a href="mailto:giohappy@gmail.com">giohappy@gmail.com</a>><br>
>> >> >> wrote:<br>
>> >> >> > Until now I've mostly created vector layers on QGIS, delegating<br>
>> >> >> > raster<br>
>> >> >> > creation to custom GDAL utilities.<br>
>> >> >> > Recently I looked into QgsGdalProvider and I saw that it exposes<br>
>> >> >> > the<br>
>> >> >> > QgsRasterDataProvider::Create capability.<br>
>> >> >> > I wonder if it's possible to create a brand new raster (geotiff or<br>
>> >> >> > what<br>
>> >> >> > else) using this provider and, in case, what is the right workflow<br>
>> >> >> > to<br>
>> >> >> > do<br>
>> >> >> > that. I haven't found examples of doing it...<br>
>> >> >><br>
>> >> >> Yes it is possible. You can use a provider directly<br>
>> >> >><br>
>> >> >> QgsRasterDataProvider * provider = ( QgsRasterDataProvider*<br>
>> >> >> )QgsProviderRegistry::instance()->provider( "gdal", dataSource );<br>
>> >> >> provider->write( data, band, width, height, xOffset, yOffset )<br>
>> >> >><br>
>> >> >> if you your algorithm implemented as QgsRasterInterface you can use<br>
>> >> >> higher level QgsRasterFileWriter which will do the work splitting<br>
>> >> >> raster into parts<br>
>> >> >><br>
>> >> >> QgsRasterPipe* pipe = new QgsRasterPipe();<br>
>> >> >> pipe->set( inputProvider->clone() );<br>
>> >> >> pipe->insert( 1, yourInterface );<br>
>> >> >> QgsRasterFileWriter fileWriter( fileName );<br>
>> >> >> fileWriter.writeRaster( pipe, width, height, extent, crs );<br>
>> >> >><br>
>> >> >> Radim<br>
>> >> >><br>
>> >> >><br>
>> >> >> > giovanni<br>
>> >> >> ><br>
>> >> >> > _______________________________________________<br>
>> >> >> > Qgis-developer mailing list<br>
>> >> >> > <a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
>> >> >> > <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
>> >> >> ><br>
>> >> ><br>
>> >> ><br>
>> ><br>
>> ><br>
><br>
><br>
</div></div></blockquote></div><br></div>