Changeset 5474 in josm for trunk


Ignore:
Timestamp:
2012-08-23T23:37:57+02:00 (12 years ago)
Author:
Don-vip
Message:

fix #7994 - WGS84-DMS-ordinates are shown as 01'60,0" instead of 02'00,0"

File:
1 edited

Legend:

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

    r5268 r5474  
    100100    /**
    101101     * Replies the coordinate in degrees/minutes/seconds format
     102     * @param pCoordinate The coordinate to convert
     103     * @return The coordinate in degrees/minutes/seconds format
    102104     */
    103105    public static String dms(double pCoordinate) {
     
    108110        int tMinutes = (int) tTmpMinutes;
    109111        double tSeconds = (tTmpMinutes - tMinutes) * 60;
    110 
    111         return tDegree + "\u00B0" + cDmsMinuteFormatter.format(tMinutes) + "\'"
    112         + cDmsSecondFormatter.format(tSeconds) + "\"";
    113     }
    114 
     112       
     113        String sDegrees = Integer.toString(tDegree);
     114        String sMinutes = cDmsMinuteFormatter.format(tMinutes);
     115        String sSeconds = cDmsSecondFormatter.format(tSeconds);
     116       
     117        if (sSeconds.equals("60.0")) {
     118            sSeconds = "00.0";
     119            sMinutes = cDmsMinuteFormatter.format(tMinutes+1);
     120        }
     121        if (sMinutes.equals("60")) {
     122            sMinutes = "00";
     123            sDegrees = Integer.toString(tDegree+1);
     124        }
     125
     126        return sDegrees + "\u00B0" + sMinutes + "\'" + sSeconds + "\"";
     127    }
     128
     129    /**
     130     * Replies the coordinate in degrees/minutes format
     131     * @param pCoordinate The coordinate to convert
     132     * @return The coordinate in degrees/minutes format
     133     */
    115134    public static String dm(double pCoordinate) {
    116135
     
    118137        int tDegree = (int) tAbsCoord;
    119138        double tMinutes = (tAbsCoord - tDegree) * 60;
    120         return tDegree + "\u00B0" + cDmMinuteFormatter.format(tMinutes) + "\'";
     139       
     140        String sDegrees = Integer.toString(tDegree);
     141        String sMinutes = cDmMinuteFormatter.format(tMinutes);
     142       
     143        if (sMinutes.equals("60.000")) {
     144            sMinutes = "00.000";
     145            sDegrees = Integer.toString(tDegree+1);
     146        }
     147       
     148        return sDegrees + "\u00B0" + sMinutes + "\'";
    121149    }
    122150
Note: See TracChangeset for help on using the changeset viewer.