Ignore:
Timestamp:
2011-06-07T19:05:14+02:00 (8 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/src/org/openstreetmap/josm/data/projection
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r3874 r4126  
    22package org.openstreetmap.josm.data.projection;
    33
     4import java.util.ArrayList;
    45import java.util.Arrays;
    5 import java.util.ArrayList;
     6
     7import org.openstreetmap.josm.Main;
     8import org.openstreetmap.josm.data.coor.EastNorth;
     9import org.openstreetmap.josm.data.coor.LatLon;
    610
    711/**
     
    1418     */
    1519    private static ArrayList<Projection> allProjections =
    16     new ArrayList<Projection>(Arrays.asList(new Projection[] {
    17         // global projections
    18         new Epsg4326(),
    19         new Mercator(),
    20         new UTM(),
    21         // regional - alphabetical order by country name
    22         new LambertEST(), // Still needs proper default zoom
    23         new Lambert(),    // Still needs proper default zoom
    24         new LambertCC9Zones(),    // Still needs proper default zoom
    25         new UTM_France_DOM(),
    26         new TransverseMercatorLV(),
    27         new Puwg(),
    28         new Epsg3008(), // SWEREF99 13 30
    29         new SwissGrid(),
    30     }));
     20        new ArrayList<Projection>(Arrays.asList(new Projection[] {
     21                // global projections
     22                new Epsg4326(),
     23                new Mercator(),
     24                new UTM(),
     25                // regional - alphabetical order by country name
     26                new LambertEST(), // Still needs proper default zoom
     27                new Lambert(),    // Still needs proper default zoom
     28                new LambertCC9Zones(),    // Still needs proper default zoom
     29                new UTM_France_DOM(),
     30                new TransverseMercatorLV(),
     31                new Puwg(),
     32                new Epsg3008(), // SWEREF99 13 30
     33                new SwissGrid(),
     34        }));
    3135
    3236    public static ArrayList<Projection> getProjections() {
     
    4347        allProjections.add(proj);
    4448    }
     49
     50    static public EastNorth project(LatLon ll) {
     51        if (ll == null) return null;
     52        return Main.getProjection().latlon2eastNorth(ll);
     53    }
     54
     55    static public LatLon inverseProject(EastNorth en) {
     56        if (en == null) return null;
     57        return Main.getProjection().eastNorth2latlon(en);
     58    }
    4559}
Note: See TracChangeset for help on using the changeset viewer.