null+****@clear*****
null+****@clear*****
2010年 8月 11日 (水) 15:43:35 JST
Kouhei Sutou 2010-08-11 06:43:35 +0000 (Wed, 11 Aug 2010) New Revision: 2090b4dddc256b909aa6f1d2855566f5094d574b Log: remove duplicated codes. Modified files: lib/geo.c Modified: lib/geo.c (+15 -15) =================================================================== --- lib/geo.c 2010-08-11 06:37:53 +0000 (c01008c) +++ lib/geo.c 2010-08-11 06:43:35 +0000 (d5a1c95) @@ -513,34 +513,34 @@ grn_geo_search(grn_ctx *ctx, grn_obj *obj, grn_obj **args, int nargs, lat1 = GRN_GEO_INT2RAD(geo_point1->latitude); switch (pos2->header.domain) { case GRN_DB_INT32 : - d = GRN_INT32_VALUE(pos2); - geo_point2.latitude = geo_point1->latitude + GRN_GEO_RAD2INT(d / GRN_GEO_RADIUS); + d = GRN_INT32_VALUE(pos2) / (double)GRN_GEO_RADIUS; + geo_point2.latitude = geo_point1->latitude + GRN_GEO_RAD2INT(d); geo_point2.longitude = geo_point1->longitude; - d = (d / GRN_GEO_RADIUS) * (d / GRN_GEO_RADIUS); + d = d * d; break; case GRN_DB_UINT32 : - d = GRN_UINT32_VALUE(pos2); - geo_point2.latitude = geo_point1->latitude + GRN_GEO_RAD2INT(d / GRN_GEO_RADIUS); + d = GRN_UINT32_VALUE(pos2) / (double)GRN_GEO_RADIUS; + geo_point2.latitude = geo_point1->latitude + GRN_GEO_RAD2INT(d); geo_point2.longitude = geo_point1->longitude; - d = (d / GRN_GEO_RADIUS) * (d / GRN_GEO_RADIUS); + d = (d) * (d); break; case GRN_DB_INT64 : - d = GRN_INT64_VALUE(pos2); - geo_point2.latitude = geo_point1->latitude + GRN_GEO_RAD2INT(d / GRN_GEO_RADIUS); + d = GRN_INT64_VALUE(pos2) / (double)GRN_GEO_RADIUS; + geo_point2.latitude = geo_point1->latitude + GRN_GEO_RAD2INT(d); geo_point2.longitude = geo_point1->longitude; - d = (d / GRN_GEO_RADIUS) * (d / GRN_GEO_RADIUS); + d = d * d; break; case GRN_DB_UINT64 : - d = GRN_UINT64_VALUE(pos2); - geo_point2.latitude = geo_point1->latitude + GRN_GEO_RAD2INT(d / GRN_GEO_RADIUS); + d = GRN_UINT64_VALUE(pos2) / (double)GRN_GEO_RADIUS; + geo_point2.latitude = geo_point1->latitude + GRN_GEO_RAD2INT(d); geo_point2.longitude = geo_point1->longitude; - d = (d / GRN_GEO_RADIUS) * (d / GRN_GEO_RADIUS); + d = d * d; break; case GRN_DB_FLOAT : - d = GRN_FLOAT_VALUE(pos2); - geo_point2.latitude = geo_point1->latitude + GRN_GEO_RAD2INT(d / GRN_GEO_RADIUS); + d = GRN_FLOAT_VALUE(pos2) / (double)GRN_GEO_RADIUS; + geo_point2.latitude = geo_point1->latitude + GRN_GEO_RAD2INT(d); geo_point2.longitude = geo_point1->longitude; - d = (d / GRN_GEO_RADIUS) * (d / GRN_GEO_RADIUS); + d = d * d; break; case GRN_DB_SHORT_TEXT : case GRN_DB_TEXT :