Changeset 2699 in josm


Ignore:
Timestamp:
Dec 29, 2009 6:25:40 AM (3 years ago)
Author:
mjulius
Message:

moved MAX_SERVER_PRECISION from Projection to LatLon
LatLon.getRoundedToOsmPrecision() now also uses MAX_SERVER_PRECISION to be consistent with LatLon.equalEpsilon()

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

Legend:

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

    r2694 r2699  
    1515import org.openstreetmap.josm.Main; 
    1616import org.openstreetmap.josm.data.Bounds; 
    17 import org.openstreetmap.josm.data.projection.Projection; 
    1817 
    1918/** 
     
    2625public class LatLon extends Coordinate { 
    2726 
     27    /** 
     28     * Minimum difference in location to not be represented as the same position. 
     29     * The API returns 7 decimals. 
     30     */ 
     31    public static final double MAX_SERVER_PRECISION = 1e-7; 
     32 
    2833    private static DecimalFormat cDmsMinuteFormatter = new DecimalFormat("00"); 
    2934    private static DecimalFormat cDmsSecondFormatter = new DecimalFormat("00.0"); 
     
    101106     * @return <code>true</code> if the other point has almost the same lat/lon 
    102107     * values, only differing by no more than 
    103      * 1 / {@link org.openstreetmap.josm.data.projection.Projection#MAX_SERVER_PRECISION MAX_SERVER_PRECISION}. 
     108     * 1 / {@link #MAX_SERVER_PRECISION MAX_SERVER_PRECISION}. 
    104109     */ 
    105110    public boolean equalsEpsilon(LatLon other) { 
    106         final double p = Projection.MAX_SERVER_PRECISION; 
     111        double p = MAX_SERVER_PRECISION / 2; 
    107112        return Math.abs(lat()-other.lat()) <= p && Math.abs(lon()-other.lon()) <= p; 
    108113    } 
     
    197202    /** 
    198203     * Replies a clone of this lat LatLon, rounded to OSM precisions, i.e. to 
    199      * 10^-7 
     204     * MAX_SERVER_PRECISION 
    200205     *  
    201206     * @return a clone of this lat LatLon 
     
    203208    public LatLon getRoundedToOsmPrecision() { 
    204209        return new LatLon( 
    205                 Math.round(lat() * 10e6) / 10e6d, 
    206                 Math.round(lon() * 10e6) / 10e6d 
     210                Math.round(lat() / MAX_SERVER_PRECISION) * MAX_SERVER_PRECISION, 
     211                Math.round(lon() / MAX_SERVER_PRECISION) * MAX_SERVER_PRECISION 
    207212        ); 
    208213    } 
  • trunk/src/org/openstreetmap/josm/data/projection/Projection.java

    r2612 r2699  
    1313 */ 
    1414public interface Projection { 
    15     /** 
    16      * Minimum difference in location to not be represented as the same position. 
    17      * The API returns 7 decimals. 
    18      */ 
    19     public static final double MAX_SERVER_PRECISION = 5e-8; 
    20  
    2115    /** 
    2216     * List of all available projections. 
Note: See TracChangeset for help on using the changeset viewer.