Ignore:
Timestamp:
2011-11-03T23:23:34+01:00 (13 years ago)
Author:
Don-vip
Message:

see #7028 - improves GPX dragging performances by 50%, but the main issue is still here (rounding is exact, but 1000 times slower than before)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/coor/LatLonTest.java

    r4541 r4573  
    1212public class LatLonTest {
    1313
     14    protected static final double[] sampleValues = new double[]{
     15            -180.0, -179.9, -179.6, -179.5, -179.4, -179.1, -179.0, -100.0, -99.9, -10.0, -9.9, -1.0, -0.1,
     16            180.0,  179.9,  179.6,  179.5,  179.4,  179.1,  179.0,  100.0,  99.9,  10.0,  9.9,  1.0,  0.1,
     17            0.12, 0.123, 0.1234, 0.12345, 0.123456, 0.1234567,
     18            1.12, 1.123, 1.1234, 1.12345, 1.123456, 1.1234567,
     19            10.12, 10.123, 10.1234, 10.12345, 10.123456, 10.1234567,
     20            100.12, 100.123, 100.1234, 100.12345, 100.123456, 100.1234567
     21           };
     22   
    1423    @Test
    1524    public void roundingTests() {
    1625       
    17         for (double value : new double[]{
    18                 -180.0, -179.9, -179.6, -179.5, -179.4, -179.1, -179.0, -100.0, -99.9, -10.0, -9.9, -1.0, -0.1,
    19                  180.0,  179.9,  179.6,  179.5,  179.4,  179.1,  179.0,  100.0,  99.9,  10.0,  9.9,  1.0,  0.1,
    20                  0.12, 0.123, 0.1234, 0.12345, 0.123456, 0.1234567,
    21                  1.12, 1.123, 1.1234, 1.12345, 1.123456, 1.1234567,
    22                  10.12, 10.123, 10.1234, 10.12345, 10.123456, 10.1234567,
    23                  100.12, 100.123, 100.1234, 100.12345, 100.123456, 100.1234567
    24                 }) {
     26        for (double value : sampleValues) {
    2527            assertEquals(LatLon.roundToOsmPrecision(value), value, 0);
    2628        }
     
    4042        assertEquals(LatLon.roundToOsmPrecision(100.12345678),  100.1234568, 0);
    4143        assertEquals(LatLon.roundToOsmPrecision(100.123456789), 100.1234568, 0);
     44
     45        assertEquals(LatLon.roundToOsmPrecision(100.00000001),  100.0000000, 0);
     46        assertEquals(LatLon.roundToOsmPrecision(100.000000001),  100.0000000, 0);
     47        assertEquals(LatLon.roundToOsmPrecision(100.0000000001),  100.0000000, 0);
     48        assertEquals(LatLon.roundToOsmPrecision(100.00000000001),  100.0000000, 0);
     49        assertEquals(LatLon.roundToOsmPrecision(100.000000000001),  100.0000000, 0);
     50        assertEquals(LatLon.roundToOsmPrecision(100.0000000000001),  100.0000000, 0);
     51        assertEquals(LatLon.roundToOsmPrecision(100.00000000000001),  100.0000000, 0);
     52        assertEquals(LatLon.roundToOsmPrecision(100.000000000000001),  100.0000000, 0);
     53        assertEquals(LatLon.roundToOsmPrecision(100.0000000000000001),  100.0000000, 0);
     54        assertEquals(LatLon.roundToOsmPrecision(100.00000000000000001),  100.0000000, 0);
     55        assertEquals(LatLon.roundToOsmPrecision(100.000000000000000001),  100.0000000, 0);
     56        assertEquals(LatLon.roundToOsmPrecision(100.0000000000000000001),  100.0000000, 0);
     57        assertEquals(LatLon.roundToOsmPrecision(100.00000000000000000001),  100.0000000, 0);
     58
     59        assertEquals(LatLon.roundToOsmPrecision(99.999999999999999999999),  100.0000000, 0);
     60        assertEquals(LatLon.roundToOsmPrecision(99.99999999999999999999),  100.0000000, 0);
     61        assertEquals(LatLon.roundToOsmPrecision(99.9999999999999999999),  100.0000000, 0);
     62        assertEquals(LatLon.roundToOsmPrecision(99.999999999999999999),  100.0000000, 0);
     63        assertEquals(LatLon.roundToOsmPrecision(99.99999999999999999),  100.0000000, 0);
     64        assertEquals(LatLon.roundToOsmPrecision(99.9999999999999999),  100.0000000, 0);
     65        assertEquals(LatLon.roundToOsmPrecision(99.999999999999999),  100.0000000, 0);
     66        assertEquals(LatLon.roundToOsmPrecision(99.99999999999999),  100.0000000, 0);
     67        assertEquals(LatLon.roundToOsmPrecision(99.9999999999999),  100.0000000, 0);
     68        assertEquals(LatLon.roundToOsmPrecision(99.999999999999),  100.0000000, 0);
     69        assertEquals(LatLon.roundToOsmPrecision(99.99999999999),  100.0000000, 0);
     70        assertEquals(LatLon.roundToOsmPrecision(99.9999999999),  100.0000000, 0);
     71        assertEquals(LatLon.roundToOsmPrecision(99.999999999),  100.0000000, 0);
     72        assertEquals(LatLon.roundToOsmPrecision(99.99999999),  100.0000000, 0);
     73        assertEquals(LatLon.roundToOsmPrecision(99.9999999),  99.9999999, 0);
    4274    }
    4375}
Note: See TracChangeset for help on using the changeset viewer.