Skip to content
Permalink
Browse files

Using external_wms for printing without adding layer to the project

  • Loading branch information...
uprel committed Jul 9, 2019
1 parent d0a0f57 commit f057291e8fbb79158c8e254d2ee58c127bd5e444
Showing with 42 additions and 7 deletions.
  1. +9 −2 client/site/js/QGISExtensions.js
  2. +33 −5 client/site/js/WebgisInit_functions.js
@@ -428,8 +428,11 @@ Ext.extend(QGIS.PrintProvider, GeoExt.data.PrintProvider, {
layers = layers.concat(thematicLayer.params.LAYERS.split(','));
}
var extra = getVisibleExtraLayersForPrint();
if(extra>'') {
layers.unshift(extra);
var extraDefinition = '';
if(extra.length>0) {
var extraNames = extra.map(function(item){return item.name;});
extraDefinition = extra.map(function(item){return item.definition;})[0]; //get only first one, ok?
layers.unshift(extraNames.join(','));
}

//add currently visible base layer for printing if exists in projects
@@ -463,6 +466,10 @@ Ext.extend(QGIS.PrintProvider, GeoExt.data.PrintProvider, {
printUrl += '&OPACITIES='+encodeURIComponent(thematicLayer.params.OPACITIES);
}

if (extraDefinition>'') {
printUrl += '&' + extraDefinition;
}

// add highlight
//var highlightParams = highlighter.printParams("map0");
//if (highlightParams != null) {
@@ -2768,18 +2768,46 @@ function home() {
//Eqwc.settings.useGisPortal ? window.location.href = Eqwc.settings.gisPortalRoot + "login?ru="+Eqwc.common.getProjectUrl() : window.location.href="/";
}

function getExternalWMSDefinition(layer) {

var layerName = layer.name;
var type = layer.type;
var def = JSON.parse(layer.definition);

if(type=='WMS' && (Eqwc.settings.qgisVersion && parseInt(Eqwc.settings.qgisVersion)>2)) {
var definition = {
[layerName+':url']: def.url,
[layerName+':format']: def.params.FORMAT,
[layerName+':crs']: projectData.crs,
[layerName+':layers']: def.params.LAYERS,
[layerName+':styles']: def.params.STYLES
};

return {name: 'EXTERNAL_WMS:'+layerName, definition: Ext.urlEncode(definition)};
} else {
return null;
}
}

function getVisibleExtraLayersForPrint() {
var ret = [];
var extraLayers = projectData.extraLayers();
if(extraLayers==null) {
return '';
}
for (var i=0; i<extraLayers.length; i++) {
var extra = extraLayers[i].title;
var lay = geoExtMap.map.getLayersByName(extra)[0];
if (lay && lay.visibility && wmsLoader.layerTitleNameMapping[extra]) {
ret.push(wmsLoader.layerTitleNameMapping[extra]);
var extra = extraLayers[i];
var lay = geoExtMap.map.getLayersByName(extra.title)[0];
if (lay && lay.visibility) {
if(wmsLoader.layerTitleNameMapping[extra.title]) {
ret.push({name: wmsLoader.layerTitleNameMapping[extra.title], definition: ''});
} else {
var externalWms = getExternalWMSDefinition(extra);
if(externalWms) {
ret.push({name: externalWms.name, definition: externalWms.definition});
}
}
}
}
return ret.join(',');
return ret;
}

0 comments on commit f057291

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