Changeset 10914 in josm
- Timestamp:
- 2016-08-29T17:44:50+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r10334 r10914 131 131 } 132 132 133 /** 134 * Clamp the lat value to be inside the world. 135 * @param value The value 136 * @return The value clamped to the world. 137 */ 133 138 public static double toIntervalLat(double value) { 134 if (value < -90) 135 return -90; 136 if (value > 90) 137 return 90; 138 return value; 139 return Utils.clamp(value, -90, 90); 139 140 } 140 141 … … 419 420 } 420 421 422 /** 423 * Interpolate between this and a other latlon 424 * @param ll2 The other lat/lon object 425 * @param proportion The proportion to interpolate 426 * @return a new latlon at this position if proportion is 0, at the other position it proportion is 1 and lineary interpolated otherwise. 427 */ 421 428 public LatLon interpolate(LatLon ll2, double proportion) { 422 429 return new LatLon(this.lat() + proportion * (ll2.lat() - this.lat()), … … 424 431 } 425 432 433 /** 434 * Get the center between two lat/lon points 435 * @param ll2 The other {@link LatLon} 436 * @return The center at the average coordinates of the two points. Does not take the 180° meridian into account. 437 */ 426 438 public LatLon getCenter(LatLon ll2) { 427 return new LatLon((this.lat() + ll2.lat())/2.0, (this.lon() + ll2.lon())/2.0);439 return interpolate(ll2, .5); 428 440 } 429 441
Note:
See TracChangeset
for help on using the changeset viewer.