dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27559
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13724: csd: support for geocode if featuretype=point
------------------------------------------------------------
revno: 13724
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-01-14 19:35:08 +0700
message:
csd: support for geocode if featuretype=point
modified:
dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/webapi/CsdController.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/csd/webapi/CsdController.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/webapi/CsdController.java 2014-01-14 10:37:53 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/csd/webapi/CsdController.java 2014-01-14 12:35:08 +0000
@@ -35,9 +35,11 @@
import org.hisp.dhis.web.csd.domain.csd.CodedType;
import org.hisp.dhis.web.csd.domain.csd.Csd;
import org.hisp.dhis.web.csd.domain.csd.Facility;
+import org.hisp.dhis.web.csd.domain.csd.Geocode;
import org.hisp.dhis.web.csd.domain.csd.Organization;
import org.hisp.dhis.web.csd.domain.csd.OtherID;
import org.hisp.dhis.web.csd.domain.csd.Record;
+import org.hisp.dhis.web.fred.webapi.v1.utils.GeoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
@@ -117,6 +119,24 @@
Organization organization = new Organization( "1.3.6.1.4.1.21367.200.99.1" );
facility.getOrganizations().add( organization );
+ if ( OrganisationUnit.FEATURETYPE_POINT.equals( organisationUnit.getFeatureType() ) )
+ {
+ Geocode geocode = new Geocode();
+
+ try
+ {
+ GeoUtils.Coordinates coordinates = GeoUtils.parseCoordinates( organisationUnit.getCoordinates() );
+
+ geocode.setLongitude( coordinates.lng );
+ geocode.setLatitude( coordinates.lat );
+ }
+ catch ( NumberFormatException ignored )
+ {
+ }
+
+ facility.setGeocode( geocode );
+ }
+
Record record = new Record();
record.setCreated( organisationUnit.getCreated() );
record.setUpdated( organisationUnit.getLastUpdated() );