Skip to content

Commit

Permalink
Merge pull request #6787 from pblottiere/bugfix_ellipse
Browse files Browse the repository at this point in the history
[server] Add project's context before rendering
  • Loading branch information
pblottiere authored Apr 16, 2018
2 parents d7fd14b + 2d340a0 commit 5e33d7d
Show file tree
Hide file tree
Showing 5 changed files with 546 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/core/qgsogcutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2191,7 +2191,10 @@ QDomElement QgsOgcUtils::expressionToOgcExpression( const QgsExpression &exp,
break;
}
default:
*errorMessage = QObject::tr( "Node type not supported in expression translation: %1" ).arg( node->nodeType() );
{
if ( errorMessage )
*errorMessage = QObject::tr( "Node type not supported in expression translation: %1" ).arg( node->nodeType() );
}
}
// got an error
return QDomElement();
Expand Down
5 changes: 5 additions & 0 deletions src/server/services/wms/qgswmsrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,11 @@ namespace QgsWms
{
mapSettings.setBackgroundColor( backgroundColor );
}

// add context from project (global variables, ...)
QgsExpressionContext context = mProject->createExpressionContext();
context << QgsExpressionContextUtils::mapSettingsScope( mapSettings );
mapSettings.setExpressionContext( context );
}

QDomDocument QgsRenderer::featureInfoDocument( QList<QgsMapLayer *> &layers, const QgsMapSettings &mapSettings,
Expand Down
21 changes: 20 additions & 1 deletion tests/src/python/test_qgsserver_wms_getmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,25 @@ def test_wms_getmap_basic(self):
r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetMap_Basic4")

def test_wms_getmap_context_rendering(self):
project = os.path.join(self.testdata_path, "test_project_render_context.qgs")
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(project),
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetMap",
"LAYERS": "points",
"STYLES": "",
"FORMAT": "image/png",
"BBOX": "-119.8,20.4,-82.4,49.2",
"HEIGHT": "500",
"WIDTH": "500",
"CRS": "EPSG:4326"
}.items())])

r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetMap_ContextRendering")

def test_wms_getmap_dpi(self):
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
Expand Down Expand Up @@ -947,7 +966,7 @@ def test_wms_getmap_sld(self):
self._img_diff_error(r, h, "WMS_GetMap_SLDRestored")

def test_wms_getmap_group(self):
"""A WMS shall render the requested layers by drawing the leftmost in the list
"""A WMS shall render the requested layers by drawing the leftmost in the list
bottommost, the next one over that, and so on."""

qs = "?" + "&".join(["%s=%s" % i for i in list({
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5e33d7d

Please sign in to comment.