Skip to content
Permalink
Browse files

Remove getMap method with hitTest

  • Loading branch information
pblottiere committed Apr 9, 2019
1 parent ebccfb6 commit 9b298ca753209c6df9206bb7342bcdd758d1e164
Showing with 28 additions and 43 deletions.
  1. +22 −33 src/server/services/wms/qgswmsrenderer.cpp
  2. +6 −10 src/server/services/wms/qgswmsrenderer.h
@@ -749,13 +749,7 @@ namespace QgsWms
return true;
}

QImage *QgsRenderer::getMap( HitTest *hitTest )
{
QgsMapSettings mapSettings;
return getMap( mapSettings, hitTest );
}

QImage *QgsRenderer::getMap( QgsMapSettings &mapSettings, HitTest *hitTest )
QImage *QgsRenderer::getMap()
{
// check size
checkMaximumWidthHeight();
@@ -766,6 +760,8 @@ namespace QgsWms

// configure layers
QList<QgsMapLayer *> layers = mContext.layersToRender();

QgsMapSettings mapSettings;
configureLayers( layers, &mapSettings );

// create the output image and the painter
@@ -779,7 +775,7 @@ namespace QgsWms
mapSettings.setLayers( layers );

// rendering step for layers
painter.reset( layersRendering( mapSettings, *image, hitTest ) );
painter.reset( layersRendering( mapSettings, *image ) );

// rendering step for annotations
annotationsRendering( painter.get() );
@@ -2710,38 +2706,31 @@ namespace QgsWms
mTemporaryLayers.clear();
}

QPainter *QgsRenderer::layersRendering( const QgsMapSettings &mapSettings, QImage &image, HitTest *hitTest ) const
QPainter *QgsRenderer::layersRendering( const QgsMapSettings &mapSettings, QImage &image ) const
{
QPainter *painter = nullptr;
if ( hitTest )
{
runHitTest( mapSettings, *hitTest );
painter = new QPainter();
}
else
{
QgsFeatureFilterProviderGroup filters;
filters.addProvider( &mFeatureFilter );

QgsFeatureFilterProviderGroup filters;
filters.addProvider( &mFeatureFilter );
#ifdef HAVE_SERVER_PYTHON_PLUGINS
mContext.accessControl()->resolveFilterFeatures( mapSettings.layers() );
filters.addProvider( mContext.accessControl() );
mContext.accessControl()->resolveFilterFeatures( mapSettings.layers() );
filters.addProvider( mContext.accessControl() );
#endif
QgsMapRendererJobProxy renderJob( mContext.settings().parallelRendering(), mContext.settings().maxThreads(), &filters );
renderJob.render( mapSettings, &image );
painter = renderJob.takePainter();
QgsMapRendererJobProxy renderJob( mContext.settings().parallelRendering(), mContext.settings().maxThreads(), &filters );
renderJob.render( mapSettings, &image );
painter = renderJob.takePainter();

if ( !renderJob.errors().isEmpty() )
if ( !renderJob.errors().isEmpty() )
{
QString layerWMSName;
QString firstErrorLayerId = renderJob.errors().at( 0 ).layerID;
QgsMapLayer *errorLayer = mProject->mapLayer( firstErrorLayerId );
if ( errorLayer )
{
QString layerWMSName;
QString firstErrorLayerId = renderJob.errors().at( 0 ).layerID;
QgsMapLayer *errorLayer = mProject->mapLayer( firstErrorLayerId );
if ( errorLayer )
{
layerWMSName = mContext.layerNickname( *errorLayer );
}

throw QgsException( QStringLiteral( "Map rendering error in layer '%1'" ).arg( layerWMSName ) );
layerWMSName = mContext.layerNickname( *errorLayer );
}

throw QgsException( QStringLiteral( "Map rendering error in layer '%1'" ).arg( layerWMSName ) );
}

return painter;
@@ -104,15 +104,11 @@ namespace QgsWms
HitTest symbols();

/**
* Returns the map as an image (or NULLPTR in case of error). The caller takes ownership
of the image object). If an instance to existing hit test structure is passed, instead of rendering
it will fill the structure with symbols that would be used for rendering */
QImage *getMap( HitTest *hitTest = nullptr );

/**
* Identical to getMap( HitTest* hitTest ) and updates the map settings actually used.
\since QGIS 3.0 */
QImage *getMap( QgsMapSettings &mapSettings, HitTest *hitTest = nullptr );
* Returns the map as an image (or NULLPTR in case of error). The caller
* takes ownership of the image object).
* \since QGIS 3.8
*/
QImage *getMap();

/**
* Returns the map as DXF data
@@ -141,7 +137,7 @@ namespace QgsWms
QList<QgsMapLayer *> externalLayers( const QList<QgsWmsParametersExternalLayer> &params );

// Rendering step for layers
QPainter *layersRendering( const QgsMapSettings &mapSettings, QImage &image, HitTest *hitTest = nullptr ) const;
QPainter *layersRendering( const QgsMapSettings &mapSettings, QImage &image ) const;

// Rendering step for annotations
void annotationsRendering( QPainter *painter ) const;

0 comments on commit 9b298ca

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