Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix vincenty inverse for equatorial line #2282
I looked in detail the calculation of vincenty inverse to fix the unit test on Alpine (see #1825). I think that a case is not correctly handled when
The problematic unit test calculates the distance between (0, 0) and (0, 17) which is precisely an equatorial line. Handling the
Moreover, this case is also handled in geopy in the same way.
I also did some minor changes:
u2 = pow(math.cos(alpha), 2) * (a * a - b * b) / (b * b) _a = 1 + (u2 / 16384) * (4096 + u2 * (-768 + u2 * (320 - 175 * u2))) _b = (u2 / 1024) * (256 + u2 * (-128 + u2 * (74 - 47 * u2))) delta_sigma = _b * sin_sigma * \ (cos2sigma_m + (_b / 4) * (cos_sigma * (-1 + 2 * pow(cos2sigma_m, 2)) - (_b / 6) * cos2sigma_m * (-3 + 4 * sqr_sin_sigma) * (-3 + 4 * pow(cos2sigma_m, 2)))) dist = b * _a * (sigma - delta_sigma) alpha12 = math.atan2( (math.cos(u_2) * math.sin(dlon)), (math.cos(u_1) * math.sin(u_2) - math.sin(u_1) * math.cos(u_2) * math.cos(dlon))) alpha21 = math.atan2( (math.cos(u_1) * math.sin(dlon)), (-math.sin(u_1) * math.cos(u_2) + math.cos(u_1) * math.sin(u_2) * math.cos(dlon)))
It was useless to calculate these variables at each iteration, I moved the block at the end of the function.