2 changes: 1 addition & 1 deletion python/core/core.sip
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
%Include raster/qgssinglebandcolordatarenderer.sip
%Include raster/qgssinglebandpseudocolorrenderer.sip
%Include raster/qgssinglebandgrayrenderer.sip
%Include raster/qgspaletterasterrenderer.sip
%Include raster/qgspalettedrasterrenderer.sip
%Include raster/qgscubicrasterresampler.sip
%Include raster/qgsmultibandcolorrenderer.sip

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
class QgsPalettedRasterRenderer: QgsRasterRenderer
class QgsPalettedRasterRenderer : QgsRasterRenderer
{
%TypeHeaderCode
#include "qgspalettedrasterrenderer.h"
%End
public:
/**Renderer owns color array*/
QgsPalettedRasterRenderer( QgsRasterDataProvider* provider, int bandNumber, QColor* colorArray /Array,Transfer/, int nColors /ArraySize/ );
QgsPalettedRasterRenderer( QgsRasterInterface* input, int bandNumber, QColor* colorArray /Array,Transfer/, int nColors /ArraySize/ );
~QgsPalettedRasterRenderer();
QgsRasterInterface * clone() /Factory/;
static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterDataProvider* provider ) /Factory/;
QgsRasterInterface * clone() const /Factory/;
static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterInterface* input ) /Factory/;

QgsRasterBlock * block( int bandNo, const QgsRectangle & extent, int width, int height ) / Factory /;
// void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );

QgsRasterBlock *block( int bandNo, const QgsRectangle & extent, int width, int height ) /Factory/;

/**Returns number of colors*/
int nColors() const;
Expand All @@ -20,4 +22,6 @@ class QgsPalettedRasterRenderer: QgsRasterRenderer
void writeXML( QDomDocument& doc, QDomElement& parentElem ) const;

void legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const;
};

QList<int> usesBands() const;
};
31 changes: 25 additions & 6 deletions src/core/qgsproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "qgsprojectversion.h"
#include "qgspluginlayer.h"
#include "qgspluginlayerregistry.h"
#include "qgsdatasourceuri.h"

#include <QApplication>
#include <QFileInfo>
Expand Down Expand Up @@ -1597,13 +1598,31 @@ bool QgsProject::createEmbeddedLayer( const QString& layerId, const QString& pro
//change datasource path from relative to absolute if necessary
if ( !useAbsolutePathes )
{
QDomElement dsElem = mapLayerElem.firstChildElement( "datasource" );
QString debug( QFileInfo( projectFilePath ).absolutePath() + "/" + dsElem.text() );
QFileInfo absoluteDs( QFileInfo( projectFilePath ).absolutePath() + "/" + dsElem.text() );
if ( absoluteDs.exists() )
QDomElement provider = mapLayerElem.firstChildElement( "provider" );
if ( provider.text() == "spatialite" )
{
dsElem.removeChild( dsElem.childNodes().at( 0 ) );
dsElem.appendChild( projectDocument.createTextNode( absoluteDs.absoluteFilePath() ) );
QDomElement dsElem = mapLayerElem.firstChildElement( "datasource" );

QgsDataSourceURI uri( dsElem.text() );

QFileInfo absoluteDs( QFileInfo( projectFilePath ).absolutePath() + "/" + uri.database() );
if ( absoluteDs.exists() )
{
uri.setDatabase( absoluteDs.absoluteFilePath() );
dsElem.removeChild( dsElem.childNodes().at( 0 ) );
dsElem.appendChild( projectDocument.createTextNode( uri.uri() ) );
}
}
else
{
QDomElement dsElem = mapLayerElem.firstChildElement( "datasource" );
QString debug( QFileInfo( projectFilePath ).absolutePath() + "/" + dsElem.text() );
QFileInfo absoluteDs( QFileInfo( projectFilePath ).absolutePath() + "/" + dsElem.text() );
if ( absoluteDs.exists() )
{
dsElem.removeChild( dsElem.childNodes().at( 0 ) );
dsElem.appendChild( projectDocument.createTextNode( absoluteDs.absoluteFilePath() ) );
}
}
}

Expand Down
9 changes: 4 additions & 5 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2313,7 +2313,6 @@ bool QgsVectorLayer::readXml( const QDomNode& layer_node )
} // void QgsVectorLayer::readXml



