dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #07774
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2283: (GIS) Improved code.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2283 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-09-30 12:11:03 +0200
message:
(GIS) Improved code.
modified:
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/util.js
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.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/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 2010-09-29 12:26:39 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js 2010-09-30 10:09:26 +0000
@@ -54,6 +54,7 @@
MAP = new OpenLayers.Map({controls:[new OpenLayers.Control.Navigation(),new OpenLayers.Control.ArgParser(),new OpenLayers.Control.Attribution()]});
MASK = new Ext.LoadMask(Ext.getBody(),{msg:i18n_loading,msgCls:'x-mask-loading2'});
+ PARAMETER = GLOBALS.util.getUrlParam('view') ? GLOBALS.util.getUrlParam('view') : 0;
/* Base layers */
function addBaseLayersToMap() {
@@ -90,14 +91,8 @@
}
});
}
-
addBaseLayersToMap();
- /* Get map view parameter and apply to global variable */
- if (getUrlParam('view')) {
- PARAMETER = getUrlParam('view');
- }
-
Ext.Ajax.request({
url: path_mapping + 'getBaseCoordinate' + type,
method: 'GET',
@@ -108,7 +103,7 @@
Ext.Ajax.request({
url: path_mapping + 'getMapView' + type,
method: 'GET',
- params: { id: PARAMETER || 0 },
+ params: {id: PARAMETER},
success: function(r) {
var mst = Ext.util.JSON.decode(r.responseText).mapView[0].mapSourceType;
var mdt = Ext.util.JSON.decode(r.responseText).mapView[0].mapDateType;
@@ -125,7 +120,7 @@
Ext.Ajax.request({
url: path_mapping + 'setMapUserSettings' + type,
method: 'POST',
- params: { mapSourceType: MAPSOURCE, mapDateType: MAPDATETYPE },
+ params: {mapSourceType: MAPSOURCE, mapDateType: MAPDATETYPE},
success: function() {
/* Section: mapview */
@@ -215,7 +210,7 @@
}
}
- if (validateInputNameLength(vn) == false) {
+ if (GLOBALS.util.validateInputNameLength(vn) == false) {
Ext.message.msg(false, i18n_map_view_name_cannot_be_longer_than_25_characters );
return;
}
@@ -491,7 +486,7 @@
lcb = Ext.getCmp('maplegendtype_cb').getValue() == map_legend_type_automatic ? true : Ext.getCmp('maplegendset_cb').getValue() ? true : false;
}
else if (ACTIVEPANEL == thematicMap2) {
- Ext.message.msg(false,'Please use the <span class="x-msg-hl">polygon layer</span> for printing');
+ Ext.message.msg(false,'Please use <span class="x-msg-hl">polygon layer</span> for printing');
return;
}
else {
@@ -532,7 +527,7 @@
document.getElementById('includeLegendsField').value = includeLegend;
document.getElementById('periodField').value = period;
document.getElementById('indicatorField').value = vcb;
- document.getElementById('legendsField').value = getLegendsJSON();
+ document.getElementById('legendsField').value = GLOBALS.util.getLegendsJSON();
exportForm.submit();
}
@@ -625,7 +620,7 @@
document.getElementById('includeValuesField').value = includeValues;
document.getElementById('periodField').value = period;
document.getElementById('indicatorField').value = indicator;
- document.getElementById('legendsField').value = getLegendsJSON();
+ document.getElementById('legendsField').value = GLOBALS.util.getLegendsJSON();
document.getElementById('dataValuesField').value = EXPORTVALUES;
exportForm.submit();
@@ -678,7 +673,7 @@
return;
}
- if (!validateInputNameLength(mln)) {
+ if (!GLOBALS.util.validateInputNameLength(mln)) {
Ext.message.msg(false, i18n_name_can_not_longer_than_25 );
return;
}
@@ -768,7 +763,7 @@
{ html: '<div class="window-field-label-first">'+i18n_display_name+'</div>' },
new Ext.form.TextField({id:'predefinedmaplegendsetname_tf',isFormField:true,hideLabel:true,emptyText:emptytext,width:combo_width}),
{ html: '<div class="window-field-label">'+i18n_legends+'</div>' },
- new Ext.ux.Multiselect({id:'predefinednewmaplegend_ms',isFormField:true,hideLabel:true,dataFields:['id','name','startValue','endValue','color','displayString'],valueField:'id',displayField:'displayString',width:multiselect_width,height:getMultiSelectHeight(),store:predefinedMapLegendStore}),
+ new Ext.ux.Multiselect({id:'predefinednewmaplegend_ms',isFormField:true,hideLabel:true,dataFields:['id','name','startValue','endValue','color','displayString'],valueField:'id',displayField:'displayString',width:multiselect_width,height:GLOBALS.util.getMultiSelectHeight(),store:predefinedMapLegendStore}),
{
xtype: 'button',
id: 'newpredefinedmaplegendset_b',
@@ -934,7 +929,7 @@
}
}),
{ html: '<div class="window-field-label">'+i18n_indicator+'</div>' },
- new Ext.ux.Multiselect({id:'predefinedmaplegendsetindicator_ms',isFormField:true,hideLabel:true,dataFields:['id','name','shortName'],valueField:'id',displayField:'shortName',width:multiselect_width,height:getMultiSelectHeight(),store:predefinedMapLegendSetIndicatorStore}),
+ new Ext.ux.Multiselect({id:'predefinedmaplegendsetindicator_ms',isFormField:true,hideLabel:true,dataFields:['id','name','shortName'],valueField:'id',displayField:'shortName',width:multiselect_width,height:GLOBALS.util.getMultiSelectHeight(),store:predefinedMapLegendSetIndicatorStore}),
{
xtype: 'button',
id: 'assignpredefinedmaplegendsetindicator_b',
@@ -1036,7 +1031,7 @@
}
}),
{ html: '<div class="window-field-label">'+i18n_dataelement+'</div>' },
- new Ext.ux.Multiselect({id:'predefinedmaplegendsetdataelement_ms',isFormField:true,hideLabel:true,dataFields:['id','name','shortName'],valueField:'id',displayField:'shortName',width:multiselect_width,height:getMultiSelectHeight(),store:predefinedMapLegendSetDataElementStore}),
+ new Ext.ux.Multiselect({id:'predefinedmaplegendsetdataelement_ms',isFormField:true,hideLabel:true,dataFields:['id','name','shortName'],valueField:'id',displayField:'shortName',width:multiselect_width,height:GLOBALS.util.getMultiSelectHeight(),store:predefinedMapLegendSetDataElementStore}),
{
xtype: 'button',
id: 'assignpredefinedmaplegendsetdataelement_b',
@@ -1112,16 +1107,16 @@
w.setHeight(151);
}
else if (tab.id == 'predefinedmaplegendset2') {
- w.setHeight(getMultiSelectHeight() + 180);
+ w.setHeight(GLOBALS.util.getMultiSelectHeight() + 180);
}
else if (tab.id == 'predefinedmaplegendset3') {
w.setHeight(151);
}
else if (tab.id == 'predefinedmaplegendset4') {
- w.setHeight(getMultiSelectHeight() + 180);
+ w.setHeight(GLOBALS.util.getMultiSelectHeight() + 180);
}
else if (tab.id == 'predefinedmaplegendset5') {
- w.setHeight(getMultiSelectHeight() + 180);
+ w.setHeight(GLOBALS.util.getMultiSelectHeight() + 180);
}
}
},
@@ -1325,7 +1320,7 @@
var keys = [];
var data = [];
- var nameList = getKeys(file.features[0].properties);
+ var nameList = GLOBALS.util.getKeys(file.features[0].properties);
for (var i = 0; i < nameList.length; i++) {
data.push(new Array(nameList[i]));
}
@@ -1473,7 +1468,7 @@
var file = Ext.util.JSON.decode(r.responseText);
var keys = [];
- var nameList = getKeys(file.features[0].properties);
+ var nameList = GLOBALS.util.getKeys(file.features[0].properties);
for (var i = 0; i < nameList.length; i++) {
data.push(new Array(nameList[i]));
}
@@ -1527,7 +1522,7 @@
return;
}
- if (validateInputNameLength(nn) == false) {
+ if (GLOBALS.util.validateInputNameLength(nn) == false) {
Ext.message.msg(false, '<span class="x-msg-hl">' + i18n_map + ' ' + i18n_name_can_not_longer_than_25 + '</span>');
return;
}
@@ -1627,7 +1622,7 @@
return;
}
- if (validateInputNameLength(en) == false) {
+ if (GLOBALS.util.validateInputNameLength(en) == false) {
Ext.message.msg(false, i18n_name_can_not_longer_than_25 );
return;
}
@@ -1750,7 +1745,7 @@
var keys = [];
var data = [];
- var nameList = getKeys(file.features[0].properties);
+ var nameList = GLOBALS.util.getKeys(file.features[0].properties);
for (var i = 0; i < nameList.length; i++) {
data.push(new Array(nameList[i]));
}
@@ -1769,7 +1764,7 @@
var keys = [];
var data = [];
- var nameList = getKeys(file.features[0].properties);
+ var nameList = GLOBALS.util.getKeys(file.features[0].properties);
for (var i = 0; i < nameList.length; i++) {
data.push(new Array(nameList[i]));
}
@@ -2098,7 +2093,7 @@
return;
}
- if (validateInputNameLength(mln) == false) {
+ if (GLOBALS.util.validateInputNameLength(mln) == false) {
Ext.message.msg(false, i18n_overlay_name_cannot_be_longer_than_25_characters );
return;
}
@@ -2309,7 +2304,7 @@
return;
}
- if (validateInputNameLength(mlbn) == false) {
+ if (GLOBALS.util.validateInputNameLength(mlbn) == false) {
Ext.message.msg(false, i18n_baselayer_name_cannot_be_longer_than_25_characters );
return;
}
@@ -2963,7 +2958,7 @@
layout: 'fit',
defaults: {layout: 'fit', bodyStyle:'padding:8px; border:0px'},
width: 250,
- height: getMultiSelectHeight() + 145,
+ height: GLOBALS.util.getMultiSelectHeight() + 145,
items: [
{
xtype: 'panel',
@@ -2999,7 +2994,7 @@
{
xtype: 'grid',
id: 'featuregrid_gp',
- height: getMultiSelectHeight(),
+ height: GLOBALS.util.getMultiSelectHeight(),
store: featureStore,
cm: new Ext.grid.ColumnModel({
columns: [{id: 'name', header: 'Features', dataIndex: 'name', width: 250}]
@@ -3087,14 +3082,14 @@
if (layer.features.length > 0) {
if (layer.name == 'Polygon layer') {
if (ACTIVEPANEL == thematicMap) {
- toggleFeatureLabelsPolygons(layer);
+ GLOBALS.util.toggleFeatureLabelsPolygons(layer);
}
else {
- toggleFeatureLabelsAssignment(true, layer);
+ GLOBALS.util.toggleFeatureLabelsAssignment(true, layer);
}
}
else if (layer.name == 'Point layer') {
- toggleFeatureLabelsPoints(layer);
+ GLOBALS.util.toggleFeatureLabelsPoints(layer);
}
}
else {
@@ -3858,7 +3853,7 @@
// valueField: 'id',
// displayField: 'name',
// width: multiselect_width,
- // height: getMultiSelectHeight(),
+ // height: GLOBALS.util.getMultiSelectHeight(),
// store: periodTimeseriesStore
// },
// { html: '<div class="window-field-label">Window width</div>' },
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/util.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/util.js 2010-09-28 22:06:26 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/util.js 2010-09-30 10:09:26 +0000
@@ -1,210 +1,216 @@
-/* Detect mapview parameter in URL */
-function getUrlParam(strParamName) {
- var output = '';
- var strHref = window.location.href;
- if (strHref.indexOf('?') > -1 ) {
- var strQueryString = strHref.substr(strHref.indexOf('?')).toLowerCase();
- var aQueryString = strQueryString.split('&');
- for (var iParam = 0; iParam < aQueryString.length; iParam++) {
- if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + '=') > -1) {
- var aParam = aQueryString[iParam].split('=');
- output =aParam[1];
- break;
- }
- }
- }
- return unescape(output);
-}
-
-/* Get all properties in an object */
-function getKeys(obj) {
- var temp = [];
- for (var k in obj) {
- if (obj.hasOwnProperty(k)) {
- temp.push(k);
- }
- }
- return temp;
-}
-
-/* Input validation */
-function validateInputNameLength(name) {
- return (name.length <= 25);
-}
-
-/* Decide multiselect height based on screen resolution */
-function getMultiSelectHeight() {
- var h = screen.height;
- return h <= 800 ? 220 :
- h <= 1050 ? 310 :
- h <= 1200 ? 470 : 900;
-}
-
-/* Make map view numbers numeric */
-function getNumericMapView(mapView) {
- mapView.id = parseFloat(mapView.id);
- mapView.indicatorGroupId = parseFloat(mapView.indicatorGroupId);
- mapView.indicatorId = parseFloat(mapView.indicatorId);
- mapView.periodId = parseFloat(mapView.periodId);
- mapView.method = parseFloat(mapView.method);
- mapView.classes = parseFloat(mapView.classes);
- mapView.mapLegendSetId = parseFloat(mapView.mapLegendSetId);
- mapView.longitude = parseFloat(mapView.longitude);
- mapView.latitude = parseFloat(mapView.latitude);
- mapView.zoom = parseFloat(mapView.zoom);
- return mapView;
-}
-
-/* Get number of decimals */
-function getNumberOfDecimals(x,dec_sep) {
- var tmp = new String();
- tmp = x;
- return tmp.indexOf(dec_sep) > -1 ? tmp.length-tmp.indexOf(dec_sep) - 1 : 0;
-}
-
-/* Toggle feature labels */
-function getActivatedOpenLayersStyleMap() {
- return new OpenLayers.StyleMap({
- 'default' : new OpenLayers.Style(
- OpenLayers.Util.applyDefaults({
- 'fillOpacity': 1,
- 'strokeColor': '#222222',
- 'strokeWidth': 1,
- 'label': '${labelString}',
- 'fontFamily': 'arial,lucida sans unicode',
- 'fontWeight': 'bold',
- 'fontSize': 14
- },
- OpenLayers.Feature.Vector.style['default'])
- ),
- 'select': new OpenLayers.Style({
- 'strokeColor': '#000000',
- 'strokeWidth': 2,
- 'cursor': 'pointer'
- })
- });
-}
-
-function getDeactivatedOpenLayersStyleMap() {
- return new OpenLayers.StyleMap({
- 'default': new OpenLayers.Style(
- OpenLayers.Util.applyDefaults({
- 'fillOpacity': 1,
- 'strokeColor': '#222222',
- 'strokeWidth': 1
- },
- OpenLayers.Feature.Vector.style['default'])
- ),
- 'select': new OpenLayers.Style({
- 'strokeColor': '#000000',
- 'strokeWidth': 2,
- 'cursor': 'pointer'
- })
- });
-}
-
-function toggleFeatureLabelsPolygons(layer) {
- function activateLabels() {
- layer.styleMap = getActivatedOpenLayersStyleMap();
- LABELS[thematicMap] = true;
- }
- function deactivateLabels() {
- layer.styleMap = getDeactivatedOpenLayersStyleMap();
- LABELS[thematicMap] = false;
- }
-
- if (LABELS[thematicMap]) {
- deactivateLabels();
- }
- else {
- activateLabels();
- }
-
- FEATURE[thematicMap] = layer.features;
- choropleth.applyValues();
-}
-
-function toggleFeatureLabelsPoints(layer) {
- function activateLabels() {
- layer.styleMap = getActivatedOpenLayersStyleMap(MAPDATA[thematicMap2].nameColumn);
- LABELS[thematicMap2] = true;
- }
- function deactivateLabels() {
- layer.styleMap = getDeactivatedOpenLayersStyleMap();
- LABELS[thematicMap2] = false;
- }
-
- if (LABELS[thematicMap2]) {
- deactivateLabels();
- }
- else {
- activateLabels();
- }
-
- FEATURE[thematicMap2] = layer.features;
- proportionalSymbol.applyValues();
-}
-
-function toggleFeatureLabelsAssignment(classify, layer) {
- function activateLabels() {
- layer.styleMap = getActivatedOpenLayersStyleMap(MAPDATA[organisationUnitAssignment].nameColumn);
- LABELS[organisationUnitAssignment] = true;
- }
- function deactivateLabels() {
- layer.styleMap = getDeactivatedOpenLayersStyleMap();
- LABELS[organisationUnitAssignment] = false;
- }
-
- if (classify) {
- if (LABELS[organisationUnitAssignment]) {
- deactivateLabels();
- }
- else {
- activateLabels();
- }
- mapping.classify(false,true);
- }
- else {
- if (LABELS[organisationUnitAssignment]) {
- activateLabels();
- }
- }
-}
-
-/* Sort values */
-function sortByValue(a,b) {
- return b.value-a.value;
-}
-
-/* Create JSON for map export */
-function getExportDataValueJSON(mapvalues) {
- var json = '{';
- json += '"datavalues": ';
- json += '[';
- mapvalues.sort(sortByValue);
- for (var i = 0; i < mapvalues.length; i++) {
- json += '{';
- json += '"organisation": "' + mapvalues[i].orgUnitId + '",';
- json += '"value": "' + mapvalues[i].value + '" ';
- json += i < mapvalues.length - 1 ? '},' : '}'
- }
- json += ']';
- json += '}';
- return json
-}
-
-function getLegendsJSON(){
- var widget = ACTIVEPANEL == thematicMap ? choropleth : proportionalSymbol;
- var json = '{';
- json += '"legends":';
- json += '[';
- for(var i = 0; i < widget.imageLegend.length; i++) {
- json += '{';
- json += '"label": "' + widget.imageLegend[i].label + '",';
- json += '"color": "' + widget.imageLegend[i].color + '" ';
- json += i < widget.imageLegend.length-1 ? '},' : '}';
- }
- json += ']';
- json += '}';
- return json;
-}
\ No newline at end of file
+var GLOBALS = {};
+
+GLOBALS.util = {
+
+ /* Detect mapview parameter in URL */
+ getUrlParam: function(strParam) {
+ var output = '';
+ var strHref = window.location.href;
+ if (strHref.indexOf('?') > -1 ) {
+ var strQueryString = strHref.substr(strHref.indexOf('?')).toLowerCase();
+ var aQueryString = strQueryString.split('&');
+ for (var iParam = 0; iParam < aQueryString.length; iParam++) {
+ if (aQueryString[iParam].indexOf(strParam.toLowerCase() + '=') > -1) {
+ var aParam = aQueryString[iParam].split('=');
+ output =aParam[1];
+ break;
+ }
+ }
+ }
+ return unescape(output);
+ },
+
+ /* Get all properties in an object */
+ getKeys: function(obj) {
+ var temp = [];
+ for (var k in obj) {
+ if (obj.hasOwnProperty(k)) {
+ temp.push(k);
+ }
+ }
+ return temp;
+ },
+
+ /* Input validation */
+ validateInputNameLength: function(name) {
+ return (name.length <= 25);
+ },
+
+ /* Decide multiselect height based on screen resolution */
+ getMultiSelectHeight: function() {
+ var h = screen.height;
+ return h <= 800 ? 220 :
+ h <= 1050 ? 310 :
+ h <= 1200 ? 470 : 900;
+ },
+
+ /* Make map view numbers numeric */
+ getNumericMapView: function(mapView) {
+ mapView.id = parseFloat(mapView.id);
+ mapView.indicatorGroupId = parseFloat(mapView.indicatorGroupId);
+ mapView.indicatorId = parseFloat(mapView.indicatorId);
+ mapView.periodId = parseFloat(mapView.periodId);
+ mapView.method = parseFloat(mapView.method);
+ mapView.classes = parseFloat(mapView.classes);
+ mapView.mapLegendSetId = parseFloat(mapView.mapLegendSetId);
+ mapView.longitude = parseFloat(mapView.longitude);
+ mapView.latitude = parseFloat(mapView.latitude);
+ mapView.zoom = parseFloat(mapView.zoom);
+ return mapView;
+ },
+
+ /* Get number of decimals */
+ getNumberOfDecimals: function(x,dec_sep) {
+ var tmp = new String();
+ tmp = x;
+ return tmp.indexOf(dec_sep) > -1 ? tmp.length-tmp.indexOf(dec_sep) - 1 : 0;
+ },
+
+ /* Toggle feature labels */
+ labels: {
+ getActivatedOpenLayersStyleMap: function() {
+ return new OpenLayers.StyleMap({
+ 'default' : new OpenLayers.Style(
+ OpenLayers.Util.applyDefaults({
+ 'fillOpacity': 1,
+ 'strokeColor': '#222222',
+ 'strokeWidth': 1,
+ 'label': '${labelString}',
+ 'fontFamily': 'arial,lucida sans unicode',
+ 'fontWeight': 'bold',
+ 'fontSize': 14
+ },
+ OpenLayers.Feature.Vector.style['default'])
+ ),
+ 'select': new OpenLayers.Style({
+ 'strokeColor': '#000000',
+ 'strokeWidth': 2,
+ 'cursor': 'pointer'
+ })
+ });
+ },
+ getDeactivatedOpenLayersStyleMap: function() {
+ return new OpenLayers.StyleMap({
+ 'default': new OpenLayers.Style(
+ OpenLayers.Util.applyDefaults({
+ 'fillOpacity': 1,
+ 'strokeColor': '#222222',
+ 'strokeWidth': 1
+ },
+ OpenLayers.Feature.Vector.style['default'])
+ ),
+ 'select': new OpenLayers.Style({
+ 'strokeColor': '#000000',
+ 'strokeWidth': 2,
+ 'cursor': 'pointer'
+ })
+ });
+ }
+ },
+
+ toggleFeatureLabelsPolygons: function(layer) {
+ function activateLabels(scope) {
+ layer.styleMap = scope.labels.getActivatedOpenLayersStyleMap();
+ LABELS[thematicMap] = true;
+ }
+ function deactivateLabels(scope) {
+ layer.styleMap = scope.labels.getDeactivatedOpenLayersStyleMap();
+ LABELS[thematicMap] = false;
+ }
+
+ if (LABELS[thematicMap]) {
+ deactivateLabels(this);
+ }
+ else {
+ activateLabels(this);
+ }
+
+ FEATURE[thematicMap] = layer.features;
+ choropleth.applyValues();
+ },
+
+ toggleFeatureLabelsPoints: function(layer) {
+ function activateLabels(scope) {
+ layer.styleMap = scope.labels.getActivatedOpenLayersStyleMap();
+ LABELS[thematicMap2] = true;
+ }
+ function deactivateLabels(scope) {
+ layer.styleMap = scope.labels.getDeactivatedOpenLayersStyleMap();
+ LABELS[thematicMap2] = false;
+ }
+
+ if (LABELS[thematicMap2]) {
+ deactivateLabels(this);
+ }
+ else {
+ activateLabels(this);
+ }
+
+ FEATURE[thematicMap2] = layer.features;
+ proportionalSymbol.applyValues();
+ },
+
+ toggleFeatureLabelsAssignment: function(classify, layer) {
+ function activateLabels(scope) {
+ layer.styleMap = scope.labels.getActivatedOpenLayersStyleMap();
+ LABELS[organisationUnitAssignment] = true;
+ }
+ function deactivateLabels(scope) {
+ layer.styleMap = scope.labels.getDeactivatedOpenLayersStyleMap();
+ LABELS[organisationUnitAssignment] = false;
+ }
+
+ if (classify) {
+ if (LABELS[organisationUnitAssignment]) {
+ deactivateLabels();
+ }
+ else {
+ activateLabels();
+ }
+ mapping.classify(false,true);
+ }
+ else {
+ if (LABELS[organisationUnitAssignment]) {
+ activateLabels();
+ }
+ }
+ },
+
+ /* Sort values */
+ sortByValue: function(a,b) {
+ return b.value-a.value;
+ },
+
+ /* Create JSON for map export */
+ getExportDataValueJSON: function(mapValues) {
+ var json = '{';
+ json += '"datavalues": ';
+ json += '[';
+ mapValues.sort(this.sortByValue);
+ for (var i = 0; i < mapValues.length; i++) {
+ json += '{';
+ json += '"organisation": "' + mapValues[i].orgUnitId + '",';
+ json += '"value": "' + mapValues[i].value + '" ';
+ json += i < mapValues.length - 1 ? '},' : '}'
+ }
+ json += ']';
+ json += '}';
+ return json
+ },
+
+ getLegendsJSON: function() {
+ var widget = ACTIVEPANEL == thematicMap ? choropleth : proportionalSymbol;
+ var json = '{';
+ json += '"legends":';
+ json += '[';
+ for(var i = 0; i < widget.imageLegend.length; i++) {
+ json += '{';
+ json += '"label": "' + widget.imageLegend[i].label + '",';
+ json += '"color": "' + widget.imageLegend[i].color + '" ';
+ json += i < widget.imageLegend.length-1 ? '},' : '}';
+ }
+ json += ']';
+ json += '}';
+ return json;
+ }
+};
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js 2010-09-24 22:44:20 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js 2010-09-30 10:09:26 +0000
@@ -244,7 +244,7 @@
var maxDec = 0;
for (var i = 0; i < bounds.length; i++) {
- var dec = getNumberOfDecimals(bounds[i].toString(), ".");
+ var dec = GLOBALS.util.getNumberOfDecimals(bounds[i].toString(), ".");
maxDec = dec > maxDec ? dec : maxDec;
}
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js 2010-09-29 12:21:47 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js 2010-09-30 10:09:26 +0000
@@ -96,7 +96,7 @@
scope: this,
success: function(r) {
PARAMETER = false;
- this.mapView = getNumericMapView(Ext.util.JSON.decode(r.responseText).mapView[0]);
+ this.mapView = GLOBALS.util.getNumericMapView(Ext.util.JSON.decode(r.responseText).mapView[0]);
MAPSOURCE = this.mapView.mapSourceType;
MAP.setCenter(new OpenLayers.LonLat(this.mapView.longitude, this.mapView.latitude), this.mapView.zoom);
@@ -487,16 +487,14 @@
listeners: {
'select': {
scope: this,
- fn: function() {
- var mId = Ext.getCmp('mapview_cb').getValue();
-
+ fn: function(cb) {
Ext.Ajax.request({
url: path_mapping + 'getMapView' + type,
method: 'POST',
- params: {id: mId},
+ params: {id: cb.getValue()},
scope: this,
success: function(r) {
- this.mapView = getNumericMapView(Ext.util.JSON.decode(r.responseText).mapView[0]);
+ this.mapView = GLOBALS.util.getNumericMapView(Ext.util.JSON.decode(r.responseText).mapView[0]);
MAPSOURCE = this.mapView.mapSourceType;
MAPDATETYPE = this.mapView.mapDateType;
Ext.getCmp('mapdatetype_cb').setValue(MAPDATETYPE);
@@ -989,7 +987,7 @@
xtype: 'treepanel',
id: 'orgunit_tp',
bodyStyle: 'padding:7px',
- height: getMultiSelectHeight(),
+ height: GLOBALS.util.getMultiSelectHeight(),
autoScroll: true,
loader: new Ext.tree.TreeLoader({
dataUrl: path_mapping + 'getOrganisationUnitChildren' + type
@@ -1543,7 +1541,7 @@
scope: this,
success: function(r) {
var mapvalues = Ext.util.JSON.decode(r.responseText).mapvalues;
- EXPORTVALUES = getExportDataValueJSON(mapvalues);
+ EXPORTVALUES = GLOBALS.util.getExportDataValueJSON(mapvalues);
if (mapvalues.length == 0) {
Ext.message.msg(false, i18n_current_selection_no_data );
@@ -1623,7 +1621,7 @@
scope: this,
success: function(r) {
var mapvalues = Ext.util.JSON.decode(r.responseText).mapvalues;
- EXPORTVALUES = getExportDataValueJSON(mapvalues);
+ EXPORTVALUES = GLOBALS.util.getExportDataValueJSON(mapvalues);
var mv = new Array();
var mour = new Array();
var nameColumn = this.mapData.nameColumn;
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js 2010-09-28 22:06:26 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js 2010-09-30 10:09:26 +0000
@@ -380,7 +380,7 @@
params: {id: mId},
scope: this,
success: function(r) {
- this.mapView = getNumericMapView(Ext.util.JSON.decode(r.responseText).mapView[0]);
+ this.mapView = GLOBALS.util.getNumericMapView(Ext.util.JSON.decode(r.responseText).mapView[0]);
MAPSOURCE = this.mapView.mapSourceType;
MAPDATETYPE = this.mapView.mapDateType;
Ext.getCmp('mapdatetype_cb').setValue(MAPDATETYPE);
@@ -873,7 +873,7 @@
xtype: 'treepanel',
id: 'orgunit_tp2',
bodyStyle: 'padding:7px',
- height: getMultiSelectHeight(),
+ height: GLOBALS.util.getMultiSelectHeight(),
autoScroll: true,
loader: new Ext.tree.TreeLoader({
dataUrl: path_mapping + 'getOrganisationUnitChildren' + type
@@ -1427,7 +1427,7 @@
scope: this,
success: function(r) {
var mapvalues = Ext.util.JSON.decode(r.responseText).mapvalues;
- EXPORTVALUES = getExportDataValueJSON(mapvalues);
+ EXPORTVALUES = GLOBALS.util.getExportDataValueJSON(mapvalues);
if (mapvalues.length == 0) {
Ext.message.msg(false, i18n_current_selection_no_data );
@@ -1507,7 +1507,7 @@
scope: this,
success: function(r) {
var mapvalues = Ext.util.JSON.decode(r.responseText).mapvalues;
- EXPORTVALUES = getExportDataValueJSON(mapvalues);
+ EXPORTVALUES = GLOBALS.util.getExportDataValueJSON(mapvalues);
var mv = new Array();
var mour = new Array();
var nameColumn = this.mapData.nameColumn;