Skip to content

Commit

Permalink
Remove getMap method with hitTest
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Apr 9, 2019
1 parent ebccfb6 commit 9b298ca
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 43 deletions.
55 changes: 22 additions & 33 deletions src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -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();
Expand All @@ -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
Expand All @@ -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() );
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 6 additions & 10 deletions src/server/services/wms/qgswmsrenderer.h
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9b298ca

Please sign in to comment.