[Groonga-commit] groonga/groonga [master] test: calculate distance by approximate_type "rectangle"

Back to archive index

Ryo Onodera onode****@clear*****
2012年 5月 22日 (火) 11:51:37 JST


小野寺です。

> +  def geo_int2rad(value)
> +    ((Math::PI / (GRN_GEO_RESOLUTION * 180)) * (value))
> +  end

ここの一番外側の括弧とvalueだけを囲っている括弧はいらないかなと思いまし
た。具体的には以下のようにするとよいと思います。

式の結合を強制するための括弧は、あればあるほど読みにくくなると思いますの
で、いらない時は書かなくてよいと思います。

> +  def geo_int2rad(value)
> +    (Math::PI / (GRN_GEO_RESOLUTION * 180)) * value
> +  end

On Mon, 2012-05-21 at 18:44 +0900, null+****@clear***** wrote:
> HAYASHI Kentaro	2012-05-21 18:44:32 +0900 (Mon, 21 May 2012)
> 
>   New Revision: b79f57d962fcd24c9b97847d97e1b668e3d26284
> 
>   Log:
>     test: calculate distance by approximate_type "rectangle"
> 
>   Modified files:
>     test/function/tools/geo/generate-grntest-data.rb
> 
>   Modified: test/function/tools/geo/generate-grntest-data.rb (+17 -1)
> ===================================================================
> --- test/function/tools/geo/generate-grntest-data.rb    2012-05-21 18:42:40 +0900 (fa1b4e7)
> +++ test/function/tools/geo/generate-grntest-data.rb    2012-05-21 18:44:32 +0900 (1ecc1d6)
> @@ -20,6 +20,9 @@ SELECT = "select Geo --output_columns distance "
>  SELECT_PRE = "[[0,0.0,0.0],[[[1],[[\"distance\",\"Int32\"]],["
>  SELECT_POST = "]]]]"
>  
> +GRN_GEO_RESOLUTION=3600000
> +GRN_GEO_RADIUS=6357303
> +
>  class GrnTestData
>    attr_accessor :csv_file
>    attr_accessor :options
> @@ -414,8 +417,21 @@ class GrnTestData
>              SELECT, scorer, select_postfix)
>    end
>  
> +  def geo_int2rad(value)
> +    ((Math::PI / (GRN_GEO_RESOLUTION * 180)) * (value))
> +  end
> +
>    def geo_distance(app_type)
> -    0
> +    case app_type
> +    when "", "rect", "rectangle"
> +      lat1 = geo_int2rad(@latitude_start_degree)
> +      lng1 = geo_int2rad(@longitude_start_degree)
> +      lat2 = geo_int2rad(@latitude_end_degree)
> +      lng2 = geo_int2rad(@longitude_end_degree)
> +      x = (lng2 - lng1) * Math.cos((lat1 + lat2) * 0.5)
> +      y = (lat2 - lat1)
> +      return (Math.sqrt((x * x) + (y * y)) * GRN_GEO_RADIUS).floor
> +    end
>    end
>  
>    def generate_expected_data(app_type)
> 
> _______________________________________________
> Groonga-commit mailing list
> Groon****@lists*****
> http://lists.sourceforge.jp/mailman/listinfo/groonga-commit




Groonga-commit メーリングリストの案内
Back to archive index