def calc_distance(current_x, current_y, new_x, new_y):
distancex = new_x - current_x
if distancex < -89:
distancex += 360
elif distancex > 89:
distancex -= 360
if distancex < 0.0:
distancex = -distancex
distancey = new_y - current_y
if distancey < -180:
distancey += 360
elif distancey > 180:
distancey -= 360
if distancey < 0.0:
distancey = -distancey
return distancex, distancey