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

Last change on this file since 2702 was 2017, checked in by Gubaer, 15 years ago

removed OptionPaneUtil
cleanup of deprecated Layer API
cleanup of deprecated APIs in OsmPrimitive and Way
cleanup of imports

File size: 1.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 * lat/lon min/max values.
9 *
10 * @author imi
11 */
12public class ProjectionBounds {
13 /**
14 * The minimum and maximum coordinates.
15 */
16 public EastNorth min, max;
17
18 /**
19 * Construct bounds out of two points
20 */
21 public ProjectionBounds(EastNorth min, EastNorth max) {
22 this.min = min;
23 this.max = max;
24 }
25 public ProjectionBounds(EastNorth p) {
26 this.min = p;
27 this.max = p;
28 }
29 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 }
33 public void extend(EastNorth e)
34 {
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()));
39 }
40 public EastNorth getCenter()
41 {
42 return min.getCenter(max);
43 }
44
45 @Override public String toString() {
46 return "ProjectionBounds["+min.east()+","+min.north()+","+max.east()+","+max.north()+"]";
47 }
48}
Note: See TracBrowser for help on using the repository browser.