[android] #4475 - Only wrapping when needed in LatLng.wrap(). Making Javadoc more clear. Making tests consistent.

This commit is contained in:
Brad Leege
2016-03-25 16:32:33 -05:00
parent 464c29f043
commit 7a9a58f4fb
3 changed files with 16 additions and 5 deletions

View File

@@ -126,7 +126,10 @@ public class LatLng implements ILatLng, Parcelable {
*/
public LatLng wrap(){
LatLng wrappedVersion = new LatLng(this);
wrappedVersion.setLongitude(MathUtils.wrap(wrappedVersion.getLongitude(), GeoConstants.MIN_LONGITUDE, GeoConstants.MAX_LONGITUDE));
double lon = wrappedVersion.getLongitude();
if (lon < GeoConstants.MIN_LONGITUDE || lon > GeoConstants.MAX_LONGITUDE) {
wrappedVersion.setLongitude(MathUtils.wrap(wrappedVersion.getLongitude(), GeoConstants.MIN_LONGITUDE, GeoConstants.MAX_LONGITUDE));
}
return wrappedVersion;
}

View File

@@ -25,7 +25,7 @@ public class MathUtils {
}
/**
* Constrains n to the given range (including min, excluding max) via modular arithmetic.
* Constrains value to the given range (including min, excluding max) via modular arithmetic.
*
* Same formula as used in Core GL (math.hpp)
* std::fmod((std::fmod((value - min), d) + d), d) + min;