bool QgsVectorLayer::setDataProvider( QString const & provider )
{
// XXX should I check for and possibly delete any pre-existing providers?
Expand Down Expand Up @@ -2619,7 +2618,7 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
mEditTypes.insert( name, editType );

int editable = editTypeElement.attribute( "editable" , "1" ).toInt();
mFieldEditables.insert( name, editable == 1);
mFieldEditables.insert( name, editable == 1 );

switch ( editType )
{
Expand Down Expand Up @@ -2936,7 +2935,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
QDomElement editTypeElement = doc.createElement( "edittype" );
editTypeElement.setAttribute( "name", it.key() );
editTypeElement.setAttribute( "type", it.value() );
editTypeElement.setAttribute( "editable", mFieldEditables[ it.key()]?1:0 );
editTypeElement.setAttribute( "editable", mFieldEditables[ it.key()] ? 1 : 0 );

switch (( EditType ) it.value() )
{
Expand Down Expand Up @@ -3903,7 +3902,7 @@ bool QgsVectorLayer::fieldEditable( int idx )
{
const QgsFields &fields = pendingFields();
if ( idx >= 0 && idx < fields.count() && mEditTypes.contains( fields[idx].name() ) )
return mFieldEditables[ fields[idx].name() ];
return mFieldEditables[ fields[idx].name()];
else
return false;
}
Expand All @@ -3912,7 +3911,7 @@ void QgsVectorLayer::setFieldEditable( int idx, bool editable )
{
const QgsFields &fields = pendingFields();
if ( idx >= 0 && idx < fields.count() && mEditTypes.contains( fields[idx].name() ) )
mFieldEditables[ fields[idx].name() ] = editable;
mFieldEditables[ fields[idx].name()] = editable;
}

void QgsVectorLayer::addOverlay( QgsVectorOverlay* overlay )
Expand Down
7 changes: 5 additions & 2 deletions src/core/raster/qgspalettedrasterrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ class CORE_EXPORT QgsPalettedRasterRenderer: public QgsRasterRenderer

void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );

QgsRasterBlock * block( int bandNo, QgsRectangle const & extent, int width, int height );
QgsRasterBlock *block( int bandNo, const QgsRectangle & extent, int width, int height );

/**Returns number of colors*/
int nColors() const { return mNColors; }
/**Returns copy of color array (caller takes ownership)*/
QColor* colors() const;
/**Returns copy of rgb array (caller takes ownership)*/

/**Returns copy of rgb array (caller takes ownership)
@note not available in python bindings
*/
QRgb* rgbArray() const;

void writeXML( QDomDocument& doc, QDomElement& parentElem ) const;
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgsrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ void QgsFeatureRendererV2::renderFeatureWithSymbol( QgsFeature& feature, QgsSymb
break;

default:
QgsDebugMsg( QString( "unsupported wkb type 0x%1 for rendering" ).arg( geom->wkbType(), 0, 16 ) );
QgsDebugMsg( QString( "feature %1: unsupported wkb type 0x%2 for rendering" ).arg( feature.id() ).arg( geom->wkbType(), 0, 16 ) );
}
}

Expand Down
124 changes: 55 additions & 69 deletions src/providers/oracle/ocispatial/qsql_ocispatial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ class enter
}
};

#ifdef _MSC_VER
#define ENTER enter here(__FUNCTION__,__FILE__,__LINE__);
#else
#define ENTER enter here(__PRETTY_FUNCTION__,__FILE__,__LINE__);
#endif

