Changeset 2943 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2010-02-05T22:30:40+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/UpdateDataAction.java
r2942 r2943 53 53 List<Area> areas = new ArrayList<Area>(); 54 54 for(DataSource ds : getEditLayer().data.dataSources) { 55 areas.add(new Area(ds.bounds. getRoundedToOsmPrecision().asRect()));55 areas.add(new Area(ds.bounds.asRect())); 56 56 } 57 57 -
trunk/src/org/openstreetmap/josm/data/Bounds.java
r2942 r2943 13 13 /** 14 14 * This is a simple data class for "rectangular" areas of the world, given in 15 * lat/lon min/max values. 15 * lat/lon min/max values. The values are rounded to LatLon.OSM_SERVER_PRECISION 16 16 * 17 17 * @author imi … … 43 43 44 44 public Bounds(double minlat, double minlon, double maxlat, double maxlon) { 45 this.minLat = minlat;46 this.minLon = minlon;47 this.maxLat = maxlat;48 this.maxLon = maxlon;45 this.minLat = roundToOsmPrecision(minlat); 46 this.minLon = roundToOsmPrecision(minlon); 47 this.maxLat = roundToOsmPrecision(maxlat); 48 this.maxLon = roundToOsmPrecision(maxlon); 49 49 } 50 50 … … 53 53 if (coords.length != 4) 54 54 throw new IllegalArgumentException(MessageFormat.format("Expected array of length 4, got {0}", coords.length)); 55 this.minLat = coords[0];56 this.minLon = coords[1];57 this.maxLat = coords[2];58 this.maxLon = coords[3];55 this.minLat = roundToOsmPrecision(coords[0]); 56 this.minLon = roundToOsmPrecision(coords[1]); 57 this.maxLat = roundToOsmPrecision(coords[2]); 58 this.maxLon = roundToOsmPrecision(coords[3]); 59 59 } 60 60 … … 81 81 throw new IllegalArgumentException(tr("Illegal latitude value ''{0}''", values[3])); 82 82 83 this.minLat = values[0];84 this.minLon = values[1];85 this.maxLat = values[2];86 this.maxLon = values[3];83 this.minLat = roundToOsmPrecision(values[0]); 84 this.minLon = roundToOsmPrecision(values[1]); 85 this.maxLat = roundToOsmPrecision(values[2]); 86 this.maxLon = roundToOsmPrecision(values[3]); 87 87 } 88 88 … … 114 114 throw new IllegalArgumentException(MessageFormat.format("Parameter ''{0}'' > 0.0 exptected, got {1}", "lonExtent", lonExtent)); 115 115 116 this.minLat = center.lat() - latExtent / 2;117 this.minLon = center.lon() - lonExtent / 2;118 this.maxLat = center.lat() + latExtent / 2;119 this.maxLon = center.lon() + lonExtent / 2;116 this.minLat = roundToOsmPrecision(center.lat() - latExtent / 2); 117 this.minLon = roundToOsmPrecision(center.lon() - lonExtent / 2); 118 this.maxLat = roundToOsmPrecision(center.lat() + latExtent / 2); 119 this.maxLon = roundToOsmPrecision(center.lon() + lonExtent / 2); 120 120 } 121 121 … … 145 145 public void extend(LatLon ll) { 146 146 if (ll.lat() < minLat) { 147 minLat = ll.lat();147 minLat = roundToOsmPrecision(ll.lat()); 148 148 } 149 149 if (ll.lon() < minLon) { 150 minLon = ll.lon();150 minLon = roundToOsmPrecision(ll.lon()); 151 151 } 152 152 if (ll.lat() > maxLat) { 153 maxLat = ll.lat();153 maxLat = roundToOsmPrecision(ll.lat()); 154 154 } 155 155 if (ll.lon() > maxLon) { 156 maxLon = ll.lon();156 maxLon = roundToOsmPrecision(ll.lon()); 157 157 } 158 158 } … … 172 172 return true; 173 173 } 174 174 175 175 /** 176 176 * The two bounds intersect? Compared to java Shape.intersects, if does not use … … 178 178 */ 179 179 public boolean intersects(Bounds b) { 180 181 182 183 184 } 185 180 return b.getMax().lat() >= minLat && 181 b.getMax().lon() >= minLon && 182 b.getMin().lat() <= maxLat && 183 b.getMin().lon() <= maxLon; 184 } 185 186 186 187 187 /** … … 242 242 243 243 /** 244 * Returns a clone of this Bounds,rounded to OSM precisions, i.e. to244 * Returns the value rounded to OSM precisions, i.e. to 245 245 * LatLon.MAX_SERVER_PRECISION 246 246 * 247 * @return a clone of this Bounds 248 */ 249 public Bounds getRoundedToOsmPrecision() { 250 return new Bounds( 251 Math.round(minLat / LatLon.MAX_SERVER_PRECISION) * LatLon.MAX_SERVER_PRECISION, 252 Math.round(minLon / LatLon.MAX_SERVER_PRECISION) * LatLon.MAX_SERVER_PRECISION, 253 Math.round(maxLat / LatLon.MAX_SERVER_PRECISION) * LatLon.MAX_SERVER_PRECISION, 254 Math.round(maxLon / LatLon.MAX_SERVER_PRECISION) * LatLon.MAX_SERVER_PRECISION 255 ); 247 * @return rounded value 248 */ 249 private double roundToOsmPrecision(double value) { 250 return Math.round(value / LatLon.MAX_SERVER_PRECISION) * LatLon.MAX_SERVER_PRECISION; 256 251 } 257 252 }
Note:
See TracChangeset
for help on using the changeset viewer.