Below is the list of changes that have just been committed into a local
5.1 repository of hf. When hf does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-11-24 19:26:05+04:00, holyfoot@stripped +1 -0
Bug #32032 OpenGIS Contains() does not work on MultiPolygons; disconnects in some cases.
Gis_multi_* objects have an error in ::store_shapes() function
implementation that produced a very long list of objects,
which usually leads to crash.
sql/spatial.cc@stripped, 2007-11-24 19:26:03+04:00, holyfoot@stripped +62 -93
Bug #32032 OpenGIS Contains() does not work on MultiPolygons; disconnects in some
cases.
Gis_multi_*::store_shapes functions fixed
diff -Nrup a/sql/spatial.cc b/sql/spatial.cc
--- a/sql/spatial.cc 2007-09-21 18:11:54 +05:00
+++ b/sql/spatial.cc 2007-11-24 19:26:03 +04:00
@@ -315,13 +315,12 @@ bool Geometry::envelope(String *result)
bool Geometry::create_point(String *result, const char *data) const
{
- if (no_data(data, SIZEOF_STORED_DOUBLE * 2) ||
- result->reserve(1 + 4 + SIZEOF_STORED_DOUBLE * 2))
+ if (no_data(data, POINT_DATA_SIZE) || result->reserve(1+4+POINT_DATA_SIZE))
return 1;
result->q_append((char) wkb_ndr);
result->q_append((uint32) wkb_point);
/* Copy two double in same format */
- result->q_append(data, SIZEOF_STORED_DOUBLE*2);
+ result->q_append(data, POINT_DATA_SIZE);
return 0;
}
@@ -341,7 +340,7 @@ bool Geometry::create_point(String *resu
bool Geometry::create_point(String *result, double x, double y) const
{
- if (result->reserve(1 + 4 + SIZEOF_STORED_DOUBLE * 2))
+ if (result->reserve(1 + 4 + POINT_DATA_SIZE))
return 1;
result->q_append((char) wkb_ndr);
@@ -373,7 +372,7 @@ const char *Geometry::append_points(Stri
double x,y;
data+= offset;
get_point(&x, &y, data);
- data+= SIZEOF_STORED_DOUBLE * 2;
+ data+= POINT_DATA_SIZE;
txt->qs_append(x);
txt->qs_append(' ');
txt->qs_append(y);
@@ -408,7 +407,7 @@ const char *Geometry::get_mbr_for_points
points= uint4korr(data);
data+= 4;
- if (no_data(data, (SIZEOF_STORED_DOUBLE * 2 + offset) * points))
+ if (no_data(data, (POINT_DATA_SIZE + offset) * points))
return 0;
/* Calculate MBR for points */
@@ -416,7 +415,7 @@ const char *Geometry::get_mbr_for_points
{
data+= offset;
mbr->add_xy(data, data + SIZEOF_STORED_DOUBLE);
- data+= SIZEOF_STORED_DOUBLE * 2;
+ data+= POINT_DATA_SIZE;
}
return data;
}
@@ -434,7 +433,7 @@ bool Gis_point::init_from_wkt(Gis_read_s
{
double x, y;
if (trs->get_next_number(&x) || trs->get_next_number(&y) ||
- wkb->reserve(SIZEOF_STORED_DOUBLE * 2))
+ wkb->reserve(POINT_DATA_SIZE))
return 1;
wkb->q_append(x);
wkb->q_append(y);
@@ -576,7 +575,7 @@ bool Gis_line_string::get_data_as_wkt(St
data += 4;
if (n_points < 1 ||
- no_data(data, SIZEOF_STORED_DOUBLE * 2 * n_points) ||
+ no_data(data, POINT_DATA_SIZE * n_points) ||
txt->reserve(((MAX_DIGITS_IN_DOUBLE + 1)*2 + 1) * n_points))
return 1;
@@ -584,7 +583,7 @@ bool Gis_line_string::get_data_as_wkt(St
{
double x, y;
get_point(&x, &y, data);
- data+= SIZEOF_STORED_DOUBLE * 2;
+ data+= POINT_DATA_SIZE;
txt->qs_append(x);
txt->qs_append(' ');
txt->qs_append(y);
@@ -613,17 +612,16 @@ int Gis_line_string::geom_length(double
return 1;
n_points= uint4korr(data);
data+= 4;
- if (n_points < 1 || no_data(data, SIZEOF_STORED_DOUBLE * 2 * n_points))
+ if (n_points < 1 || no_data(data, POINT_DATA_SIZE * n_points))
return 1;
get_point(&prev_x, &prev_y, data);
- data+= SIZEOF_STORED_DOUBLE*2;
-
+ data+= POINT_DATA_SIZE;
while (--n_points)
{
double x, y;
get_point(&x, &y, data);
- data+= SIZEOF_STORED_DOUBLE * 2;
+ data+= POINT_DATA_SIZE;
*len+= sqrt(pow(prev_x-x,2)+pow(prev_y-y,2));
prev_x= x;
prev_y= y;
@@ -647,14 +645,14 @@ int Gis_line_string::is_closed(int *clos
return 0;
}
data+= 4;
- if (no_data(data, SIZEOF_STORED_DOUBLE * 2 * n_points))
+ if (no_data(data, POINT_DATA_SIZE * n_points))
return 1;
/* Get first point */
get_point(&x1, &y1, data);
/* get last point */
- data+= SIZEOF_STORED_DOUBLE*2 + (n_points-2)*POINT_DATA_SIZE;
+ data+= POINT_DATA_SIZE + (n_points-2)*POINT_DATA_SIZE;
get_point(&x2, &y2, data);
*closed= (x1==x2) && (y1==y2);
@@ -714,7 +712,7 @@ int Gis_line_string::store_shapes(gcalc_
return 1;
n_points= uint4korr(data);
data+= 4;
- if (n_points < 1 || no_data(data, SIZEOF_STORED_DOUBLE * 2 * n_points))
+ if (n_points < 1 || no_data(data, POINT_DATA_SIZE * n_points))
return 1;
trn.start_line(si);
@@ -722,7 +720,7 @@ int Gis_line_string::store_shapes(gcalc_
while (n_points--)
{
get_point(&x, &y, data);
- data+= SIZEOF_STORED_DOUBLE * 2;
+ data+= POINT_DATA_SIZE;
if (trn.add_point(x, y))
return 1;
}
@@ -885,7 +883,7 @@ bool Gis_polygon::get_data_as_wkt(String
return 1;
n_points= uint4korr(data);
data+= 4;
- if (no_data(data, (SIZEOF_STORED_DOUBLE*2) * n_points) ||
+ if (no_data(data, POINT_DATA_SIZE * n_points) ||
txt->reserve(2 + ((MAX_DIGITS_IN_DOUBLE + 1) * 2 + 1) * n_points))
return 1;
txt->qs_append('(');
@@ -939,16 +937,16 @@ int Gis_polygon::area(double *ar, const
if (no_data(data, 4))
return 1;
n_points= uint4korr(data);
- if (no_data(data, (SIZEOF_STORED_DOUBLE*2) * n_points))
+ if (no_data(data, POINT_DATA_SIZE * n_points))
return 1;
get_point(&prev_x, &prev_y, data+4);
- data+= (4+SIZEOF_STORED_DOUBLE*2);
+ data+= (4+POINT_DATA_SIZE);
while (--n_points) // One point is already read
{
double x, y;
get_point(&x, &y, data);
- data+= (SIZEOF_STORED_DOUBLE*2);
+ data+= POINT_DATA_SIZE;
lr_area+= (prev_x + x)* (prev_y - y);
prev_x= x;
prev_y= y;
@@ -1063,16 +1061,16 @@ int Gis_polygon::centroid_xy(double *x,
return 1;
org_n_points= n_points= uint4korr(data);
data+= 4;
- if (no_data(data, (SIZEOF_STORED_DOUBLE*2) * n_points))
+ if (no_data(data, POINT_DATA_SIZE * n_points))
return 1;
get_point(&prev_x, &prev_y, data);
- data+= (SIZEOF_STORED_DOUBLE*2);
+ data+= POINT_DATA_SIZE;
while (--n_points) // One point is already read
{
double tmp_x, tmp_y;
get_point(&tmp_x, &tmp_y, data);
- data+= (SIZEOF_STORED_DOUBLE*2);
+ data+= POINT_DATA_SIZE;
cur_area+= (prev_x + tmp_x) * (prev_y - tmp_y);
cur_cx+= tmp_x;
cur_cy+= tmp_y;
@@ -1136,7 +1134,7 @@ int Gis_polygon::store_shapes(gcalc_heap
return 1;
n_points= uint4korr(data);
data+= 4;
- if (no_data(data, (SIZEOF_STORED_DOUBLE*2) * n_points))
+ if (no_data(data, POINT_DATA_SIZE * n_points))
return 1;
trn.start_ring(si);
@@ -1144,11 +1142,11 @@ int Gis_polygon::store_shapes(gcalc_heap
{
double x, y;
get_point(&x, &y, data);
- data+= (SIZEOF_STORED_DOUBLE*2);
+ data+= POINT_DATA_SIZE;
if (trn.add_point(x, y))
return 1;
}
- data+= (SIZEOF_STORED_DOUBLE*2);
+ data+= POINT_DATA_SIZE;
trn.complete();
}
@@ -1263,7 +1261,7 @@ bool Gis_multi_point::get_data_as_wkt(St
n_points= uint4korr(m_data);
if (no_data(m_data+4,
- n_points * (SIZEOF_STORED_DOUBLE * 2 + WKB_HEADER_SIZE)) ||
+ n_points * (POINT_DATA_SIZE + WKB_HEADER_SIZE)) ||
txt->reserve(((MAX_DIGITS_IN_DOUBLE + 1) * 2 + 1) * n_points))
return 1;
*end= append_points(txt, n_points, m_data+4, WKB_HEADER_SIZE);
@@ -1309,34 +1307,28 @@ int Gis_multi_point::store_shapes(gcalc_
{
gcalc_shape_transporter trn(heap);
uint32 n_points;
- double x, y;
- const char *data;
- gcalc_shape_info si;
+ Gis_point pt;
+ const char *data= m_data;
- if (no_data(m_data, 4))
- return 1;
- n_points= uint4korr(m_data);
- if (no_data(m_data+4,
- n_points * (SIZEOF_STORED_DOUBLE * 2 + WKB_HEADER_SIZE)))
+ if (no_data(data, 4))
return 1;
+ n_points= uint4korr(data);
+ data+= 4;
if (fn->reserve_shape_buffer(n_points) || fn->reserve_op_buffer(1))
return 1;
fn->add_operation(gcalc_function::op_union, n_points);
- data= m_data + 4;
while (n_points--)
{
- double x,y;
- si= fn->add_new_shape(n_points, gcalc_function::shape_point);
+ if (no_data(data, WKB_HEADER_SIZE))
+ return 1;
data+= WKB_HEADER_SIZE;
- get_point(&x, &y, data);
- data+= SIZEOF_STORED_DOUBLE * 2;
- if (trn.single_point(si, x, y))
+ pt.set_data_ptr(data, (uint32) (m_data_end - data));
+ if (pt.store_shapes(heap, fn))
return 1;
- trn.complete();
+ data+= pt.get_data_size();
}
-
return 0;
}
@@ -1485,7 +1477,7 @@ bool Gis_multi_line_string::get_data_as_
return 1;
n_points= uint4korr(data + WKB_HEADER_SIZE);
data+= WKB_HEADER_SIZE + 4;
- if (no_data(data, n_points * (SIZEOF_STORED_DOUBLE*2)) ||
+ if (no_data(data, n_points * POINT_DATA_SIZE) ||
txt->reserve(2 + ((MAX_DIGITS_IN_DOUBLE + 1) * 2 + 1) * n_points))
return 1;
txt->qs_append('(');
@@ -1619,39 +1611,28 @@ int Gis_multi_line_string::is_closed(int
int Gis_multi_line_string::store_shapes(gcalc_heap *heap, gcalc_function *fn) const
{
gcalc_shape_transporter trn(heap);
- uint32 n_line_strings;
+ uint32 n_lines;
+ Gis_line_string ls;
const char *data= m_data;
- gcalc_shape_info si;
if (no_data(data, 4))
return 1;
- n_line_strings= uint4korr(data);
+ n_lines= uint4korr(data);
data+= 4;
- if (fn->reserve_shape_buffer(n_line_strings) || fn->reserve_op_buffer(1))
+ if (fn->reserve_shape_buffer(n_lines) || fn->reserve_op_buffer(1))
return 1;
- fn->add_operation(gcalc_function::op_union, n_line_strings);
+ fn->add_operation(gcalc_function::op_union, n_lines);
- while (n_line_strings--)
+ while (n_lines--)
{
- uint32 n_points;
- if (no_data(data, (WKB_HEADER_SIZE + 4)))
+ if (no_data(data, WKB_HEADER_SIZE))
return 1;
- si= fn->add_new_shape(n_points, gcalc_function::shape_line);
- n_points= uint4korr(data + WKB_HEADER_SIZE);
- data+= WKB_HEADER_SIZE + 4;
- if (no_data(data, n_points * (SIZEOF_STORED_DOUBLE*2)))
+ data+= WKB_HEADER_SIZE;
+ ls.set_data_ptr(data, (uint32) (m_data_end - data));
+ if (ls.store_shapes(heap, fn))
return 1;
- trn.start_line(si);
- while (n_points--)
- {
- double x, y;
- get_point(&x, &y, data);
- data+= (SIZEOF_STORED_DOUBLE*2);
- if (trn.add_point(x, y))
- return 1;
- }
- trn.complete();
+ data+= ls.get_data_size();
}
return 0;
}
@@ -1788,7 +1769,7 @@ bool Gis_multi_polygon::get_data_as_wkt(
return 1;
uint32 n_points= uint4korr(data);
data+= 4;
- if (no_data(data, (SIZEOF_STORED_DOUBLE * 2) * n_points) ||
+ if (no_data(data, POINT_DATA_SIZE * n_points) ||
txt->reserve(2 + ((MAX_DIGITS_IN_DOUBLE + 1) * 2 + 1) * n_points,
512))
return 1;
@@ -1957,39 +1938,28 @@ int Gis_multi_polygon::centroid(String *
int Gis_multi_polygon::store_shapes(gcalc_heap *heap, gcalc_function *fn) const
{
gcalc_shape_transporter trn(heap);
- uint32 n_line_strings;
+ uint32 n_polygons;
+ Gis_polygon p;
const char *data= m_data;
- gcalc_shape_info si;
if (no_data(data, 4))
return 1;
- n_line_strings= uint4korr(data);
+ n_polygons= uint4korr(data);
data+= 4;
- if (fn->reserve_shape_buffer(n_line_strings) || fn->reserve_op_buffer(1))
+ if (fn->reserve_shape_buffer(n_polygons) || fn->reserve_op_buffer(1))
return 1;
- fn->add_operation(gcalc_function::op_union, n_line_strings);
+ fn->add_operation(gcalc_function::op_union, n_polygons);
- while (n_line_strings--)
+ while (n_polygons--)
{
- uint32 n_points;
- if (no_data(data, (WKB_HEADER_SIZE + 4)))
+ if (no_data(data, WKB_HEADER_SIZE))
return 1;
- si= fn->add_new_shape(n_points, gcalc_function::shape_polygon);
- n_points= uint4korr(data + WKB_HEADER_SIZE);
- data+= WKB_HEADER_SIZE + 4;
- if (no_data(data, n_points * (SIZEOF_STORED_DOUBLE*2)))
+ data+= WKB_HEADER_SIZE;
+ p.set_data_ptr(data, (uint32) (m_data_end - data));
+ if (p.store_shapes(heap, fn))
return 1;
- trn.start_ring(si);
- while (n_points--)
- {
- double x, y;
- get_point(&x, &y, data);
- data+= (SIZEOF_STORED_DOUBLE*2);
- if (trn.add_point(x, y))
- return 1;
- }
- trn.complete();
+ data+= p.get_data_size();
}
return 0;
}
@@ -2074,7 +2044,6 @@ uint Gis_geometry_collection::init_from_
Geometry_buffer buffer;
Geometry *geom;
int g_len;
- gcalc_function::shape_type shape;
uint32 wkb_type;
if (bin->reserve(4, 512))
@@ -2337,7 +2306,7 @@ int Gis_geometry_collection::store_shape
while (n_objects--)
{
- uint32 wkb_type, length, dim;
+ uint32 wkb_type;
if (no_data(data, WKB_HEADER_SIZE))
return 1;
| Thread |
|---|
| • bk commit into 5.1 tree (holyfoot:1.2639) BUG#32032 | holyfoot | 24 Nov |