dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16636
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6367: Coerced coordinate parsing in GML import to always use decimal point (rather than comma) regardle...
------------------------------------------------------------
revno: 6367
committer: Bob Jolliffe <bobjolliffe@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-03-23 15:55:20 +0000
message:
Coerced coordinate parsing in GML import to always use decimal point (rather than comma) regardless of system locale.
modified:
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/Util.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-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/Util.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/Util.java 2011-10-28 12:24:59 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/Util.java 2012-03-23 15:55:20 +0000
@@ -1,7 +1,10 @@
package org.hisp.dhis.importexport.xml;
+import java.text.NumberFormat;
+import java.text.ParseException;
import java.util.Calendar;
import java.util.GregorianCalendar;
+import java.util.Locale;
/*
* Copyright (c) 2004-2005, University of Oslo
@@ -70,8 +73,11 @@
* @param coordinates
* @return
*/
- public static String gmlToCoords(String coordinates, String decimalPlacesAsString)
+ public static String gmlToCoords(String coordinates, String decimalPlacesAsString)
+ throws ParseException
{
+ NumberFormat nf = NumberFormat.getInstance(Locale.FRANCE);
+
int decimalPlaces = Integer.parseInt( decimalPlacesAsString);
String formatString = "%."+decimalPlaces+"f,%."+decimalPlaces+"f";
StringBuilder sb = new StringBuilder();
@@ -80,8 +86,8 @@
for (String coordAsString : coords)
{
String[] latlon = coordAsString.split( ",");
- double lat = Double.parseDouble( latlon[0] );
- double lon = Double.parseDouble( latlon[1] );
+ double lat = nf.parse( latlon[0] ).doubleValue();
+ double lon = nf.parse( latlon[1] ).doubleValue();
sb.append( "<coord>");
sb.append( String.format(formatString, lat, lon));
sb.append( "</coord>");