← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9228: minor fix

 

------------------------------------------------------------
revno: 9228
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2012-12-08 23:35:51 +0300
message:
  minor fix
modified:
  dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/GeoUtils.java
  dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/ToFacilityConverter.java
  dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/ToOrganisationUnitConverter.java
  dhis-2/dhis-web/dhis-web-api-fred/src/test/java/org/hisp/dhis/web/webapi/v1/utils/GeoUtilsTest.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-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/GeoUtils.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/GeoUtils.java	2012-12-08 17:25:09 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/GeoUtils.java	2012-12-08 20:35:51 +0000
@@ -61,10 +61,10 @@
     // helper for most common case, our internal lnglat to latlng
     public static Coordinates parseCoordinates( String coordinatesString )
     {
-        return parseCoordinates( coordinatesString, CoordinateOrder.COORDINATE_LNGLAT, CoordinateOrder.COORDINATE_LATLNG );
+        return parseCoordinates( coordinatesString, CoordinateOrder.COORDINATE_LNGLAT );
     }
 
-    public static Coordinates parseCoordinates( String coordinatesString, CoordinateOrder from, CoordinateOrder to )
+    public static Coordinates parseCoordinates( String coordinatesString, CoordinateOrder from )
     {
         Coordinates coordinates = new Coordinates();
 
@@ -74,29 +74,13 @@
 
             if ( from == CoordinateOrder.COORDINATE_LATLNG )
             {
-                if ( to == CoordinateOrder.COORDINATE_LATLNG )
-                {
-                    coordinates.lat = convertToDouble( list.get( 0 ) );
-                    coordinates.lng = convertToDouble( list.get( 1 ) );
-                }
-                else if ( to == CoordinateOrder.COORDINATE_LNGLAT )
-                {
-                    coordinates.lat = convertToDouble( list.get( 0 ) );
-                    coordinates.lng = convertToDouble( list.get( 1 ) );
-                }
+                coordinates.lat = convertToDouble( list.get( 0 ) );
+                coordinates.lng = convertToDouble( list.get( 1 ) );
             }
             else if ( from == CoordinateOrder.COORDINATE_LNGLAT )
             {
-                if ( to == CoordinateOrder.COORDINATE_LATLNG )
-                {
-                    coordinates.lat = convertToDouble( list.get( 1 ) );
-                    coordinates.lng = convertToDouble( list.get( 0 ) );
-                }
-                else if ( to == CoordinateOrder.COORDINATE_LNGLAT )
-                {
-                    coordinates.lat = convertToDouble( list.get( 1 ) );
-                    coordinates.lng = convertToDouble( list.get( 0 ) );
-                }
+                coordinates.lat = convertToDouble( list.get( 1 ) );
+                coordinates.lng = convertToDouble( list.get( 0 ) );
             }
         }
         catch ( Exception ignored )

=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/ToFacilityConverter.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/ToFacilityConverter.java	2012-12-08 17:25:09 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/ToFacilityConverter.java	2012-12-08 20:35:51 +0000
@@ -61,9 +61,7 @@
         if ( organisationUnit.getFeatureType() != null && organisationUnit.getFeatureType().equalsIgnoreCase( "POINT" )
             && organisationUnit.getCoordinates() != null )
         {
-            System.err.println( "INPUT: " + organisationUnit.getCoordinates() );
             GeoUtils.Coordinates coordinates = GeoUtils.parseCoordinates( organisationUnit.getCoordinates() );
-            System.err.println( "OUTPUT: " + coordinates );
 
             facility.getCoordinates().add( coordinates.lat );
             facility.getCoordinates().add( coordinates.lng );

=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/ToOrganisationUnitConverter.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/ToOrganisationUnitConverter.java	2012-12-08 16:49:44 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/utils/ToOrganisationUnitConverter.java	2012-12-08 20:35:51 +0000
@@ -87,7 +87,7 @@
         organisationUnit.setFeatureType( OrganisationUnit.FEATURETYPE_POINT );
 
         GeoUtils.Coordinates coordinates = GeoUtils.parseCoordinates(
-            facility.getCoordinates().toString(), GeoUtils.CoordinateOrder.COORDINATE_LATLNG, GeoUtils.CoordinateOrder.COORDINATE_LNGLAT );
+            facility.getCoordinates().toString(), GeoUtils.CoordinateOrder.COORDINATE_LATLNG );
 
         organisationUnit.setCoordinates( String.format( "[%f, %f]", coordinates.lng, coordinates.lat ) );
 

=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/test/java/org/hisp/dhis/web/webapi/v1/utils/GeoUtilsTest.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/test/java/org/hisp/dhis/web/webapi/v1/utils/GeoUtilsTest.java	2012-12-08 17:25:09 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/test/java/org/hisp/dhis/web/webapi/v1/utils/GeoUtilsTest.java	2012-12-08 20:35:51 +0000
@@ -36,62 +36,30 @@
 public class GeoUtilsTest
 {
     @Test
-    public void latToLat()
-    {
-        Double lat = 1.0d;
-        Double lng = 2.0d;
-
-        String coordinatesString = String.format( "[%f, %f]", lat, lng );
-
-        GeoUtils.Coordinates coordinates = GeoUtils.parseCoordinates( coordinatesString, GeoUtils.CoordinateOrder.COORDINATE_LATLNG,
-            GeoUtils.CoordinateOrder.COORDINATE_LATLNG );
-
-        Assert.assertEquals( lat, coordinates.lat );
-        Assert.assertEquals( lng, coordinates.lng );
-    }
-
-    @Test
-    public void lngToLng()
-    {
-        Double lat = 1.0d;
-        Double lng = 2.0d;
-
-        String coordinatesString = String.format( "[%f, %f]", lng, lat );
-
-        GeoUtils.Coordinates coordinates = GeoUtils.parseCoordinates( coordinatesString, GeoUtils.CoordinateOrder.COORDINATE_LNGLAT,
-            GeoUtils.CoordinateOrder.COORDINATE_LNGLAT );
-
-        Assert.assertEquals( lng, coordinates.lng );
-        Assert.assertEquals( lat, coordinates.lat );
-    }
-
-    @Test
-    public void latToLng()
-    {
-        Double lat = 1.0d;
-        Double lng = 2.0d;
-
-        String coordinatesString = String.format( "[%f, %f]", lat, lng );
-
-        GeoUtils.Coordinates coordinates = GeoUtils.parseCoordinates( coordinatesString, GeoUtils.CoordinateOrder.COORDINATE_LATLNG,
-            GeoUtils.CoordinateOrder.COORDINATE_LNGLAT );
-
-        Assert.assertEquals( lat, coordinates.lat );
-        Assert.assertEquals( lng, coordinates.lng );
-    }
-
-    @Test
-    public void lngToLat()
-    {
-        Double lat = 1.0d;
-        Double lng = 2.0d;
-
-        String coordinatesString = String.format( "[%f, %f]", lng, lat );
-
-        GeoUtils.Coordinates coordinates = GeoUtils.parseCoordinates( coordinatesString, GeoUtils.CoordinateOrder.COORDINATE_LNGLAT,
-            GeoUtils.CoordinateOrder.COORDINATE_LATLNG );
-
-        Assert.assertEquals( lng, coordinates.lng );
-        Assert.assertEquals( lat, coordinates.lat );
+    public void fromLatLng()
+    {
+        Double lat = 1.0d;
+        Double lng = 2.0d;
+
+        String coordinatesString = String.format( "[%f, %f]", lat, lng );
+
+        GeoUtils.Coordinates coordinates = GeoUtils.parseCoordinates( coordinatesString, GeoUtils.CoordinateOrder.COORDINATE_LATLNG );
+
+        Assert.assertEquals( lat, coordinates.lat );
+        Assert.assertEquals( lng, coordinates.lng );
+    }
+
+    @Test
+    public void fromLngLat()
+    {
+        Double lat = 1.0d;
+        Double lng = 2.0d;
+
+        String coordinatesString = String.format( "[%f, %f]", lng, lat );
+
+        GeoUtils.Coordinates coordinates = GeoUtils.parseCoordinates( coordinatesString, GeoUtils.CoordinateOrder.COORDINATE_LNGLAT );
+
+        Assert.assertEquals( lat, coordinates.lat );
+        Assert.assertEquals( lng, coordinates.lng );
     }
 }