Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make a correct copy of QgsCoordinateTransform for labeling (hope it f…
…ixes #9600)
  • Loading branch information
mhugent committed Feb 19, 2014
1 parent 42a4e75 commit 34f79cf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/core/qgscoordinatetransform.cpp
Expand Up @@ -127,6 +127,15 @@ QgsCoordinateTransform::~QgsCoordinateTransform()
}
}

QgsCoordinateTransform* QgsCoordinateTransform::clone() const
{
QgsCoordinateTransform* tr = new QgsCoordinateTransform( sourceCrs(), destCRS() );
tr->setSourceDatumTransform( sourceDatumTransform() );
tr->setDestinationDatumTransform( destinationDatumTransform() );
tr->initialise();
return tr;
}

void QgsCoordinateTransform::setSourceCrs( const QgsCoordinateReferenceSystem& theCRS )
{
mSourceCRS = theCRS;
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgscoordinatetransform.h
Expand Up @@ -88,6 +88,8 @@ class CORE_EXPORT QgsCoordinateTransform : public QObject
//! destructor
~QgsCoordinateTransform();

QgsCoordinateTransform* clone() const;

//! Enum used to indicate the direction (forward or inverse) of the transform
enum TransformDirection
{
Expand Down
22 changes: 16 additions & 6 deletions src/core/qgspallabeling.cpp
Expand Up @@ -3297,10 +3297,15 @@ int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QSet<int>& attrIndices,
lyr.fieldIndex = fldIndex;

lyr.xform = mMapRenderer->coordinateTransform();
lyr.ct = 0;
if ( mMapRenderer->hasCrsTransformEnabled() )
lyr.ct = new QgsCoordinateTransform( layer->crs(), mMapRenderer->destinationCrs() );
else
lyr.ct = NULL;
{
const QgsCoordinateTransform* tr = mMapRenderer->transformation( layer );
if ( tr )
{
lyr.ct = tr->clone();
}
}
lyr.ptZero = lyr.xform->toMapCoordinates( 0, 0 );
lyr.ptOne = lyr.xform->toMapCoordinates( 1, 0 );

Expand All @@ -3318,10 +3323,15 @@ int QgsPalLabeling::addDiagramLayer( QgsVectorLayer* layer, QgsDiagramLayerSetti
l->setArrangementFlags( s->placementFlags );

s->palLayer = l;
s->ct = 0;
if ( mMapRenderer->hasCrsTransformEnabled() )
s->ct = new QgsCoordinateTransform( layer->crs(), mMapRenderer->destinationCrs() );
else
s->ct = NULL;
{
const QgsCoordinateTransform* tr = mMapRenderer->transformation( layer );
if ( tr )
{
s->ct = tr->clone();
}
}
s->xform = mMapRenderer->coordinateTransform();
mActiveDiagramLayers.insert( layer, *s );
return 1;
Expand Down

0 comments on commit 34f79cf

Please sign in to comment.