Changeset 9123 in josm for trunk/src/org
- Timestamp:
- 2015-12-14T23:11:44+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r9122 r9123 206 206 } 207 207 208 /** 209 * Get the distance in meter that correspond to 100 px on screen. 210 * 211 * @return the distance in meter that correspond to 100 px on screen 212 */ 208 213 public double getDist100Pixel() { 214 return getDist100Pixel(true); 215 } 216 217 /** 218 * Get the distance in meter that correspond to 100 px on screen. 219 * 220 * @param alwaysPositive if true, makes sure the return value is always 221 * > 0. (Two points 100 px apart can appear to be identical if the user 222 * has zoomed out a lot and the projection code does something funny.) 223 * @return the distance in meter that correspond to 100 px on screen 224 */ 225 public double getDist100Pixel(boolean alwaysPositive) { 209 226 int w = getWidth()/2; 210 227 int h = getHeight()/2; 211 228 LatLon ll1 = getLatLon(w-50, h); 212 229 LatLon ll2 = getLatLon(w+50, h); 213 return ll1.greatCircleDistance(ll2); 230 double gcd = ll1.greatCircleDistance(ll2); 231 if (alwaysPositive && gcd <= 0) 232 return 0.1; 233 return gcd; 214 234 } 215 235
Note:
See TracChangeset
for help on using the changeset viewer.