Commit 539b3ca8 authored by Alexander Barkov's avatar Alexander Barkov

- Moving Item_func_spatial_mbr_rel from Item_bool_func2 to Item_bool_func,

  as Item_func_spatial_mbr_rel needs nothing from Item_bool_func2.
- Renaming Item_func_spacial_rel (the class that implements precise spacial
  relations) to Item_func_spatial_precise_rel
- Adding a new abstract class Item_func_spatial_rel as a common parent
  for Item_func_spatial_precise_rel and Item_func_spatial_mbr_rel.
parent 2fe4d0e6
......@@ -3560,8 +3560,8 @@ Create_func_contains Create_func_contains::s_singleton;
Item*
Create_func_contains::create_2_arg(THD *thd, Item *arg1, Item *arg2)
{
return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
Item_func::SP_CONTAINS_FUNC);
return new (thd->mem_root) Item_func_spatial_precise_rel(arg1, arg2,
Item_func::SP_CONTAINS_FUNC);
}
#endif
......@@ -3617,7 +3617,7 @@ Create_func_crosses Create_func_crosses::s_singleton;
Item*
Create_func_crosses::create_2_arg(THD *thd, Item *arg1, Item *arg2)
{
return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
return new (thd->mem_root) Item_func_spatial_precise_rel(arg1, arg2,
Item_func::SP_CROSSES_FUNC);
}
#endif
......@@ -3800,8 +3800,8 @@ Create_func_disjoint Create_func_disjoint::s_singleton;
Item*
Create_func_disjoint::create_2_arg(THD *thd, Item *arg1, Item *arg2)
{
return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
Item_func::SP_DISJOINT_FUNC);
return new (thd->mem_root) Item_func_spatial_precise_rel(arg1, arg2,
Item_func::SP_DISJOINT_FUNC);
}
......@@ -3931,8 +3931,8 @@ Create_func_equals Create_func_equals::s_singleton;
Item*
Create_func_equals::create_2_arg(THD *thd, Item *arg1, Item *arg2)
{
return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
Item_func::SP_EQUALS_FUNC);
return new (thd->mem_root) Item_func_spatial_precise_rel(arg1, arg2,
Item_func::SP_EQUALS_FUNC);
}
#endif
......@@ -4427,7 +4427,7 @@ Create_func_relate Create_func_relate::s_singleton;
Item*
Create_func_relate::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *matrix)
{
return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2, matrix);
return new (thd->mem_root) Item_func_spatial_precise_rel(arg1, arg2, matrix);
}
......@@ -4446,8 +4446,8 @@ Create_func_intersects Create_func_intersects::s_singleton;
Item*
Create_func_intersects::create_2_arg(THD *thd, Item *arg1, Item *arg2)
{
return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
Item_func::SP_INTERSECTS_FUNC);
return new (thd->mem_root) Item_func_spatial_precise_rel(arg1, arg2,
Item_func::SP_INTERSECTS_FUNC);
}
......@@ -5048,8 +5048,8 @@ Create_func_overlaps Create_func_overlaps::s_singleton;
Item*
Create_func_overlaps::create_2_arg(THD *thd, Item *arg1, Item *arg2)
{
return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
Item_func::SP_OVERLAPS_FUNC);
return new (thd->mem_root) Item_func_spatial_precise_rel(arg1, arg2,
Item_func::SP_OVERLAPS_FUNC);
}
#endif
......@@ -5485,7 +5485,7 @@ Create_func_touches Create_func_touches::s_singleton;
Item*
Create_func_touches::create_2_arg(THD *thd, Item *arg1, Item *arg2)
{
return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
return new (thd->mem_root) Item_func_spatial_precise_rel(arg1, arg2,
Item_func::SP_TOUCHES_FUNC);
}
#endif
......@@ -5636,8 +5636,8 @@ Create_func_within Create_func_within::s_singleton;
Item*
Create_func_within::create_2_arg(THD *thd, Item *arg1, Item *arg2)
{
return new (thd->mem_root) Item_func_spatial_rel(arg1, arg2,
Item_func::SP_WITHIN_FUNC);
return new (thd->mem_root) Item_func_spatial_precise_rel(arg1, arg2,
Item_func::SP_WITHIN_FUNC);
}
#endif
......
......@@ -957,8 +957,8 @@ const char *Item_func_spatial_mbr_rel::func_name() const
longlong Item_func_spatial_mbr_rel::val_int()
{
DBUG_ASSERT(fixed == 1);
String *res1= args[0]->val_str(&cmp.value1);
String *res2= args[1]->val_str(&cmp.value2);
String *res1= args[0]->val_str(&tmp_value1);
String *res2= args[1]->val_str(&tmp_value2);
Geometry_buffer buffer1, buffer2;
Geometry *g1, *g2;
MBR mbr1, mbr2;
......@@ -999,25 +999,7 @@ longlong Item_func_spatial_mbr_rel::val_int()
}
Item_func_spatial_rel::Item_func_spatial_rel(Item *a,Item *b,
enum Functype sp_rel) :
Item_bool_func(a,b), collector()
{
spatial_rel = sp_rel;
}
Item_func_spatial_rel::Item_func_spatial_rel(Item *a,Item *b, Item *mask) :
Item_bool_func(a,b,mask), spatial_rel(SP_RELATE_FUNC)
{}
Item_func_spatial_rel::~Item_func_spatial_rel()
{
}
const char *Item_func_spatial_rel::func_name() const
const char *Item_func_spatial_precise_rel::func_name() const
{
switch (spatial_rel) {
case SP_CONTAINS_FUNC:
......@@ -1158,9 +1140,9 @@ static int setup_relate_func(Geometry *g1, Geometry *g2,
#define GIS_ZERO 0.00000000001
longlong Item_func_spatial_rel::val_int()
longlong Item_func_spatial_precise_rel::val_int()
{
DBUG_ENTER("Item_func_spatial_rel::val_int");
DBUG_ENTER("Item_func_spatial_precise_rel::val_int");
DBUG_ASSERT(fixed == 1);
String *res1;
String *res2;
......
......@@ -272,54 +272,51 @@ public:
Spatial relations
*/
class Item_func_spatial_mbr_rel: public Item_bool_func2
class Item_func_spatial_rel: public Item_bool_func
{
protected:
enum Functype spatial_rel;
String tmp_value1, tmp_value2;
public:
Item_func_spatial_rel(Item *a, Item *b, enum Functype sp_rel)
:Item_bool_func(a, b), spatial_rel(sp_rel)
{ }
Item_func_spatial_rel(Item *a, Item *b, Item *c, enum Functype sp_rel)
:Item_bool_func(a, b, c), spatial_rel(sp_rel)
{ }
enum Functype functype() const { return spatial_rel; }
enum Functype rev_functype() const { return spatial_rel; }
bool is_null() { (void) val_int(); return null_value; }
optimize_type select_optimize() const { return OPTIMIZE_OP; }
};
class Item_func_spatial_mbr_rel: public Item_func_spatial_rel
{
public:
Item_func_spatial_mbr_rel(Item *a,Item *b, enum Functype sp_rel) :
Item_bool_func2(a,b) { spatial_rel = sp_rel; }
Item_func_spatial_mbr_rel(Item *a, Item *b, enum Functype sp_rel)
:Item_func_spatial_rel(a, b, sp_rel)
{ }
longlong val_int();
enum Functype functype() const
{
return spatial_rel;
}
enum Functype rev_functype() const { return spatial_rel; }
const char *func_name() const;
virtual inline void print(String *str, enum_query_type query_type)
{
Item_func::print(str, query_type);
}
void fix_length_and_dec() { maybe_null= 1; }
bool is_null() { (void) val_int(); return null_value; }
};
class Item_func_spatial_rel: public Item_bool_func
class Item_func_spatial_precise_rel: public Item_func_spatial_rel
{
enum Functype spatial_rel;
Gcalc_heap collector;
Gcalc_scan_iterator scan_it;
Gcalc_function func;
String tmp_value1,tmp_value2, tmp_matrix;
public:
Item_func_spatial_rel(Item *a,Item *b, enum Functype sp_rel);
Item_func_spatial_rel(Item *a, Item *b, Item *matrix);
virtual ~Item_func_spatial_rel();
String tmp_matrix;
public:
Item_func_spatial_precise_rel(Item *a, Item *b, enum Functype sp_rel)
:Item_func_spatial_rel(a, b, sp_rel), collector()
{ }
Item_func_spatial_precise_rel(Item *a, Item *b, Item *matrix)
:Item_func_spatial_rel(a, b, matrix, SP_RELATE_FUNC)
{ }
longlong val_int();
enum Functype functype() const
{
return spatial_rel;
}
enum Functype rev_functype() const { return spatial_rel; }
const char *func_name() const;
virtual inline void print(String *str, enum_query_type query_type)
{
Item_func::print(str, query_type);
}
bool is_null() { (void) val_int(); return null_value; }
uint decimal_precision() const { return 1; }
optimize_type select_optimize() const { return OPTIMIZE_OP; }
};
......
......@@ -9938,8 +9938,8 @@ geometry_function:
CONTAINS_SYM '(' expr ',' expr ')'
{
$$= GEOM_NEW(thd,
Item_func_spatial_rel($3, $5,
Item_func::SP_CONTAINS_FUNC));
Item_func_spatial_precise_rel($3, $5,
Item_func::SP_CONTAINS_FUNC));
}
| GEOMETRYCOLLECTION '(' expr_list ')'
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment