Ignore:
Timestamp:
2011-06-07T19:05:14+02:00 (14 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/io/imagery
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/imagery/Grabber.java

    r4065 r4126  
    4141        }
    4242
    43         this.proj = Main.proj;
     43        this.proj = Main.getProjection();
    4444        this.pixelPerDegree = request.getPixelPerDegree();
    4545        this.request = request;
  • trunk/src/org/openstreetmap/josm/io/imagery/HTMLGrabber.java

    r4065 r4126  
    5252        BufferedImage img = layer.normalizeImage(ImageIO.read(bais));
    5353        bais.reset();
    54         layer.cache.saveToCache(layer.isOverlapEnabled()?img:null, bais, Main.proj, pixelPerDegree, b.minEast, b.minNorth);
     54        layer.cache.saveToCache(layer.isOverlapEnabled()?img:null, bais, Main.getProjection(), pixelPerDegree, b.minEast, b.minNorth);
    5555
    5656        return img;
  • trunk/src/org/openstreetmap/josm/io/imagery/OsmosnimkiOffsetServer.java

    r3852 r4126  
    4040    @Override
    4141    public EastNorth getOffset(ImageryInfo info, EastNorth en) {
    42         LatLon ll = Main.proj.eastNorth2latlon(en);
     42        LatLon ll = Main.getProjection().eastNorth2latlon(en);
    4343        try {
    4444            URL url = new URL(this.url + "action=GetOffsetForPoint&lat=" + ll.lat() + "&lon=" + ll.lon() + "&id=" + URLEncoder.encode(info.getFullUrl(), "UTF-8"));
     
    5050            String sLon = s.substring(1,i);
    5151            String sLat = s.substring(i+1,s.length()-1);
    52             return Main.proj.latlon2eastNorth(new LatLon(Double.valueOf(sLat),Double.valueOf(sLon))).sub(en);
     52            return Main.getProjection().latlon2eastNorth(new LatLon(Double.valueOf(sLat),Double.valueOf(sLon))).sub(en);
    5353        } catch (Exception e) {
    5454            e.printStackTrace();
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSGrabber.java

    r4065 r4126  
    7272    protected URL getURL(double w, double s,double e,double n,
    7373            int wi, int ht) throws MalformedURLException {
    74         String myProj = Main.proj.toCode();
    75         if(Main.proj instanceof Mercator) // don't use mercator code directly
     74        String myProj = Main.getProjection().toCode();
     75        if(Main.getProjection() instanceof Mercator) // don't use mercator code directly
    7676        {
    77             LatLon sw = Main.proj.eastNorth2latlon(new EastNorth(w, s));
    78             LatLon ne = Main.proj.eastNorth2latlon(new EastNorth(e, n));
     77            LatLon sw = Main.getProjection().eastNorth2latlon(new EastNorth(w, s));
     78            LatLon ne = Main.getProjection().eastNorth2latlon(new EastNorth(e, n));
    7979            myProj = "EPSG:4326";
    8080            s = sw.lat();
     
    114114    static public String getProjection(String baseURL, Boolean warn)
    115115    {
    116         String projname = Main.proj.toCode();
    117         if(Main.proj instanceof Mercator) {
     116        String projname = Main.getProjection().toCode();
     117        if(Main.getProjection() instanceof Mercator) {
    118118            projname = "EPSG:4326";
    119119        }
     
    146146    @Override
    147147    public boolean loadFromCache(WMSRequest request) {
    148         BufferedImage cached = layer.cache.getExactMatch(Main.proj, pixelPerDegree, b.minEast, b.minNorth);
     148        BufferedImage cached = layer.cache.getExactMatch(Main.getProjection(), pixelPerDegree, b.minEast, b.minNorth);
    149149
    150150        if (cached != null) {
     
    152152            return true;
    153153        } else if (request.isAllowPartialCacheMatch()) {
    154             BufferedImage partialMatch = layer.cache.getPartialMatch(Main.proj, pixelPerDegree, b.minEast, b.minNorth);
     154            BufferedImage partialMatch = layer.cache.getPartialMatch(Main.getProjection(), pixelPerDegree, b.minEast, b.minNorth);
    155155            if (partialMatch != null) {
    156156                request.finish(State.PARTLY_IN_CACHE, partialMatch);
     
    194194        BufferedImage img = layer.normalizeImage(ImageIO.read(bais));
    195195        bais.reset();
    196         layer.cache.saveToCache(layer.isOverlapEnabled()?img:null, bais, Main.proj, pixelPerDegree, b.minEast, b.minNorth);
     196        layer.cache.saveToCache(layer.isOverlapEnabled()?img:null, bais, Main.getProjection(), pixelPerDegree, b.minEast, b.minNorth);
    197197        return img;
    198198    }
Note: See TracChangeset for help on using the changeset viewer.