Skip to content

Commit

Permalink
added spatial printing
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Reber committed Jan 21, 2014
1 parent 1952dbe commit a5b4927
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Expand Up @@ -13,7 +13,5 @@ index.xml
qgis-web-client.conf
*.swp

site/js/Customizations.js
site/js/GlobalOptions.js
.gitignore

13 changes: 13 additions & 0 deletions README
Expand Up @@ -15,6 +15,7 @@ Last Change : Thursday January 16, 2014
4.2. Configuration of search panels
4.3. Configuration of the theme switcher
4.4. Extending the interface
4.5. Configuration of spatial printing
5. URL Rewriting
6. Configuration of search python script
6.1. Configuration of mod_wsgi
Expand Down Expand Up @@ -466,6 +467,18 @@ The tags are also used in the search filter used in the theme switcher.
You can add buttons to implements additional functions (editing, advanced identify, etc.).
See the example in site/js/Customizations.js.

4.5. Configuration of spatial printing
======================================

It is possible to add a polygone-layer in QGIS, which is queried in the Web-Client for spatial related printing-information. You could e.g. add a layer with regional information as name of the region, phone number and other contact details of the responsible administration. To do this, follow-up these steps in QGIS:
1. The layer providing spatial related printing-information has to be named 'print'
2. The polygone-geometry field of the layer has to be named 'geometry'
2. Use the attribute-title of the layer in the print template as 'Item ID' (de: 'Elementkennung')
3. To hide the layer 'print', you could exclude it from the WMS-Capabilities (QGIS: project-settings->ows server-> WMS-Capabilities)
4. The layer has to be published in the WFS-Capabilities

Now the QGIS-client sends the spatial information (attribute-titles of the layer 'print') to the server and there the corresponding item will be filled in when generating a .pdf-document. For the spatial query, the center of the map is being used.


5. URL Rewriting
================
Expand Down
35 changes: 33 additions & 2 deletions site/js/QGISExtensions.js
Expand Up @@ -342,7 +342,7 @@ Ext.extend(QGIS.PrintProvider, GeoExt.data.PrintProvider, {
grid_interval = 10000000;
}

//if the var fixedPrintResolution of GlobalOptions.js is set, the print resolution will be this value
// if the var fixedPrintResolution of GlobalOptions.js is set, the print resolution will be this value
if (fixedPrintResolution != null && parseInt(fixedPrintResolution) > 0){
printResolution = fixedPrintResolution;
} else {
Expand All @@ -356,7 +356,37 @@ Ext.extend(QGIS.PrintProvider, GeoExt.data.PrintProvider, {
if (thematicLayer.params.SELECTION) {
printUrl += '&SELECTION='+encodeURIComponent(thematicLayer.params.SELECTION);
}
this.download(printUrl);

// makes spatial query from map to use the attributes in the print template (more in README chap 4.5)
var lonlat = printExtent.page.getPrintExtent(map).getCenterLonLat();
var mapCenter = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
var myfilter = new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Spatial.INTERSECTS,
value: mapCenter
});
Ext.getBody().mask(printLoadingString[lang], 'x-mask-loading');
var protocol = new OpenLayers.Protocol.WFS({
url: serverAndCGI + '/'+ wmsMapName,
featureType: 'print',
geometryName: 'geometry',
srsName: authid,
filter: myfilter,
readWithPOST: true
});

protocol.read({
callback: function(response) {
if(response.features.length > 0) {
attributes = response.features[0].attributes;
for (key in attributes){
printUrl += '&' + key + '=' + encodeURIComponent(attributes[key]);
}
}
this.download(printUrl);
},
scope: this
});

},
download: function(url) {
if (this.fireEvent("beforedownload", this, url) !== false) {
Expand All @@ -377,6 +407,7 @@ Ext.extend(QGIS.PrintProvider, GeoExt.data.PrintProvider, {
}
);
pdfWindow.show();
Ext.getBody().unmask();
}
this.fireEvent("print", this, url);
}
Expand Down
12 changes: 12 additions & 0 deletions site/js/Translations.js
Expand Up @@ -228,6 +228,18 @@ modePrintingString["uk"] = "Режим: друк. Обаріть ділянку
modePrintingString["hu"] = "Mód: nyomtatás. Mozgatható, forgatható a nyomtatási terület.";
modePrintingString["ro"] = "Mod: tipărire/print. Suprafața hărtii se poate mișca sau roti. Când ești gata apasă butonul 'Print'";

//indicating is waiting for print
var printLoadingString = new Array();
printLoadingString["en"] = "Printing initialised. Please wait...";
printLoadingString["es"] = "Printing initialised. Please wait..."; //FIXME
printLoadingString["de"] = "Der Druckauftrag ist erfolgt. Bitte haben sie etwas Geduld...";
printLoadingString["fr"] = "Printing initialised. Please wait..."; //FIXME
printLoadingString["it"] = "Printing initialised. Please wait..."; //FIXME
printLoadingString["pt_PT"] = "Printing initialised. Please wait..."; //FIXME
printLoadingString["uk"] = "Printing initialised. Please wait..."; //FIXME
printLoadingString["hu"] = "Printing initialised. Please wait..."; //FIXME
printLoadingString["ro"] = "Printing initialised. Please wait..."; //FIXME

/***********************
GUI stuff
***********************/
Expand Down

0 comments on commit a5b4927

Please sign in to comment.