1 #ifndef ITEM_GEOFUNC_INCLUDED
2 #define ITEM_GEOFUNC_INCLUDED
24 #include "gcalc_slicescan.h"
34 void fix_length_and_dec();
35 enum_field_types field_type()
const {
return MYSQL_TYPE_GEOMETRY; }
37 bool is_null() { (void) val_int();
return null_value; }
40 class Item_func_geometry_from_text:
public Item_geometry_func
43 Item_func_geometry_from_text(
Item *a) :Item_geometry_func(a) {}
44 Item_func_geometry_from_text(
Item *a,
Item *srid) :Item_geometry_func(a, srid) {}
45 const char *func_name()
const {
return "st_geometryfromtext"; }
49 class Item_func_geometry_from_wkb:
public Item_geometry_func
53 Item_func_geometry_from_wkb(
Item *a): Item_geometry_func(a) {}
54 Item_func_geometry_from_wkb(
Item *a,
Item *srid): Item_geometry_func(a, srid) {}
55 const char *func_name()
const {
return "st_geometryfromwkb"; }
63 const char *func_name()
const {
return "st_astext"; }
65 void fix_length_and_dec();
68 class Item_func_as_wkb:
public Item_geometry_func
71 Item_func_as_wkb(
Item *a): Item_geometry_func(a) {}
72 const char *func_name()
const {
return "st_aswkb"; }
74 enum_field_types field_type()
const {
return MYSQL_TYPE_BLOB; }
82 const char *func_name()
const {
return "st_geometrytype"; }
83 void fix_length_and_dec()
86 fix_length_and_charset(20, default_charset());
91 class Item_func_centroid:
public Item_geometry_func
94 Item_func_centroid(
Item *a): Item_geometry_func(a) {}
95 const char *func_name()
const {
return "st_centroid"; }
97 Field::geometry_type get_geometry_type()
const;
100 class Item_func_envelope:
public Item_geometry_func
103 Item_func_envelope(
Item *a): Item_geometry_func(a) {}
104 const char *func_name()
const {
return "st_envelope"; }
106 Field::geometry_type get_geometry_type()
const;
109 class Item_func_point:
public Item_geometry_func
112 Item_func_point(
Item *a,
Item *b): Item_geometry_func(a, b) {}
113 Item_func_point(
Item *a,
Item *b,
Item *srid): Item_geometry_func(a, b, srid) {}
114 const char *func_name()
const {
return "st_point"; }
116 Field::geometry_type get_geometry_type()
const;
119 class Item_func_spatial_decomp:
public Item_geometry_func
121 enum Functype decomp_func;
123 Item_func_spatial_decomp(
Item *a, Item_func::Functype ft) :
124 Item_geometry_func(a) { decomp_func = ft; }
125 const char *func_name()
const
130 return "st_startpoint";
132 return "st_endpoint";
133 case SP_EXTERIORRING:
134 return "st_exteriorring";
137 return "spatial_decomp_unknown";
143 class Item_func_spatial_decomp_n:
public Item_geometry_func
145 enum Functype decomp_func_n;
147 Item_func_spatial_decomp_n(
Item *a,
Item *b, Item_func::Functype ft):
148 Item_geometry_func(a, b) { decomp_func_n = ft; }
149 const char *func_name()
const
151 switch (decomp_func_n)
156 return "st_geometryn";
157 case SP_INTERIORRINGN:
158 return "st_interiorringn";
161 return "spatial_decomp_n_unknown";
167 class Item_func_spatial_collection:
public Item_geometry_func
170 enum Geometry::wkbType coll_type;
171 enum Geometry::wkbType item_type;
173 Item_func_spatial_collection(
174 List<Item> &list,
enum Geometry::wkbType ct,
enum Geometry::wkbType it):
175 Item_geometry_func(list)
181 void fix_length_and_dec()
183 Item_geometry_func::fix_length_and_dec();
184 for (
unsigned int i= 0;
i < arg_count; ++
i)
186 if (args[
i]->fixed && args[
i]->field_type() != MYSQL_TYPE_GEOMETRY)
189 args[
i]->print(&str, QT_ORDINARY);
191 my_error(ER_ILLEGAL_VALUE_FOR_TYPE, MYF(0),
"non geometric",
197 const char *func_name()
const {
return "st_multipoint"; }
207 enum Functype spatial_rel;
209 Item_func_spatial_mbr_rel(
Item *a,
Item *b,
enum Functype sp_rel) :
212 enum Functype functype()
const
216 enum Functype rev_functype()
const
220 case SP_CONTAINS_FUNC:
221 return SP_WITHIN_FUNC;
223 return SP_CONTAINS_FUNC;
229 const char *func_name()
const;
230 virtual inline void print(
String *str, enum_query_type query_type)
234 void fix_length_and_dec() { maybe_null= 1; }
235 bool is_null() { (void) val_int();
return null_value; }
241 enum Functype spatial_rel;
245 String tmp_value1,tmp_value2;
247 Item_func_spatial_rel(
Item *a,
Item *b,
enum Functype sp_rel);
248 virtual ~Item_func_spatial_rel();
250 enum Functype functype()
const
254 enum Functype rev_functype()
const
258 case SP_CONTAINS_FUNC:
259 return SP_WITHIN_FUNC;
261 return SP_CONTAINS_FUNC;
267 const char *func_name()
const;
268 virtual inline void print(
String *str, enum_query_type query_type)
273 void fix_length_and_dec() { maybe_null= 1; }
274 bool is_null() { (void) val_int();
return null_value; }
285 class Item_func_spatial_operation:
public Item_geometry_func
288 Gcalc_function::op_type spatial_op;
294 String tmp_value1,tmp_value2;
296 Item_func_spatial_operation(
Item *a,
Item *b, Gcalc_function::op_type sp_op) :
297 Item_geometry_func(a, b), spatial_op(sp_op)
299 virtual ~Item_func_spatial_operation();
301 const char *func_name()
const;
302 virtual inline void print(
String *str, enum_query_type query_type)
309 class Item_func_buffer:
public Item_geometry_func
316 Gcalc_function::op_type m_buffer_op;
318 double x00,y00,x01,y01;
320 double x3,
double y3,
bool round_p1,
bool round_p2);
328 m_buffer_op= d > 0.0 ? Gcalc_function::op_union :
329 Gcalc_function::op_difference;
344 bool skip_point()
const
345 {
return m_buffer_op == Gcalc_function::op_difference; }
346 bool skip_line_string()
const
347 {
return m_buffer_op == Gcalc_function::op_difference; }
348 bool skip_poly()
const
359 Item_func_buffer(
Item *obj,
Item *distance):
360 Item_geometry_func(obj, distance) {}
361 const char *func_name()
const {
return "st_buffer"; }
371 optimize_type select_optimize()
const {
return OPTIMIZE_NONE; }
372 const char *func_name()
const {
return "st_isempty"; }
373 void fix_length_and_dec() { maybe_null= 1; }
385 optimize_type select_optimize()
const {
return OPTIMIZE_NONE; }
386 const char *func_name()
const {
return "st_issimple"; }
387 void fix_length_and_dec() { maybe_null= 1; }
395 optimize_type select_optimize()
const {
return OPTIMIZE_NONE; }
396 const char *func_name()
const {
return "st_isclosed"; }
397 void fix_length_and_dec() { maybe_null= 1; }
406 const char *func_name()
const {
return "st_dimension"; }
407 void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
416 const char *func_name()
const {
return "st_x"; }
417 void fix_length_and_dec()
419 Item_real_func::fix_length_and_dec();
431 const char *func_name()
const {
return "st_y"; }
432 void fix_length_and_dec()
434 Item_real_func::fix_length_and_dec();
446 const char *func_name()
const {
return "st_numgeometries"; }
447 void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
457 const char *func_name()
const {
return "st_numinteriorrings"; }
458 void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
468 const char *func_name()
const {
return "st_numpoints"; }
469 void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
479 const char *func_name()
const {
return "st_area"; }
480 void fix_length_and_dec()
482 Item_real_func::fix_length_and_dec();
494 const char *func_name()
const {
return "st_length"; }
495 void fix_length_and_dec()
497 Item_real_func::fix_length_and_dec();
509 const char *func_name()
const {
return "srid"; }
510 void fix_length_and_dec() { max_length= 10; maybe_null= 1; }
524 const char *func_name()
const {
return "st_distance"; }
533 const char *func_name()
const {
return "st_gis_debug"; }
539 #define GEOM_NEW(thd, obj_constructor) new (thd->mem_root) obj_constructor
543 #define GEOM_NEW(thd, obj_constructor) NULL