Ignore:
Timestamp:
04.11.2011 01:17:49 (7 months ago)
Author:
Don-vip
Message:

fix #7028 - Dragging map is extremely slow when large GPX file is loaded

File:
1 edited

Legend:

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

    r4541 r4574  
    244244     */ 
    245245    public static double roundToOsmPrecision(double value) { 
     246        return Math.round(value / MAX_SERVER_PRECISION) * MAX_SERVER_PRECISION; // causes tiny rounding errors (see LatLonTest) 
     247    } 
     248 
     249    /** 
     250     * Returns the value rounded to OSM precisions, i.e. to 
     251     * LatLon.MAX_SERVER_PRECISION. The result is guaranteed to be exact, but at a great cost. 
     252     * This function is about 1000 times slower than roundToOsmPrecision(), use it with caution. 
     253     * 
     254     * @return rounded value 
     255     */ 
     256    public static double roundToOsmPrecisionStrict(double value) { 
    246257        double absV = Math.abs(value); 
    247258        int numOfDigits = MAX_SERVER_DIGITS + (absV < 1 ? 0 : (absV < 10 ? 1 : (absV < 100 ? 2 : 3)));  
    248259        return BigDecimal.valueOf(value).round(new MathContext(numOfDigits)).doubleValue(); 
    249         //return Math.round(value / MAX_SERVER_PRECISION) * MAX_SERVER_PRECISION; // Old method, causes rounding errors (see LatLonTest) ! 
    250     } 
    251      
     260    } 
     261 
    252262    /** 
    253263     * Replies a clone of this lat LatLon, rounded to OSM precisions, i.e. to 
     
    260270                roundToOsmPrecision(lat()), 
    261271                roundToOsmPrecision(lon()) 
     272        ); 
     273    } 
     274 
     275    /** 
     276     * Replies a clone of this lat LatLon, rounded to OSM precisions, i.e. to 
     277     * MAX_SERVER_PRECISION 
     278     * 
     279     * @return a clone of this lat LatLon 
     280     */ 
     281    public LatLon getRoundedToOsmPrecisionStrict() { 
     282        return new LatLon( 
     283                roundToOsmPrecisionStrict(lat()), 
     284                roundToOsmPrecisionStrict(lon()) 
    262285        ); 
    263286    } 
Note: See TracChangeset for help on using the changeset viewer.