source: josm/src/org/openstreetmap/josm/data/Bounds.java@ 9

Last change on this file since 9 was 1, checked in by imi, 19 years ago

wiki 19:37, 27. Sep 2005

File size: 1012 bytes
Line 
1package org.openstreetmap.josm.data;
2
3/**
4 * This is a simple data class for "rectangular" areas of the world, given in lat/lon/min/max
5 * values.
6 *
7 * Do not confuse this with "Area", which is an OSM-primitive for a vector of nodes,
8 * describing some area (like a sea).
9 *
10 * @author imi
11 */
12public class Bounds {
13 /**
14 * The minimum and maximum coordinates.
15 */
16 public GeoPoint min, max;
17
18 /**
19 * Return the center point based on the lat/lon values.
20 *
21 * @return The center of these bounds.
22 */
23 public GeoPoint centerLatLon() {
24 GeoPoint p = new GeoPoint((min.lat+max.lat) / 2, (min.lon+max.lon) / 2);
25 return p;
26 }
27
28 /**
29 * Return the center point based on the x/y values.
30 *
31 * @return The center of these bounds.
32 */
33 public GeoPoint centerXY() {
34 GeoPoint p = new GeoPoint();
35 p.x = (min.x+max.x) / 2;
36 p.y = (min.y+max.y) / 2;
37 return p;
38 }
39
40 /**
41 * Construct bounds out of two geopoints
42 */
43 public Bounds(GeoPoint min, GeoPoint max) {
44 this.min = min;
45 this.max = max;
46 }
47}
Note: See TracBrowser for help on using the repository browser.