mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
GIS code.
Forward calculations introduced. per-file comments: sql/gcalc_slicescan.cc sql/gcalc_slicescan.h sql/gcalc_tools.cc sql/gcalc_tools.h sql/item_geofunc.cc
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -28,11 +28,13 @@
|
|||||||
#define GCALC_DBUG_PRINT(b) DBUG_PRINT("Gcalc", b)
|
#define GCALC_DBUG_PRINT(b) DBUG_PRINT("Gcalc", b)
|
||||||
#define GCALC_DBUG_ENTER(a) DBUG_ENTER("Gcalc "a)
|
#define GCALC_DBUG_ENTER(a) DBUG_ENTER("Gcalc "a)
|
||||||
#define GCALC_DBUG_RETURN(r) DBUG_RETURN(r)
|
#define GCALC_DBUG_RETURN(r) DBUG_RETURN(r)
|
||||||
|
#define GCALC_DBUG_VOID_RETURN DBUG_VOID_RETURN
|
||||||
#define GCALC_DBUG_ASSERT(r) DBUG_ASSERT(r)
|
#define GCALC_DBUG_ASSERT(r) DBUG_ASSERT(r)
|
||||||
#else
|
#else
|
||||||
#define GCALC_DBUG_PRINT(b) do {} while(0)
|
#define GCALC_DBUG_PRINT(b) do {} while(0)
|
||||||
#define GCALC_DBUG_ENTER(a) do {} while(0)
|
#define GCALC_DBUG_ENTER(a) do {} while(0)
|
||||||
#define GCALC_DBUG_RETURN(r) return (r)
|
#define GCALC_DBUG_RETURN(r) return (r)
|
||||||
|
#define GCALC_DBUG_VOID_RETURN do {} while(0)
|
||||||
#define GCALC_DBUG_ASSERT(r) do {} while(0)
|
#define GCALC_DBUG_ASSERT(r) do {} while(0)
|
||||||
#endif /*GCALC_DBUG_OFF*/
|
#endif /*GCALC_DBUG_OFF*/
|
||||||
|
|
||||||
@ -158,6 +160,18 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Gcalc_coord3 : public Gcalc_internal_coord
|
||||||
|
{
|
||||||
|
gcalc_digit_t c[GCALC_COORD_BASE*3];
|
||||||
|
public:
|
||||||
|
void init()
|
||||||
|
{
|
||||||
|
n_digits= GCALC_COORD_BASE*3;
|
||||||
|
digits= c;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void gcalc_mul_coord(Gcalc_internal_coord *result,
|
void gcalc_mul_coord(Gcalc_internal_coord *result,
|
||||||
const Gcalc_internal_coord *a,
|
const Gcalc_internal_coord *a,
|
||||||
const Gcalc_internal_coord *b);
|
const Gcalc_internal_coord *b);
|
||||||
@ -192,41 +206,71 @@ typedef uint gcalc_shape_info;
|
|||||||
class Gcalc_heap : public Gcalc_dyn_list
|
class Gcalc_heap : public Gcalc_dyn_list
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum node_type
|
||||||
|
{
|
||||||
|
nt_shape_node,
|
||||||
|
nt_intersection,
|
||||||
|
nt_eq_node
|
||||||
|
};
|
||||||
class Info : public Gcalc_dyn_list::Item
|
class Info : public Gcalc_dyn_list::Item
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
gcalc_shape_info shape;
|
node_type type;
|
||||||
Info *left;
|
union
|
||||||
Info *right;
|
{
|
||||||
double x,y;
|
struct
|
||||||
Gcalc_coord1 ix, iy;
|
{
|
||||||
|
/* nt_shape_node */
|
||||||
|
gcalc_shape_info shape;
|
||||||
|
Info *left;
|
||||||
|
Info *right;
|
||||||
|
double x,y;
|
||||||
|
Gcalc_coord1 ix, iy;
|
||||||
|
int top_node;
|
||||||
|
};
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
/* nt_intersection */
|
||||||
|
/* Line p1-p2 supposed to intersect line p3-p4 */
|
||||||
|
const Info *p1;
|
||||||
|
const Info *p2;
|
||||||
|
const Info *p3;
|
||||||
|
const Info *p4;
|
||||||
|
void *intersection_data;
|
||||||
|
int equal_intersection;
|
||||||
|
};
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
/* nt_eq_node */
|
||||||
|
const Info *node;
|
||||||
|
void *eq_data;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
bool is_bottom() const
|
||||||
|
{ GCALC_DBUG_ASSERT(type == nt_shape_node); return !left; }
|
||||||
|
bool is_top() const
|
||||||
|
{ GCALC_DBUG_ASSERT(type == nt_shape_node); return top_node; }
|
||||||
|
bool is_single_node() const
|
||||||
|
{ return is_bottom() && is_top(); }
|
||||||
|
|
||||||
inline bool is_bottom() const { return !left; }
|
|
||||||
inline Info *get_next() { return (Info *)next; }
|
|
||||||
inline const Info *get_next() const { return (const Info *)next; }
|
|
||||||
};
|
|
||||||
class Intersection_info : public Gcalc_dyn_list::Item
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/* Line p1-p2 supposed to intersect line p3-p4 */
|
|
||||||
const Info *p1;
|
|
||||||
const Info *p2;
|
|
||||||
const Info *p3;
|
|
||||||
const Info *p4;
|
|
||||||
void calc_xy(double *x, double *y) const;
|
void calc_xy(double *x, double *y) const;
|
||||||
|
int equal_pi(const Info *pi) const;
|
||||||
#ifdef GCALC_CHECK_WITH_FLOAT
|
#ifdef GCALC_CHECK_WITH_FLOAT
|
||||||
void calc_xy_ld(long double *x, long double *y) const;
|
void calc_xy_ld(long double *x, long double *y) const;
|
||||||
#endif /*GCALC_CHECK_WITH_FLOAT*/
|
#endif /*GCALC_CHECK_WITH_FLOAT*/
|
||||||
|
|
||||||
|
Info *get_next() { return (Info *)next; }
|
||||||
|
const Info *get_next() const { return (const Info *)next; }
|
||||||
};
|
};
|
||||||
|
|
||||||
Gcalc_heap(size_t blk_size=8192) :
|
Gcalc_heap(size_t blk_size=8192) :
|
||||||
Gcalc_dyn_list(blk_size, sizeof(Info)),
|
Gcalc_dyn_list(blk_size, sizeof(Info)),
|
||||||
m_hook(&m_first), m_n_points(0),
|
m_hook(&m_first), m_n_points(0)
|
||||||
m_intersection_hook((Gcalc_dyn_list::Item **) &m_first_intersection)
|
|
||||||
{}
|
{}
|
||||||
Info *new_point_info(double x, double y, gcalc_shape_info shape);
|
Info *new_point_info(double x, double y, gcalc_shape_info shape);
|
||||||
Intersection_info *new_intersection(const Info *p1, const Info *p2,
|
Info *new_intersection(const Info *p1, const Info *p2,
|
||||||
const Info *p3, const Info *p4);
|
const Info *p3, const Info *p4);
|
||||||
void prepare_operation();
|
void prepare_operation();
|
||||||
inline bool ready() const { return m_hook == NULL; }
|
inline bool ready() const { return m_hook == NULL; }
|
||||||
Info *get_first() { return (Info *)m_first; }
|
Info *get_first() { return (Info *)m_first; }
|
||||||
@ -240,8 +284,6 @@ private:
|
|||||||
Gcalc_dyn_list::Item *m_first;
|
Gcalc_dyn_list::Item *m_first;
|
||||||
Gcalc_dyn_list::Item **m_hook;
|
Gcalc_dyn_list::Item **m_hook;
|
||||||
int m_n_points;
|
int m_n_points;
|
||||||
Intersection_info *m_first_intersection;
|
|
||||||
Gcalc_dyn_list::Item **m_intersection_hook;
|
|
||||||
double coord_extent;
|
double coord_extent;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -345,7 +387,6 @@ enum Gcalc_scan_events
|
|||||||
scev_single_point= 64 /* Got single point */
|
scev_single_point= 64 /* Got single point */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int sc_thread_id;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Gcalc_scan_iterator incapsulates the slisescan algorithm.
|
Gcalc_scan_iterator incapsulates the slisescan algorithm.
|
||||||
@ -366,12 +407,11 @@ public:
|
|||||||
Gcalc_coord1 dy;
|
Gcalc_coord1 dy;
|
||||||
Gcalc_heap::Info *pi;
|
Gcalc_heap::Info *pi;
|
||||||
Gcalc_heap::Info *next_pi;
|
Gcalc_heap::Info *next_pi;
|
||||||
sc_thread_id thread;
|
Gcalc_heap::Info *ev_pi;
|
||||||
const Gcalc_coord1 *l_border;
|
const Gcalc_coord1 *l_border;
|
||||||
const Gcalc_coord1 *r_border;
|
const Gcalc_coord1 *r_border;
|
||||||
int always_on_left;
|
point *ev_next;
|
||||||
|
|
||||||
const point *intersection_link;
|
|
||||||
Gcalc_scan_events event;
|
Gcalc_scan_events event;
|
||||||
|
|
||||||
inline const point *c_get_next() const
|
inline const point *c_get_next() const
|
||||||
@ -380,9 +420,6 @@ public:
|
|||||||
gcalc_shape_info get_shape() const { return pi->shape; }
|
gcalc_shape_info get_shape() const { return pi->shape; }
|
||||||
inline point *get_next() { return (point *)next; }
|
inline point *get_next() { return (point *)next; }
|
||||||
inline const point *get_next() const { return (const point *)next; }
|
inline const point *get_next() const { return (const point *)next; }
|
||||||
/* copies all but 'next' 'x' and 'precursor' */
|
|
||||||
void copy_core(const point *from);
|
|
||||||
void copy_all(const point *from);
|
|
||||||
/* Compare the dx_dy parameters regarding the horiz_dir */
|
/* Compare the dx_dy parameters regarding the horiz_dir */
|
||||||
/* returns -1 if less, 0 if equal, 1 if bigger */
|
/* returns -1 if less, 0 if equal, 1 if bigger */
|
||||||
static int cmp_dx_dy(const Gcalc_coord1 *dx_a,
|
static int cmp_dx_dy(const Gcalc_coord1 *dx_a,
|
||||||
@ -394,48 +431,52 @@ public:
|
|||||||
const Gcalc_heap::Info *p3,
|
const Gcalc_heap::Info *p3,
|
||||||
const Gcalc_heap::Info *p4);
|
const Gcalc_heap::Info *p4);
|
||||||
int cmp_dx_dy(const point *p) const;
|
int cmp_dx_dy(const point *p) const;
|
||||||
int simple_event() const
|
point **next_ptr() { return (point **) &next; }
|
||||||
{
|
#ifndef GCALC_DBUG_OFF
|
||||||
return !next ? (event & (scev_point | scev_end)) :
|
unsigned int thread;
|
||||||
(!next->next && event == scev_two_ends);
|
#endif /*GCALC_DBUG_OFF*/
|
||||||
}
|
|
||||||
#ifndef DBUG_OFF
|
|
||||||
void dbug_print();
|
|
||||||
#endif /*DBUG_OFF*/
|
|
||||||
#ifdef GCALC_CHECK_WITH_FLOAT
|
#ifdef GCALC_CHECK_WITH_FLOAT
|
||||||
void calc_x(long double *x, long double y, long double ix) const;
|
void calc_x(long double *x, long double y, long double ix) const;
|
||||||
#endif /*GCALC_CHECK_WITH_FLOAT*/
|
#endif /*GCALC_CHECK_WITH_FLOAT*/
|
||||||
};
|
};
|
||||||
|
|
||||||
class intersection : public Gcalc_dyn_list::Item
|
/* That class introduced mostly for the 'typecontrol' reason. */
|
||||||
|
/* only difference from the point classis the get_next() function. */
|
||||||
|
class event_point : public point
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int n_row;
|
inline const event_point *get_next() const
|
||||||
sc_thread_id thread_a;
|
{ return (const event_point*) ev_next; }
|
||||||
sc_thread_id thread_b;
|
int simple_event() const
|
||||||
const Gcalc_heap::Intersection_info *ii;
|
{
|
||||||
inline intersection *get_next() { return (intersection *)next; }
|
return !ev_next ? (event & (scev_point | scev_end)) :
|
||||||
|
(!ev_next->ev_next && event == scev_two_ends);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class intersection_info : public Gcalc_dyn_list::Item
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
point *edge_a;
|
||||||
|
point *edge_b;
|
||||||
|
|
||||||
|
Gcalc_coord2 t_a;
|
||||||
|
Gcalc_coord2 t_b;
|
||||||
|
int t_calculated;
|
||||||
|
Gcalc_coord3 x_exp;
|
||||||
|
int x_calculated;
|
||||||
|
Gcalc_coord3 y_exp;
|
||||||
|
int y_calculated;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class slice_state
|
class slice_state
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
point *slice;
|
point *slice;
|
||||||
point *event_position;
|
point **event_position_hook;
|
||||||
Gcalc_dyn_list::Item **event_position_hook;
|
point *event_end;
|
||||||
Gcalc_dyn_list::Item **event_end_hook;
|
const Gcalc_heap::Info *pi;
|
||||||
int intersection_scan;
|
|
||||||
union
|
|
||||||
{
|
|
||||||
const Gcalc_heap::Info *pi;
|
|
||||||
const Gcalc_heap::Intersection_info *isc;
|
|
||||||
};
|
|
||||||
slice_state() : slice(NULL) {}
|
|
||||||
void clear_event_position()
|
|
||||||
{
|
|
||||||
event_position= NULL;
|
|
||||||
event_end_hook= (Gcalc_dyn_list::Item **) &event_position;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -443,68 +484,56 @@ public:
|
|||||||
|
|
||||||
void init(Gcalc_heap *points); /* Iterator can be reused */
|
void init(Gcalc_heap *points); /* Iterator can be reused */
|
||||||
void reset();
|
void reset();
|
||||||
int step()
|
int step();
|
||||||
{
|
|
||||||
DBUG_ASSERT(more_points());
|
|
||||||
return m_intersections ? intersection_scan() : normal_scan();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Gcalc_heap::Info *more_points() { return m_cur_pi; }
|
Gcalc_heap::Info *more_points() { return m_cur_pi; }
|
||||||
inline bool more_trapezoids()
|
bool more_trapezoids()
|
||||||
{ return m_cur_pi && m_cur_pi->next; }
|
{ return m_cur_pi && m_cur_pi->next; }
|
||||||
|
|
||||||
inline const point *get_events() const
|
const point *get_bottom_points() const
|
||||||
{ return m_events; }
|
{ return m_bottom_points; }
|
||||||
inline const point *get_event_position() const
|
const point *get_event_position() const
|
||||||
{ return current_state->event_position; }
|
{ return *state.event_position_hook; }
|
||||||
inline const point *get_event_end() const
|
const point *get_event_end() const
|
||||||
{ return (point *) *current_state->event_end_hook; }
|
{ return state.event_end; }
|
||||||
inline const point *get_b_slice() const { return current_state->slice; }
|
const event_point *get_events() const
|
||||||
inline const point *get_t_slice() const { return next_state->slice; }
|
{ return (const event_point *)
|
||||||
|
(*state.event_position_hook == state.event_end ?
|
||||||
|
m_bottom_points : *state.event_position_hook); }
|
||||||
|
const point *get_b_slice() const { return state.slice; }
|
||||||
double get_h() const;
|
double get_h() const;
|
||||||
double get_y() const;
|
double get_y() const;
|
||||||
double get_event_x() const;
|
double get_event_x() const;
|
||||||
double get_sp_x(const point *sp) const;
|
double get_sp_x(const point *sp) const;
|
||||||
int intersection_step() const { return current_state->intersection_scan; }
|
int intersection_step() const
|
||||||
|
{ return state.pi->type == Gcalc_heap::nt_intersection; }
|
||||||
const Gcalc_heap::Info *get_cur_pi() const
|
const Gcalc_heap::Info *get_cur_pi() const
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(!intersection_step());
|
return state.pi;
|
||||||
return current_state->pi;
|
|
||||||
}
|
|
||||||
const Gcalc_heap::Intersection_info *get_cur_ii() const
|
|
||||||
{
|
|
||||||
DBUG_ASSERT(intersection_step());
|
|
||||||
return current_state->isc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Gcalc_heap *m_heap;
|
Gcalc_heap *m_heap;
|
||||||
Gcalc_heap::Info *m_cur_pi;
|
Gcalc_heap::Info *m_cur_pi;
|
||||||
slice_state state0, state1, state_s;
|
slice_state state;
|
||||||
slice_state *current_state;
|
|
||||||
slice_state *next_state;
|
|
||||||
slice_state *saved_state;
|
|
||||||
|
|
||||||
intersection *m_intersections;
|
#ifndef GCALC_DBUG_OFF
|
||||||
int m_n_intersections;
|
unsigned int m_cur_thread;
|
||||||
intersection *m_cur_intersection;
|
#endif /*GCALC_DBUG_OFF*/
|
||||||
bool m_next_is_top_point;
|
|
||||||
sc_thread_id m_cur_thread;
|
|
||||||
|
|
||||||
point *m_events;
|
point *m_bottom_points;
|
||||||
int normal_scan();
|
point **m_bottom_hook;
|
||||||
int intersection_scan();
|
|
||||||
void sort_intersections();
|
int node_scan();
|
||||||
int handle_intersections();
|
void eq_scan();
|
||||||
int insert_top_point();
|
void intersection_scan();
|
||||||
int add_intersection(int n_row, const point *a, const point *b,
|
void remove_bottom_node();
|
||||||
Gcalc_dyn_list::Item ***p_hook);
|
int insert_top_node();
|
||||||
int find_intersections();
|
int add_intersection(point *sp_a, point *sp_b,
|
||||||
|
Gcalc_heap::Info *pi_from);
|
||||||
|
int add_eq_node(Gcalc_heap::Info *node, point *sp);
|
||||||
|
int add_events_for_node(point *sp_node);
|
||||||
|
|
||||||
intersection *new_intersection()
|
|
||||||
{
|
|
||||||
return (intersection *)new_item();
|
|
||||||
}
|
|
||||||
point *new_slice_point()
|
point *new_slice_point()
|
||||||
{
|
{
|
||||||
point *new_point= (point *)new_item();
|
point *new_point= (point *)new_item();
|
||||||
@ -512,9 +541,15 @@ private:
|
|||||||
new_point->dy.init();
|
new_point->dy.init();
|
||||||
return new_point;
|
return new_point;
|
||||||
}
|
}
|
||||||
point *new_slice(point *example);
|
intersection_info *new_intersection_info(point *a, point *b)
|
||||||
int arrange_event();
|
{
|
||||||
void mark_event_position1(point *ep, Gcalc_dyn_list::Item **ep_hook);
|
intersection_info *ii= (intersection_info *)new_item();
|
||||||
|
ii->edge_a= a;
|
||||||
|
ii->edge_b= b;
|
||||||
|
ii->t_calculated= ii->x_calculated= ii->y_calculated= 0;
|
||||||
|
return ii;
|
||||||
|
}
|
||||||
|
int arrange_event(int do_sorting, int n_intersections);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -525,6 +560,7 @@ private:
|
|||||||
previous and current slices.
|
previous and current slices.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef TMP_BLOCK
|
||||||
class Gcalc_trapezoid_iterator
|
class Gcalc_trapezoid_iterator
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
@ -556,6 +592,7 @@ public:
|
|||||||
sp1= rt();
|
sp1= rt();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif /*TMP_BLOCK*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -192,7 +192,7 @@ int Gcalc_function::count_internal(const char *cur_func, uint set_type,
|
|||||||
result= result & !next_res;
|
result= result & !next_res;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DBUG_ASSERT(FALSE);
|
GCALC_DBUG_ASSERT(FALSE);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +262,8 @@ void Gcalc_function::reset()
|
|||||||
|
|
||||||
int Gcalc_function::check_function(Gcalc_scan_iterator &scan_it)
|
int Gcalc_function::check_function(Gcalc_scan_iterator &scan_it)
|
||||||
{
|
{
|
||||||
const Gcalc_scan_iterator::point *eq_start, *cur_eq, *events;
|
const Gcalc_scan_iterator::point *eq_start, *cur_eq;
|
||||||
|
const Gcalc_scan_iterator::event_point *events;
|
||||||
GCALC_DBUG_ENTER("Gcalc_function::check_function");
|
GCALC_DBUG_ENTER("Gcalc_function::check_function");
|
||||||
|
|
||||||
while (scan_it.more_points())
|
while (scan_it.more_points())
|
||||||
@ -502,7 +503,7 @@ int Gcalc_result_receiver::complete_shape()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(cur_shape != Gcalc_function::shape_point);
|
GCALC_DBUG_ASSERT(cur_shape != Gcalc_function::shape_point);
|
||||||
if (cur_shape == Gcalc_function::shape_hole)
|
if (cur_shape == Gcalc_function::shape_hole)
|
||||||
{
|
{
|
||||||
shape_area+= prev_x*first_y - prev_y*first_x;
|
shape_area+= prev_x*first_y - prev_y*first_x;
|
||||||
@ -534,7 +535,7 @@ do_complete:
|
|||||||
|
|
||||||
if (!n_shapes++)
|
if (!n_shapes++)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(cur_shape != Gcalc_function::shape_hole);
|
GCALC_DBUG_ASSERT(cur_shape != Gcalc_function::shape_hole);
|
||||||
common_shapetype= cur_shape;
|
common_shapetype= cur_shape;
|
||||||
}
|
}
|
||||||
else if (cur_shape == Gcalc_function::shape_hole)
|
else if (cur_shape == Gcalc_function::shape_hole)
|
||||||
@ -587,7 +588,7 @@ int Gcalc_result_receiver::get_result_typeid()
|
|||||||
return (n_shapes == 1) ? Geometry::wkb_linestring :
|
return (n_shapes == 1) ? Geometry::wkb_linestring :
|
||||||
Geometry::wkb_multilinestring;
|
Geometry::wkb_multilinestring;
|
||||||
default:
|
default:
|
||||||
DBUG_ASSERT(0);
|
GCALC_DBUG_ASSERT(0);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -648,6 +649,7 @@ Gcalc_operation_reducer(Gcalc_function *fn, modes mode, size_t blk_size) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef TMP_BLOCK
|
||||||
void Gcalc_operation_reducer::res_point::set(const Gcalc_scan_iterator *si)
|
void Gcalc_operation_reducer::res_point::set(const Gcalc_scan_iterator *si)
|
||||||
{
|
{
|
||||||
if ((intersection_point= si->intersection_step()))
|
if ((intersection_point= si->intersection_step()))
|
||||||
@ -655,6 +657,12 @@ void Gcalc_operation_reducer::res_point::set(const Gcalc_scan_iterator *si)
|
|||||||
else
|
else
|
||||||
pi= si->get_cur_pi();
|
pi= si->get_cur_pi();
|
||||||
}
|
}
|
||||||
|
#endif /*TMP_BLOCK*/
|
||||||
|
void Gcalc_operation_reducer::res_point::set(const Gcalc_scan_iterator *si)
|
||||||
|
{
|
||||||
|
intersection_point= si->intersection_step();
|
||||||
|
pi= si->get_cur_pi();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Gcalc_operation_reducer::res_point *
|
Gcalc_operation_reducer::res_point *
|
||||||
@ -726,7 +734,7 @@ int Gcalc_operation_reducer::continue_range(active_thread *t,
|
|||||||
|
|
||||||
|
|
||||||
inline int Gcalc_operation_reducer::continue_i_range(active_thread *t,
|
inline int Gcalc_operation_reducer::continue_i_range(active_thread *t,
|
||||||
const Gcalc_heap::Intersection_info *ii)
|
const Gcalc_heap::Info *ii)
|
||||||
{
|
{
|
||||||
res_point *rp= add_res_point(t->rp->type);
|
res_point *rp= add_res_point(t->rp->type);
|
||||||
GCALC_DBUG_ENTER("Gcalc_operation_reducer::continue_i_range");
|
GCALC_DBUG_ENTER("Gcalc_operation_reducer::continue_i_range");
|
||||||
@ -736,7 +744,7 @@ inline int Gcalc_operation_reducer::continue_i_range(active_thread *t,
|
|||||||
rp->down= t->rp;
|
rp->down= t->rp;
|
||||||
t->rp->up= rp;
|
t->rp->up= rp;
|
||||||
rp->intersection_point= true;
|
rp->intersection_point= true;
|
||||||
rp->ii= ii;
|
rp->pi= ii;
|
||||||
t->rp= rp;
|
t->rp= rp;
|
||||||
GCALC_DBUG_RETURN(0);
|
GCALC_DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
@ -746,7 +754,7 @@ int Gcalc_operation_reducer::end_couple(active_thread *t0, active_thread *t1,
|
|||||||
{
|
{
|
||||||
res_point *rp0, *rp1;
|
res_point *rp0, *rp1;
|
||||||
GCALC_DBUG_ENTER("Gcalc_operation_reducer::end_couple");
|
GCALC_DBUG_ENTER("Gcalc_operation_reducer::end_couple");
|
||||||
DBUG_ASSERT(t0->rp->type == t1->rp->type);
|
GCALC_DBUG_ASSERT(t0->rp->type == t1->rp->type);
|
||||||
if (!(rp0= add_res_point(t0->rp->type)) ||
|
if (!(rp0= add_res_point(t0->rp->type)) ||
|
||||||
!(rp1= add_res_point(t0->rp->type)))
|
!(rp1= add_res_point(t0->rp->type)))
|
||||||
GCALC_DBUG_RETURN(1);
|
GCALC_DBUG_RETURN(1);
|
||||||
@ -769,7 +777,7 @@ int Gcalc_operation_reducer::count_slice(Gcalc_scan_iterator *si)
|
|||||||
int prev_state= 0;
|
int prev_state= 0;
|
||||||
int sav_prev_state;
|
int sav_prev_state;
|
||||||
active_thread *prev_range= NULL;
|
active_thread *prev_range= NULL;
|
||||||
const Gcalc_scan_iterator::point *events;
|
const Gcalc_scan_iterator::event_point *events;
|
||||||
const Gcalc_scan_iterator::point *eq_start;
|
const Gcalc_scan_iterator::point *eq_start;
|
||||||
active_thread **cur_t_hook= &m_first_active_thread;
|
active_thread **cur_t_hook= &m_first_active_thread;
|
||||||
active_thread **starting_t_hook;
|
active_thread **starting_t_hook;
|
||||||
@ -834,7 +842,7 @@ int Gcalc_operation_reducer::count_slice(Gcalc_scan_iterator *si)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
DBUG_ASSERT(0);
|
GCALC_DBUG_ASSERT(0);
|
||||||
}
|
}
|
||||||
GCALC_DBUG_RETURN(0);
|
GCALC_DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
@ -875,7 +883,7 @@ int Gcalc_operation_reducer::count_slice(Gcalc_scan_iterator *si)
|
|||||||
{
|
{
|
||||||
if (cur_t->rp->type == Gcalc_function::shape_line)
|
if (cur_t->rp->type == Gcalc_function::shape_line)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(!prev_state);
|
GCALC_DBUG_ASSERT(!prev_state);
|
||||||
add_line(1, cur_t, events);
|
add_line(1, cur_t, events);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -971,7 +979,7 @@ int Gcalc_operation_reducer::count_slice(Gcalc_scan_iterator *si)
|
|||||||
{
|
{
|
||||||
poly_border *pb1, *pb2;
|
poly_border *pb1, *pb2;
|
||||||
pb1= m_poly_borders;
|
pb1= m_poly_borders;
|
||||||
DBUG_ASSERT(m_poly_borders->next);
|
GCALC_DBUG_ASSERT(m_poly_borders->next);
|
||||||
|
|
||||||
pb2= get_pair_border(pb1);
|
pb2= get_pair_border(pb1);
|
||||||
/* Remove pb1 from the list. The pb2 already removed in get_pair_border. */
|
/* Remove pb1 from the list. The pb2 already removed in get_pair_border. */
|
||||||
@ -1098,7 +1106,7 @@ int Gcalc_operation_reducer::connect_threads(
|
|||||||
if (incoming_a && incoming_b)
|
if (incoming_a && incoming_b)
|
||||||
{
|
{
|
||||||
res_point *rpa, *rpb;
|
res_point *rpa, *rpb;
|
||||||
DBUG_ASSERT(ta->rp->type == tb->rp->type);
|
GCALC_DBUG_ASSERT(ta->rp->type == tb->rp->type);
|
||||||
if (!(rpa= add_res_point(ta->rp->type)) ||
|
if (!(rpa= add_res_point(ta->rp->type)) ||
|
||||||
!(rpb= add_res_point(ta->rp->type)))
|
!(rpb= add_res_point(ta->rp->type)))
|
||||||
GCALC_DBUG_RETURN(1);
|
GCALC_DBUG_RETURN(1);
|
||||||
@ -1116,7 +1124,7 @@ int Gcalc_operation_reducer::connect_threads(
|
|||||||
}
|
}
|
||||||
if (!incoming_a)
|
if (!incoming_a)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(!incoming_b);
|
GCALC_DBUG_ASSERT(!incoming_b);
|
||||||
|
|
||||||
res_point *rp0, *rp1;
|
res_point *rp0, *rp1;
|
||||||
if (!(rp0= add_res_point(s_t)) || !(rp1= add_res_point(s_t)))
|
if (!(rp0= add_res_point(s_t)) || !(rp1= add_res_point(s_t)))
|
||||||
@ -1152,14 +1160,14 @@ int Gcalc_operation_reducer::connect_threads(
|
|||||||
}
|
}
|
||||||
/* else, if only ta is incoming */
|
/* else, if only ta is incoming */
|
||||||
|
|
||||||
DBUG_ASSERT(tb != ta);
|
GCALC_DBUG_ASSERT(tb != ta);
|
||||||
tb->rp= ta->rp;
|
tb->rp= ta->rp;
|
||||||
tb->thread_start= ta->thread_start;
|
tb->thread_start= ta->thread_start;
|
||||||
if (Gcalc_scan_iterator::point::
|
if (Gcalc_scan_iterator::point::
|
||||||
cmp_dx_dy(ta->p1, ta->p2, pb->pi, pb->next_pi) != 0)
|
cmp_dx_dy(ta->p1, ta->p2, pb->pi, pb->next_pi) != 0)
|
||||||
{
|
{
|
||||||
if (si->intersection_step() ?
|
if (si->intersection_step() ?
|
||||||
continue_i_range(tb, si->get_cur_ii()) :
|
continue_i_range(tb, si->get_cur_pi()) :
|
||||||
continue_range(tb, si->get_cur_pi(), pb->next_pi))
|
continue_range(tb, si->get_cur_pi(), pb->next_pi))
|
||||||
GCALC_DBUG_RETURN(1);
|
GCALC_DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
@ -1191,7 +1199,7 @@ int Gcalc_operation_reducer::end_line(active_thread *t,
|
|||||||
const Gcalc_scan_iterator *si)
|
const Gcalc_scan_iterator *si)
|
||||||
{
|
{
|
||||||
GCALC_DBUG_ENTER("Gcalc_operation_reducer::end_line");
|
GCALC_DBUG_ENTER("Gcalc_operation_reducer::end_line");
|
||||||
DBUG_ASSERT(t->rp->type == Gcalc_function::shape_line);
|
GCALC_DBUG_ASSERT(t->rp->type == Gcalc_function::shape_line);
|
||||||
res_point *rp= add_res_point(Gcalc_function::shape_line);
|
res_point *rp= add_res_point(Gcalc_function::shape_line);
|
||||||
if (!rp)
|
if (!rp)
|
||||||
GCALC_DBUG_RETURN(1);
|
GCALC_DBUG_RETURN(1);
|
||||||
@ -1237,7 +1245,7 @@ inline int Gcalc_operation_reducer::get_single_result(res_point *res,
|
|||||||
if (res->intersection_point)
|
if (res->intersection_point)
|
||||||
{
|
{
|
||||||
double x, y;
|
double x, y;
|
||||||
res->ii->calc_xy(&x, &y);
|
res->pi->calc_xy(&x, &y);
|
||||||
if (storage->single_point(x,y))
|
if (storage->single_point(x,y))
|
||||||
GCALC_DBUG_RETURN(1);
|
GCALC_DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
@ -1264,7 +1272,7 @@ int Gcalc_operation_reducer::get_result_thread(res_point *cur,
|
|||||||
{
|
{
|
||||||
if (cur->intersection_point)
|
if (cur->intersection_point)
|
||||||
{
|
{
|
||||||
cur->ii->calc_xy(&x, &y);
|
cur->pi->calc_xy(&x, &y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1368,7 +1376,7 @@ int Gcalc_operation_reducer::get_result(Gcalc_result_receiver *storage)
|
|||||||
uint32 insert_position, hole_position, position_shift;
|
uint32 insert_position, hole_position, position_shift;
|
||||||
poly_instance *cur_poly;
|
poly_instance *cur_poly;
|
||||||
insert_position= m_result->outer_poly->first_poly_node->poly_position;
|
insert_position= m_result->outer_poly->first_poly_node->poly_position;
|
||||||
DBUG_ASSERT(insert_position);
|
GCALC_DBUG_ASSERT(insert_position);
|
||||||
hole_position= storage->position();
|
hole_position= storage->position();
|
||||||
storage->start_shape(Gcalc_function::shape_hole);
|
storage->start_shape(Gcalc_function::shape_hole);
|
||||||
if (get_polygon_result(m_result, storage,
|
if (get_polygon_result(m_result, storage,
|
||||||
|
@ -233,7 +233,6 @@ public:
|
|||||||
union
|
union
|
||||||
{
|
{
|
||||||
const Gcalc_heap::Info *pi;
|
const Gcalc_heap::Info *pi;
|
||||||
const Gcalc_heap::Intersection_info *ii;
|
|
||||||
res_point *first_poly_node;
|
res_point *first_poly_node;
|
||||||
};
|
};
|
||||||
union
|
union
|
||||||
@ -331,7 +330,7 @@ private:
|
|||||||
int continue_range(active_thread *t, const Gcalc_heap::Info *p,
|
int continue_range(active_thread *t, const Gcalc_heap::Info *p,
|
||||||
const Gcalc_heap::Info *p_next);
|
const Gcalc_heap::Info *p_next);
|
||||||
int continue_i_range(active_thread *t,
|
int continue_i_range(active_thread *t,
|
||||||
const Gcalc_heap::Intersection_info *ii);
|
const Gcalc_heap::Info *ii);
|
||||||
int end_couple(active_thread *t0, active_thread *t1, const Gcalc_heap::Info *p);
|
int end_couple(active_thread *t0, active_thread *t1, const Gcalc_heap::Info *p);
|
||||||
int get_single_result(res_point *res, Gcalc_result_receiver *storage);
|
int get_single_result(res_point *res, Gcalc_result_receiver *storage);
|
||||||
int get_result_thread(res_point *cur, Gcalc_result_receiver *storage,
|
int get_result_thread(res_point *cur, Gcalc_result_receiver *storage,
|
||||||
|
@ -1445,7 +1445,7 @@ longlong Item_func_issimple::val_int()
|
|||||||
Gcalc_operation_transporter trn(&func, &collector);
|
Gcalc_operation_transporter trn(&func, &collector);
|
||||||
Geometry *g;
|
Geometry *g;
|
||||||
int result= 1;
|
int result= 1;
|
||||||
const Gcalc_scan_iterator::point *ev;
|
const Gcalc_scan_iterator::event_point *ev;
|
||||||
|
|
||||||
DBUG_ENTER("Item_func_issimple::val_int");
|
DBUG_ENTER("Item_func_issimple::val_int");
|
||||||
DBUG_ASSERT(fixed == 1);
|
DBUG_ASSERT(fixed == 1);
|
||||||
@ -1669,7 +1669,7 @@ double Item_func_distance::val_real()
|
|||||||
bool above_cur_point, cur_point_edge;
|
bool above_cur_point, cur_point_edge;
|
||||||
const Gcalc_scan_iterator::point *evpos;
|
const Gcalc_scan_iterator::point *evpos;
|
||||||
const Gcalc_heap::Info *cur_point, *dist_point;
|
const Gcalc_heap::Info *cur_point, *dist_point;
|
||||||
const Gcalc_scan_iterator::point *ev;
|
const Gcalc_scan_iterator::event_point *ev;
|
||||||
double t, distance, cur_distance;
|
double t, distance, cur_distance;
|
||||||
double x1, x2, y1, y2;
|
double x1, x2, y1, y2;
|
||||||
double ex, ey, vx, vy, e_sqrlen;
|
double ex, ey, vx, vy, e_sqrlen;
|
||||||
|
Reference in New Issue
Block a user