From 791052e259ae96dda56f9cfa2157f2a7a3040cbd Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 3 Aug 2016 15:06:57 +0200 Subject: [PATCH] cleaner code: replace while() statements --- sanitiser/wrap.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/sanitiser/wrap.js b/sanitiser/wrap.js index c89088e7..bc8a9cd2 100644 --- a/sanitiser/wrap.js +++ b/sanitiser/wrap.js @@ -34,14 +34,8 @@ function wrap( lat, lon ){ break; } - // reduce lon - while( point.lon > 180 ){ - point.lon -= 360; - } - - // increase lon - while( point.lon < -180 ){ - point.lon += 360; + if( point.lon > 180 || point.lon <= -180 ){ + point.lon -= Math.floor(( point.lon + 180 ) / 360) * 360; } return point;