← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5382: Map generation: checking for valid feature type

 

------------------------------------------------------------
revno: 5382
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-12-13 11:24:33 +0100
message:
  Map generation: checking for valid feature type
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java
  dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java
  dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/InternalMapLayer.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	2011-12-11 01:24:32 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2011-12-13 10:24:33 +0000
@@ -55,25 +55,19 @@
 @XmlAccessorType( value = XmlAccessType.NONE )
 public class OrganisationUnit extends BaseNameableObject
 {
-    /**
-     * Determines if a de-serialized file is compatible with this class.
-     */
     private static final long serialVersionUID = 1228298379303894619L;
-
+    
     public static final String FEATURETYPE_NONE = "None";
-
     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 RESULTTYPE_SYMBOL = "Symbol";
 
+    private static final List<String> FEATURETYPES = Arrays.asList( FEATURETYPE_NONE, FEATURETYPE_MULTIPOLYGON, FEATURETYPE_POLYGON, FEATURETYPE_POINT );
+    
     private static final Comparator<OrganisationUnit> COMPARATOR = new OrganisationUnitNameComparator();
 
     private static final Pattern JSON_COORDINATE_PATTERN = Pattern.compile( "(\\[{3}.*?\\]{3})" );
-
     private static final Pattern COORDINATE_PATTERN = Pattern.compile( "([\\-0-9.]+,[\\-0-9.]+)" );
 
     private static final String NAME_SEPARATOR = " - ";
@@ -264,6 +258,11 @@
     {
         return coordinates != null && coordinates.trim().length() > 0;
     }
+    
+    public boolean hasFeatureType()
+    {
+        return featureType != null && FEATURETYPES.contains( featureType );
+    }
 
     public List<CoordinatesTuple> getCoordinatesAsList()
     {

=== modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java'
--- dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java	2011-12-13 09:43:27 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java	2011-12-13 10:24:33 +0000
@@ -138,7 +138,6 @@
 
     private InternalMapLayer buildSingleInternalMapLayer( MapView mapView )
     {
-
         Assert.isTrue( mapView != null );
         Assert.isTrue( mapView.getMapValueType() != null );
 
@@ -184,8 +183,7 @@
 
         // Get the aggregated map values
         // TODO Might make version of getIndicatorMapValues that takes Indicator
-        // and
-        // parent OrganisationUnit *directly*, i.e. not from ID-s, since we have
+        // and parent OrganisationUnit *directly*, i.e. not from ID-s, since we have
         // them
         // NOTE There is no need to provide startDate and endDate as period is
         // set
@@ -222,7 +220,6 @@
     private List<GeoToolsMapObject> buildGeoToolsMapObjectsForMapLayer( InternalMapLayer mapLayer,
         Collection<AggregatedMapValue> mapValues )
     {
-
         // Create a list of map objects
         List<GeoToolsMapObject> mapObjects = new LinkedList<GeoToolsMapObject>();
 
@@ -232,7 +229,7 @@
             // Get the org unit for this map value
             OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( mapValue.getOrganisationUnitId() );
 
-            if ( orgUnit != null && orgUnit.hasCoordinates() )
+            if ( orgUnit != null && orgUnit.hasCoordinates() && orgUnit.hasFeatureType() )
             {
                 mapObjects.add( buildSingleGeoToolsMapObjectForMapLayer( mapLayer, mapValue, orgUnit ) );
             }
@@ -267,7 +264,6 @@
 
     private BufferedImage combineLegendAndMapImages( BufferedImage legendImage, BufferedImage mapImage )
     {
-
         Assert.isTrue( legendImage != null );
         Assert.isTrue( mapImage != null );
         Assert.isTrue( legendImage.getType() == mapImage.getType() );

=== modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/InternalMapLayer.java'
--- dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/InternalMapLayer.java	2011-12-13 09:43:27 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/InternalMapLayer.java	2011-12-13 10:24:33 +0000
@@ -79,8 +79,6 @@
      */
     public InternalMapLayer()
     {
-
-        // Create a new list for the map objects in this map layer
         this.mapObjects = new ArrayList<InternalMapObject>();
     }
 
@@ -90,7 +88,6 @@
      */
     public void applyInterpolatedRadii()
     {
-
         Assert.isTrue( mapObjects != null );
         Assert.isTrue( mapObjects.size() > 0 );