dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #05122
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1699: (GIS) Work in progress on adapting MapView to the new legend system.
------------------------------------------------------------
revno: 1699
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-03-25 19:55:29 +0100
message:
(GIS) Work in progress on adapting MapView to the new legend system.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/comparator/MapLegendComparator.java
dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java
dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml
dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java
dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingStoreTest.java
dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapViewAction.java
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapView.vm
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css
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
--
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-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java 2010-03-25 15:27:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java 2010-03-25 18:55:29 +0000
@@ -37,6 +37,10 @@
*/
public class MapLegendSet
{
+ public static final String MAPLEGENDSET_TYPE_AUTOMATIC = "automatic";
+
+ public static final String MAPLEGENDSET_TYPE_PREDEFINED = "predefined";
+
private int id;
private String name;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java 2010-02-24 17:50:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java 2010-03-25 18:55:29 +0000
@@ -60,6 +60,8 @@
private String mapSource;
+ private String mapLegendType;
+
private int method;
private int classes;
@@ -68,6 +70,8 @@
private String colorHigh;
+ private int mapLegendSetId;
+
private String longitude;
private String latitude;
@@ -79,8 +83,8 @@
}
public MapView( String name, IndicatorGroup indicatorGroup, Indicator indicator, PeriodType periodType,
- Period period, String mapSourceType, String mapSource, int method, int classes, String colorLow,
- String colorHigh, String longitude, String latitude, int zoom )
+ Period period, String mapSourceType, String mapSource, String mapLegendType, int method, int classes,
+ String colorLow, String colorHigh, int mapLegendSetId, String longitude, String latitude, int zoom )
{
this.name = name;
this.indicatorGroup = indicatorGroup;
@@ -89,10 +93,12 @@
this.period = period;
this.mapSourceType = mapSourceType;
this.mapSource = mapSource;
+ this.mapLegendType = mapLegendType;
this.method = method;
this.classes = classes;
this.colorLow = colorLow;
this.colorHigh = colorHigh;
+ this.mapLegendSetId = mapLegendSetId;
this.longitude = longitude;
this.latitude = latitude;
this.zoom = zoom;
@@ -216,6 +222,16 @@
this.mapSource = mapSource;
}
+ public String getMapLegendType()
+ {
+ return mapLegendType;
+ }
+
+ public void setMapLegendType( String mapLegendType )
+ {
+ this.mapLegendType = mapLegendType;
+ }
+
public int getMethod()
{
return method;
@@ -256,6 +272,16 @@
this.colorHigh = colorHigh;
}
+ public int getMapLegendSetId()
+ {
+ return mapLegendSetId;
+ }
+
+ public void setMapLegendSetId( int mapLegendSetId )
+ {
+ this.mapLegendSetId = mapLegendSetId;
+ }
+
public String getLongitude()
{
return longitude;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2010-03-25 15:27:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2010-03-25 18:55:29 +0000
@@ -341,8 +341,8 @@
void updateMapLegendSet( MapLegendSet legendSet );
- void addOrUpdateMapLegendSet( String name, String type, int method, int classes, String colorLow,
- String colorHigh, Set<MapLegend> mapLegends );
+ void addOrUpdateMapLegendSet( String name, String type, int method, int classes, String colorLow, String colorHigh,
+ Set<MapLegend> mapLegends );
void deleteMapLegendSet( MapLegendSet legendSet );
@@ -365,14 +365,14 @@
int addMapView( MapView mapView );
int addMapView( String name, int indicatorGroupId, int indicatorId, String periodTypeName, int periodId,
- String mapSourceType, String mapSource, int method, int classes, String colorLow, String colorHigh,
- String longitude, String latitude, int zoom );
+ String mapSourceType, String mapSource, String mapLegendType, int method, int classes, String colorLow,
+ String colorHigh, int mapLegendSetId, String longitude, String latitude, int zoom );
void updateMapView( MapView mapView );
void addOrUpdateMapView( String name, int indicatorGroupId, int indicatorId, String periodTypeName, int periodId,
- String mapSource, int method, int classes, String colorLow, String colorHigh, String longitude,
- String latitude, int zoom );
+ String mapSource, String mapLegendType, int method, int classes, String colorLow, String colorHigh,
+ int mapLegendSetId, String longitude, String latitude, int zoom );
void deleteMapView( MapView view );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/comparator/MapLegendComparator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/comparator/MapLegendComparator.java 2010-03-25 17:25:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/comparator/MapLegendComparator.java 2010-03-25 18:55:29 +0000
@@ -35,6 +35,7 @@
* @author Tran Thanh Tri
* @version $Id$
*/
+
public class MapLegendComparator
implements Comparator<MapLegend>
{
@@ -43,4 +44,4 @@
{
return o1.getStartValue().compareTo( o2.getStartValue() );
}
-}
+}
\ No newline at end of file
=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2010-03-25 15:27:40 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2010-03-25 18:55:29 +0000
@@ -649,8 +649,8 @@
}
public int addMapView( String name, int indicatorGroupId, int indicatorId, String periodTypeName, int periodId,
- String mapSourceType, String mapSource, int method, int classes, String colorLow, String colorHigh,
- String longitude, String latitude, int zoom )
+ String mapSourceType, String mapSource, String mapLegendType, int method, int classes, String colorLow,
+ String colorHigh, int mapLegendSetId, String longitude, String latitude, int zoom )
{
MapView mapView = new MapView();
@@ -670,10 +670,12 @@
mapView.setPeriod( period );
mapView.setMapSourceType( mapSourceType );
mapView.setMapSource( mapSource );
+ mapView.setMapLegendType( mapLegendType );
mapView.setMethod( method );
mapView.setClasses( classes );
mapView.setColorLow( colorLow );
mapView.setColorHigh( colorHigh );
+ mapView.setMapLegendSetId( mapLegendSetId );
mapView.setLongitude( longitude );
mapView.setLatitude( latitude );
mapView.setZoom( zoom );
@@ -687,8 +689,8 @@
}
public void addOrUpdateMapView( String name, int indicatorGroupId, int indicatorId, String periodTypeName,
- int periodId, String mapSource, int method, int classes, String colorLow, String colorHigh, String longitude,
- String latitude, int zoom )
+ int periodId, String mapSource, String mapLegendType, int method, int classes, String colorLow, String colorHigh,
+ int mapLegendSetId, String longitude, String latitude, int zoom )
{
IndicatorGroup indicatorGroup = indicatorService.getIndicatorGroup( indicatorGroupId );
@@ -713,10 +715,12 @@
mapView.setPeriod( period );
mapView.setMapSourceType( mapSourceType );
mapView.setMapSource( mapSource );
+ mapView.setMapLegendType( mapLegendType );
mapView.setMethod( method );
mapView.setClasses( classes );
mapView.setColorLow( colorLow );
mapView.setColorHigh( colorHigh );
+ mapView.setMapLegendSetId( mapLegendSetId );
mapView.setLongitude( longitude );
mapView.setLatitude( latitude );
mapView.setZoom( zoom );
@@ -726,7 +730,7 @@
else
{
mapView = new MapView( name, indicatorGroup, indicator, periodType, period, mapSourceType, mapSource,
- method, classes, colorLow, colorHigh, longitude, latitude, zoom );
+ mapLegendType, method, classes, colorLow, colorHigh, mapLegendSetId, longitude, latitude, zoom );
addMapView( mapView );
}
=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml 2010-02-24 14:11:32 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml 2010-03-25 18:55:29 +0000
@@ -29,6 +29,8 @@
<property name="mapSource"/>
+ <property name="mapLegendType"/>
+
<property name="method"/>
<property name="classes"/>
@@ -37,6 +39,8 @@
<property name="colorHigh"/>
+ <property name="mapLegendSetId"/>
+
<property name="longitude"/>
<property name="latitude"/>
=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java 2010-02-24 14:11:32 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java 2010-03-25 18:55:29 +0000
@@ -205,7 +205,7 @@
MapView mapView = new MapView("MapViewA", indicatorGroup, indicator,
periodType, period, MapView.MAP_SOURCE_TYPE_SHAPEFILE,
- "sl_districts", 1, 1, "A", "B", "1", "1", 1);
+ "sl_districts", MapLegendSet.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "A", "B", 1, "1", "1", 1);
int idA = mappingService.addMapView(mapView);
=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingStoreTest.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingStoreTest.java 2010-02-24 14:11:32 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingStoreTest.java 2010-03-25 18:55:29 +0000
@@ -146,7 +146,7 @@
MapView mapView = new MapView("MapViewA", indicatorGroup, indicator,
periodType, period, MapView.MAP_SOURCE_TYPE_SHAPEFILE,
- "sl_districts", 1, 1, "A", "B", "1", "1", 1);
+ "sl_districts", MapLegendSet.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "A", "B", 1, "1", "1", 1);
int idA = mappingStore.addMapView(mapView);
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapViewAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapViewAction.java 2010-02-24 16:36:32 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapViewAction.java 2010-03-25 18:55:29 +0000
@@ -94,6 +94,13 @@
{
this.mapSource = mapSource;
}
+
+ private String mapLegendType;
+
+ public void setMapLegendType( String mapLegendType )
+ {
+ this.mapLegendType = mapLegendType;
+ }
private int method;
@@ -122,6 +129,13 @@
{
this.colorHigh = colorHigh;
}
+
+ private int mapLegendSetId;
+
+ public void setMapLegendSetId( int mapLegendSetId )
+ {
+ this.mapLegendSetId = mapLegendSetId;
+ }
private String longitude;
@@ -152,7 +166,7 @@
throws Exception
{
mappingService.addOrUpdateMapView( name, indicatorGroupId, indicatorId, periodTypeId, periodId, mapSource,
- method, classes, colorLow, colorHigh, longitude, latitude, zoom );
+ mapLegendType, method, classes, colorLow, colorHigh, mapLegendSetId, longitude, latitude, zoom );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapView.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapView.vm 2010-02-24 14:11:32 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapView.vm 2010-03-25 18:55:29 +0000
@@ -8,10 +8,12 @@
"periodId": "$!{object.period.id}",
"mapSourceType": "$!encoder.jsEncode( ${object.mapSourceType} )",
"mapSource": "$!encoder.jsEncode( ${object.mapSource} )",
+ "mapLegendType": "$!encoder.jsEncode( ${object.mapLegendType} )",
"method": "$!{object.method}",
"classes": "$!{object.classes}",
"colorLow": "$!encoder.jsEncode( ${object.colorLow} )",
"colorHigh": "$!encoder.jsEncode( ${object.colorHigh} )",
+ "mapLegendSetId": "$!{object.mapLegendSetId}",
"longitude": "$!encoder.jsEncode( ${object.longitude} )",
"latitude": "$!encoder.jsEncode( ${object.latitude} )",
"zoom": "$!{object.zoom}"
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css 2010-03-25 16:43:52 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css 2010-03-25 18:55:29 +0000
@@ -77,9 +77,6 @@
.x-btn .icon-pdf {
background-image:url(../../../images/pdf.png);
}
-.x-btn .icon-export-map {
- background-image:url(../../../images/export.png);
-}
.aa_dark button {
font-family:lucida sans unicode,arial;
font-weight:normal;
@@ -155,12 +152,6 @@
font:bold 11px arial;
color:#111;
}
-#window-export-map-title {
- padding:0 0 3px 21px;
- background:url('../../../images/export.png') no-repeat 0 0 transparent;
- font:bold 11px arial;
- color:#111;
-}
/* Ext Panel */
.panel-title {
=== 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-03-25 16:43:52 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js 2010-03-25 18:55:29 +0000
@@ -12,7 +12,6 @@
var MASK;
var LABELS;
var COLORINTERPOLATION;
-var EXPORTVALUES;
function getUrlParam(strParamName) {
var output = '';
@@ -304,7 +303,7 @@
params: { mapSourceType: MAPSOURCE },
success: function() {
- /* VIEW PANEL */
+ /* MAPVIEW PANEL */
var viewStore = new Ext.data.JsonStore({
url: path + 'getAllMapViews' + type,
root: 'mapViews',
@@ -379,9 +378,11 @@
var pt = Ext.getCmp('periodtype_cb').getValue();
var p = Ext.getCmp('period_cb').getValue();
var ms = Ext.getCmp('map_cb').getValue();
+ var mlt = Ext.getCmp('maplegendtype_cb').getValue();
var c = Ext.getCmp('numClasses').getValue();
var ca = Ext.getCmp('colorA_cf').getValue();
var cb = Ext.getCmp('colorB_cf').getValue();
+ var mlsid = Ext.getCmp('maplegendset_cb').getValue() ? Ext.getCmp('maplegendset_cb').getValue() : 0;
var lon = MAP.getCenter().lon;
var lat = MAP.getCenter().lat;
var zoom = parseInt(MAP.getZoom());
@@ -405,7 +406,7 @@
url: path + 'getAllMapViews' + type,
method: 'GET',
success: function(r) {
- var mapViews = Ext.util.JSON.decode( r.responseText ).mapViews;
+ var mapViews = Ext.util.JSON.decode(r.responseText).mapViews;
for (var i = 0; i < mapViews.length; i++) {
if (mapViews[i].name == vn) {
@@ -417,7 +418,7 @@
Ext.Ajax.request({
url: path + 'addOrUpdateMapView' + type,
method: 'POST',
- params: { name: vn, indicatorGroupId: ig, indicatorId: ii, periodTypeId: pt, periodId: p, mapSource: ms, method: 2, classes: c, colorLow: ca, colorHigh: cb, longitude: lon, latitude: lat, zoom: zoom },
+ params: { name: vn, indicatorGroupId: ig, indicatorId: ii, periodTypeId: pt, periodId: p, mapSource: ms, mapLegendType: mlt, method: 2, classes: c, colorLow: ca, colorHigh: cb, mapLegendSetId: mlsid, longitude: lon, latitude: lat, zoom: zoom },
success: function(r) {
Ext.messageBlack.msg('New map view', 'The view <span class="x-msg-hl">' + vn + '</span> was registered.');
@@ -1551,7 +1552,7 @@
title: '<span id="window-legendset-title">Predefined legend sets</span>',
layout: 'fit',
closeAction: 'hide',
- width: 245,
+ width: 311,
items:
[
{
@@ -3619,8 +3620,6 @@
'-',
pdfButton,
'-',
- exportMapButton,
- '-',
favoritesButton,
'-',
automaticMapLegendSetButton,
@@ -3939,27 +3938,6 @@
});
}
-function getExportDataValueJSON( mapvalues ){
- var json = '{';
- json += '"datavalues":';
- json += '[';
- for (var i = 0; i < mapvalues.length; i++) {
- json += '{';
- json += '"organisation": "' + mapvalues[i].orgUnitId + '",';
- json += '"value": "' + mapvalues[i].value + '" ';
- if(i < mapvalues.length-1){
- json += '},';
- }else{
- json += '}';
- }
- }
- json += ']';
- json += '}';
-
- return json;
-
-}
-
/*CHOROPLETH*/
function getChoroplethData() {
MASK.msg = 'Creating choropleth...';
@@ -3980,9 +3958,6 @@
var layers = MAP.getLayersByName('Thematic map');
var features = layers[0].features;
var mapvalues = Ext.util.JSON.decode(r.responseText).mapvalues;
-
- EXPORTVALUES = getExportDataValueJSON( mapvalues );
-
var mv = new Array();
var nameColumn = MAPDATA.nameColumn;
var options = {};
=== 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-03-25 15:27:40 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js 2010-03-25 18:55:29 +0000
@@ -145,6 +145,38 @@
newUrl: false,
+ applyPredefinedLegend: function() {
+ var mls = Ext.getCmp('maplegendset_cb').getValue();
+ var bounds = [];
+ Ext.Ajax.request({
+ url: path + 'getMapLegendsByMapLegendSet' + type,
+ method: 'POST',
+ params: { mapLegendSetId: mls },
+ success: function(r) {
+ var mapLegends = Ext.util.JSON.decode(r.responseText).mapLegends;
+ var colors = [];
+ var bounds = [];
+ for (var i = 0; i < mapLegends.length; i++) {
+ if (bounds[bounds.length-1] != mapLegends[i].startValue) {
+ if (bounds.length != 0) {
+ colors.push(new mapfish.ColorRgb(240,240,240));
+ }
+ bounds.push(mapLegends[i].startValue);
+ }
+ colors.push(new mapfish.ColorRgb());
+ colors[colors.length-1].setFromHex(mapLegends[i].color);
+ bounds.push(mapLegends[i].endValue);
+ }
+ choropleth.colorInterpolation = colors;
+ choropleth.bounds = bounds;
+ choropleth.classify(false);
+ },
+ failure: function() {
+ alert('Error: getMapLegendsByMapLegendSet');
+ }
+ });
+ },
+
initComponent : function() {
mapViewStore = new Ext.data.JsonStore({
@@ -161,17 +193,38 @@
url: path + 'getMapView' + type,
method: 'POST',
params: { id: PARAMETER },
-
- success: function( responseObject ) {
+ success: function(r) {
PARAMETER = false;
- MAPVIEW = Ext.util.JSON.decode(responseObject.responseText).mapView[0];
-
+ MAPVIEW = Ext.util.JSON.decode(r.responseText).mapView[0];
MAPSOURCE = MAPVIEW.mapSourceType;
Ext.getCmp('mapsource_cb').setValue(MAPSOURCE);
Ext.getCmp('mapview_cb').setValue(MAPVIEW.id);
- Ext.getCmp('numClasses').setValue(MAPVIEW.classes);
- Ext.getCmp('colorA_cf').setValue(MAPVIEW.colorLow);
- Ext.getCmp('colorB_cf').setValue(MAPVIEW.colorHigh);
+
+ if (MAPVIEW.mapLegendType == map_legend_type_automatic) {
+ Ext.getCmp('maplegendtype_cb').setValue(map_legend_type_automatic);
+ Ext.getCmp('numClasses').setValue(MAPVIEW.classes);
+ Ext.getCmp('colorA_cf').setValue(MAPVIEW.colorLow);
+ Ext.getCmp('colorB_cf').setValue(MAPVIEW.colorHigh);
+
+ Ext.getCmp('method').show();
+ Ext.getCmp('bounds').hide();
+ Ext.getCmp('numClasses').show();
+ Ext.getCmp('colorA_cf').show();
+ Ext.getCmp('colorB_cf').show();
+ Ext.getCmp('maplegendset_cb').hide();
+ }
+ else if (MAPVIEW.mapLegendType == map_legend_type_predefined) {
+ Ext.getCmp('maplegendtype_cb').setValue(map_legend_type_predefined);
+ Ext.getCmp('method').hide();
+ Ext.getCmp('bounds').hide();
+ Ext.getCmp('numClasses').hide();
+ Ext.getCmp('colorA_cf').hide();
+ Ext.getCmp('colorB_cf').hide();
+ Ext.getCmp('maplegendset_cb').show();
+
+ predefinedMapLegendSetStore.load();
+ }
+
MAP.setCenter(new OpenLayers.LonLat(MAPVIEW.longitude, MAPVIEW.latitude), MAPVIEW.zoom);
Ext.getCmp('indicatorgroup_cb').setValue(MAPVIEW.indicatorGroupId);
@@ -305,9 +358,21 @@
listeners: {
'load': {
fn: function() {
- // if (MAPVIEW) {
- // Ext.getCmp('maplegendset_cb').setValue(MAPVIEW.legendType);
- // }
+ if (MAPVIEW) {
+ Ext.Ajax.request({
+ url: path + 'getMapLegendSet' + type,
+ method: 'POST',
+ params: { mapLegendSetId: MAPVIEW.mapLegendSetId },
+ success: function(r) {
+ var mls = Ext.util.JSON.decode(r.responseText).mapLegendSet[0];
+ Ext.getCmp('maplegendset_cb').setValue(mls.id);
+ choropleth.applyPredefinedLegend();
+ },
+ failure: function() {
+ alert('Error: getMapLegendSet');
+ }
+ });
+ }
}
}
}
@@ -340,14 +405,46 @@
url: path + 'getMapView' + type,
method: 'POST',
params: { id: mId },
-
- success: function( responseObject ) {
- MAPVIEW = Ext.util.JSON.decode(responseObject.responseText).mapView[0];
+ success: function(r) {
+ MAPVIEW = Ext.util.JSON.decode(r.responseText).mapView[0];
MAPSOURCE = MAPVIEW.mapSourceType;
- Ext.getCmp('numClasses').setValue(MAPVIEW.classes);
- Ext.getCmp('colorA_cf').setValue(MAPVIEW.colorLow);
- Ext.getCmp('colorB_cf').setValue(MAPVIEW.colorHigh);
+ if (MAPVIEW.mapLegendType == map_legend_type_automatic) {
+ Ext.getCmp('maplegendtype_cb').setValue(map_legend_type_automatic);
+ Ext.getCmp('numClasses').setValue(MAPVIEW.classes);
+ Ext.getCmp('colorA_cf').setValue(MAPVIEW.colorLow);
+ Ext.getCmp('colorB_cf').setValue(MAPVIEW.colorHigh);
+
+ Ext.getCmp('method').show();
+ Ext.getCmp('bounds').hide();
+ Ext.getCmp('numClasses').show();
+ Ext.getCmp('colorA_cf').show();
+ Ext.getCmp('colorB_cf').show();
+ Ext.getCmp('maplegendset_cb').hide();
+ }
+ else if (MAPVIEW.mapLegendType == map_legend_type_predefined) {
+ Ext.getCmp('maplegendtype_cb').setValue(map_legend_type_predefined);
+ Ext.getCmp('method').hide();
+ Ext.getCmp('bounds').hide();
+ Ext.getCmp('numClasses').hide();
+ Ext.getCmp('colorA_cf').hide();
+ Ext.getCmp('colorB_cf').hide();
+ Ext.getCmp('maplegendset_cb').show();
+ Ext.Ajax.request({
+ url: path + 'getMapLegendSet' + type,
+ method: 'POST',
+ params: { id: MAPVIEW.mapLegendSetId },
+ success: function(r) {
+ var mls = Ext.util.JSON.decode(r.responseText).mapLegendSet[0];
+ Ext.getCmp('maplegendset_cb').setValue(mls.id);
+ choropleth.applyPredefinedLegend();
+ },
+ failure: function() {
+ alert('Error: getMapLegendSet');
+ }
+ });
+ }
+
Ext.getCmp('indicatorgroup_cb').setValue(MAPVIEW.indicatorGroupId);
var igId = Ext.getCmp('indicatorgroup_cb').getValue();
@@ -612,35 +709,7 @@
listeners: {
'select': {
fn: function() {
- var mapLegendSet = Ext.getCmp('maplegendset_cb').getValue();
- var bounds = [];
- Ext.Ajax.request({
- url: path + 'getMapLegendsByMapLegendSet' + type,
- method: 'POST',
- params: { mapLegendSetId: mapLegendSet },
- success: function(r) {
- var mapLegends = Ext.util.JSON.decode(r.responseText).mapLegends;
- var colors = [];
- var bounds = [];
- for (var i = 0; i < mapLegends.length; i++) {
- if (bounds[bounds.length-1] != mapLegends[i].startValue) {
- if (bounds.length != 0) {
- colors.push(new mapfish.ColorRgb(240,240,240));
- }
- bounds.push(mapLegends[i].startValue);
- }
- colors.push(new mapfish.ColorRgb());
- colors[colors.length-1].setFromHex(mapLegends[i].color);
- bounds.push(mapLegends[i].endValue);
- }
- choropleth.colorInterpolation = colors;
- choropleth.bounds = bounds;
- choropleth.classify(false);
- },
- failure: function() {
- alert('Error: getMapLegendsByMapLegendSet');
- }
- });
+ choropleth.applyPredefinedLegend();
},
scope: this
}