diff options
author | Alexey Botchkov <holyfoot@askmonty.org> | 2011-09-21 09:29:37 +0500 |
---|---|---|
committer | Alexey Botchkov <holyfoot@askmonty.org> | 2011-09-21 09:29:37 +0500 |
commit | 25b5019c34e717aff95bf405e7d5eb15c2bedf75 (patch) | |
tree | 8bb2999f4be55900e1867c61973614f05bfff80b | |
parent | 0249413a6ae4a5900b51f434b361b9efa6133ad1 (diff) | |
download | mariadb-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.
-rw-r--r-- | mysql-test/r/gis.result | 15 | ||||
-rw-r--r-- | mysql-test/t/gis.test | 5 | ||||
-rw-r--r-- | sql/gcalc_slicescan.cc | 2 | ||||
-rw-r--r-- | sql/spatial.cc | 60 | ||||
-rw-r--r-- | sql/spatial.h | 3 |
5 files changed, 78 insertions, 7 deletions
diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 190795855dd..5a8571bb17e 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -230,7 +230,7 @@ fid AsText(Envelope(g)) 119 POLYGON((0 0,3 0,3 3,0 3,0 0)) 120 POLYGON((0 0,10 0,10 10,0 10,0 0)) 121 POLYGON((3 6,44 6,44 9,3 9,3 6)) -122 POLYGON((1.79769313486232e+308 1.79769313486232e+308,-1.79769313486232e+308 1.79769313486232e+308,-1.79769313486232e+308 -1.79769313486232e+308,1.79769313486232e+308 -1.79769313486232e+308,1.79769313486232e+308 1.79769313486232e+308)) +122 NULL explain extended select Dimension(g), GeometryType(g), IsEmpty(g), AsText(Envelope(g)) from gis_geometry; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE gis_geometry ALL NULL NULL NULL NULL 22 100.00 @@ -396,13 +396,13 @@ FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second first second w c o e d t i r 120 120 1 1 0 1 0 1 1 1 120 121 0 0 1 0 0 0 1 0 -120 122 0 1 0 0 1 0 0 0 +120 122 0 1 NULL NULL NULL 0 NULL 0 121 120 0 0 1 0 0 0 1 0 121 121 1 1 0 1 0 1 1 1 -121 122 0 1 0 0 1 0 0 0 -122 120 1 0 0 0 1 0 0 0 -122 121 1 0 0 0 1 0 0 0 -122 122 1 1 0 1 1 0 0 0 +121 122 0 1 NULL NULL NULL 0 NULL 0 +122 120 1 0 NULL NULL NULL 0 NULL 0 +122 121 1 0 NULL NULL NULL 0 NULL 0 +122 122 1 1 NULL NULL NULL 0 NULL 0 explain extended SELECT g1.fid as first, g2.fid as second, Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o, Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t, @@ -1077,6 +1077,9 @@ SPATIAL INDEX i1 (col1, col2) ERROR HY000: Incorrect arguments to SPATIAL INDEX DROP TABLE t1; DROP TABLE t2; +select ST_AREA(ST_GEOMCOLLFROMTEXT(' GEOMETRYCOLLECTION(LINESTRING(100 100, 31 10, 77 80), POLYGON((0 0,4 7,1 1,0 0)), POINT(20 20))')); +ST_AREA(ST_GEOMCOLLFROMTEXT(' GEOMETRYCOLLECTION(LINESTRING(100 100, 31 10, 77 80), POLYGON((0 0,4 7,1 1,0 0)), POINT(20 20))')) +1.5 DROP DATABASE IF EXISTS gis_ogs; CREATE DATABASE gis_ogs; USE gis_ogs; diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index 25fec4cca4e..359d0e8520a 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -804,6 +804,11 @@ CREATE TABLE t3 ( DROP TABLE t1; DROP TABLE t2; +#bug 850775 ST_AREA does not work on GEOMETRYCOLLECTIONs in maria-5.3-gis +select ST_AREA(ST_GEOMCOLLFROMTEXT(' GEOMETRYCOLLECTION(LINESTRING(100 100, 31 10, 77 80), POLYGON((0 0,4 7,1 1,0 0)), POINT(20 20))')); + + + # Conformance tests # # C.3.3 Geometry types and functions diff --git a/sql/gcalc_slicescan.cc b/sql/gcalc_slicescan.cc index 07120d2e87e..8a9fcc60ad0 100644 --- a/sql/gcalc_slicescan.cc +++ b/sql/gcalc_slicescan.cc @@ -2033,7 +2033,7 @@ double Gcalc_scan_iterator::get_h() const double Gcalc_scan_iterator::get_sp_x(const point *sp) const { double dy; - if (sp->event == scev_end | scev_two_ends | scev_point) + if (sp->event & (scev_end | scev_two_ends | scev_point)) return sp->pi->x; dy= sp->next_pi->y - sp->pi->y; if (fabs(dy) < 1e-12) 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)) diff --git a/sql/spatial.h b/sql/spatial.h index e8f230f9127..eaf048b7a3d 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -375,6 +375,7 @@ public: return 0; } + int area(double *ar, const char **end) const; bool dimension(uint32 *dim, const char **end) const { *dim= 0; @@ -399,6 +400,7 @@ public: bool get_data_as_wkt(String *txt, const char **end) const; bool get_mbr(MBR *mbr, const char **end) const; int geom_length(double *len) const; + int area(double *ar, const char **end) const; int is_closed(int *closed) const; int num_points(uint32 *n_points) const; int start_point(String *point) const; @@ -540,6 +542,7 @@ public: uint init_from_opresult(String *bin, const char *opres, uint res_len); bool get_data_as_wkt(String *txt, const char **end) const; bool get_mbr(MBR *mbr, const char **end) const; + int area(double *ar, const char **end) const; int num_geometries(uint32 *num) const; int geometry_n(uint32 num, String *result) const; bool dimension(uint32 *dim, const char **end) const; |