diff options
author | unknown <ram@mysql.r18.ru> | 2003-03-18 15:30:32 +0400 |
---|---|---|
committer | unknown <ram@mysql.r18.ru> | 2003-03-18 15:30:32 +0400 |
commit | 3ccd93c704556d9496b643e580dca8a9fcd2f4d4 (patch) | |
tree | 0e83c851e37727716fb38186353324ae67952771 /sql/field.cc | |
parent | 1c1f407dd33951d44b4e2eaa30d4025998514e47 (diff) | |
download | mariadb-git-3ccd93c704556d9496b643e580dca8a9fcd2f4d4.tar.gz |
SRID support.
GeomertyFromWKB() function.
SRID() function.
::store() methods for Field_geom.
Code cleanup.
myisam/sp_key.c:
SRID support.
mysql-test/r/gis.result:
We should use GeometryFromWKB().
mysql-test/t/gis.test:
We should use GeometryFromWKB().
sql/field.cc:
SRID support.
::store() methods for Field_geom.
Code cleanup.
sql/field.h:
SRID support.
::store() methods for Field_geom.
Code cleanup.
sql/item_cmpfunc.cc:
SRID support.
Code cleanup.
sql/item_create.cc:
Code cleanup.
sql/item_create.h:
Code cleanup.
sql/item_func.cc:
SRID support.
Code cleanup.
sql/item_func.h:
SRID support.
sql/item_strfunc.cc:
SRID support.
GeometryFromWKB() function.
Code cleanup.
sql/item_strfunc.h:
SRID support.
GeometryFromWKB() function.
Code cleanup.
sql/lex.h:
GeometryFromWKB() function.
SRID() function.
sql/spatial.cc:
Code cleanup.
sql/spatial.h:
Code cleanup.
sql/sql_yacc.yy:
Fix for xxxFromText() functions.
GeometryFromWKB() function.
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 89 |
1 files changed, 59 insertions, 30 deletions
diff --git a/sql/field.cc b/sql/field.cc index 0c17209003c..b5ed7885af5 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4525,7 +4525,7 @@ void Field_blob::get_key_image(char *buff,uint length, MBR mbr; Geometry gobj; - gobj.create_from_wkb(blob,blob_length); + gobj.create_from_wkb(blob + SRID_SIZE, blob_length - SRID_SIZE); gobj.get_mbr(&mbr); float8store(buff, mbr.xmin); float8store(buff+8, mbr.xmax); @@ -4555,35 +4555,6 @@ void Field_blob::set_key_image(char *buff,uint length, CHARSET_INFO *cs) } -void Field_geom::get_key_image(char *buff,uint length,CHARSET_INFO *cs, - imagetype type) -{ - length-=HA_KEY_BLOB_LENGTH; - ulong blob_length=get_length(ptr); - char *blob; - get_ptr(&blob); - - MBR mbr; - Geometry gobj; - gobj.create_from_wkb(blob,blob_length); - gobj.get_mbr(&mbr); - float8store(buff, mbr.xmin); - float8store(buff+8, mbr.xmax); - float8store(buff+16, mbr.ymin); - float8store(buff+24, mbr.ymax); - return; -} - -void Field_geom::set_key_image(char *buff,uint length,CHARSET_INFO *cs) -{ - Field_blob::set_key_image(buff, length, cs); -} - -void Field_geom::sql_type(String &res) const -{ - res.set("geometry", 8, &my_charset_latin1); -} - int Field_blob::key_cmp(const byte *key_ptr, uint max_key_length) { char *blob1; @@ -4776,6 +4747,64 @@ uint Field_blob::max_packed_col_length(uint max_length) return (max_length > 255 ? 2 : 1)+max_length; } + +void Field_geom::get_key_image(char *buff, uint length, CHARSET_INFO *cs, + imagetype type) +{ + length-= HA_KEY_BLOB_LENGTH; + ulong blob_length= get_length(ptr); + char *blob; + get_ptr(&blob); + + MBR mbr; + Geometry gobj; + gobj.create_from_wkb(blob + SRID_SIZE, blob_length - SRID_SIZE); + gobj.get_mbr(&mbr); + float8store(buff, mbr.xmin); + float8store(buff + 8, mbr.xmax); + float8store(buff + 16, mbr.ymin); + float8store(buff + 24, mbr.ymax); + return; +} + + +void Field_geom::set_key_image(char *buff, uint length, CHARSET_INFO *cs) +{ + Field_blob::set_key_image(buff, length, cs); +} + +void Field_geom::sql_type(String &res) const +{ + res.set("geometry", 8, &my_charset_latin1); +} + + +int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs) +{ + if (!length) + { + bzero(ptr, Field_blob::pack_length()); + } + else + { + // Should check given WKB + if (length < 4 + 1 + 4 + 8 + 8) // SRID + WKB_HEADER + X + Y + return 1; + uint32 wkb_type= uint4korr(from + 5); + if (wkb_type < 1 || wkb_type > 7) + return 1; + Field_blob::store_length(length); + if (table->copy_blobs || length <= MAX_FIELD_WIDTH) + { // Must make a copy + value.copy(from, length, cs); + from= value.ptr(); + } + bmove(ptr + packlength, (char*) &from, sizeof(char*)); + } + return 0; +} + + /**************************************************************************** ** enum type. ** This is a string which only can have a selection of different values. |