Changeset 4065 in josm for trunk/src/org/openstreetmap/josm/data/ProjectionBounds.java
- Timestamp:
- 01.05.2011 21:56:49 (13 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/ProjectionBounds.java
r3083 r4065 6 6 /** 7 7 * This is a simple data class for "rectangular" areas of the world, given in 8 * lat/lonmin/max values.8 * east/north min/max values. 9 9 * 10 10 * @author imi … … 14 14 * The minimum and maximum coordinates. 15 15 */ 16 public EastNorth min, max;16 public double minEast, minNorth, maxEast, maxNorth; 17 17 18 18 /** … … 20 20 */ 21 21 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(); 24 26 } 25 27 public ProjectionBounds(EastNorth p) { 26 this.min = p;27 this.m ax = p;28 this.minEast = this.maxEast = p.east(); 29 this.minNorth = this.maxNorth = p.north(); 28 30 } 29 31 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; 32 42 } 33 43 public void extend(EastNorth e) 34 44 { 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 } 39 57 } 40 58 public EastNorth getCenter() 41 59 { 42 return min.getCenter(max);60 return new EastNorth((minEast + maxEast) / 2.0, (minNorth + maxNorth) / 2.0); 43 61 } 44 62 45 63 @Override public String toString() { 46 return "ProjectionBounds["+min .east()+","+min.north()+","+max.east()+","+max.north()+"]";64 return "ProjectionBounds["+minEast+","+minNorth+","+maxEast+","+maxNorth+"]"; 47 65 } 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 48 86 }
Note: See TracChangeset
for help on using the changeset viewer.
