Ignore:
Timestamp:
01.05.2011 21:56:49 (13 months ago)
Author:
jttt
Message:

Improved wms cache

  • files saved in original format (no need to recode to png)
  • possibility to tile with different pos/ppd that overlaps current tile
File:
1 edited

Legend:

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

    r3083 r4065  
    66/** 
    77 * This is a simple data class for "rectangular" areas of the world, given in 
    8  * lat/lon min/max values. 
     8 * east/north min/max values. 
    99 * 
    1010 * @author imi 
     
    1414     * The minimum and maximum coordinates. 
    1515     */ 
    16     public EastNorth min, max; 
     16    public double minEast, minNorth, maxEast, maxNorth; 
    1717 
    1818    /** 
     
    2020     */ 
    2121    public ProjectionBounds(EastNorth min, EastNorth max) { 
    22         this.min = min; 
    23         this.max = max; 
     22        this.minEast = min.east(); 
     23        this.minNorth = min.north(); 
     24        this.maxEast = max.east(); 
     25        this.maxNorth = max.north(); 
    2426    } 
    2527    public ProjectionBounds(EastNorth p) { 
    26         this.min = p; 
    27         this.max = p; 
     28        this.minEast = this.maxEast = p.east(); 
     29        this.minNorth = this.maxNorth = p.north(); 
    2830    } 
    2931    public ProjectionBounds(EastNorth center, double east, double north) { 
    30         this.min = new EastNorth(center.east()-east/2.0, center.north()-north/2.0); 
    31         this.max = new EastNorth(center.east()+east/2.0, center.north()+north/2.0); 
     32        this.minEast = center.east()-east/2.0; 
     33        this.minNorth = center.north()-north/2.0; 
     34        this.maxEast = center.east()+east/2.0; 
     35        this.maxNorth = center.north()+north/2.0; 
     36    } 
     37    public ProjectionBounds(double minEast, double minNorth, double maxEast, double maxNorth) { 
     38        this.minEast = minEast; 
     39        this.minNorth = minNorth; 
     40        this.maxEast = maxEast; 
     41        this.maxNorth = maxNorth; 
    3242    } 
    3343    public void extend(EastNorth e) 
    3444    { 
    35         if (e.east() < min.east() || e.north() < min.north()) 
    36             min = new EastNorth(Math.min(e.east(), min.east()), Math.min(e.north(), min.north())); 
    37         if (e.east() > max.east() || e.north() > max.north()) 
    38             max = new EastNorth(Math.max(e.east(), max.east()), Math.max(e.north(), max.north())); 
     45        if (e.east() < minEast) { 
     46            minEast = e.east(); 
     47        } 
     48        if (e.east() > maxEast) { 
     49            maxEast = e.east(); 
     50        } 
     51        if (e.north() < minNorth) { 
     52            minNorth = e.north(); 
     53        } 
     54        if (e.north() > maxNorth) { 
     55            maxNorth = e.north(); 
     56        } 
    3957    } 
    4058    public EastNorth getCenter() 
    4159    { 
    42         return min.getCenter(max); 
     60        return new EastNorth((minEast + maxEast) / 2.0, (minNorth + maxNorth) / 2.0); 
    4361    } 
    4462 
    4563    @Override public String toString() { 
    46         return "ProjectionBounds["+min.east()+","+min.north()+","+max.east()+","+max.north()+"]"; 
     64        return "ProjectionBounds["+minEast+","+minNorth+","+maxEast+","+maxNorth+"]"; 
    4765    } 
     66 
     67    /** 
     68     * The two bounds intersect? Compared to java Shape.intersects, if does not use 
     69     * the interior but the closure. (">=" instead of ">") 
     70     */ 
     71    public boolean intersects(ProjectionBounds b) { 
     72        return b.maxEast >= minEast && 
     73        b.maxNorth >= minNorth && 
     74        b.minEast <= maxEast && 
     75        b.minNorth <= maxNorth; 
     76    } 
     77 
     78    public EastNorth getMin() { 
     79        return new EastNorth(minEast, minNorth); 
     80    } 
     81 
     82    public EastNorth getMax() { 
     83        return new EastNorth(maxEast, maxNorth); 
     84    } 
     85 
    4886} 
Note: See TracChangeset for help on using the changeset viewer.