summaryrefslogtreecommitdiff
path: root/sql/spatial.cc
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2011-09-21 09:29:37 +0500
committerAlexey Botchkov <holyfoot@askmonty.org>2011-09-21 09:29:37 +0500
commit25b5019c34e717aff95bf405e7d5eb15c2bedf75 (patch)
tree8bb2999f4be55900e1867c61973614f05bfff80b /sql/spatial.cc
parent0249413a6ae4a5900b51f434b361b9efa6133ad1 (diff)
downloadmariadb-git-25b5019c34e717aff95bf405e7d5eb15c2bedf75.tar.gz
bugs fixed
855253 Compiler error: gcalc_slicescan.cc:2036: error: suggest parentheses around comparison in operand of .|. in maria-5.3-gis 850775 ST_AREA does not work on GEOMETRYCOLLECTIONs in maria-5.3-gis per-file comments: mysql-test/r/gis.result test result updated. mysql-test/t/gis.test test case added for 850775. sql/gcalc_slicescan.cc compiler error fixed. sql/spatial.cc ST_AREA implementation for GEOMETRY_COLLECTION, POINT and LINESTRING. sql/spatial.h area() declarations added.
Diffstat (limited to 'sql/spatial.cc')
-rw-r--r--sql/spatial.cc60
1 files changed, 60 insertions, 0 deletions
diff --git a/sql/spatial.cc b/sql/spatial.cc
index 0e535d11056..4d5e5db10c0 100644
--- a/sql/spatial.cc
+++ b/sql/spatial.cc
@@ -489,6 +489,14 @@ bool Gis_point::get_mbr(MBR *mbr, const char **end) const
}
+int Gis_point::area(double *ar, const char **end) const
+{
+ *ar= 0;
+ *end= m_data+ POINT_DATA_SIZE;
+ return 0;
+}
+
+
int Gis_point::store_shapes(Gcalc_shape_transporter *trn) const
{
double x, y;
@@ -634,6 +642,20 @@ int Gis_line_string::geom_length(double *len) const
}
+int Gis_line_string::area(double *ar, const char **end) const
+{
+ uint32 n_points;
+ *ar= 0.0;
+
+ /* read number of points */
+ if (no_data(m_data, 4))
+ return 1;
+ n_points= uint4korr(m_data);
+ *end= m_data + 4 + POINT_DATA_SIZE * n_points;
+ return 0;
+}
+
+
int Gis_line_string::is_closed(int *closed) const
{
uint32 n_points;
@@ -2253,6 +2275,44 @@ bool Gis_geometry_collection::get_mbr(MBR *mbr, const char **end) const
}
+int Gis_geometry_collection::area(double *ar, const char **end_of_data) const
+{
+ uint32 n_objects;
+ const char *data= m_data;
+ Geometry_buffer buffer;
+ Geometry *geom;
+ double result;
+
+ if (no_data(data, 4))
+ return 1;
+ n_objects= uint4korr(data);
+ data+= 4;
+ if (n_objects == 0)
+ return 1;
+
+ result= 0.0;
+ while (n_objects--)
+ {
+ uint32 wkb_type;
+
+ if (no_data(data, WKB_HEADER_SIZE))
+ return 1;
+ wkb_type= uint4korr(data + 1);
+ data+= WKB_HEADER_SIZE;
+
+ if (!(geom= create_by_typeid(&buffer, wkb_type)))
+ return 1;
+ geom->set_data_ptr(data, (uint32) (m_data_end - data));
+ if (geom->area(ar, &data))
+ return 1;
+ result+= *ar;
+ }
+ *end_of_data= data;
+ *ar= result;
+ return 0;
+}
+
+
int Gis_geometry_collection::num_geometries(uint32 *num) const
{
if (no_data(m_data, 4))