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

Last change on this file since 1750 was 1724, checked in by stoecker, 15 years ago

some more changes and bug fixes related to new projection stuff - GPX should now work also

File size: 1.5 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.data;
3
4import java.awt.geom.Rectangle2D;
5
6import org.openstreetmap.josm.data.coor.EastNorth;
7
8/**
9 * This is a simple data class for "rectangular" areas of the world, given in
10 * lat/lon min/max values.
11 *
12 * @author imi
13 */
14public class ProjectionBounds {
15 /**
16 * The minimum and maximum coordinates.
17 */
18 public EastNorth min, max;
19
20 /**
21 * Construct bounds out of two points
22 */
23 public ProjectionBounds(EastNorth min, EastNorth max) {
24 this.min = min;
25 this.max = max;
26 }
27 public ProjectionBounds(EastNorth p) {
28 this.min = p;
29 this.max = p;
30 }
31 public ProjectionBounds(EastNorth center, double east, double north) {
32 this.min = new EastNorth(center.east()-east/2.0, center.north()-north/2.0);
33 this.max = new EastNorth(center.east()+east/2.0, center.north()+north/2.0);
34 }
35 public void extend(EastNorth e)
36 {
37 if (e.east() < min.east() || e.north() < min.north())
38 min = new EastNorth(Math.min(e.east(), min.east()), Math.min(e.north(), min.north()));
39 if (e.east() > max.east() || e.north() > max.north())
40 max = new EastNorth(Math.max(e.east(), max.east()), Math.max(e.north(), max.north()));
41 }
42 public EastNorth getCenter()
43 {
44 return min.getCenter(max);
45 }
46
47 @Override public String toString() {
48 return "ProjectionBounds["+min.east()+","+min.north()+","+max.east()+","+max.north()+"]";
49 }
50}
Note: See TracBrowser for help on using the repository browser.