Fix mistake in greatCircleAngle

This commit is contained in:
Alexey Milovidov 2021-01-29 05:05:46 +03:00
parent 10160e5adf
commit f4a05bd773
3 changed files with 13 additions and 2 deletions

View File

@ -95,7 +95,7 @@ void geodistInit()
sphere_metric_meters_lut[i] = static_cast<float>(sqr((EARTH_DIAMETER * PI / 360) * cos(latitude)));
sphere_metric_lut[i] = cosf(latitude);
sphere_metric_lut[i] = sqr(cosf(latitude));
}
}
@ -182,7 +182,7 @@ float distance(float lon1deg, float lat1deg, float lon2deg, float lat2deg)
/// (Remember how a plane flies from Moscow to New York)
/// But if longitude is close but latitude is different enough, there is no difference between meridian and great circle line.
float latitude_midpoint = (lat1deg + lat2deg + 180) * METRIC_LUT_SIZE / 360; // [-90, 90] degrees -> [0, KTABLE] indexes
float latitude_midpoint = (lat1deg + lat2deg + 180) * METRIC_LUT_SIZE / 360; // [-90, 90] degrees -> [0, METRIC_LUT_SIZE] indexes
size_t latitude_midpoint_index = floatToIndex(latitude_midpoint) & (METRIC_LUT_SIZE - 1);
/// This is linear interpolation between two table items at index "latitude_midpoint_index" and "latitude_midpoint_index + 1".

View File

@ -0,0 +1,5 @@
0.1224
0.7071
0.7135
10007554
10007554

View File

@ -0,0 +1,6 @@
SELECT round(greatCircleAngle(0, 45, 0.1, 45.1), 4);
SELECT round(greatCircleAngle(0, 45, 1, 45), 4);
SELECT round(greatCircleAngle(0, 45, 1, 45.1), 4);
SELECT round(greatCircleDistance(0, 0, 0, 90), 4);
SELECT round(greatCircleDistance(0, 0, 90, 0), 4);