Changeset 4126 in josm for trunk/test/unit


Ignore:
Timestamp:
2011-06-07T19:05:14+02:00 (13 years ago)
Author:
bastiK
Message:

memory optimizations for Node & WayPoint (Patch by Gubaer, modified)

The field 'proj' in CachedLatLon is a waste of memory. For the 2 classes where this has the greatest impact, the cache for the projected coordinates is replaced by 2 simple double fields (east & north). On projection change, they have to be invalidated explicitly. This is handled by the DataSet & the GpxLayer.

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java

    r3577 r4126  
    7676        their = new DataSet();
    7777        their.setVersion("0.6");
    78         Main.proj = new Mercator();
     78        Main.setProjection(new Mercator());
    7979    }
    8080
  • trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java

    r3577 r4126  
    2929    @BeforeClass
    3030    public static void setUp() {
    31         Main.proj = new Mercator();
     31        Main.setProjection(new Mercator());
    3232        Main.pref = new Preferences();
    3333    }
  • trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveTest.java

    r3577 r4126  
    2929    @BeforeClass
    3030    public static void setUp() {
    31         Main.proj = new Mercator();
     31        Main.setProjection(new Mercator());
    3232    }
    3333
  • trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java

    r3577 r4126  
    6666    @Test
    6767    public void testRemove() throws Exception {
    68         Main.proj = new Mercator();
     68        Main.setProjection(new Mercator());
    6969        DataSet ds = OsmReader.parseDataSet(new FileInputStream("data_nodist/restriction.osm"), NullProgressMonitor.INSTANCE);
    7070        removeAllTest(ds);
     
    7373    @Test
    7474    public void testMove() throws Exception {
    75         Main.proj = new Mercator();
     75        Main.setProjection(new Mercator());
    7676        DataSet ds = OsmReader.parseDataSet(new FileInputStream("data_nodist/restriction.osm"), NullProgressMonitor.INSTANCE);
    7777
  • trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java

    r3577 r4126  
    1616    @BeforeClass
    1717    public static void setUp() {
    18         Main.proj = new Mercator();
     18        Main.setProjection(new Mercator());
    1919        Main.pref = new Preferences();
    2020    }
  • trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java

    r3577 r4126  
    3737    @BeforeClass
    3838    public static void setUp() {
    39         Main.proj = new Mercator();
     39        Main.setProjection(new Mercator());
    4040        Main.pref = new Preferences();
    4141    }
  • trunk/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java

    r3485 r4126  
    1515    @BeforeClass
    1616    public static void setUp() {
    17         Main.proj = new SwissGrid();
     17        Main.setProjection(new SwissGrid());
    1818    }
    1919
     
    6262        {
    6363            LatLon ll = new LatLon(46.518, 6.567);
    64             EastNorth en = Main.proj.latlon2eastNorth(ll);
    65             if (debug) System.out.println(en);
     64            EastNorth en = Main.getProjection().latlon2eastNorth(ll);
     65            if (debug) {
     66                System.out.println(en);
     67            }
    6668            assertTrue("Lausanne", Math.abs(en.east() - 533111.69) < 0.1);
    6769            assertTrue("Lausanne", Math.abs(en.north() - 152227.85) < 0.1);
     
    7072        {
    7173            LatLon ll = new LatLon(47.78, 8.58);
    72             EastNorth en = Main.proj.latlon2eastNorth(ll);
    73             if (debug) System.out.println(en);
     74            EastNorth en = Main.getProjection().latlon2eastNorth(ll);
     75            if (debug) {
     76                System.out.println(en);
     77            }
    7478            assertTrue("Schafouse", Math.abs(en.east() - 685544.16) < 0.1);
    7579            assertTrue("Schafouse", Math.abs(en.north() - 292782.91) < 0.1);
     
    7882        {
    7983            LatLon ll = new LatLon(46.58, 10.48);
    80             EastNorth en = Main.proj.latlon2eastNorth(ll);
    81             if (debug) System.out.println(en);
     84            EastNorth en = Main.getProjection().latlon2eastNorth(ll);
     85            if (debug) {
     86                System.out.println(en);
     87            }
    8288            assertTrue("Grinson", Math.abs(en.east() - 833068.04) < 0.1);
    8389            assertTrue("Grinson", Math.abs(en.north() - 163265.39) < 0.1);
     
    8692        {
    8793            LatLon ll = new LatLon(46.0 + 57.0 / 60 + 3.89813884505 / 3600, 7.0 + 26.0 / 60 + 19.076595154147 / 3600);
    88             EastNorth en = Main.proj.latlon2eastNorth(ll);
    89             if (debug) System.out.println(en);
     94            EastNorth en = Main.getProjection().latlon2eastNorth(ll);
     95            if (debug) {
     96                System.out.println(en);
     97            }
    9098            assertTrue("Berne", Math.abs(en.east() - 600000.0) < 0.1);
    9199            assertTrue("Berne", Math.abs(en.north() - 200000.0) < 0.1);
     
    93101        {
    94102            LatLon ll = new LatLon(46.0 + 2.0 / 60 + 38.87 / 3600, 8.0 + 43.0 / 60 + 49.79 / 3600);
    95             EastNorth en = Main.proj.latlon2eastNorth(ll);
    96             if (debug) System.out.println(en);
     103            EastNorth en = Main.getProjection().latlon2eastNorth(ll);
     104            if (debug) {
     105                System.out.println(en);
     106            }
    97107            assertTrue("Ref", Math.abs(en.east() - 700000.0) < 0.1);
    98108            assertTrue("Ref", Math.abs(en.north() - 100000.0) < 0.1);
     
    105115        {
    106116            EastNorth en = new EastNorth(533111.69, 152227.85);
    107             LatLon ll = Main.proj.eastNorth2latlon(en);
    108             if (debug) System.out.println(ll);
     117            LatLon ll = Main.getProjection().eastNorth2latlon(en);
     118            if (debug) {
     119                System.out.println(ll);
     120            }
    109121            assertTrue("Lausanne", Math.abs(ll.lat() - 46.518) < 0.00001);
    110122            assertTrue("Lausanne", Math.abs(ll.lon() - 6.567) < 0.00001);
     
    113125        {
    114126            EastNorth en = new EastNorth(685544.16, 292782.91);
    115             LatLon ll = Main.proj.eastNorth2latlon(en);
    116             if (debug) System.out.println(ll);
     127            LatLon ll = Main.getProjection().eastNorth2latlon(en);
     128            if (debug) {
     129                System.out.println(ll);
     130            }
    117131            assertTrue("Schafouse", Math.abs(ll.lat() - 47.78) < 0.00001);
    118132            assertTrue("Schafouse", Math.abs(ll.lon() - 8.58) < 0.00001);
     
    121135        {
    122136            EastNorth en = new EastNorth(833068.04, 163265.39);
    123             LatLon ll = Main.proj.eastNorth2latlon(en);
    124             if (debug) System.out.println(ll);
     137            LatLon ll = Main.getProjection().eastNorth2latlon(en);
     138            if (debug) {
     139                System.out.println(ll);
     140            }
    125141            assertTrue("Grinson", Math.abs(ll.lat() - 46.58) < 0.00001);
    126142            assertTrue("Grinson", Math.abs(ll.lon() - 10.48) < 0.00001);
     
    129145        {
    130146            EastNorth en = new EastNorth(600000.0, 200000.0);
    131             LatLon ll = Main.proj.eastNorth2latlon(en);
    132             if (debug) System.out.println(ll);
     147            LatLon ll = Main.getProjection().eastNorth2latlon(en);
     148            if (debug) {
     149                System.out.println(ll);
     150            }
    133151            assertTrue("Berne", Math.abs(ll.lat() - (46.0 + 57.0 / 60 + 3.89813884505 / 3600)) < 0.00001);
    134152            assertTrue("Berne", Math.abs(ll.lon() - (7.0 + 26.0 / 60 + 19.076595154147 / 3600)) < 0.00001);
     
    137155        {
    138156            EastNorth en = new EastNorth(700000.0, 100000.0);
    139             LatLon ll = Main.proj.eastNorth2latlon(en);
    140             if (debug) System.out.println(ll);
     157            LatLon ll = Main.getProjection().eastNorth2latlon(en);
     158            if (debug) {
     159                System.out.println(ll);
     160            }
    141161            assertTrue("Ref", Math.abs(ll.lat() - (46.0 + 2.0 / 60 + 38.87 / 3600)) < 0.00001);
    142162            assertTrue("Ref", Math.abs(ll.lon() - (8.0 + 43.0 / 60 + 49.79 / 3600)) < 0.00001);
     
    152172        {
    153173            EastNorth en = new EastNorth(533111.69, 152227.85);
    154             LatLon ll = Main.proj.eastNorth2latlon(en);
    155             EastNorth en2 = Main.proj.latlon2eastNorth(ll);
    156             if (debug) System.out.println(en.east() - en2.east());
    157             if (debug) System.out.println(en.north() - en2.north());
     174            LatLon ll = Main.getProjection().eastNorth2latlon(en);
     175            EastNorth en2 = Main.getProjection().latlon2eastNorth(ll);
     176            if (debug) {
     177                System.out.println(en.east() - en2.east());
     178            }
     179            if (debug) {
     180                System.out.println(en.north() - en2.north());
     181            }
    158182            assertTrue("Lausanne", Math.abs(en.east() - en2.east()) < 0.002);
    159183            assertTrue("Lausanne", Math.abs(en.north() - en2.north()) < 0.002);
     
    162186        {
    163187            EastNorth en = new EastNorth(685544.16, 292782.91);
    164             LatLon ll = Main.proj.eastNorth2latlon(en);
    165             EastNorth en2 = Main.proj.latlon2eastNorth(ll);
    166             if (debug) System.out.println(en.east() - en2.east());
    167             if (debug) System.out.println(en.north() - en2.north());
     188            LatLon ll = Main.getProjection().eastNorth2latlon(en);
     189            EastNorth en2 = Main.getProjection().latlon2eastNorth(ll);
     190            if (debug) {
     191                System.out.println(en.east() - en2.east());
     192            }
     193            if (debug) {
     194                System.out.println(en.north() - en2.north());
     195            }
    168196            assertTrue("Schafouse", Math.abs(en.east() - en2.east()) < 0.002);
    169197            assertTrue("Schafouse", Math.abs(en.north() - en2.north()) < 0.002);
     
    172200        {
    173201            EastNorth en = new EastNorth(833068.04, 163265.39);
    174             LatLon ll = Main.proj.eastNorth2latlon(en);
    175             EastNorth en2 = Main.proj.latlon2eastNorth(ll);
    176             if (debug) System.out.println(en.east() - en2.east());
    177             if (debug) System.out.println(en.north() - en2.north());
     202            LatLon ll = Main.getProjection().eastNorth2latlon(en);
     203            EastNorth en2 = Main.getProjection().latlon2eastNorth(ll);
     204            if (debug) {
     205                System.out.println(en.east() - en2.east());
     206            }
     207            if (debug) {
     208                System.out.println(en.north() - en2.north());
     209            }
    178210            assertTrue("Grinson", Math.abs(en.east() - en2.east()) < 0.002);
    179211            assertTrue("Grinson", Math.abs(en.north() - en2.north()) < 0.002);
     
    182214        {
    183215            EastNorth en = new EastNorth(600000.0, 200000.0);
    184             LatLon ll = Main.proj.eastNorth2latlon(en);
    185             EastNorth en2 = Main.proj.latlon2eastNorth(ll);
    186             if (debug) System.out.println(en.east() - en2.east());
    187             if (debug) System.out.println(en.north() - en2.north());
     216            LatLon ll = Main.getProjection().eastNorth2latlon(en);
     217            EastNorth en2 = Main.getProjection().latlon2eastNorth(ll);
     218            if (debug) {
     219                System.out.println(en.east() - en2.east());
     220            }
     221            if (debug) {
     222                System.out.println(en.north() - en2.north());
     223            }
    188224            assertTrue("Berne", Math.abs(en.east() - en2.east()) < 0.002);
    189225            assertTrue("Berne", Math.abs(en.north() - en2.north()) < 0.002);
     
    192228        {
    193229            EastNorth en = new EastNorth(700000.0, 100000.0);
    194             LatLon ll = Main.proj.eastNorth2latlon(en);
    195             EastNorth en2 = Main.proj.latlon2eastNorth(ll);
    196             if (debug) System.out.println(en.east() - en2.east());
    197             if (debug) System.out.println(en.north() - en2.north());
     230            LatLon ll = Main.getProjection().eastNorth2latlon(en);
     231            EastNorth en2 = Main.getProjection().latlon2eastNorth(ll);
     232            if (debug) {
     233                System.out.println(en.east() - en2.east());
     234            }
     235            if (debug) {
     236                System.out.println(en.north() - en2.north());
     237            }
    198238            assertTrue("Ref", Math.abs(en.east() - en2.east()) < 0.002);
    199239            assertTrue("Ref", Math.abs(en.north() - en2.north()) < 0.002);
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java

    r3577 r4126  
    4747    @BeforeClass
    4848    public static void init() {
    49         Main.proj = new Epsg4326();
     49        Main.setProjection(new Epsg4326());
    5050        Main.pref = new Preferences();
    5151    }
Note: See TracChangeset for help on using the changeset viewer.