diff options
Diffstat (limited to 'sql/spatial.h')
-rw-r--r-- | sql/spatial.h | 62 |
1 files changed, 42 insertions, 20 deletions
diff --git a/sql/spatial.h b/sql/spatial.h index 1e2decd6ef3..1277e7bc01c 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. +/* + Copyright (c) 2002, 2010, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,6 +24,8 @@ class Gis_read_stream; +#include "gcalc_tools.h" + const uint SRID_SIZE= 4; const uint SIZEOF_STORED_DOUBLE= 8; const uint POINT_DATA_SIZE= SIZEOF_STORED_DOUBLE*2; @@ -98,6 +101,13 @@ struct MBR if (mbr->ymax > ymax) ymax= mbr->ymax; } + void buffer(double d) + { + xmin-= d; + ymin-= d; + xmax+= d; + ymax+= d; + } int equals(const MBR *mbr) { @@ -247,16 +257,19 @@ public: virtual const Class_info *get_class_info() const=0; virtual uint32 get_data_size() const=0; virtual bool init_from_wkt(Gis_read_stream *trs, String *wkb)=0; - /* returns the length of the wkb that was read */ virtual uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res)=0; + virtual uint init_from_opresult(String *bin, + const char *opres, uint res_len) + { return init_from_wkb(opres + 4, UINT_MAX32, wkb_ndr, bin) + 4; } + virtual bool get_data_as_wkt(String *txt, const char **end) const=0; virtual bool get_mbr(MBR *mbr, const char **end) const=0; virtual bool dimension(uint32 *dim, const char **end) const=0; virtual int get_x(double *x) const { return -1; } virtual int get_y(double *y) const { return -1; } - virtual int geom_length(double *len) const { return -1; } + virtual int geom_length(double *len, const char **end) const { return -1; } virtual int area(double *ar, const char **end) const { return -1;} virtual int is_closed(int *closed) const { return -1; } virtual int num_interior_ring(uint32 *n_int_rings) const { return -1; } @@ -269,6 +282,7 @@ public: virtual int point_n(uint32 num, String *result) const { return -1; } virtual int interior_ring_n(uint32 num, String *result) const { return -1; } virtual int geometry_n(uint32 num, String *result) const { return -1; } + virtual int store_shapes(Gcalc_shape_transporter *trn) const=0; public: static Geometry *create_by_typeid(Geometry_buffer *buffer, int type_id); @@ -278,20 +292,11 @@ public: static Geometry *create_from_wkt(Geometry_buffer *buffer, Gis_read_stream *trs, String *wkt, bool init_stream=1); - static Geometry *create_from_wkb(Geometry_buffer *buffer, const char *wkb, - uint32 len, String *res); - int as_wkt(String *wkt, const char **end) - { - uint32 len= (uint) get_class_info()->m_name.length; - if (wkt->reserve(len + 2, 512)) - return 1; - wkt->qs_append(get_class_info()->m_name.str, len); - wkt->qs_append('('); - if (get_data_as_wkt(wkt, end)) - return 1; - wkt->qs_append(')'); - return 0; - } + static Geometry *create_from_wkb(Geometry_buffer *buffer, + const char *wkb, uint32 len, String *res); + static int create_from_opresult(Geometry_buffer *g_buf, + String *res, Gcalc_result_receiver &rr); + int as_wkt(String *wkt, const char **end); inline void set_data_ptr(const char *data, uint32 data_len) { @@ -369,12 +374,15 @@ public: return 0; } + int geom_length(double *len, const char **end) const; + int area(double *ar, const char **end) const; bool dimension(uint32 *dim, const char **end) const { *dim= 0; *end= 0; /* No default end */ return 0; } + int store_shapes(Gcalc_shape_transporter *trn) const; const Class_info *get_class_info() const; }; @@ -395,7 +403,8 @@ public: uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res); 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 geom_length(double *len, const char **end) 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; @@ -407,6 +416,7 @@ public: *end= 0; /* No default end */ return 0; } + int store_shapes(Gcalc_shape_transporter *trn) const; const Class_info *get_class_info() const; }; @@ -421,6 +431,7 @@ public: uint32 get_data_size() const; bool init_from_wkt(Gis_read_stream *trs, String *wkb); uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res); + 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; @@ -435,6 +446,7 @@ public: *end= 0; /* No default end */ return 0; } + int store_shapes(Gcalc_shape_transporter *trn) const; const Class_info *get_class_info() const; }; @@ -453,6 +465,7 @@ public: uint32 get_data_size() const; bool init_from_wkt(Gis_read_stream *trs, String *wkb); uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res); + 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 num_geometries(uint32 *num) const; @@ -463,6 +476,7 @@ public: *end= 0; /* No default end */ return 0; } + int store_shapes(Gcalc_shape_transporter *trn) const; const Class_info *get_class_info() const; }; @@ -477,11 +491,12 @@ public: uint32 get_data_size() const; bool init_from_wkt(Gis_read_stream *trs, String *wkb); uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res); + 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 num_geometries(uint32 *num) const; int geometry_n(uint32 num, String *result) const; - int geom_length(double *len) const; + int geom_length(double *len, const char **end) const; int is_closed(int *closed) const; bool dimension(uint32 *dim, const char **end) const { @@ -489,6 +504,7 @@ public: *end= 0; /* No default end */ return 0; } + int store_shapes(Gcalc_shape_transporter *trn) const; const Class_info *get_class_info() const; }; @@ -515,7 +531,9 @@ public: *end= 0; /* No default end */ return 0; } + int store_shapes(Gcalc_shape_transporter *trn) const; const Class_info *get_class_info() const; + uint init_from_opresult(String *bin, const char *opres, uint res_len); }; @@ -529,16 +547,20 @@ public: uint32 get_data_size() const; bool init_from_wkt(Gis_read_stream *trs, String *wkb); uint init_from_wkb(const char *wkb, uint len, wkbByteOrder bo, String *res); + 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 geom_length(double *len, 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; + int store_shapes(Gcalc_shape_transporter *trn) const; const Class_info *get_class_info() const; }; struct Geometry_buffer : public my_aligned_storage<sizeof(Gis_point), MY_ALIGNOF(Gis_point)> {}; -#endif /*HAVE_SPATAIAL*/ +#endif /*HAVE_SPATIAL*/ #endif |