Changeset 14203 in josm


Ignore:
Timestamp:
2018-08-29T21:15:20+02:00 (3 weeks ago)
Author:
Don-vip
Message:

fix #15696, see #16688 - Don't use the localized decimal separator for coordinates

Location:
trunk/src/org/openstreetmap/josm/data/coor/conversion
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/coor/conversion/AbstractCoordinateFormat.java

    r12735 r14203  
    1717    protected final String displayName;
    1818
    19     /**
    20      * The normal number format for server precision coordinates
    21      */
    22     protected static final DecimalFormat cDdFormatter;
    23     static {
    24         // Don't use the localized decimal separator. This way we can present
    25         // a comma separated list of coordinates.
    26         cDdFormatter = (DecimalFormat) NumberFormat.getInstance(Locale.UK);
    27         cDdFormatter.applyPattern("###0.0######");
    28     }
    29 
     19    /** The normal number format for server precision coordinates */
     20    protected static final DecimalFormat cDdFormatter = newUnlocalizedDecimalFormat("###0.0######");
    3021    /** Character denoting South, as string */
    3122    protected static final String SOUTH = trc("compass", "S");
     
    4031        this.id = id;
    4132        this.displayName = displayName;
     33    }
     34
     35    /**
     36     * Creates a new unlocalized {@link DecimalFormat}.
     37     * By not using the localized decimal separator, we can present a comma separated list of coordinates.
     38     * @param pattern decimal format pattern
     39     * @return {@code DecimalFormat} using dot as decimal separator
     40     * @see DecimalFormat#applyPattern
     41     * @since 14203
     42     */
     43    public static DecimalFormat newUnlocalizedDecimalFormat(String pattern) {
     44        DecimalFormat format = (DecimalFormat) NumberFormat.getInstance(Locale.UK);
     45        format.applyPattern(pattern);
     46        return format;
    4247    }
    4348
  • trunk/src/org/openstreetmap/josm/data/coor/conversion/DMSCoordinateFormat.java

    r12846 r14203  
    1515public class DMSCoordinateFormat extends AbstractCoordinateFormat {
    1616
    17     private static final DecimalFormat DMS_MINUTE_FORMATTER = new DecimalFormat("00");
    18     private static final DecimalFormat DMS_SECOND_FORMATTER = new DecimalFormat(
     17    private static final DecimalFormat DMS_MINUTE_FORMATTER = newUnlocalizedDecimalFormat("00");
     18    private static final DecimalFormat DMS_SECOND_FORMATTER = newUnlocalizedDecimalFormat(
    1919            Config.getPref() == null ? "00.0" : Config.getPref().get("latlon.dms.decimal-format", "00.0"));
    2020    private static final String DMS60 = DMS_SECOND_FORMATTER.format(60.0);
  • trunk/src/org/openstreetmap/josm/data/coor/conversion/NauticalCoordinateFormat.java

    r12846 r14203  
    1414 */
    1515public class NauticalCoordinateFormat extends AbstractCoordinateFormat {
    16     private static final DecimalFormat DM_MINUTE_FORMATTER = new DecimalFormat(
     16    private static final DecimalFormat DM_MINUTE_FORMATTER = newUnlocalizedDecimalFormat(
    1717            Config.getPref() == null ? "00.000" : Config.getPref().get("latlon.dm.decimal-format", "00.000"));
    1818    private static final String DM60 = DM_MINUTE_FORMATTER.format(60.0);
Note: See TracChangeset for help on using the changeset viewer.