Changeset 6203 in josm for trunk/src/org/openstreetmap/josm/data/osm
- Timestamp:
- 2013-08-28T03:03:40+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/BBox.java
r6178 r6203 4 4 import java.util.Arrays; 5 5 6 import org.openstreetmap.josm.data.Bounds;7 6 import org.openstreetmap.josm.data.coor.LatLon; 8 7 import org.openstreetmap.josm.data.coor.QuadTiling; … … 16 15 private double ymax = Double.NEGATIVE_INFINITY; 17 16 18 public BBox(Bounds bounds) { 19 add(bounds.getMin()); 20 add(bounds.getMax()); 21 } 22 17 /** 18 * Constructs a new {@code BBox} defined by a single point. 19 * 20 * @param x X coordinate 21 * @param y Y coordinate 22 * @since 6203 23 */ 24 public BBox(final double x, final double y) { 25 xmax = xmin = x; 26 ymax = ymin = y; 27 sanity(); 28 } 29 30 /** 31 * Constructs a new {@code BBox} defined by points <code>a</code> and <code>b</code>. 32 * Result is minimal BBox containing both points. 33 * 34 * @param a 35 * @param b 36 */ 23 37 public BBox(LatLon a, LatLon b) { 24 add(a); 25 add(b); 26 } 27 38 this(a.lon(), a.lat(), b.lon(), b.lat()); 39 } 40 41 /** 42 * Constructs a new {@code BBox} from another one. 43 * 44 * @param copy the BBox to copy 45 */ 28 46 public BBox(BBox copy) { 29 47 this.xmin = copy.xmin; … … 34 52 35 53 public BBox(double a_x, double a_y, double b_x, double b_y) { 36 xmin = Math.min(a_x, b_x); 37 xmax = Math.max(a_x, b_x); 38 ymin = Math.min(a_y, b_y); 39 ymax = Math.max(a_y, b_y); 54 55 if (a_x > b_x) { 56 xmax = a_x; 57 xmin = b_x; 58 } else { 59 xmax = b_x; 60 xmin = a_x; 61 } 62 63 if (a_y > b_y) { 64 ymax = a_y; 65 ymin = b_y; 66 } else { 67 ymax = b_y; 68 ymin = a_y; 69 } 70 40 71 sanity(); 41 72 } … … 84 115 */ 85 116 public void add(double x, double y) { 86 xmin = Math.min(xmin, x); 87 xmax = Math.max(xmax, x); 88 ymin = Math.min(ymin, y); 89 ymax = Math.max(ymax, y); 117 118 if (x < xmin) { 119 xmin = x; 120 } else if (x > xmax) { 121 xmax = x; 122 } 123 124 if (y < ymin) { 125 ymin = y; 126 } else if (y > ymax) { 127 ymax = y; 128 } 129 90 130 sanity(); 91 131 } 92 132 93 133 public void add(BBox box) { 94 add(box.getTopLeft()); 95 add(box.getBottomRight()); 134 xmin = Math.min(xmin, box.xmin); 135 xmax = Math.max(xmax, box.xmax); 136 ymin = Math.min(ymin, box.ymin); 137 ymax = Math.max(ymax, box.ymax); 138 sanity(); 96 139 } 97 140 … … 151 194 } 152 195 196 /** 197 * Returns the top-left point. 198 * @return The top-left point 199 */ 153 200 public LatLon getTopLeft() { 154 201 return new LatLon(ymax, xmin); 155 202 } 156 203 204 /** 205 * Returns the latitude of top-left point. 206 * @return The latitude of top-left point 207 * @since 6203 208 */ 209 public double getTopLeftLat() { 210 return ymax; 211 } 212 213 /** 214 * Returns the longitude of top-left point. 215 * @return The longitude of top-left point 216 * @since 6203 217 */ 218 public double getTopLeftLon() { 219 return xmin; 220 } 221 222 /** 223 * Returns the bottom-right point. 224 * @return The bottom-right point 225 */ 157 226 public LatLon getBottomRight() { 158 227 return new LatLon(ymin, xmax); 228 } 229 230 /** 231 * Returns the latitude of bottom-right point. 232 * @return The latitude of bottom-right point 233 * @since 6203 234 */ 235 public double getBottomRightLat() { 236 return ymin; 237 } 238 239 /** 240 * Returns the longitude of bottom-right point. 241 * @return The longitude of bottom-right point 242 * @since 6203 243 */ 244 public double getBottomRightLon() { 245 return xmax; 159 246 } 160 247 -
trunk/src/org/openstreetmap/josm/data/osm/DatasetConsistencyTest.java
r5356 r6203 81 81 LatLon c = n.getCoor(); 82 82 if (c != null) { 83 BBox box = new BBox(new LatLon(c.lat() - 0.0001, c.lon() - 0.0001), new LatLon(c.lat() + 0.0001, c.lon() + 0.0001));83 BBox box = c.toBBox(0.0001); 84 84 if (!dataSet.searchNodes(box).contains(n)) { 85 85 printError("SEARCH NODES", "%s not found using Dataset.searchNodes()", n); -
trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java
r6181 r6203 117 117 double lat = bottom_left.lat() + parent.height() / 2; 118 118 double lon = bottom_left.lon() + parent.width() / 2; 119 LatLon top_right = new LatLon(lat, lon); 120 return new BBox(bottom_left, top_right); 119 return new BBox(bottom_left.lon(), bottom_left.lat(), lon, lat); 121 120 } 122 121 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r6172 r6203 1404 1404 public void render(final DataSet data, boolean renderVirtualNodes, Bounds bounds) { 1405 1405 //long start = System.currentTimeMillis(); 1406 BBox bbox = new BBox(bounds);1406 BBox bbox = bounds.toBBox(); 1407 1407 getSettings(renderVirtualNodes); 1408 1408 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/WireframeMapRenderer.java
r6113 r6203 157 157 @Override 158 158 public void render(DataSet data, boolean virtual, Bounds bounds) { 159 BBox bbox = new BBox(bounds);159 BBox bbox = bounds.toBBox(); 160 160 this.ds = data; 161 161 getSettings(virtual);
Note:
See TracChangeset
for help on using the changeset viewer.