dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32169
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16437: GIS module geojson action -> api geofeatures.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 16437 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-08-18 15:44:00 +0200
message:
GIS module geojson action -> api geofeatures.
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/GeoFeatureController.java
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/core/GeoStat/all.js
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/plugin.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-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/GeoFeatureController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/GeoFeatureController.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/GeoFeatureController.java 2014-08-18 13:24:55 +0000
@@ -139,7 +139,7 @@
if ( group != null )
{
- feature.getDimensions().put( groupSet.getUid(), group.getUid() );
+ feature.getDimensions().put( groupSet.getUid(), group.getName() );
}
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js 2014-08-13 15:53:39 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/core.js 2014-08-18 13:24:55 +0000
@@ -1339,13 +1339,15 @@
loadOrganisationUnits = function(view) {
var items = view.rows[0].items,
+ isPlugin = GIS.plugin && !GIS.app,
url = function() {
- var params = '';
+ var params = '?ou=ou:';
for (var i = 0; i < items.length; i++) {
- params += 'ids=' + items[i].id;
- params += i !== items.length - 1 ? '&' : '';
+ params += items[i].id;
+ params += i !== items.length - 1 ? ';' : '';
}
- return gis.init.contextPath + gis.conf.finals.url.path_module + 'getGeoJsonFacilities.action?' + params;
+
+ return gis.init.contextPath + '/api/geoFeatures.' + (isPlugin ? 'jsonp' : 'json') + params + '&viewClass=detailed';
}(),
success,
failure;
@@ -1606,13 +1608,14 @@
loadOrganisationUnits = function(view) {
var items = view.rows[0].items,
+ isPlugin = GIS.plugin && !GIS.app,
url = function() {
- var params = '';
+ var params = '?ou=ou:';
for (var i = 0; i < items.length; i++) {
- params += 'ids=' + items[i].id;
- params += i !== items.length - 1 ? '&' : '';
+ params += items[i].id;
+ params += i !== items.length - 1 ? ';' : '';
}
- return gis.init.contextPath + gis.conf.finals.url.path_module + 'getGeoJson.action?' + params;
+ return gis.init.contextPath + '/api/geoFeatures.' + (isPlugin ? 'jsonp' : 'json') + params;
}(),
success,
failure;
@@ -1676,7 +1679,7 @@
alert(GIS.i18n.coordinates_could_not_be_loaded);
};
- if (GIS.plugin && !GIS.app) {
+ if (isPlugin) {
Ext.data.JsonP.request({
url: url,
disableCaching: false,
@@ -1949,13 +1952,14 @@
loadOrganisationUnits = function(view) {
var items = view.rows[0].items,
- url = function() {
- var params = '';
+ isPlugin = GIS.plugin && !GIS.app,
+ url = function() {
+ var params = '?ou=ou:';
for (var i = 0; i < items.length; i++) {
- params += 'ids=' + items[i].id;
- params += i !== items.length - 1 ? '&' : '';
+ params += items[i].id;
+ params += i !== items.length - 1 ? ';' : '';
}
- return gis.init.contextPath + gis.conf.finals.url.path_module + 'getGeoJson.action?' + params;
+ return gis.init.contextPath + '/api/geoFeatures.' + (isPlugin ? 'jsonp' : 'json') + params;
}(),
success,
failure;
@@ -1987,7 +1991,7 @@
alert(GIS.i18n.coordinates_could_not_be_loaded);
};
- if (GIS.plugin && !GIS.app) {
+ if (isPlugin) {
Ext.data.JsonP.request({
url: url,
disableCaching: false,
@@ -2610,7 +2614,7 @@
util.geojson = {};
- util.geojson.decode = function(doc, levelOrder) {
+ util.geojson.decode = function(organisationUnits, levelOrder) {
var geojson = {
type: 'FeatureCollection',
crs: {
@@ -2625,26 +2629,43 @@
levelOrder = levelOrder || 'ASC';
// sort
- doc.geojson = util.array.sort(doc.geojson, levelOrder, 'le');
-
- for (var i = 0; i < doc.geojson.length; i++) {
+ organisationUnits = util.array.sort(organisationUnits, levelOrder, 'le');
+
+ for (var i = 0, ou, gpid = '', gppg = ''; i < organisationUnits.length; i++) {
+ ou = organisationUnits[i];
+
+ // grand parent
+ if (Ext.isString(ou.pg) && ou.pg.length) {
+ var ids = Ext.Array.clean(ou.pg.split('/'));
+
+ // grand parent id
+ if (ids.length >= 2) {
+ gpid = ids[ids.length - 2];
+ }
+
+ // grand parent parentgraph
+ if (ids.length > 2) {
+ gppg = '/' + ids.slice(0, ids.length - 2).join('/');
+ }
+ }
+
geojson.features.push({
+ type: 'Feature',
geometry: {
- type: parseInt(doc.geojson[i].ty) === 1 ? 'MultiPolygon' : 'Point',
- coordinates: doc.geojson[i].co
+ type: parseInt(ou.ty) === 1 ? 'Point' : 'MultiPolygon',
+ coordinates: JSON.parse(ou.co)
},
properties: {
- id: doc.geojson[i].uid,
- internalId: doc.geojson[i].iid,
- name: doc.geojson[i].na,
- hasCoordinatesDown: doc.geojson[i].hcd,
- hasCoordinatesUp: doc.geojson[i].hcu,
- level: doc.geojson[i].le,
- grandParentParentGraph: doc.geojson[i].gppg,
- grandParentId: doc.geojson[i].gpuid,
- parentGraph: doc.geojson[i].parentGraph,
- parentId: doc.geojson[i].pi,
- parentName: doc.geojson[i].pn
+ id: ou.id,
+ name: ou.na,
+ hasCoordinatesDown: ou.hcd,
+ hasCoordinatesUp: ou.hcu,
+ level: ou.le,
+ grandParentParentGraph: gppg,
+ grandParentId: gpid,
+ parentGraph: ou.pg,
+ parentId: ou.pi,
+ parentName: ou.pn
}
});
}
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/core/GeoStat/all.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/core/GeoStat/all.js 2014-07-02 16:07:40 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/mapfish/core/GeoStat/all.js 2014-08-18 13:24:55 +0000
@@ -58,7 +58,7 @@
return GIS.core.LayerLoaderFacility(this.gis, this.layer);
},
- decode: function(doc) {
+ decode: function(organisationUnits) {
var feature,
group,
attr,
@@ -73,21 +73,21 @@
features: []
};
- for (var i = 0; i < doc.geojson.length; i++) {
- attr = doc.geojson[i];
+ for (var i = 0; i < organisationUnits.length; i++) {
+ attr = organisationUnits[i];
feature = {
+ type: 'Feature',
geometry: {
- type: parseInt(attr.ty) === 1 ? 'MultiPolygon' : 'Point',
- coordinates: attr.co
+ type: parseInt(attr.ty) === 1 ? 'Point' : 'MultiPolygon',
+ coordinates: JSON.parse(attr.co)
},
properties: {
- id: attr.uid,
- internalId: attr.iid,
+ id: attr.id,
name: attr.na
}
};
- feature.properties = Ext.Object.merge(feature.properties, attr.groupSets);
+ feature.properties = Ext.Object.merge(feature.properties, attr.dimensions);
geojson.features.push(feature);
}
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/plugin.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/plugin.js 2014-08-10 20:57:05 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/scripts/plugin.js 2014-08-18 13:24:55 +0000
@@ -774,21 +774,19 @@
store: {
fields: ['id', 'name'],
data: function() {
- var pt = new PeriodType(),
- periodType = gis.init.systemSettings.infrastructuralPeriodType.id,
- data;
-
- data = pt.get(periodType).generatePeriods({
- offset: 0,
- filterFuturePeriods: true,
- reversePeriods: true
- });
-
- if (Ext.isArray(data) && data.length) {
- data = data.slice(0,5);
+ var periodType = gis.init.systemSettings.infrastructuralPeriodType.id,
+ generator = gis.init.periodGenerator,
+ periods = generator.filterFuturePeriodsExceptCurrent(generator.generateReversedPeriods(periodType, this.periodOffset)) || [];
+
+ if (Ext.isArray(periods) && periods.length) {
+ for (var i = 0; i < periods.length; i++) {
+ periods[i].id = periods[i].iso;
+ }
+
+ periods = periods.slice(0,5);
}
- return data;
+ return periods;
}()
},
lockPosition: false,
@@ -1135,7 +1133,7 @@
fillOpacity: 1,
strokeColor: '#fff',
strokeWidth: 1,
- pointRadius: 5,
+ pointRadius: 8,
labelAlign: 'cr',
labelYOffset: 13,
fontFamily: 'arial,sans-serif,roboto,helvetica neue,helvetica,consolas'
@@ -1144,7 +1142,7 @@
fillOpacity: 0.9,
strokeColor: '#fff',
strokeWidth: 1,
- pointRadius: 5,
+ pointRadius: 8,
cursor: 'pointer',
labelAlign: 'cr',
labelYOffset: 13
@@ -1733,13 +1731,15 @@
loadOrganisationUnits = function(view) {
var items = view.rows[0].items,
+ isPlugin = GIS.plugin && !GIS.app,
url = function() {
- var params = '';
+ var params = '?ou=ou:';
for (var i = 0; i < items.length; i++) {
- params += 'ids=' + items[i].id;
- params += i !== items.length - 1 ? '&' : '';
+ params += items[i].id;
+ params += i !== items.length - 1 ? ';' : '';
}
- return gis.init.contextPath + gis.conf.finals.url.path_module + 'getGeoJsonFacilities.action?' + params;
+
+ return gis.init.contextPath + '/api/geoFeatures.' + (isPlugin ? 'jsonp' : 'json') + params + '&viewClass=detailed';
}(),
success,
failure;
@@ -1808,7 +1808,7 @@
loadLegend = function(view) {
var isPlugin = GIS.plugin && !GIS.app,
type = isPlugin ? 'jsonp' : 'json',
- url = gis.init.contextPath + '/api/organisationUnitGroupSets/' + view.organisationUnitGroupSet.id + '.' + type + '?fields=organisationUnitGroups[id,name]',
+ url = gis.init.contextPath + '/api/organisationUnitGroupSets/' + view.organisationUnitGroupSet.id + '.' + type + '?fields=organisationUnitGroups[id,name,symbol]',
success;
view = view || layer.core.view;
@@ -2000,13 +2000,14 @@
loadOrganisationUnits = function(view) {
var items = view.rows[0].items,
+ isPlugin = GIS.plugin && !GIS.app,
url = function() {
- var params = '';
+ var params = '?ou=ou:';
for (var i = 0; i < items.length; i++) {
- params += 'ids=' + items[i].id;
- params += i !== items.length - 1 ? '&' : '';
+ params += items[i].id;
+ params += i !== items.length - 1 ? ';' : '';
}
- return gis.init.contextPath + gis.conf.finals.url.path_module + 'getGeoJson.action?' + params;
+ return gis.init.contextPath + '/api/geoFeatures.' + (isPlugin ? 'jsonp' : 'json') + params;
}(),
success,
failure;
@@ -2070,7 +2071,7 @@
alert(GIS.i18n.coordinates_could_not_be_loaded);
};
- if (GIS.plugin && !GIS.app) {
+ if (isPlugin) {
Ext.data.JsonP.request({
url: url,
disableCaching: false,
@@ -2343,13 +2344,14 @@
loadOrganisationUnits = function(view) {
var items = view.rows[0].items,
- url = function() {
- var params = '';
+ isPlugin = GIS.plugin && !GIS.app,
+ url = function() {
+ var params = '?ou=ou:';
for (var i = 0; i < items.length; i++) {
- params += 'ids=' + items[i].id;
- params += i !== items.length - 1 ? '&' : '';
+ params += items[i].id;
+ params += i !== items.length - 1 ? ';' : '';
}
- return gis.init.contextPath + gis.conf.finals.url.path_module + 'getGeoJson.action?' + params;
+ return gis.init.contextPath + '/api/geoFeatures.' + (isPlugin ? 'jsonp' : 'json') + params;
}(),
success,
failure;
@@ -2381,7 +2383,7 @@
alert(GIS.i18n.coordinates_could_not_be_loaded);
};
- if (GIS.plugin && !GIS.app) {
+ if (isPlugin) {
Ext.data.JsonP.request({
url: url,
disableCaching: false,
@@ -3004,7 +3006,7 @@
util.geojson = {};
- util.geojson.decode = function(doc, levelOrder) {
+ util.geojson.decode = function(organisationUnits, levelOrder) {
var geojson = {
type: 'FeatureCollection',
crs: {
@@ -3019,26 +3021,43 @@
levelOrder = levelOrder || 'ASC';
// sort
- doc.geojson = util.array.sort(doc.geojson, levelOrder, 'le');
-
- for (var i = 0; i < doc.geojson.length; i++) {
+ organisationUnits = util.array.sort(organisationUnits, levelOrder, 'le');
+
+ for (var i = 0, ou, gpid = '', gppg = ''; i < organisationUnits.length; i++) {
+ ou = organisationUnits[i];
+
+ // grand parent
+ if (Ext.isString(ou.pg) && ou.pg.length) {
+ var ids = Ext.Array.clean(ou.pg.split('/'));
+
+ // grand parent id
+ if (ids.length >= 2) {
+ gpid = ids[ids.length - 2];
+ }
+
+ // grand parent parentgraph
+ if (ids.length > 2) {
+ gppg = '/' + ids.slice(0, ids.length - 2).join('/');
+ }
+ }
+
geojson.features.push({
+ type: 'Feature',
geometry: {
- type: parseInt(doc.geojson[i].ty) === 1 ? 'MultiPolygon' : 'Point',
- coordinates: doc.geojson[i].co
+ type: parseInt(ou.ty) === 1 ? 'Point' : 'MultiPolygon',
+ coordinates: JSON.parse(ou.co)
},
properties: {
- id: doc.geojson[i].uid,
- internalId: doc.geojson[i].iid,
- name: doc.geojson[i].na,
- hasCoordinatesDown: doc.geojson[i].hcd,
- hasCoordinatesUp: doc.geojson[i].hcu,
- level: doc.geojson[i].le,
- grandParentParentGraph: doc.geojson[i].gppg,
- grandParentId: doc.geojson[i].gpuid,
- parentGraph: doc.geojson[i].parentGraph,
- parentId: doc.geojson[i].pi,
- parentName: doc.geojson[i].pn
+ id: ou.id,
+ name: ou.na,
+ hasCoordinatesDown: ou.hcd,
+ hasCoordinatesUp: ou.hcu,
+ level: ou.le,
+ grandParentParentGraph: gppg,
+ grandParentId: gpid,
+ parentGraph: ou.pg,
+ parentId: ou.pi,
+ parentName: ou.pn
}
});
}