int enter::level = 0;
#else
Expand Down Expand Up @@ -1152,8 +1156,7 @@ class QOCISpatialCols
bool getValue( OCINumber *num, int &value );
bool getValue( OCINumber *num, double &value );
bool getArraySize( OCIColl *coll, int &nSize );
bool getArrayItem( OCIArray *coll, int elem, int &item );
bool getElemInfoElem( int elem, int nElems, int nOrds, int &startOffset, int &endOffset, int &etype, int &interpretation );
bool getElemInfoElem( int elem, const QVector<int> &vElem, int nOrds, int &startOffset, int &endOffset, int &etype, int &interpretation );
static int byteorder() { static char littleEndian = htonl( 1 ) != 1; return littleEndian; }

#ifdef QOCISPATIAL_DEBUG
Expand Down Expand Up @@ -2289,46 +2292,21 @@ bool QOCISpatialCols::getArraySize( OCIColl *coll, int &nSize )
return false;
}

bool QOCISpatialCols::getArrayItem( OCIArray *coll, int elem, int &item )
{
OCINumber *num;
boolean exists;

try
{
OCI_VERIFY_E( d->err, OCICollGetElem( d->env, d->err, coll, elem, &exists, ( dvoid ** ) &num, 0 ) );

if ( !exists )
{
qWarning( "item %d does not exists.", elem );
throw OCI_ERROR;
}

return getValue( num, item );
}
catch ( int )
{
return false;
}
}

