HAYASHI Kentaro
null+****@clear*****
Mon Nov 5 15:51:04 JST 2012
HAYASHI Kentaro 2012-11-05 15:51:04 +0900 (Mon, 05 Nov 2012) New Revision: 9bdf313e86b15213b454f0ee3f0b96a1b86a4bc0 https://github.com/groonga/groonga/commit/9bdf313e86b15213b454f0ee3f0b96a1b86a4bc0 Log: test: split when clause from 2nd quadrant to 4th one Modified files: test/command/tools/geo/generate-grntest-data.rb Modified: test/command/tools/geo/generate-grntest-data.rb (+68 -1) =================================================================== --- test/command/tools/geo/generate-grntest-data.rb 2012-11-05 12:59:35 +0900 (a0375fe) +++ test/command/tools/geo/generate-grntest-data.rb 2012-11-05 15:51:04 +0900 (755ff04) @@ -723,7 +723,7 @@ class GrnTestData 180 * GRN_GEO_RESOLUTION, latitude_on_180 * GRN_GEO_RESOLUTION) (east_distance + west_distance).floor - when "1st_to_3rd", "3rd_to_1st", "2nd_to_4th" + when "1st_to_3rd", "3rd_to_1st" if @longitude_start_degree > @longitude_end_degree rounded_longitude_degree = @longitude_end_degree + 360 rounded_latitude_degree = @latitude_end_degree @@ -790,6 +790,73 @@ class GrnTestData third_latitude) (first_distance + third_distance).floor end + when "2nd_to_4th" + if @longitude_start_degree > @longitude_end_degree + rounded_longitude_degree = @longitude_end_degree + 360 + rounded_latitude_degree = @latitude_end_degree + base_longitude_degree = @longitude_start_degree + base_latitude_degree = @latitude_start_degree + base_longitude = @longitude_start.to_i + base_latitude = @latitude_start.to_i + third_longitude = @longitude_end.to_i + third_latitude = @latitude_end.to_i + else + rounded_longitude_degree = @longitude_start_degree + 360 + rounded_latitude_degree = @latitude_start_degree + base_longitude_degree = @longitude_end_degree + base_latitude_degree = @latitude_end_degree + base_longitude = @longitude_end.to_i + base_latitude = @latitude_end.to_i + third_longitude = @longitude_start.to_i + third_latitude = @latitude_start.to_i + end + longitude_delta = rounded_longitude_degree - base_longitude_degree + latitude_delta = rounded_latitude_degree - base_latitude_degree + slope = latitude_delta / longitude_delta.to_f + intercept = base_latitude_degree - slope * base_longitude_degree + latitude_on_180 = (slope * 180 + intercept) * GRN_GEO_RESOLUTION + longitude_on_equator = (-intercept / slope) + inverted_longitude = (360 - longitude_on_equator) * GRN_GEO_RESOLUTION + longitude_on_equator *= GRN_GEO_RESOLUTION + if latitude_on_180 > 0 + first_distance = calculate_distance(base_longitude, + base_latitude, + inverted_longitude, + 0) + intermediate_distance = calculate_distance(inverted_longitude, + 0, + GRN_GEO_180DEGREE_RESOLUTION, + latitude_on_180) + third_distance = calculate_distance(GRN_GEO_180DEGREE_RESOLUTION, + latitude_on_180, + -third_longitude, + third_latitude) + (first_distance + intermediate_distance + third_distance).floor + elsif latitude_on_180 < 0 + first_distance = calculate_distance(base_longitude, + base_latitude, + GRN_GEO_180DEGREE_RESOLUTION, + latitude_on_180) + intermediate_distance = calculate_distance(GRN_GEO_180DEGREE_RESOLUTION, + latitude_on_180, + inverted_longitude, + 0) + third_distance = calculate_distance(inverted_longitude, + 0, + -third_longitude, + third_latitude) + (first_distance + intermediate_distance + third_distance).floor + else + first_distance = calculate_distance(base_longitude, + base_latitude, + GRN_GEO_180DEGREE_RESOLUTION, + 0) + third_distance = calculate_distance(-GRN_GEO_180DEGREE_RESOLUTION, + 0, + third_longitude, + third_latitude) + (first_distance + third_distance).floor + end end end end -------------- next part -------------- HTML����������������������������...Download