mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Use defined datum transform also in server and fix datum transform related bugs
This commit is contained in:
parent
aec1d5e711
commit
1c47011fbb
@ -1251,7 +1251,9 @@ const QgsCoordinateTransform* QgsMapRenderer::tr( const QgsMapLayer *layer ) con
|
||||
}
|
||||
|
||||
QHash< QString, QgsLayerCoordinateTransform >::const_iterator ctIt = mLayerCoordinateTransformInfo.find( layer->id() );
|
||||
if ( ctIt != mLayerCoordinateTransformInfo.constEnd() )
|
||||
if ( ctIt != mLayerCoordinateTransformInfo.constEnd()
|
||||
&& ctIt->srcAuthId == layer->crs().authid()
|
||||
&& ctIt->destAuthId == mDestCRS->authid() )
|
||||
{
|
||||
return QgsCoordinateTransformCache::instance()->transform( ctIt->srcAuthId, ctIt->destAuthId, ctIt->srcDatumTransform, ctIt->destDatumTransform );
|
||||
}
|
||||
@ -1262,7 +1264,10 @@ const QgsCoordinateTransform* QgsMapRenderer::tr( const QgsMapLayer *layer ) con
|
||||
|
||||
//still not present? get coordinate transformation with -1/-1 datum transform as default
|
||||
ctIt = mLayerCoordinateTransformInfo.find( layer->id() );
|
||||
if ( ctIt == mLayerCoordinateTransformInfo.constEnd() )
|
||||
if ( ctIt == mLayerCoordinateTransformInfo.constEnd()
|
||||
|| ctIt->srcAuthId == layer->crs().authid()
|
||||
|| ctIt->destAuthId == mDestCRS->authid()
|
||||
)
|
||||
{
|
||||
return QgsCoordinateTransformCache::instance()->transform( layer->crs().authid(), mDestCRS->authid(), -1, -1 );
|
||||
}
|
||||
@ -1353,4 +1358,9 @@ void QgsMapRenderer::addLayerCoordinateTransform( const QString& layerId, const
|
||||
mLayerCoordinateTransformInfo.insert( layerId, lt );
|
||||
}
|
||||
|
||||
void QgsMapRenderer::clearLayerCoordinateTransforms()
|
||||
{
|
||||
mLayerCoordinateTransformInfo.clear();
|
||||
}
|
||||
|
||||
bool QgsMapRenderer::mDrawing = false;
|
||||
|
@ -296,6 +296,7 @@ class CORE_EXPORT QgsMapRenderer : public QObject
|
||||
static QgsMapRenderer::BlendMode getBlendModeEnum( const QPainter::CompositionMode blendMode );
|
||||
|
||||
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;
|
||||
|
||||
|
@ -599,3 +599,8 @@ void QgsConfigParser::serviceCapabilities( QDomElement& parentElement, QDomDocum
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QList< QPair< QString, QgsLayerCoordinateTransform > > QgsConfigParser::layerCoordinateTransforms() const
|
||||
{
|
||||
return QList< QPair< QString, QgsLayerCoordinateTransform > >();
|
||||
}
|
||||
|
@ -164,6 +164,8 @@ class QgsConfigParser
|
||||
/**Applies configuration specific label settings*/
|
||||
virtual void loadLabelSettings( QgsLabelingEngineInterface* lbl ) { Q_UNUSED( lbl ); }
|
||||
|
||||
virtual QList< QPair< QString, QgsLayerCoordinateTransform > > layerCoordinateTransforms() const;
|
||||
|
||||
protected:
|
||||
/**Parser to forward not resolved requests (e.g. SLD parser based on user request might have a fallback parser with admin configuration)*/
|
||||
QgsConfigParser* mFallbackParser;
|
||||
|
@ -3661,7 +3661,7 @@ void QgsProjectParser::loadLabelSettings( QgsLabelingEngineInterface* lbl )
|
||||
{
|
||||
pal->setShowingAllLabels( showAllLabelsElem.text().compare( "true", Qt::CaseInsensitive ) == 0 );
|
||||
}
|
||||
|
||||
|
||||
//mShowingPartialsLabels
|
||||
QDomElement showPartialsLabelsElem = palElem.firstChildElement( "ShowingPartialsLabels" );
|
||||
if ( !showPartialsLabelsElem.isNull() )
|
||||
@ -3670,3 +3670,30 @@ void QgsProjectParser::loadLabelSettings( QgsLabelingEngineInterface* lbl )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QList< QPair< QString, QgsLayerCoordinateTransform > > QgsProjectParser::layerCoordinateTransforms() const
|
||||
{
|
||||
QList< QPair< QString, QgsLayerCoordinateTransform > > layerTransformList;
|
||||
|
||||
QDomElement coordTransformInfoElem = mXMLDoc->documentElement().firstChildElement( "mapcanvas" ).firstChildElement( "layer_coordinate_transform_info" );
|
||||
if ( coordTransformInfoElem.isNull() )
|
||||
{
|
||||
return layerTransformList;
|
||||
}
|
||||
|
||||
QDomNodeList layerTransformNodeList = coordTransformInfoElem.elementsByTagName( "layer_coordinate_transform" );
|
||||
for ( int i = 0; i < layerTransformNodeList.size(); ++i )
|
||||
{
|
||||
QPair< QString, QgsLayerCoordinateTransform > layerEntry;
|
||||
QDomElement layerTransformElem = layerTransformNodeList.at( i ).toElement();
|
||||
layerEntry.first = layerTransformElem.attribute( "layerid" );
|
||||
QgsLayerCoordinateTransform t;
|
||||
t.srcAuthId = layerTransformElem.attribute( "srcAuthId" );
|
||||
t.destAuthId = layerTransformElem.attribute( "destAuthId" );
|
||||
t.srcDatumTransform = layerTransformElem.attribute( "srcDatumTransform", "-1" ).toInt();
|
||||
t.destDatumTransform = layerTransformElem.attribute( "destDatumTransform", "-1" ).toInt();
|
||||
layerEntry.second = t;
|
||||
layerTransformList.push_back( layerEntry );
|
||||
}
|
||||
return layerTransformList;
|
||||
}
|
||||
|
@ -140,6 +140,8 @@ class QgsProjectParser: public QgsConfigParser
|
||||
|
||||
void loadLabelSettings( QgsLabelingEngineInterface* lbl );
|
||||
|
||||
QList< QPair< QString, QgsLayerCoordinateTransform > > layerCoordinateTransforms() const;
|
||||
|
||||
private:
|
||||
|
||||
//forbidden
|
||||
|
@ -1136,6 +1136,7 @@ int QgsWMSServer::configureMapRender( const QPaintDevice* paintDevice ) const
|
||||
return 1; //paint device is needed for height, width, dpi
|
||||
}
|
||||
|
||||
mMapRenderer->clearLayerCoordinateTransforms();
|
||||
mMapRenderer->setOutputSize( QSize( paintDevice->width(), paintDevice->height() ), paintDevice->logicalDpiX() );
|
||||
|
||||
//map extent
|
||||
@ -1193,6 +1194,18 @@ int QgsWMSServer::configureMapRender( const QPaintDevice* paintDevice ) const
|
||||
mMapRenderer->setDestinationCrs( outputCRS );
|
||||
mMapRenderer->setProjectionsEnabled( true );
|
||||
mapUnits = outputCRS.mapUnits();
|
||||
|
||||
//read layer coordinate transforms from project file (e.g. ct with special datum shift)
|
||||
if ( mConfigParser )
|
||||
{
|
||||
QList< QPair< QString, QgsLayerCoordinateTransform > > lt = mConfigParser->layerCoordinateTransforms();
|
||||
QList< QPair< QString, QgsLayerCoordinateTransform > >::const_iterator ltIt = lt.constBegin();
|
||||
for ( ; ltIt != lt.constEnd(); ++ltIt )
|
||||
{
|
||||
QgsLayerCoordinateTransform t = ltIt->second;
|
||||
mMapRenderer->addLayerCoordinateTransform( ltIt->first, t.srcAuthId, t.destAuthId, t.srcDatumTransform, t.destDatumTransform );
|
||||
}
|
||||
}
|
||||
}
|
||||
mMapRenderer->setMapUnits( mapUnits );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user