Skip to content
Permalink
Browse files

Change tr() to transformation() and add python binding. Make datum_sh…

…ift db update in a transaction
  • Loading branch information
mhugent committed Nov 8, 2013
1 parent 3465c3e commit 64440cfc81aa703088cfbf4d8804c0bc6fa7d196
@@ -245,6 +245,8 @@ class QgsMapRenderer : QObject
//! Added in QGIS v1.4
void setLabelingEngine( QgsLabelingEngineInterface* iface /Transfer/ );

const QgsCoordinateTransform* transformation( const QgsMapLayer *layer ) const;

signals:

void drawingProgress( int current, int total );
@@ -1954,6 +1954,12 @@ bool QgsCoordinateReferenceSystem::syncDatumTransform( const QString& dbPath )
return false;
}

if ( sqlite3_exec( db, "BEGIN TRANSACTION", 0, 0, 0 ) != SQLITE_OK )
{
qCritical( "Could not begin transaction: %s [%s]\n", QgsApplication::srsDbFilePath().toLocal8Bit().constData(), sqlite3_errmsg( db ) );
return false;
}


QTextStream textStream( &f );
textStream.readLine();
@@ -2027,8 +2033,14 @@ bool QgsCoordinateReferenceSystem::syncDatumTransform( const QString& dbPath )
}
}

if ( sqlite3_exec( db, "COMMIT", 0, 0, 0 ) != SQLITE_OK )
{
qCritical( "Could not commit transaction: %s [%s]\n", QgsApplication::srsDbFilePath().toLocal8Bit().constData(), sqlite3_errmsg( db ) );
return false;
}

sqlite3_close( db );
return true; //soon...
return true;
}

QString QgsCoordinateReferenceSystem::geographicCRSAuthId() const
@@ -412,7 +412,7 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
{
r1 = mExtent;
split = splitLayersExtent( ml, r1, r2 );
ct = tr( ml );
ct = transformation( ml );
mRenderContext.setExtent( r1 );
QgsDebugMsg( " extent 1: " + r1.toString() );
QgsDebugMsg( " extent 2: " + r2.toString() );
@@ -655,7 +655,7 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
{
QgsRectangle r1 = mExtent;
split = splitLayersExtent( ml, r1, r2 );
ct = tr( ml );
ct = transformation( ml );
mRenderContext.setExtent( r1 );
}
else
@@ -794,7 +794,7 @@ bool QgsMapRenderer::splitLayersExtent( QgsMapLayer* layer, QgsRectangle& extent
// extent separately.
static const double splitCoord = 180.0;

const QgsCoordinateTransform* transform = tr( layer );
const QgsCoordinateTransform* transform = transformation( layer );
if ( layer->crs().geographicFlag() )
{
// Note: ll = lower left point
@@ -848,7 +848,7 @@ QgsRectangle QgsMapRenderer::layerExtentToOutputExtent( QgsMapLayer* theLayer, Q
{
try
{
const QgsCoordinateTransform* transform = tr( theLayer );
const QgsCoordinateTransform* transform = transformation( theLayer );
if ( transform )
{
extent = transform->transformBoundingBox( extent );
@@ -867,14 +867,14 @@ QgsRectangle QgsMapRenderer::layerExtentToOutputExtent( QgsMapLayer* theLayer, Q

QgsRectangle QgsMapRenderer::outputExtentToLayerExtent( QgsMapLayer* theLayer, QgsRectangle extent )
{
QgsDebugMsg( QString( "layer sourceCrs = " + tr( theLayer )->sourceCrs().authid() ) );
QgsDebugMsg( QString( "layer destCRS = " + tr( theLayer )->destCRS().authid() ) );
QgsDebugMsg( QString( "layer sourceCrs = " + transformation( theLayer )->sourceCrs().authid() ) );
QgsDebugMsg( QString( "layer destCRS = " + transformation( theLayer )->destCRS().authid() ) );
QgsDebugMsg( QString( "extent = " + extent.toString() ) );
if ( hasCrsTransformEnabled() )
{
try
{
extent = tr( theLayer )->transformBoundingBox( extent, QgsCoordinateTransform::ReverseTransform );
extent = transformation( theLayer )->transformBoundingBox( extent, QgsCoordinateTransform::ReverseTransform );
}
catch ( QgsCsException &cse )
{
@@ -893,7 +893,7 @@ QgsPoint QgsMapRenderer::layerToMapCoordinates( QgsMapLayer* theLayer, QgsPoint
{
try
{
point = tr( theLayer )->transform( point, QgsCoordinateTransform::ForwardTransform );
point = transformation( theLayer )->transform( point, QgsCoordinateTransform::ForwardTransform );
}
catch ( QgsCsException &cse )
{
@@ -913,7 +913,7 @@ QgsRectangle QgsMapRenderer::layerToMapCoordinates( QgsMapLayer* theLayer, QgsRe
{
try
{
rect = tr( theLayer )->transform( rect, QgsCoordinateTransform::ForwardTransform );
rect = transformation( theLayer )->transform( rect, QgsCoordinateTransform::ForwardTransform );
}
catch ( QgsCsException &cse )
{
@@ -933,7 +933,7 @@ QgsPoint QgsMapRenderer::mapToLayerCoordinates( QgsMapLayer* theLayer, QgsPoint
{
try
{
point = tr( theLayer )->transform( point, QgsCoordinateTransform::ReverseTransform );
point = transformation( theLayer )->transform( point, QgsCoordinateTransform::ReverseTransform );
}
catch ( QgsCsException &cse )
{
@@ -953,7 +953,7 @@ QgsRectangle QgsMapRenderer::mapToLayerCoordinates( QgsMapLayer* theLayer, QgsRe
{
try
{
rect = tr( theLayer )->transform( rect, QgsCoordinateTransform::ReverseTransform );
rect = transformation( theLayer )->transform( rect, QgsCoordinateTransform::ReverseTransform );
}
catch ( QgsCsException &cse )
{
@@ -1238,7 +1238,7 @@ void QgsMapRenderer::setLabelingEngine( QgsLabelingEngineInterface* iface )
mLabelingEngine = iface;
}

const QgsCoordinateTransform* QgsMapRenderer::tr( const QgsMapLayer *layer ) const
const QgsCoordinateTransform* QgsMapRenderer::transformation( const QgsMapLayer *layer ) const
{
if ( !layer || !mDestCRS )
{
@@ -298,7 +298,7 @@ class CORE_EXPORT QgsMapRenderer : public QObject
void addLayerCoordinateTransform( const QString& layerId, const QString& srcAuthId, const QString& destAuthId, int srcDatumTransform = -1, int destDatumTransform = -1 );
void clearLayerCoordinateTransforms();

const QgsCoordinateTransform* tr( const QgsMapLayer *layer ) const;
const QgsCoordinateTransform* transformation( const QgsMapLayer *layer ) const;

signals:

@@ -46,7 +46,7 @@ void QgsHighlight::init()
{
if ( mMapCanvas->mapRenderer()->hasCrsTransformEnabled() )
{
const QgsCoordinateTransform* ct = mMapCanvas->mapRenderer()->tr( mLayer );
const QgsCoordinateTransform* ct = mMapCanvas->mapRenderer()->transformation( mLayer );
if ( ct )
{
mGeometry->transform( *ct );

0 comments on commit 64440cf

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