GEOMETRYCOLLECTION EMPTY handling fixed.
The get_mbr() method shouldn't return the error, rather an invalid MBR in this case.
This commit is contained in:
parent
51a7074864
commit
045c498691
@ -559,8 +559,8 @@ longlong Item_func_spatial_mbr_rel::val_int()
|
|||||||
args[1]->null_value ||
|
args[1]->null_value ||
|
||||||
!(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) ||
|
!(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) ||
|
||||||
!(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())) ||
|
!(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())) ||
|
||||||
g1->get_mbr(&mbr1, &dummy) ||
|
g1->get_mbr(&mbr1, &dummy) || !mbr1.valid() ||
|
||||||
g2->get_mbr(&mbr2, &dummy))))
|
g2->get_mbr(&mbr2, &dummy) || !mbr2.valid())))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (spatial_rel) {
|
switch (spatial_rel) {
|
||||||
@ -686,8 +686,8 @@ longlong Item_func_spatial_rel::val_int()
|
|||||||
(args[0]->null_value || args[1]->null_value ||
|
(args[0]->null_value || args[1]->null_value ||
|
||||||
!(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) ||
|
!(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) ||
|
||||||
!(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())) ||
|
!(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())) ||
|
||||||
g1->get_mbr(&mbr1, &c_end) ||
|
g1->get_mbr(&mbr1, &c_end) || !mbr1.valid() ||
|
||||||
g2->get_mbr(&mbr2, &c_end))))
|
g2->get_mbr(&mbr2, &c_end) || !mbr2.valid())))
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
umbr= mbr1;
|
umbr= mbr1;
|
||||||
@ -824,8 +824,8 @@ String *Item_func_spatial_operation::val_str(String *str_value)
|
|||||||
(args[0]->null_value || args[1]->null_value ||
|
(args[0]->null_value || args[1]->null_value ||
|
||||||
!(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) ||
|
!(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) ||
|
||||||
!(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())) ||
|
!(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())) ||
|
||||||
g1->get_mbr(&mbr1, &c_end) ||
|
g1->get_mbr(&mbr1, &c_end) || !mbr1.valid() ||
|
||||||
g2->get_mbr(&mbr2, &c_end))))
|
g2->get_mbr(&mbr2, &c_end) || !mbr2.valid())))
|
||||||
{
|
{
|
||||||
str_value= 0;
|
str_value= 0;
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -308,6 +308,9 @@ bool Geometry::envelope(String *result) const
|
|||||||
const char *end;
|
const char *end;
|
||||||
|
|
||||||
if (get_mbr(&mbr, &end))
|
if (get_mbr(&mbr, &end))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (!mbr.valid())
|
||||||
{
|
{
|
||||||
/* Empty geometry */
|
/* Empty geometry */
|
||||||
if (result->reserve(1 + 4*2))
|
if (result->reserve(1 + 4*2))
|
||||||
@ -2322,7 +2325,7 @@ bool Gis_geometry_collection::get_mbr(MBR *mbr, const char **end) const
|
|||||||
n_objects= uint4korr(data);
|
n_objects= uint4korr(data);
|
||||||
data+= 4;
|
data+= 4;
|
||||||
if (n_objects == 0)
|
if (n_objects == 0)
|
||||||
return 1;
|
goto exit;
|
||||||
|
|
||||||
while (n_objects--)
|
while (n_objects--)
|
||||||
{
|
{
|
||||||
@ -2339,6 +2342,7 @@ bool Gis_geometry_collection::get_mbr(MBR *mbr, const char **end) const
|
|||||||
if (geom->get_mbr(mbr, &data))
|
if (geom->get_mbr(mbr, &data))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
exit:
|
||||||
*end= data;
|
*end= data;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2356,10 +2360,11 @@ int Gis_geometry_collection::area(double *ar, const char **end) const
|
|||||||
return 1;
|
return 1;
|
||||||
n_objects= uint4korr(data);
|
n_objects= uint4korr(data);
|
||||||
data+= 4;
|
data+= 4;
|
||||||
if (n_objects == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
result= 0.0;
|
result= 0.0;
|
||||||
|
if (n_objects == 0)
|
||||||
|
goto exit;
|
||||||
|
|
||||||
while (n_objects--)
|
while (n_objects--)
|
||||||
{
|
{
|
||||||
uint32 wkb_type;
|
uint32 wkb_type;
|
||||||
@ -2376,6 +2381,7 @@ int Gis_geometry_collection::area(double *ar, const char **end) const
|
|||||||
return 1;
|
return 1;
|
||||||
result+= *ar;
|
result+= *ar;
|
||||||
}
|
}
|
||||||
|
exit:
|
||||||
*end= data;
|
*end= data;
|
||||||
*ar= result;
|
*ar= result;
|
||||||
return 0;
|
return 0;
|
||||||
@ -2394,10 +2400,11 @@ int Gis_geometry_collection::geom_length(double *len, const char **end) const
|
|||||||
return 1;
|
return 1;
|
||||||
n_objects= uint4korr(data);
|
n_objects= uint4korr(data);
|
||||||
data+= 4;
|
data+= 4;
|
||||||
if (n_objects == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
result= 0.0;
|
result= 0.0;
|
||||||
|
|
||||||
|
if (n_objects == 0)
|
||||||
|
goto exit;
|
||||||
|
|
||||||
while (n_objects--)
|
while (n_objects--)
|
||||||
{
|
{
|
||||||
uint32 wkb_type;
|
uint32 wkb_type;
|
||||||
@ -2414,6 +2421,8 @@ int Gis_geometry_collection::geom_length(double *len, const char **end) const
|
|||||||
return 1;
|
return 1;
|
||||||
result+= *len;
|
result+= *len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
*end= data;
|
*end= data;
|
||||||
*len= result;
|
*len= result;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -199,6 +199,9 @@ struct MBR
|
|||||||
|
|
||||||
return (d == intersection.dimension());
|
return (d == intersection.dimension());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int valid() const
|
||||||
|
{ return xmin <= xmax && ymin <= ymax; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user