← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9227: FRED-API: coordinate fixes

 

------------------------------------------------------------
revno: 9227
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2012-12-08 20:25:09 +0300
message:
  FRED-API: coordinate fixes
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/webapp/WEB-INF/api-fred-velocity/v1/facilities.vm
  dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/layout.vm
  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 16:07:13 +0000
+++ 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
@@ -81,21 +81,21 @@
                 }
                 else if ( to == CoordinateOrder.COORDINATE_LNGLAT )
                 {
-                    coordinates.lat = convertToDouble( list.get( 1 ) );
-                    coordinates.lng = convertToDouble( list.get( 0 ) );
+                    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( 0 ) );
-                    coordinates.lng = convertToDouble( list.get( 1 ) );
+                    coordinates.lat = convertToDouble( list.get( 1 ) );
+                    coordinates.lng = convertToDouble( list.get( 0 ) );
                 }
                 else if ( to == CoordinateOrder.COORDINATE_LNGLAT )
                 {
-                    coordinates.lat = convertToDouble( list.get( 0 ) );
-                    coordinates.lng = convertToDouble( list.get( 1 ) );
+                    coordinates.lat = convertToDouble( list.get( 1 ) );
+                    coordinates.lng = convertToDouble( list.get( 0 ) );
                 }
             }
         }

=== 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-07 20:03:51 +0000
+++ 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
@@ -61,7 +61,10 @@
         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/webapp/WEB-INF/api-fred-velocity/v1/facilities.vm'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facilities.vm	2012-12-08 16:07:13 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/facilities.vm	2012-12-08 17:25:09 +0000
@@ -42,14 +42,28 @@
     <a href="facilities.json" class="btn btn-small btn-info" style="margin-bottom: 5px;">
         <span class="icon-white icon-download-alt"> </span> JSON
     </a>
-
-    <!-- future feature
-    <button id="mapFacilities" disabled="disabled" class="btn btn-small btn-info" style="margin-bottom: 5px;">
-        <span class="icon-white icon-map-marker"> </span> Show in map
-    </button>
-    -->
-</div>
-
+</div>
+
+<div class="tabbable">
+  <ul class="nav nav-tabs">
+    <li class="active"><a href="#listTab" data-toggle="tab"><span class="icon-list-alt"> </span> List</a></li>
+    <li><a href="#mapTab" data-toggle="tab"><span class="icon-globe"> </span> Map</a></li>
+  </ul>
+
+  <div class="tab-content">
+
+    <div class="tab-pane active" id="listTab">
+        #listContent()
+    </div>
+
+    <div class="tab-pane" id="mapTab">
+        #mapContent()
+    </div>
+  </div>
+
+</div>
+
+#macro( listContent )
 <table class="table table-bordered table-striped table-condensed">
     <thead>
     <tr>
@@ -83,3 +97,10 @@
         #end
     </tbody>
 </table>
+#end
+
+#macro( mapContent )
+<div class="span12 well" style="padding: 4px;">
+    <div style="height: 680px;" id="mapTarget"></div>
+</div>
+#end

=== modified file 'dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/layout.vm'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/layout.vm	2012-12-08 07:58:59 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/webapp/WEB-INF/api-fred-velocity/v1/layout.vm	2012-12-08 17:25:09 +0000
@@ -38,7 +38,7 @@
             <div class="nav-collapse collapse">
                 <ul class="nav">
                     <li #if( $pageName == "home" )class="active"#end><a href="$baseUrl"><span class="icon-home"> </span> Home</a></li>
-                    <li #if( $pageName == "facilities" )class="active"#end><a href="$baseUrl/facilities"><span class="icon-leaf"> </span> Facilities</a></li>
+                    <li #if( $pageName == "facilities" )class="active"#end><a href="$baseUrl/facilities"><span class="icon-list-alt"> </span> Facilities</a></li>
                 </ul>
             </div>
         </div>

=== 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 16:07:13 +0000
+++ 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
@@ -56,7 +56,7 @@
         Double lat = 1.0d;
         Double lng = 2.0d;
 
-        String coordinatesString = String.format( "[%f, %f]", lat, lng );
+        String coordinatesString = String.format( "[%f, %f]", lng, lat );
 
         GeoUtils.Coordinates coordinates = GeoUtils.parseCoordinates( coordinatesString, GeoUtils.CoordinateOrder.COORDINATE_LNGLAT,
             GeoUtils.CoordinateOrder.COORDINATE_LNGLAT );
@@ -76,8 +76,8 @@
         GeoUtils.Coordinates coordinates = GeoUtils.parseCoordinates( coordinatesString, GeoUtils.CoordinateOrder.COORDINATE_LATLNG,
             GeoUtils.CoordinateOrder.COORDINATE_LNGLAT );
 
-        Assert.assertEquals( lat, coordinates.lng );
-        Assert.assertEquals( lng, coordinates.lat );
+        Assert.assertEquals( lat, coordinates.lat );
+        Assert.assertEquals( lng, coordinates.lng );
     }
 
     @Test
@@ -91,7 +91,7 @@
         GeoUtils.Coordinates coordinates = GeoUtils.parseCoordinates( coordinatesString, GeoUtils.CoordinateOrder.COORDINATE_LNGLAT,
             GeoUtils.CoordinateOrder.COORDINATE_LATLNG );
 
-        Assert.assertEquals( lng, coordinates.lat );
-        Assert.assertEquals( lat, coordinates.lng );
+        Assert.assertEquals( lng, coordinates.lng );
+        Assert.assertEquals( lat, coordinates.lat );
     }
 }