X-Git-Url: https://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Fgui%2Fmap%2FMapUtils.java;h=78206a3956959f6126ed1568a29893a61ce76e36;hp=0c6cd1cb2ee5818e96444b944732772ad7fdeafd;hb=4d5796d02a15808311c09448d79e6e7d1de9d636;hpb=f1b92378a792131ac8fb33a869405851d5b2d1f7 diff --git a/tim/prune/gui/map/MapUtils.java b/tim/prune/gui/map/MapUtils.java index 0c6cd1c..78206a3 100644 --- a/tim/prune/gui/map/MapUtils.java +++ b/tim/prune/gui/map/MapUtils.java @@ -27,12 +27,16 @@ public abstract class MapUtils /** * Transform an x coordinate into a longitude - * @param inX scaled X value from 0 to 1 + * @param inX scaled X value from 0(-180deg) to 1(+180deg) * @return longitude in degrees */ public static double getLongitudeFromX(double inX) { - return inX * 360.0 - 180.0; + // Ensure x is really between 0 and 1 (to wrap longitudes) + double x = ((inX % 1.0) + 1.0) % 1.0; + // Note: First %1.0 restricts range to (-1,1), then +1.0 shifts to (0,2) + // Finally, %1.0 to give (0,1) + return x * 360.0 - 180.0; } /**