Changeset 3412 in josm


Ignore:
Timestamp:
2010-08-03T23:53:21+02:00 (14 years ago)
Author:
bastiK
Message:

fixed #3187 - Feature request: coordinates also in degrees minutes

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

Legend:

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

    r3083 r3412  
    1616
    1717    /**
    18      * the minutes/seconds format 99" 99'
     18     * the degrees/minutes/seconds format 9° 99" 99'
    1919     */
    20     DEGREES_MINUTES_SECONDS (tr("Degrees Minutes Seconds")),
    21 
     20    DEGREES_MINUTES_SECONDS (tr("deg\u00B0 min'' sec\"")),
     21   
     22    /**
     23     * the nautical format
     24     */
     25    NAUTICAL (tr("deg\u00B0 min'' (Nautical)")),
     26   
    2227    /**
    2328     * coordinates East/North
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r3411 r3412  
    3535    private static DecimalFormat cDmsMinuteFormatter = new DecimalFormat("00");
    3636    private static DecimalFormat cDmsSecondFormatter = new DecimalFormat("00.0");
     37    private static DecimalFormat cDmMinuteFormatter = new DecimalFormat("00.000");
    3738    public static DecimalFormat cDdFormatter;
    3839    static {
     
    7879    }
    7980
     81    public static String dm(double pCoordinate) {
     82
     83        double tAbsCoord = Math.abs(pCoordinate);
     84        int tDegree = (int) tAbsCoord;
     85        double tMinutes = (tAbsCoord - tDegree) * 60;
     86        return tDegree + "\u00B0" + cDmMinuteFormatter.format(tMinutes) + "\'";
     87    }
     88
    8089    public LatLon(double lat, double lon) {
    8190        super(lon, lat);
     
    9099    }
    91100
     101    private final static String SOUTH = trc("compass", "S");
     102    private final static String NORTH = trc("compass", "N");
    92103    public String latToString(CoordinateFormat d) {
    93104        switch(d) {
    94105        case DECIMAL_DEGREES: return cDdFormatter.format(y);
    95         case DEGREES_MINUTES_SECONDS: return dms(y) + ((y < 0) ?
    96                 /* short symbol for South */ trc("compass", "S") :
    97                     /* short symbol for North */ trc("compass", "N"));
     106        case DEGREES_MINUTES_SECONDS: return dms(y) + ((y < 0) ? SOUTH : NORTH);
     107        case NAUTICAL: return dm(y) + ((y < 0) ? SOUTH : NORTH);
    98108        case EAST_NORTH: return cDdFormatter.format(Main.proj.latlon2eastNorth(this).north());
    99109        default: return "ERR";
     
    105115    }
    106116
     117    private final static String WEST = trc("compass", "W");
     118    private final static String EAST = trc("compass", "E");
    107119    public String lonToString(CoordinateFormat d) {
    108120        switch(d) {
    109121        case DECIMAL_DEGREES: return cDdFormatter.format(x);
    110         case DEGREES_MINUTES_SECONDS: return dms(x) + ((x < 0) ?
    111                 /* short symbol for West */ trc("compass", "W") :
    112                     /* short symbol for East */ trc("compass", "E"));
     122        case DEGREES_MINUTES_SECONDS: return dms(x) + ((x < 0) ? WEST : EAST);
     123        case NAUTICAL: return dm(x) + ((x < 0) ? WEST : EAST);
    113124        case EAST_NORTH: return cDdFormatter.format(Main.proj.latlon2eastNorth(this).east());
    114125        default: return "ERR";
Note: See TracChangeset for help on using the changeset viewer.