dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #10172
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2796: (GIS) Image export now supports overlays.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2796 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-02-01 14:39:49 +0100
message:
(GIS) Image export now supports overlays.
modified:
dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/export/SVGDocument.java
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/export/SVGDocument.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/export/SVGDocument.java 2011-01-10 14:35:40 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/export/SVGDocument.java 2011-02-01 13:27:46 +0000
@@ -82,7 +82,7 @@
String title_ = "<g id=\"title\" style=\"display: block; visibility: visible;\"><text id=\"title\" x=\"30\" y=\"20\" font-size=\"18\" font-weight=\"bold\"><tspan>"
+ StringEscapeUtils.escapeXml( this.title ) + "</tspan></text></g>";
- if ( this.layer != 3 ) // Polygon or point layer
+ if ( this.layer == 1 || this.layer == 2 ) // Polygon or point layer
{
String indicator_ = "<g id=\"indicator\" style=\"display: block; visibility: visible;\"><text id=\"indicator\" x=\"30\" y=\"40\" font-size=\"12\"><tspan>"
+ StringEscapeUtils.escapeXml( this.indicator ) + "</tspan></text></g>";
@@ -132,6 +132,11 @@
svg_ = svg_.replaceFirst( "</svg>", this.getLegendScript2( 30, (145 + 15 * this.imageLegendRows) ) + "</svg>" );
}
}
+
+ else
+ {
+ svg_ = svg_.replaceFirst( "</svg>", title_ + "</svg>" );
+ }
return new StringBuffer( svg_ );
}
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js 2011-02-01 12:05:49 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js 2011-02-01 13:27:46 +0000
@@ -330,10 +330,48 @@
}
}
return layers;
+ },
+
+ getLayersByType: function(type) {
+ var layers = [];
+ for (var i = 0; i < G.vars.map.layers.length; i++) {
+ if (G.vars.map.layers[i].layerType == type) {
+ layers.push(G.vars.map.layers[i]);
+ }
+ }
+ return layers;
+ },
+
+ getVisibleLayers: function(layers) {
+ var vLayers = [];
+ for (var i = 0; i < layers.length; i++) {
+ if (layers[i].visibility) {
+ vLayers.push(layers[i]);
+ }
+ }
+ return vLayers;
+ },
+
+ mergeSvg: function(str, ext) {
+ if (ext.length) {
+ str = str || '<svg>';
+ for (var i = 0; i < ext.length; i++) {
+ str = str.replace('</svg>');
+ ext[i] = ext[i].substring(ext[i].indexOf('>')+1);
+ str += ext[i];
+ }
+ }
+ return str;
+ },
+
+ getOverlaysSvg: function(overlays) {
+ if (overlays.length) {
+ for (var i = 0; i < overlays.length; i++) {
+ overlays[i] = document.getElementById(overlays[i].svgId).parentNode.innerHTML;
+ }
+ }
+ return overlays;
}
-
- //extendSvg: function(src, ext) {
-
};
G.vars = {
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js 2011-02-01 12:05:49 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js 2011-02-01 13:27:46 +0000
@@ -615,7 +615,7 @@
layout: 'fit',
closeAction: 'hide',
width: G.conf.window_width,
- height: 220,
+ height: 194,
items: [
{
xtype: 'form',
@@ -692,7 +692,7 @@
iconCls: 'icon-export',
text: G.i18n.export_,
handler: function() {
- var values, svgElement, svg;
+ var values, svg;
if (polygonLayer.visibility && pointLayer.visibility) {
if (choropleth.formValidation.validateForm()) {
@@ -710,12 +710,9 @@
document.getElementById('indicatorField2').value = values.mapValueTypeValue;
document.getElementById('legendsField2').value = G.util.getLegendsJSON.call(symbol);
- svgElement = document.getElementById(polygonLayer.svgId);
- var str1 = svgElement.parentNode.innerHTML;
- str1 = svgElement.parentNode.innerHTML.replace('</svg>');
+ var str1 = document.getElementById(polygonLayer.svgId).parentNode.innerHTML;
var str2 = document.getElementById(pointLayer.svgId).parentNode.innerHTML;
- str2 = str2.substring(str2.indexOf('>')+1);
- svg = str1 + str2;
+ svg = G.util.mergeSvg(str1, [str2]);
}
else {
Ext.message.msg(false, 'Point layer not rendered');
@@ -734,8 +731,7 @@
document.getElementById('periodField').value = values.dateValue;
document.getElementById('indicatorField').value = values.mapValueTypeValue;
document.getElementById('legendsField').value = G.util.getLegendsJSON.call(choropleth);
- svgElement = document.getElementById(polygonLayer.svgId);
- svg = svgElement.parentNode.innerHTML;
+ svg = document.getElementById(polygonLayer.svgId).parentNode.innerHTML;
}
else {
Ext.message.msg(false, 'Polygon layer not rendered');
@@ -749,17 +745,27 @@
document.getElementById('periodField').value = values.dateValue;
document.getElementById('indicatorField').value = values.mapValueTypeValue;
document.getElementById('legendsField').value = G.util.getLegendsJSON.call(symbol);
- svgElement = document.getElementById(pointLayer.svgId);
- svg = svgElement.parentNode.innerHTML;
+ svg = document.getElementById(pointLayer.svgId).parentNode.innerHTML;
}
else {
Ext.message.msg(false, 'Point layer not rendered');
return;
}
}
-
+ else {
+ document.getElementById('layerField').value = 0;
+ }
+
+ var overlays = G.util.getVisibleLayers(G.util.getLayersByType(G.conf.map_layer_type_overlay));
+ svg = G.util.mergeSvg(svg, G.util.getOverlaysSvg(overlays));
+
+ if (!svg) {
+ Ext.message.msg(false, 'No layers to export');
+ return;
+ }
+
var title = Ext.getCmp('exportimagetitle_tf').getValue();
-
+
if (!title) {
Ext.message.msg(false, G.i18n.form_is_not_complete);
}
@@ -768,7 +774,6 @@
exportForm.action = '../exportImage.action';
document.getElementById('titleField').value = title;
- document.getElementById('viewBoxField').value = svgElement.getAttribute('viewBox');
document.getElementById('svgField').value = svg;
document.getElementById('widthField').value = Ext.getCmp('exportimagewidth_cb').getValue();
document.getElementById('heightField').value = Ext.getCmp('exportimageheight_cb').getValue();
@@ -2457,7 +2462,7 @@
for (var i = 0, j = 2; i < G.vars.map.layers.length; i++) {
if (G.vars.map.layers[i].layerType == G.conf.map_layer_type_overlay) {
- G.vars.map.layers[i].svgId = svg[j++];
+ G.vars.map.layers[i].svgId = svg[j++].id;
}
}