diff options
author | Alexey Botchkov <holyfoot@askmonty.org> | 2014-11-28 00:29:37 +0400 |
---|---|---|
committer | Alexey Botchkov <holyfoot@askmonty.org> | 2014-11-28 00:29:37 +0400 |
commit | d0d6284cab70af148269d95744f615454cac24bb (patch) | |
tree | a4c6151171a4ba0d3473f02e5b7ccb99eda2d365 /sql/spatial.cc | |
parent | 7b55b67de5fdfe91283357fe6c7ccc3f9e355925 (diff) | |
download | mariadb-git-d0d6284cab70af148269d95744f615454cac24bb.tar.gz |
MDEV-4045 Missing OGC Spatial functions.
Missing GIS functions added:
IsRing()
PointOnSurface
PointOnSurface
Relate
Distance
Intersection
ConvexHull
Other old OpenGis standard inconsistencies fixed.
Diffstat (limited to 'sql/spatial.cc')
-rw-r--r-- | sql/spatial.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sql/spatial.cc b/sql/spatial.cc index 34d2417f632..9f672801c9f 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -291,19 +291,18 @@ Geometry *Geometry::create_from_wkb(Geometry_buffer *buffer, } -int Geometry::create_from_opresult(Geometry_buffer *g_buf, +Geometry *Geometry::create_from_opresult(Geometry_buffer *g_buf, String *res, Gcalc_result_receiver &rr) { uint32 geom_type= rr.get_result_typeid(); Geometry *obj= create_by_typeid(g_buf, geom_type); if (!obj || res->reserve(WKB_HEADER_SIZE, 512)) - return 1; + return NULL; res->q_append((char) wkb_ndr); res->q_append(geom_type); - return obj->init_from_opresult(res, rr.result(), rr.length()) == 0 && - rr.length(); + return obj->init_from_opresult(res, rr.result(), rr.length()) ? obj : NULL; } @@ -386,7 +385,7 @@ bool Geometry::create_point(String *result, const char *data) const 1 Can't reallocate 'result' */ -bool Geometry::create_point(String *result, double x, double y) const +bool Geometry::create_point(String *result, double x, double y) { if (result->reserve(1 + 4 + POINT_DATA_SIZE)) return 1; @@ -2221,6 +2220,13 @@ uint Gis_geometry_collection::init_from_opresult(String *bin, return 0; bin->q_append(n_objects); + if (res_len == 0) + { + /* Special case of GEOMETRYCOLLECTION EMPTY. */ + opres+= 1; + goto empty_geom; + } + while (res_len) { switch ((Gcalc_function::shape_type) uint4korr(opres)) @@ -2244,6 +2250,7 @@ uint Gis_geometry_collection::init_from_opresult(String *bin, res_len-= g_len; n_objects++; } +empty_geom: bin->write_at_position(no_pos, n_objects); return (uint) (opres - opres_orig); } |