bool QOCISpatialCols::getElemInfoElem( int iElem, int nElems, int nOrds,
bool QOCISpatialCols::getElemInfoElem( int iElem, const QVector<int> &vElems, int nOrds,
int &startOffset, int &endOffset,
int &etype, int &interpretation )
{
if ( !getArrayItem( d->sdoobj->elem_info, iElem + 0, startOffset ) ||
!getArrayItem( d->sdoobj->elem_info, iElem + 1, etype ) ||
!getArrayItem( d->sdoobj->elem_info, iElem + 2, interpretation ) )
return false;
startOffset = vElems[ iElem + 0 ];
etype = vElems[ iElem + 1 ];
interpretation = vElems[ iElem + 2 ];

if ( iElem + 3 == nElems )
if ( iElem + 3 >= vElems.size() )
{
endOffset = nOrds + 1;
}
else if ( !getArrayItem( d->sdoobj->elem_info, iElem + 3, endOffset ) )
else
{
qWarning() << "end offset not found";
return false;
endOffset = vElems[ iElem + 3 ];
}

--startOffset;
Expand Down Expand Up @@ -2470,41 +2448,49 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
return false;
}

QVector<double> ordinates( nOrds );
boolean exists;
QVector<int> elems( nElems );

try
{
#if 0
// TODO figure this out - quicker, but occasionally crashes
QVector<OCINumber*> numbers( nOrds, 0 );
uword nords = nOrds;
OCI_VERIFY_E( d->err, OCICollGetElemArray( d->env, d->err, d->sdoobj->ordinates, 0, &exists, ( void** ) numbers.data(), 0, &nords ) );
if ( !exists )
QVector<boolean> exists( nElems );
QVector<OCINumber*> numbers( nElems );
uword nelems = nElems;
OCI_VERIFY_E( d->err, OCICollGetElemArray( d->env, d->err, d->sdoobj->elem_info, 0, exists.data(), ( void** ) numbers.data(), 0, &nelems ) );
if ( !exists[0] )
{
qWarning() << "ordinate array does not exists";
qWarning() << "element info array does not exists";
throw OCI_ERROR;
}
OCI_VERIFY_E( d->err, OCINumberToRealArray( d->err, ( const OCINumber ** ) numbers.data(), nOrds, sizeof( double ), ordinates.data() ) );
#else
for ( int i = 0; i < nOrds; i++ )
{
OCINumber *num;

OCI_VERIFY_E( d->err, OCICollGetElem( d->env, d->err, d->sdoobj->ordinates, i, &exists, ( dvoid ** ) &num, 0 ) );

if ( !exists )
for ( unsigned int i = 0; i < nelems; i++ )
{
if ( !getValue( numbers[i], elems[i] ) )
{
qWarning( "item %d does not exists.", i );
qWarning() << "get value of element info item" << i << "failed";
throw OCI_ERROR;
}
}
}
catch ( int )
{
return false;
}

if ( !getValue( num, ordinates[i] ) )
{
throw OCI_ERROR;
}

QVector<double> ordinates( nOrds );

try
{
QVector<boolean> exists( nOrds );
QVector<OCINumber*> numbers( nOrds );
uword nords = nOrds;
OCI_VERIFY_E( d->err, OCICollGetElemArray( d->env, d->err, d->sdoobj->ordinates, 0, exists.data(), ( void** ) numbers.data(), 0, &nords ) );
if ( !exists[0] )
{
qWarning() << "ordinate array does not exists";
throw OCI_ERROR;
}
#endif
OCI_VERIFY_E( d->err, OCINumberToRealArray( d->err, ( const OCINumber ** ) numbers.data(), nords, sizeof( double ), ordinates.data() ) );
}
catch ( int )
{
Expand All @@ -2518,7 +2504,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
for ( int i = 0; i < nElems; i += 3 )
{
int startOffset, endOffset, etype, n;
if ( !getElemInfoElem( i, nElems, nOrds, startOffset, endOffset, etype, n ) )
if ( !getElemInfoElem( i, elems, nOrds, startOffset, endOffset, etype, n ) )
{
qDebug() << "could not fetch element info" << i;
return false;
Expand Down Expand Up @@ -2552,7 +2538,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
for ( int i = 0; i < nElems; i += 3 )
{
int startOffset, endOffset, etype, n;
if ( !getElemInfoElem( i, nElems, nOrds, startOffset, endOffset, etype, n ) )
if ( !getElemInfoElem( i, elems, nOrds, startOffset, endOffset, etype, n ) )
{
qDebug() << "could not fetch element info" << i;
return false;
Expand Down Expand Up @@ -2595,9 +2581,9 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
for ( int i = 0; i < nElems; i += 3 )
{
int startOffset, endOffset, etype, n;
if ( !getElemInfoElem( i, nElems, nOrds, startOffset, endOffset, etype, n ) )
if ( !getElemInfoElem( i, elems, nOrds, startOffset, endOffset, etype, n ) )
{
qDebug() << "could not fetch element info" << i;
qWarning() << "could not fetch element info" << i;
return false;
}

Expand All @@ -2608,7 +2594,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
}
else
{
qDebug() << "unsupported line element - etype:" << etype << "n:" << n << "skipped";
qWarning( "skipped unsupported line element: etype=%08x n=%d", etype, n );
}
}

Expand All @@ -2634,9 +2620,9 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
for ( int i = 0; i < nElems; i += 3 )
{
int startOffset, endOffset, etype, n;
if ( !getElemInfoElem( i, nElems, nOrds, startOffset, endOffset, etype, n ) )
if ( !getElemInfoElem( i, elems, nOrds, startOffset, endOffset, etype, n ) )
{
qDebug() << "could not fetch element info" << i;
qWarning() << "could not fetch element info" << i;
return false;
}

Expand Down Expand Up @@ -2667,9 +2653,9 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
for ( int i = 0; i < nElems; i += 3 )
{
int startOffset, endOffset, etype, n;
if ( !getElemInfoElem( i, nElems, nOrds, startOffset, endOffset, etype, n ) )
if ( !getElemInfoElem( i, elems, nOrds, startOffset, endOffset, etype, n ) )
{
qDebug() << "could not fetch element info" << i;
qWarning() << "could not fetch element info" << i;
return false;
}

Expand All @@ -2695,7 +2681,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
}
else
{
qDebug() << "unsupported polygon element - etype:" << etype << "n:" << n << "skipped";
qWarning( "skipped unsupported polygon element: etype=%08x n=%d", etype, n );
}
}

Expand Down Expand Up @@ -2727,9 +2713,9 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
for ( int i = 0; i < nElems; i += 3 )
{
int startOffset, endOffset, etype, n;
if ( !getElemInfoElem( i, nElems, nOrds, startOffset, endOffset, etype, n ) )
if ( !getElemInfoElem( i, elems, nOrds, startOffset, endOffset, etype, n ) )
{
qDebug() << "could not fetch element info" << i;
qWarning() << "could not fetch element info" << i;
return false;
}

Expand Down
Loading