← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17185: if featureType is Point in OU, change to MultiPoint when exporting as GeoJson since we don't stor...

 

------------------------------------------------------------
revno: 17185
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-10-21 14:43:54 +0700
message:
  if featureType is Point in OU, change to MultiPoint when exporting as GeoJson since we don't store a single point, but actually an array of points (MultiPoint in GeoJson)
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java


--
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/organisationunit/OrganisationUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2014-10-01 11:05:44 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2014-10-21 07:43:54 +0000
@@ -78,6 +78,7 @@
     public static final String FEATURETYPE_MULTIPOLYGON = "MultiPolygon";
     public static final String FEATURETYPE_POLYGON = "Polygon";
     public static final String FEATURETYPE_POINT = "Point";
+    public static final String FEATURETYPE_MULTIPOINT = "MultiPoint";
     public static final String RESULTTYPE_SYMBOL = "Symbol";
 
     public static final String KEY_USER_ORGUNIT = "USER_ORGUNIT";

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java	2014-10-21 06:26:27 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java	2014-10-21 07:43:54 +0000
@@ -32,6 +32,7 @@
 import com.fasterxml.jackson.core.JsonGenerator;
 import com.google.common.collect.Lists;
 import org.hisp.dhis.common.Pager;
+import org.hisp.dhis.organisationunit.CoordinatesTuple;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.organisationunit.comparator.OrganisationUnitByLevelComparator;
@@ -234,20 +235,20 @@
 
     @RequestMapping( value = "", method = RequestMethod.GET, produces = { "application/json+geo", "application/json+geojson" } )
     public void getGeoJson(
-        @RequestParam( value = "level", defaultValue = "1" ) int pvLevel,
-        @RequestParam( value = "parent", required = false ) String pvParent,
+        @RequestParam( value = "level", defaultValue = "1" ) int rpLevel,
+        @RequestParam( value = "parent", required = false ) String rpParent,
         HttpServletResponse response ) throws IOException
     {
-        OrganisationUnit parent = manager.search( OrganisationUnit.class, pvParent );
+        OrganisationUnit parent = manager.search( OrganisationUnit.class, rpParent );
         List<OrganisationUnit> organisationUnits;
 
         if ( parent != null )
         {
-            organisationUnits = new ArrayList<>( organisationUnitService.getOrganisationUnitsAtLevel( pvLevel, parent ) );
+            organisationUnits = new ArrayList<>( organisationUnitService.getOrganisationUnitsAtLevel( rpLevel, parent ) );
         }
         else
         {
-            organisationUnits = new ArrayList<>( organisationUnitService.getOrganisationUnitsAtLevel( pvLevel ) );
+            organisationUnits = new ArrayList<>( organisationUnitService.getOrganisationUnitsAtLevel( rpLevel ) );
         }
 
         JsonFactory jsonFactory = new JsonFactory();
@@ -277,10 +278,15 @@
 
         String featureType = organisationUnit.getFeatureType();
 
-        if ( OrganisationUnit.FEATURETYPE_POLYGON.equals( featureType ) )
+        // if featureType is anything other than Point (MultiPoint), just assume MultiPolygon
+        if ( !OrganisationUnit.FEATURETYPE_POINT.equals( featureType ) )
         {
             featureType = OrganisationUnit.FEATURETYPE_MULTIPOLYGON;
         }
+        else
+        {
+            featureType = OrganisationUnit.FEATURETYPE_MULTIPOINT;
+        }
 
         generator.writeStartObject();