Skip to content
Permalink
Browse files

support datum transformation in composer (fixes #11874)

  • Loading branch information
jef-n committed Feb 11, 2015
1 parent f9ace43 commit f046d3fca27d7681be08cb287aa0eff2eb70fcf1
@@ -43,7 +43,9 @@
#include <QFontDialog>
#include <QMessageBox>

QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap ): QgsComposerItemBaseWidget( 0, composerMap ), mComposerMap( composerMap )
QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap )
: QgsComposerItemBaseWidget( 0, composerMap )
, mComposerMap( composerMap )
{
setupUi( this );

@@ -20,7 +20,6 @@
#include "qgscomposermapoverview.h"
#include "qgscomposition.h"
#include "qgscomposerutils.h"
#include "qgscoordinatetransform.h"
#include "qgslogger.h"
#include "qgsmaprenderer.h"
#include "qgsmaprenderercustompainterjob.h"
@@ -184,7 +183,6 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRectangle& extent, const
return;
}


// render
QgsMapRendererCustomPainterJob job( mapSettings( extent, size, dpi ), painter );
// Render the map in this thread. This is done because of problems
@@ -195,7 +193,7 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRectangle& extent, const

QgsMapSettings QgsComposerMap::mapSettings( const QgsRectangle& extent, const QSizeF& size, int dpi ) const
{
const QgsMapSettings& ms = mComposition->mapSettings();
const QgsMapSettings &ms = mComposition->mapSettings();

QgsMapSettings jobMapSettings;
jobMapSettings.setExtent( extent );
@@ -239,6 +237,8 @@ QgsMapSettings QgsComposerMap::mapSettings( const QgsRectangle& extent, const QS
jobMapSettings.setFlag( QgsMapSettings::DrawEditingInfo, false );
jobMapSettings.setFlag( QgsMapSettings::UseAdvancedEffects, mComposition->useAdvancedEffects() ); // respect the composition's useAdvancedEffects flag

jobMapSettings.datumTransformStore() = ms.datumTransformStore();

return jobMapSettings;
}

@@ -390,14 +390,14 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene

/**Returns pointer to map renderer of qgis map canvas*/
//! @deprecated since 2.4 - use mapSettings() instead. May return null if not initialized with QgsMapRenderer
Q_DECL_DEPRECATED QgsMapRenderer* mapRenderer() {return mMapRenderer;}
Q_DECL_DEPRECATED QgsMapRenderer* mapRenderer() { return mMapRenderer; }

//! Return setting of QGIS map canvas
//! @note added in 2.4
const QgsMapSettings& mapSettings() const { return mMapSettings; }

QgsComposition::PlotStyle plotStyle() const {return mPlotStyle;}
void setPlotStyle( const QgsComposition::PlotStyle style ) {mPlotStyle = style;}
QgsComposition::PlotStyle plotStyle() const { return mPlotStyle; }
void setPlotStyle( const QgsComposition::PlotStyle style ) { mPlotStyle = style; }

/**Returns the mm font size for a font that has point size set.
* Each item that sets a font should call this function before drawing text
@@ -37,7 +37,9 @@ const QgsCoordinateTransform* QgsCoordinateTransformCache::transform( const QStr
QList< QgsCoordinateTransform* >::const_iterator valIt = values.constBegin();
for ( ; valIt != values.constEnd(); ++valIt )
{
if ( *valIt && ( *valIt )->sourceDatumTransform() == srcDatumTransform && ( *valIt )->destinationDatumTransform() == destDatumTransform )
if ( *valIt &&
( *valIt )->sourceDatumTransform() == srcDatumTransform &&
( *valIt )->destinationDatumTransform() == destDatumTransform )
{
return *valIt;
}
@@ -22,7 +22,6 @@
QgsDatumTransformStore::QgsDatumTransformStore( const QgsCoordinateReferenceSystem& destCrs )
: mDestCRS( destCrs )
{

}

void QgsDatumTransformStore::clear()
@@ -68,7 +67,7 @@ const QgsCoordinateTransform* QgsDatumTransformStore::transformation( QgsMapLaye
}
else
{
return QgsCoordinateTransformCache::instance()->transform( srcAuthId, dstAuthId, -1, -1 );
return QgsCoordinateTransformCache::instance()->transform( srcAuthId, dstAuthId );
}
}

@@ -90,12 +89,12 @@ void QgsDatumTransformStore::readXML( const QDomNode& parentNode )
continue;
}

Entry lct;
lct.srcAuthId = layerCoordTransformElem.attribute( "srcAuthId" );
lct.destAuthId = layerCoordTransformElem.attribute( "destAuthId" );
lct.srcDatumTransform = layerCoordTransformElem.attribute( "srcDatumTransform", "-1" ).toInt();
lct.destDatumTransform = layerCoordTransformElem.attribute( "destDatumTransform", "-1" ).toInt();
mEntries.insert( layerId, lct );
addEntry( layerId,
layerCoordTransformElem.attribute( "srcAuthId" ),
layerCoordTransformElem.attribute( "destAuthId" ),
layerCoordTransformElem.attribute( "srcDatumTransform", "-1" ).toInt(),
layerCoordTransformElem.attribute( "destDatumTransform", "-1" ).toInt()
);
}
}
}
@@ -1111,7 +1111,7 @@ const QgsCoordinateTransform *QgsMapRenderer::transformation( const QgsMapLayer
|| ctIt->destAuthId == mDestCRS->authid()
)
{
return QgsCoordinateTransformCache::instance()->transform( layer->crs().authid(), mDestCRS->authid(), -1, -1 );
return QgsCoordinateTransformCache::instance()->transform( layer->crs().authid(), mDestCRS->authid() );
}
return QgsCoordinateTransformCache::instance()->transform( ctIt->srcAuthId, ctIt->destAuthId, ctIt->srcDatumTransform, ctIt->destDatumTransform );
}
@@ -337,16 +337,12 @@ double QgsMapSettings::scale() const
}





const QgsCoordinateTransform* QgsMapSettings::layerTransform( QgsMapLayer *layer ) const
{
return mDatumTransformStore.transformation( layer );
}



QgsRectangle QgsMapSettings::layerExtentToOutputExtent( QgsMapLayer* theLayer, QgsRectangle extent ) const
{
if ( hasCrsTransformEnabled() )

0 comments on commit f046d3f

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