null+****@clear*****
null+****@clear*****
2010年 7月 2日 (金) 17:38:23 JST
Daijiro MORI 2010-07-02 08:38:23 +0000 (Fri, 02 Jul 2010) New Revision: 518d8ea22b83c9a298af974335d3768e6b7ccfc5 Log: Fixed wrong distance calculation in grn_geo_search(). Modified files: lib/expr.c lib/proc.c Modified: lib/expr.c (+2 -2) =================================================================== --- lib/expr.c 2010-07-02 07:25:49 +0000 (05a6068) +++ lib/expr.c 2010-07-02 08:38:23 +0000 (d4b5a78) @@ -3455,7 +3455,7 @@ scan_info_build(grn_ctx *ctx, grn_obj *expr, int *n, } break; case GRN_OP_CALL : - if (c->flags & GRN_EXPR_CODE_RELATIONAL_EXPRESSION || c + 1 == ce) { + if ((c->flags & GRN_EXPR_CODE_RELATIONAL_EXPRESSION) || c + 1 == ce) { stat = SCAN_START; m++; } else { @@ -3577,7 +3577,7 @@ scan_info_build(grn_ctx *ctx, grn_obj *expr, int *n, break; case GRN_OP_CALL : if (!si) { SI_ALLOC(si, i, c - e->codes); } - if (c->flags & GRN_EXPR_CODE_RELATIONAL_EXPRESSION || c + 1 == ce) { + if ((c->flags & GRN_EXPR_CODE_RELATIONAL_EXPRESSION) || c + 1 == ce) { stat = SCAN_START; si->op = c->op; si->end = c - e->codes; Modified: lib/proc.c (+5 -5) =================================================================== --- lib/proc.c 2010-07-02 07:25:49 +0000 (e8d1617) +++ lib/proc.c 2010-07-02 08:38:23 +0000 (4a1141c) @@ -1979,23 +1979,23 @@ grn_geo_search(grn_ctx *ctx, grn_obj *obj, grn_obj **args, int nargs, switch (pos2->header.domain) { case GRN_DB_INT32 : d = GRN_INT32_VALUE(pos2); - d = d * d / GEO_RADIOUS; + d = (d / GEO_RADIOUS) * (d / GEO_RADIOUS); break; case GRN_DB_UINT32 : d = GRN_UINT32_VALUE(pos2); - d = d * d / GEO_RADIOUS; + d = (d / GEO_RADIOUS) * (d / GEO_RADIOUS); break; case GRN_DB_INT64 : d = GRN_INT64_VALUE(pos2); - d = d * d / GEO_RADIOUS; + d = (d / GEO_RADIOUS) * (d / GEO_RADIOUS); break; case GRN_DB_UINT64 : d = GRN_UINT64_VALUE(pos2); - d = d * d / GEO_RADIOUS; + d = (d / GEO_RADIOUS) * (d / GEO_RADIOUS); break; case GRN_DB_FLOAT : d = GRN_FLOAT_VALUE(pos2); - d = d * d / GEO_RADIOUS; + d = (d / GEO_RADIOUS) * (d / GEO_RADIOUS); break; case GRN_DB_SHORT_TEXT : case GRN_DB_TEXT :