dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #07740
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2266: (GIS) Improved code.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2266 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: trunk
timestamp: Wed 2010-09-29 00:12:05 +0200
message:
(GIS) Improved code.
added:
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/util.js
modified:
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/index.html
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/resources/mapfish/widgets/geostat/Choropleth.js
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Mapping.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/index.html'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/index.html 2010-09-14 17:14:48 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/index.html 2010-09-28 22:06:26 +0000
@@ -65,6 +65,7 @@
<!-- DHIS -->
<script type="text/javascript" src="i18nJavaScript.action"></script>
<script type="text/javascript" src="script/config.js"></script>
+ <script type="text/javascript" src="script/util.js"></script>
<script type="text/javascript" src="script/index.js"></script>
</head>
=== 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-27 11:18:38 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js 2010-09-28 22:06:26 +0000
@@ -8,8 +8,8 @@
var MAPDATETYPE;
/* A map object */
var MAPDATA = {};
-MAPDATA[thematicMap] = {};
-MAPDATA[thematicMap2] = {};
+// MAPDATA[thematicMap] = {};
+// MAPDATA[thematicMap2] = {};
MAPDATA[organisationUnitAssignment] = {};
/* Filename or level */
var URL;
@@ -43,114 +43,6 @@
/* Locate feature window */
var lfw;
-/* 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);}
-/* Input validation */
-function validateInput(name){return (name.length<=25);}
-/* Date validation */
-function validateDates(startDate,endDate){if(!startDate || !endDate){return true;}return startDate >= endDate ? false : true;}
-/* Decide multiselect height based on screen resolution */
-function getMultiSelectHeight(){var h=screen.height;if(h<=800){return 220;}else if(h<=1050){return 310;}else if(h<=1200){return 470;}else{return 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;if(tmp.indexOf(dec_sep)>-1){return tmp.length-tmp.indexOf(dec_sep)-1;}else{return 0;}}
-/* Get property names in an object */
-function getKeys(obj){var temp=[];for(var k in obj){if(obj.hasOwnProperty(k)){temp.push(k);}}return temp;}
-/* Toggle feature labels */
-function getActivatedOpenLayersStyleMap(nameColumn) {
- 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(MAPDATA[thematicMap].nameColumn);
- 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 method */
-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;
-}
-
Ext.onReady( function() {
Ext.BLANK_IMAGE_URL = '../resources/ext/resources/images/default/s.gif';
/* Ext 3.2.0 override */
@@ -323,7 +215,7 @@
}
}
- if (validateInput(vn) == false) {
+ if (validateInputNameLength(vn) == false) {
Ext.message.msg(false, i18n_map_view_name_cannot_be_longer_than_25_characters );
return;
}
@@ -786,7 +678,7 @@
return;
}
- if (!validateInput(mln)) {
+ if (!validateInputNameLength(mln)) {
Ext.message.msg(false, i18n_name_can_not_longer_than_25 );
return;
}
@@ -1635,7 +1527,7 @@
return;
}
- if (validateInput(nn) == false) {
+ if (validateInputNameLength(nn) == false) {
Ext.message.msg(false, '<span class="x-msg-hl">' + i18n_map + ' ' + i18n_name_can_not_longer_than_25 + '</span>');
return;
}
@@ -1735,7 +1627,7 @@
return;
}
- if (validateInput(en) == false) {
+ if (validateInputNameLength(en) == false) {
Ext.message.msg(false, i18n_name_can_not_longer_than_25 );
return;
}
@@ -2206,7 +2098,7 @@
return;
}
- if (validateInput(mln) == false) {
+ if (validateInputNameLength(mln) == false) {
Ext.message.msg(false, i18n_overlay_name_cannot_be_longer_than_25_characters );
return;
}
@@ -2417,7 +2309,7 @@
return;
}
- if (validateInput(mlbn) == false) {
+ if (validateInputNameLength(mlbn) == false) {
Ext.message.msg(false, i18n_baselayer_name_cannot_be_longer_than_25_characters );
return;
}
@@ -4085,7 +3977,7 @@
Ext.getCmp('featureinfo_l').setText('<span style="color:black">' + FEATURE[thematicMap].attributes[MAPDATA[organisationUnitAssignment].nameColumn] + '</span>', false);
}
else {
- Ext.getCmp('featureinfo_l').setText('<div style="color:black">' + FEATURE[thematicMap].attributes[MAPDATA[thematicMap].nameColumn] + '</div><div style="color:#555">' + FEATURE[thematicMap].attributes.value + '</div>', false);
+ Ext.getCmp('featureinfo_l').setText('<div style="color:black">' + FEATURE[thematicMap].attributes[choropleth.mapData.nameColumn] + '</div><div style="color:#555">' + FEATURE[thematicMap].attributes.value + '</div>', false);
}
}
@@ -4154,7 +4046,7 @@
/* Section: select features point */
function onHoverSelectPoint(feature) {
FEATURE[thematicMap2] = feature;
- Ext.getCmp('featureinfo_l').setText('<div style="color:black">' + FEATURE[thematicMap2].attributes[MAPDATA[thematicMap2].nameColumn] + '</div><div style="color:#555">' + FEATURE[thematicMap2].attributes.value + '</div>', false);
+ Ext.getCmp('featureinfo_l').setText('<div style="color:black">' + FEATURE[thematicMap2].attributes[proportionalSymbol.mapData.nameColumn] + '</div><div style="color:#555">' + FEATURE[thematicMap2].attributes.value + '</div>', false);
}
function onHoverUnselectPoint(feature) {
@@ -4176,7 +4068,7 @@
Ext.getCmp('map_tf2').setValue(feature.data.name);
Ext.getCmp('map_tf2').value = feature.attributes.id;
- proportionalSymbol.loadFromDatabase(Ext.getCmp('map_tf2').value);
+ proportionalSymbol.loadFromDatabase(feature.attributes.id, true);
}
else {
Ext.message.msg(false, i18n_no_coordinates_found);
=== added 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 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/util.js 2010-09-28 22:06:26 +0000
@@ -0,0 +1,210 @@
+/* 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
=== 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-27 11:18:38 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js 2010-09-28 22:06:26 +0000
@@ -27,51 +27,55 @@
mapfish.widgets.geostat.Choropleth = Ext.extend(Ext.FormPanel, {
layer: null,
-
+
format: null,
-
+
url: null,
-
+
featureSelection: true,
-
+
nameAttribute: null,
-
+
indicator: null,
-
+
indicatorText: null,
-
+
coreComp: null,
-
+
classificationApplied: false,
-
+
ready: false,
-
+
border: false,
-
+
loadMask: false,
-
+
labelGenerator: null,
-
+
colorInterpolation: false,
-
+
newUrl: false,
-
+
legend: false,
-
- imageLegend: false,
-
- bounds: false,
-
+
+ imageLegend: false,
+
+ bounds: false,
+
parentId: false,
-
+
mapView: false,
+
+ mapData: false,
initComponent: function() {
- this.legend = new Object();
+ this.legend = {};
this.legend.type = map_legend_type_automatic;
this.legend.method = 2;
this.legend.classes = 5;
+ this.mapData = {};
+
mapViewStore = new Ext.data.JsonStore({
url: path_mapping + 'getAllMapViews' + type,
root: 'mapViews',
@@ -477,7 +481,7 @@
Ext.Ajax.request({
url: path_mapping + 'getMapView' + type,
method: 'POST',
- params: { id: mId },
+ params: {id: mId},
scope: this,
success: function(r) {
this.mapView = getNumericMapView(Ext.util.JSON.decode(r.responseText).mapView[0]);
@@ -546,7 +550,7 @@
}
},
failure: function() {
- alert( i18n_status , i18n_error_while_retrieving_data );
+ alert(i18n_status, i18n_error_while_retrieving_data);
}
});
}
@@ -1057,7 +1061,7 @@
TOPLEVELUNIT.id = rootNode.id;
TOPLEVELUNIT.name = rootNode.name;
TOPLEVELUNIT.hasChildrenWithCoordinates = rootNode.hasChildrenWithCoordinates;
- showTree(this);
+ showTree(this);
},
failure: function(r) {
alert('getOrganisationUnits');
@@ -1452,7 +1456,7 @@
applyValues: function() {
var options = {};
this.indicator = 'value';
- options.indicator = 'value';
+ options.indicator = this.indicator;
options.method = Ext.getCmp('method_cb').getValue();
options.numClasses = Ext.getCmp('numClasses_cb').getValue();
options.colors = this.getColors();
@@ -1480,17 +1484,17 @@
MASK.msg = i18n_aggregating_map_values;
MASK.show();
- MAPDATA[ACTIVEPANEL].name = Ext.getCmp('map_tf').getValue();
- MAPDATA[ACTIVEPANEL].nameColumn = 'name';
- MAPDATA[ACTIVEPANEL].longitude = BASECOORDINATE.longitude;
- MAPDATA[ACTIVEPANEL].latitude = BASECOORDINATE.latitude;
- MAPDATA[ACTIVEPANEL].zoom = 7;
+ this.mapData.name = Ext.getCmp('map_tf').getValue();
+ this.mapData.nameColumn = 'name';
+ this.mapData.longitude = BASECOORDINATE.longitude;
+ this.mapData.latitude = BASECOORDINATE.latitude;
+ this.mapData.zoom = 7;
if (!position) {
- if (MAPDATA[ACTIVEPANEL].zoom != MAP.getZoom()) {
- MAP.zoomTo(MAPDATA[ACTIVEPANEL].zoom);
+ if (this.mapData.zoom != MAP.getZoom()) {
+ MAP.zoomTo(this.mapData.zoom);
}
- MAP.setCenter(new OpenLayers.LonLat(MAPDATA[ACTIVEPANEL].longitude, MAPDATA[ACTIVEPANEL].latitude));
+ MAP.setCenter(new OpenLayers.LonLat(this.mapData.longitude, this.mapData.latitude));
}
if (this.mapView) {
@@ -1498,18 +1502,18 @@
MAP.setCenter(new OpenLayers.LonLat(this.mapView.longitude, this.mapView.latitude), this.mapView.zoom);
}
else {
- MAP.setCenter(new OpenLayers.LonLat(MAPDATA[ACTIVEPANEL].longitude, MAPDATA[ACTIVEPANEL].latitude), MAPDATA[ACTIVEPANEL].zoom);
+ MAP.setCenter(new OpenLayers.LonLat(this.mapData.longitude, this.mapData.latitude), this.mapData.zoom);
}
this.mapView = false;
}
-
- FEATURE[thematicMap] = MAP.getLayersByName('Polygon layer')[0].features;
+
+ FEATURE[thematicMap] = this.layer.features;
var indicatorOrDataElementId = VALUETYPE.polygon == map_value_type_indicator ?
Ext.getCmp('indicator_cb').getValue() : Ext.getCmp('dataelement_cb').getValue();
var dataUrl = VALUETYPE.polygon == map_value_type_indicator ?
'getIndicatorMapValuesByParentOrganisationUnit' : 'getDataMapValuesByParentOrganisationUnit';
- var params = new Object();
+ var params = {};
if (MAPDATETYPE == map_date_type_fixed) {
params.periodId = Ext.getCmp('period_cb').getValue();
}
@@ -1567,18 +1571,18 @@
params: {mapLayerPath: this.newUrl},
scope: this,
success: function(r) {
- MAPDATA[ACTIVEPANEL] = Ext.util.JSON.decode(r.responseText).map[0];
+ this.mapData = Ext.util.JSON.decode(r.responseText).map[0];
- MAPDATA[ACTIVEPANEL].organisationUnitLevel = parseFloat(MAPDATA[ACTIVEPANEL].organisationUnitLevel);
- MAPDATA[ACTIVEPANEL].longitude = parseFloat(MAPDATA[ACTIVEPANEL].longitude);
- MAPDATA[ACTIVEPANEL].latitude = parseFloat(MAPDATA[ACTIVEPANEL].latitude);
- MAPDATA[ACTIVEPANEL].zoom = parseFloat(MAPDATA[ACTIVEPANEL].zoom);
+ this.mapData.organisationUnitLevel = parseFloat(this.mapData.organisationUnitLevel);
+ this.mapData.longitude = parseFloat(this.mapData.longitude);
+ this.mapData.latitude = parseFloat(this.mapData.latitude);
+ this.mapData.zoom = parseFloat(this.mapData.zoom);
if (!position) {
- if (MAPDATA[ACTIVEPANEL].zoom != MAP.getZoom()) {
- MAP.zoomTo(MAPDATA[ACTIVEPANEL].zoom);
+ if (this.mapData.zoom != MAP.getZoom()) {
+ MAP.zoomTo(this.mapData.zoom);
}
- MAP.setCenter(new OpenLayers.LonLat(MAPDATA[ACTIVEPANEL].longitude, MAPDATA[ACTIVEPANEL].latitude));
+ MAP.setCenter(new OpenLayers.LonLat(this.mapData.longitude, this.mapData.latitude));
}
if (this.mapView) {
@@ -1586,12 +1590,12 @@
MAP.setCenter(new OpenLayers.LonLat(this.mapView.longitude, this.mapView.latitude), this.mapView.zoom);
}
else {
- MAP.setCenter(new OpenLayers.LonLat(MAPDATA[ACTIVEPANEL].longitude, MAPDATA[ACTIVEPANEL].latitude), MAPDATA[ACTIVEPANEL].zoom);
+ MAP.setCenter(new OpenLayers.LonLat(this.mapData.longitude, this.mapData.latitude), this.mapData.zoom);
}
this.mapView = false;
}
- FEATURE[thematicMap] = MAP.getLayersByName('Polygon layer')[0].features;
+ FEATURE[thematicMap] = this.layer.features;
var indicatorOrDataElementId = VALUETYPE.polygon == map_value_type_indicator ?
Ext.getCmp('indicator_cb').getValue() : Ext.getCmp('dataelement_cb').getValue();
@@ -1610,7 +1614,7 @@
EXPORTVALUES = getExportDataValueJSON(mapvalues);
var mv = new Array();
var mour = new Array();
- var nameColumn = MAPDATA[thematicMap].nameColumn;
+ var nameColumn = this.mapData.nameColumn;
var options = {};
if (mapvalues.length == 0) {
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Mapping.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Mapping.js 2010-09-24 22:44:20 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Mapping.js 2010-09-28 22:06:26 +0000
@@ -24,105 +24,32 @@
Ext.namespace('mapfish.widgets', 'mapfish.widgets.geostat');
-/**
- * Class: mapfish.widgets.geostat.Choropleth
- * Use this class to create a widget allowing to display choropleths
- * on the map.
- *
- * Inherits from:
- * - {Ext.FormPanel}
- */
-
mapfish.widgets.geostat.Mapping = Ext.extend(Ext.FormPanel, {
- /**
- * APIProperty: layer
- * {<OpenLayers.Layer.Vector>} The vector layer containing the features that
- * are styled based on statistical values. If none is provided, one will
- * be created.
- */
layer: null,
-
- /**
- * APIProperty: format
- * {<OpenLayers.Format>} The OpenLayers format used to get features from
- * the HTTP request response. GeoJSON is used if none is provided.
- */
+
format: null,
- /**
- * APIProperty: url
- * {String} The URL to the web service. If none is provided, the features
- * found in the provided vector layer will be used.
- */
url: null,
- /**
- * APIProperty: featureSelection
- * {Boolean} A boolean value specifying whether feature selection must
- * be put in place. If true a popup will be displayed when the
- * mouse goes over a feature.
- */
featureSelection: true,
- /**
- * APIProperty: nameAttribute
- * {String} The feature attribute that will be used as the popup title.
- * Only applies if featureSelection is true.
- */
nameAttribute: null,
- /**
- * APIProperty: indicator
- * {String} (read-only) The feature attribute currently chosen
- * Useful if callbacks are registered on 'featureselected'
- * and 'featureunselected' events
- */
indicator: null,
- /**
- * APIProperty: indicatorText
- * {String} (read-only) The raw value of the currently chosen indicator
- * (ie. human readable)
- * Useful if callbacks are registered on 'featureselected'
- * and 'featureunselected' events
- */
indicatorText: null,
- /**
- * Property: coreComp
- * {<mapfish.GeoStat.ProportionalSymbol>} The core component object.
- */
coreComp: null,
- /**
- * Property: classificationApplied
- * {Boolean} true if the classify was applied
- */
classificationApplied: false,
- /**
- * Property: ready
- * {Boolean} true if the widget is ready to accept user commands.
- */
ready: false,
- /**
- * Property: border
- * Styling border
- */
border: false,
- /**
- * APIProperty: loadMask
- * An Ext.LoadMask config or true to mask the widget while loading (defaults to false).
- */
loadMask: false,
- /**
- * APIProperty: labelGenerator
- * Generator for bin labels
- */
labelGenerator: null,
getGridPanelHeight: function() {
=== 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-27 11:18:38 +0000
+++ 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
@@ -51,26 +51,30 @@
loadMask: false,
labelGenerator: null,
-
- colorInterpolation: false,
-
+
+ colorInterpolation: false,
+
newUrl: false,
-
+
legend: false,
-
+
imageLegend: false,
-
+
bounds: false,
-
+
parentId: false,
-
+
mapView: false,
-
+
+ mapData: false,
+
initComponent: function() {
- this.legend = new Object();
+ this.legend = {};
this.legend.type = map_legend_type_automatic;
this.legend.method = 2;
this.legend.classes = 5;
+
+ this.mapData = {};
mapViewStore2 = new Ext.data.JsonStore({
url: path_mapping + 'getAllMapViews' + type,
@@ -317,7 +321,7 @@
predefinedMapLegendSetStore2 = new Ext.data.JsonStore({
url: path_mapping + 'getMapLegendSetsByType' + type,
- baseParams: { type: map_legend_type_predefined },
+ baseParams: {type: map_legend_type_predefined},
root: 'mapLegendSets',
fields: ['id', 'name'],
autoLoad: true,
@@ -329,7 +333,7 @@
Ext.Ajax.request({
url: path_mapping + 'getMapLegendSet' + type,
method: 'POST',
- params: { id: this.mapView.mapLegendSetId },
+ params: {id: this.mapView.mapLegendSetId},
scope: this,
success: function(r) {
var mls = Ext.util.JSON.decode(r.responseText).mapLegendSet[0];
@@ -631,7 +635,7 @@
{
xtype: 'combo',
id: 'dataelement_cb2',
- fieldLabel: i18n_dataelement ,
+ fieldLabel: i18n_dataelement,
typeAhead: true,
editable: false,
valueField: 'id',
@@ -938,7 +942,7 @@
w.setPosition(x,y);
w.show();
}
-
+
if (TOPLEVELUNIT.id) {
showTree(this);
}
@@ -1347,7 +1351,8 @@
applyValues: function() {
var options = {};
- this.indicator = options.indicator = 'value';
+ this.indicator = 'value';
+ options.indicator = this.indicator;
options.method = Ext.getCmp('method_cb2').getValue();
options.numClasses2 = Ext.getCmp('numClasses_cb2').getValue();
options.colors = this.getColors();
@@ -1375,17 +1380,17 @@
MASK.msg = i18n_aggregating_map_values;
MASK.show();
- MAPDATA[ACTIVEPANEL].name = Ext.getCmp('map_tf2').getValue();
- MAPDATA[ACTIVEPANEL].nameColumn = 'name';
- MAPDATA[ACTIVEPANEL].longitude = BASECOORDINATE.longitude;
- MAPDATA[ACTIVEPANEL].latitude = BASECOORDINATE.latitude;
- MAPDATA[ACTIVEPANEL].zoom = 7;
+ this.mapData.name = Ext.getCmp('map_tf2').getValue();
+ this.mapData.nameColumn = 'name';
+ this.mapData.longitude = BASECOORDINATE.longitude;
+ this.mapData.latitude = BASECOORDINATE.latitude;
+ this.mapData.zoom = 7;
if (!position) {
- if (MAPDATA[ACTIVEPANEL].zoom != MAP.getZoom()) {
- MAP.zoomTo(MAPDATA[ACTIVEPANEL].zoom);
+ if (this.mapData.zoom != MAP.getZoom()) {
+ MAP.zoomTo(this.mapData.zoom);
}
- MAP.setCenter(new OpenLayers.LonLat(MAPDATA[ACTIVEPANEL].longitude, MAPDATA[ACTIVEPANEL].latitude));
+ MAP.setCenter(new OpenLayers.LonLat(this.mapData.longitude, this.mapData.latitude));
}
if (this.mapView) {
@@ -1393,18 +1398,18 @@
MAP.setCenter(new OpenLayers.LonLat(this.mapView.longitude, this.mapView.latitude), this.mapView.zoom);
}
else {
- MAP.setCenter(new OpenLayers.LonLat(MAPDATA[ACTIVEPANEL].longitude, MAPDATA[ACTIVEPANEL].latitude), MAPDATA[ACTIVEPANEL].zoom);
+ MAP.setCenter(new OpenLayers.LonLat(this.mapData.longitude, this.mapData.latitude), this.mapData.zoom);
}
this.mapView = false;
}
- FEATURE[thematicMap2] = MAP.getLayersByName('Point layer')[0].features;
+ FEATURE[thematicMap2] = this.layer.features;
var indicatorOrDataElementId = VALUETYPE.point == map_value_type_indicator ?
Ext.getCmp('indicator_cb2').getValue() : Ext.getCmp('dataelement_cb2').getValue();
var dataUrl = VALUETYPE.point == map_value_type_indicator ?
'getIndicatorMapValuesByParentOrganisationUnit' : 'getDataMapValuesByParentOrganisationUnit';
- var params = new Object();
+ var params = {};
if (MAPDATETYPE == map_date_type_fixed) {
params.periodId = Ext.getCmp('period_cb2').getValue();
}
@@ -1462,18 +1467,18 @@
params: {mapLayerPath: this.newUrl},
scope: this,
success: function(r) {
- MAPDATA[ACTIVEPANEL] = Ext.util.JSON.decode(r.responseText).map[0];
+ this.mapData = Ext.util.JSON.decode(r.responseText).map[0];
- MAPDATA[ACTIVEPANEL].organisationUnitLevel = parseFloat(MAPDATA[ACTIVEPANEL].organisationUnitLevel);
- MAPDATA[ACTIVEPANEL].longitude = parseFloat(MAPDATA[ACTIVEPANEL].longitude);
- MAPDATA[ACTIVEPANEL].latitude = parseFloat(MAPDATA[ACTIVEPANEL].latitude);
- MAPDATA[ACTIVEPANEL].zoom = parseFloat(MAPDATA[ACTIVEPANEL].zoom);
+ this.mapData.organisationUnitLevel = parseFloat(this.mapData.organisationUnitLevel);
+ this.mapData.longitude = parseFloat(this.mapData.longitude);
+ this.mapData.latitude = parseFloat(this.mapData.latitude);
+ this.mapData.zoom = parseFloat(this.mapData.zoom);
if (!position) {
- if (MAPDATA[ACTIVEPANEL].zoom != MAP.getZoom()) {
- MAP.zoomTo(MAPDATA[ACTIVEPANEL].zoom);
+ if (this.mapData.zoom != MAP.getZoom()) {
+ MAP.zoomTo(this.mapData.zoom);
}
- MAP.setCenter(new OpenLayers.LonLat(MAPDATA[ACTIVEPANEL].longitude, MAPDATA[ACTIVEPANEL].latitude));
+ MAP.setCenter(new OpenLayers.LonLat(this.mapData.longitude, this.mapData.latitude));
}
if (this.mapView) {
@@ -1481,12 +1486,12 @@
MAP.setCenter(new OpenLayers.LonLat(this.mapView.longitude, this.mapView.latitude), this.mapView.zoom);
}
else {
- MAP.setCenter(new OpenLayers.LonLat(MAPDATA[ACTIVEPANEL].longitude, MAPDATA[ACTIVEPANEL].latitude), MAPDATA[ACTIVEPANEL].zoom);
+ MAP.setCenter(new OpenLayers.LonLat(this.mapData.longitude, this.mapData.latitude), this.mapData.zoom);
}
this.mapView = false;
}
- FEATURE[thematicMap2] = MAP.getLayersByName('Point layer')[0].features;
+ FEATURE[thematicMap2] = this.layer.features;
var indicatorOrDataElementId = VALUETYPE.point == map_value_type_indicator ?
Ext.getCmp('indicator_cb2').getValue() : Ext.getCmp('dataelement_cb2').getValue();
@@ -1505,7 +1510,7 @@
EXPORTVALUES = getExportDataValueJSON(mapvalues);
var mv = new Array();
var mour = new Array();
- var nameColumn = MAPDATA[thematicMap2].nameColumn;
+ var nameColumn = this.mapData.nameColumn;
var options = {};
if (mapvalues.length == 0) {