[Groonga-commit] groonga/groonga [master] test: fix not to calculate the value of distance by splitting region excessively

Back to archive index

HAYASHI Kentaro null+****@clear*****
Mon Nov 12 13:42:32 JST 2012


HAYASHI Kentaro	2012-11-12 13:42:32 +0900 (Mon, 12 Nov 2012)

  New Revision: fbb7924d4448602742de88d6c597632e54e3a6f5
  https://github.com/groonga/groonga/commit/fbb7924d4448602742de88d6c597632e54e3a6f5

  Log:
    test: fix not to calculate the value of distance by splitting region excessively

  Modified files:
    test/command/tools/geo/generate-grntest-data.rb

  Modified: test/command/tools/geo/generate-grntest-data.rb (+11 -13)
===================================================================
--- test/command/tools/geo/generate-grntest-data.rb    2012-11-12 13:34:07 +0900 (5fb7eb3)
+++ test/command/tools/geo/generate-grntest-data.rb    2012-11-12 13:42:32 +0900 (079ccce)
@@ -555,19 +555,17 @@ class GrnTestData
   def geo_distance_short_type
     case quadrant
     when "1st_to_2nd", "2nd_to_1st", "3rd_to_4th", "4th_to_3rd"
-      longitude_delta = @longitude_end_degree - @longitude_start_degree
-      latitude_delta = @latitude_end_degree - @latitude_start_degree
-      slope = latitude_delta / longitude_delta.to_f
-      intercept = @latitude_start_degree - slope * @longitude_start_degree
-      east_distance = calculate_distance(@longitude_start.to_i,
-                                         @latitude_start.to_i,
-                                         0,
-                                         intercept * GRN_GEO_RESOLUTION)
-      west_distance = calculate_distance(0,
-                                         intercept * GRN_GEO_RESOLUTION,
-                                         @longitude_end.to_i,
-                                         @latitude_end.to_i)
-      (east_distance + west_distance).floor
+      if @latitude_end_degree > @latitude_start_degree
+        calculate_distance(@longitude_start.to_i,
+                           @latitude_start.to_i,
+                           @longitude_end.to_i,
+                           @latitude_end.to_i).floor
+      else
+        calculate_distance(@longitude_end.to_i,
+                           @latitude_end.to_i,
+                           @longitude_start.to_i,
+                           @latitude_start.to_i).floor
+      end
     when "1st_to_4th", "4th_to_1st", "2nd_to_3rd", "3rd_to_2nd"
       if @latitude_end_degree > @latitude_start_degree
         calculate_distance(@longitude_start.to_i,
-------------- next part --------------
HTML����������������������������...
Télécharger 



More information about the Groonga-commit mailing list
Back to archive index