summaryrefslogtreecommitdiff
path: root/sql/item_geofunc.cc
diff options
context:
space:
mode:
authorunknown <jani@ua141d10.elisa.omakaista.fi>2005-10-31 11:54:36 +0200
committerunknown <jani@ua141d10.elisa.omakaista.fi>2005-10-31 11:54:36 +0200
commit5f6b100ed0eaacd644352972939a77f0a964c1af (patch)
treedb7782f75178512900e6e862142d57d3d0d96cf4 /sql/item_geofunc.cc
parent6de8b295a7dd53b47f7e0d4ebc109dabb07c6397 (diff)
parenta006453fad260a35df973a8785f0d9a8977c1cac (diff)
downloadmariadb-git-5f6b100ed0eaacd644352972939a77f0a964c1af.tar.gz
Merge ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-4.1
into ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-5.0-tmp client/mysqlimport.c: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/r/gis.result: Auto merged mysql-test/t/mysqldump.test: Auto merged sql/field.cc: Auto merged sql/item_geofunc.cc: Auto merged sql/spatial.cc: Auto merged sql/spatial.h: Auto merged support-files/my-huge.cnf.sh: Auto merged support-files/my-innodb-heavy-4G.cnf.sh: Auto merged support-files/my-large.cnf.sh: Auto merged mysql-test/mysql-test-run.sh: Merged from 4.1. mysql-test/r/mysqldump.result: Merged from 4.1. mysql-test/t/gis.test: Merged from 4.1.
Diffstat (limited to 'sql/item_geofunc.cc')
-rw-r--r--sql/item_geofunc.cc77
1 files changed, 28 insertions, 49 deletions
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index 4a6ceb4bf7d..2b92e72e728 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -81,8 +81,7 @@ String *Item_func_geometry_from_wkb::val_str(String *str)
str->q_append(srid);
if ((null_value=
(args[0]->null_value ||
- !Geometry::create_from_wkb(&buffer, wkb->ptr(), wkb->length()) ||
- str->append(*wkb))))
+ !Geometry::create_from_wkb(&buffer, wkb->ptr(), wkb->length(), str))))
return 0;
return str;
}
@@ -99,8 +98,7 @@ String *Item_func_as_wkt::val_str(String *str)
if ((null_value=
(args[0]->null_value ||
- !(geom= Geometry::create_from_wkb(&buffer, swkb->ptr() + SRID_SIZE,
- swkb->length() - SRID_SIZE)))))
+ !(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length())))))
return 0;
str->length(0);
@@ -126,8 +124,7 @@ String *Item_func_as_wkb::val_str(String *str)
if ((null_value=
(args[0]->null_value ||
- !(Geometry::create_from_wkb(&buffer, swkb->ptr() + SRID_SIZE,
- swkb->length() - SRID_SIZE)))))
+ !(Geometry::construct(&buffer, swkb->ptr(), swkb->length())))))
return 0;
str->copy(swkb->ptr() + SRID_SIZE, swkb->length() - SRID_SIZE,
@@ -145,8 +142,7 @@ String *Item_func_geometry_type::val_str(String *str)
if ((null_value=
(args[0]->null_value ||
- !(geom= Geometry::create_from_wkb(&buffer, swkb->ptr() + SRID_SIZE,
- swkb->length() - SRID_SIZE)))))
+ !(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length())))))
return 0;
/* String will not move */
str->copy(geom->get_class_info()->m_name.str,
@@ -167,8 +163,7 @@ String *Item_func_envelope::val_str(String *str)
if ((null_value=
args[0]->null_value ||
- !(geom= Geometry::create_from_wkb(&buffer, swkb->ptr() + SRID_SIZE,
- swkb->length() - SRID_SIZE))))
+ !(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length()))))
return 0;
srid= uint4korr(swkb->ptr());
@@ -191,8 +186,7 @@ String *Item_func_centroid::val_str(String *str)
uint32 srid;
if ((null_value= args[0]->null_value ||
- !(geom= Geometry::create_from_wkb(&buffer, swkb->ptr() + SRID_SIZE,
- swkb->length() - SRID_SIZE))))
+ !(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length()))))
return 0;
str->set_charset(&my_charset_bin);
@@ -221,8 +215,7 @@ String *Item_func_spatial_decomp::val_str(String *str)
if ((null_value=
(args[0]->null_value ||
- !(geom= Geometry::create_from_wkb(&buffer, swkb->ptr() + SRID_SIZE,
- swkb->length() - SRID_SIZE)))))
+ !(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length())))))
return 0;
srid= uint4korr(swkb->ptr());
@@ -270,8 +263,7 @@ String *Item_func_spatial_decomp_n::val_str(String *str)
if ((null_value=
(args[0]->null_value || args[1]->null_value ||
- !(geom= Geometry::create_from_wkb(&buffer, swkb->ptr() + SRID_SIZE,
- swkb->length() - SRID_SIZE)))))
+ !(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length())))))
return 0;
str->set_charset(&my_charset_bin);
@@ -478,10 +470,8 @@ longlong Item_func_spatial_rel::val_int()
if ((null_value=
(args[0]->null_value ||
args[1]->null_value ||
- !(g1= Geometry::create_from_wkb(&buffer1, res1->ptr() + SRID_SIZE,
- res1->length() - SRID_SIZE)) ||
- !(g2= Geometry::create_from_wkb(&buffer2, res2->ptr() + SRID_SIZE,
- res2->length() - SRID_SIZE)) ||
+ !(g1= Geometry::construct(&buffer1, res1->ptr(), res1->length())) ||
+ !(g2= Geometry::construct(&buffer2, res2->ptr(), res2->length())) ||
g1->get_mbr(&mbr1, &dummy) ||
g2->get_mbr(&mbr2, &dummy))))
return 0;
@@ -546,8 +536,7 @@ longlong Item_func_isclosed::val_int()
null_value= (!swkb ||
args[0]->null_value ||
!(geom=
- Geometry::create_from_wkb(&buffer, swkb->ptr() + SRID_SIZE,
- swkb->length() - SRID_SIZE)) ||
+ Geometry::construct(&buffer, swkb->ptr(), swkb->length())) ||
geom->is_closed(&isclosed));
return (longlong) isclosed;
@@ -569,9 +558,7 @@ longlong Item_func_dimension::val_int()
null_value= (!swkb ||
args[0]->null_value ||
- !(geom= Geometry::create_from_wkb(&buffer,
- swkb->ptr() + SRID_SIZE,
- swkb->length() - SRID_SIZE)) ||
+ !(geom= Geometry::construct(&buffer, swkb->ptr(), swkb->length())) ||
geom->dimension(&dim, &dummy));
return (longlong) dim;
}
@@ -586,9 +573,8 @@ longlong Item_func_numinteriorring::val_int()
Geometry *geom;
null_value= (!swkb ||
- !(geom= Geometry::create_from_wkb(&buffer,
- swkb->ptr() + SRID_SIZE,
- swkb->length() - SRID_SIZE)) ||
+ !(geom= Geometry::construct(&buffer,
+ swkb->ptr(), swkb->length())) ||
geom->num_interior_ring(&num));
return (longlong) num;
}
@@ -603,9 +589,8 @@ longlong Item_func_numgeometries::val_int()
Geometry *geom;
null_value= (!swkb ||
- !(geom= Geometry::create_from_wkb(&buffer,
- swkb->ptr() + SRID_SIZE,
- swkb->length() - SRID_SIZE)) ||
+ !(geom= Geometry::construct(&buffer,
+ swkb->ptr(), swkb->length())) ||
geom->num_geometries(&num));
return (longlong) num;
}
@@ -621,9 +606,8 @@ longlong Item_func_numpoints::val_int()
null_value= (!swkb ||
args[0]->null_value ||
- !(geom= Geometry::create_from_wkb(&buffer,
- swkb->ptr() + SRID_SIZE,
- swkb->length() - SRID_SIZE)) ||
+ !(geom= Geometry::construct(&buffer,
+ swkb->ptr(), swkb->length())) ||
geom->num_points(&num));
return (longlong) num;
}
@@ -638,9 +622,8 @@ double Item_func_x::val_real()
Geometry *geom;
null_value= (!swkb ||
- !(geom= Geometry::create_from_wkb(&buffer,
- swkb->ptr() + SRID_SIZE,
- swkb->length() - SRID_SIZE)) ||
+ !(geom= Geometry::construct(&buffer,
+ swkb->ptr(), swkb->length())) ||
geom->get_x(&res));
return res;
}
@@ -655,9 +638,8 @@ double Item_func_y::val_real()
Geometry *geom;
null_value= (!swkb ||
- !(geom= Geometry::create_from_wkb(&buffer,
- swkb->ptr() + SRID_SIZE,
- swkb->length() - SRID_SIZE)) ||
+ !(geom= Geometry::construct(&buffer,
+ swkb->ptr(), swkb->length())) ||
geom->get_y(&res));
return res;
}
@@ -673,9 +655,8 @@ double Item_func_area::val_real()
const char *dummy;
null_value= (!swkb ||
- !(geom= Geometry::create_from_wkb(&buffer,
- swkb->ptr() + SRID_SIZE,
- swkb->length() - SRID_SIZE)) ||
+ !(geom= Geometry::construct(&buffer,
+ swkb->ptr(), swkb->length())) ||
geom->area(&res, &dummy));
return res;
}
@@ -689,9 +670,8 @@ double Item_func_glength::val_real()
Geometry *geom;
null_value= (!swkb ||
- !(geom= Geometry::create_from_wkb(&buffer,
- swkb->ptr() + SRID_SIZE,
- swkb->length() - SRID_SIZE)) ||
+ !(geom= Geometry::construct(&buffer,
+ swkb->ptr(), swkb->length())) ||
geom->length(&res));
return res;
}
@@ -703,9 +683,8 @@ longlong Item_func_srid::val_int()
Geometry_buffer buffer;
null_value= (!swkb ||
- !Geometry::create_from_wkb(&buffer,
- swkb->ptr() + SRID_SIZE,
- swkb->length() - SRID_SIZE));
+ !Geometry::construct(&buffer,
+ swkb->ptr(), swkb->length()));
if (null_value)
return 0;