source: josm/trunk/src/org/openstreetmap/josm/data/ProjectionBounds.java@ 4067

Last change on this file since 4067 was 4065, checked in by jttt, 13 years ago

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
  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.data;
3
4import org.openstreetmap.josm.data.coor.EastNorth;
5
6/**
7 * This is a simple data class for "rectangular" areas of the world, given in
8 * east/north min/max values.
9 *
10 * @author imi
11 */
12public class ProjectionBounds {
13 /**
14 * The minimum and maximum coordinates.
15 */
16 public double minEast, minNorth, maxEast, maxNorth;
17
18 /**
19 * Construct bounds out of two points
20 */
21 public ProjectionBounds(EastNorth min, EastNorth max) {
22 this.minEast = min.east();
23 this.minNorth = min.north();
24 this.maxEast = max.east();
25 this.maxNorth = max.north();
26 }
27 public ProjectionBounds(EastNorth p) {
28 this.minEast = this.maxEast = p.east();
29 this.minNorth = this.maxNorth = p.north();
30 }
31 public ProjectionBounds(EastNorth center, double east, double north) {
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;
42 }
43 public void extend(EastNorth e)
44 {
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 }
57 }
58 public EastNorth getCenter()
59 {
60 return new EastNorth((minEast + maxEast) / 2.0, (minNorth + maxNorth) / 2.0);
61 }
62
63 @Override public String toString() {
64 return "ProjectionBounds["+minEast+","+minNorth+","+maxEast+","+maxNorth+"]";
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
86}
Note: See TracBrowser for help on using the repository browser.