mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +00:00
Fix mistake in greatCircleAngle
This commit is contained in:
parent
10160e5adf
commit
f4a05bd773
@ -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".
|
||||
|
@ -0,0 +1,5 @@
|
||||
0.1224
|
||||
0.7071
|
||||
0.7135
|
||||
10007554
|
||||
10007554
|
6
tests/queries/0_stateless/01678_great_circle_angle.sql
Normal file
6
tests/queries/0_stateless/01678_great_circle_angle.sql
Normal 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);
|
Loading…
Reference in New Issue
Block a user