=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ConversionUtils.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ConversionUtils.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ConversionUtils.java 2010-10-29 15:58:05 +0000 @@ -35,6 +35,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * @author Lars Helge Overland @@ -245,4 +247,25 @@ return array; } + + /** + * Strips the number of decimals to a maximum of 4. The string must be on the + * form .,. + * + * @param coordinates the coordinates string. + * @return the stripped coordinates string. + */ + public static String stripCoordinates( String coordinates ) + { + final int decimals = 4; + + if ( coordinates != null ) + { + Matcher matcher = Pattern.compile( "\\d+\\.\\d{0," + decimals + "}" ).matcher( coordinates ); + matcher.find(); + return matcher.group() + "," + matcher.group(); + } + + return null; + } }