Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
5150bd8f
Commit
5150bd8f
authored
Oct 31, 2005
by
hf@deer.(none)
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk@192.168.21.1:/usr/home/bk/mysql-4.1
into deer.(none):/home/hf/work/mysql-4.1.12839
parents
b919b29d
16c66d49
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
353 additions
and
79 deletions
+353
-79
mysql-test/r/gis.result
mysql-test/r/gis.result
+6
-0
mysql-test/t/gis.test
mysql-test/t/gis.test
+3
-0
sql/field.cc
sql/field.cc
+3
-5
sql/item_geofunc.cc
sql/item_geofunc.cc
+28
-49
sql/spatial.cc
sql/spatial.cc
+297
-22
sql/spatial.h
sql/spatial.h
+16
-3
No files found.
mysql-test/r/gis.result
View file @
5150bd8f
...
...
@@ -655,3 +655,9 @@ t1 where object_id=85984;
object_id geometrytype(geo) ISSIMPLE(GEO) ASTEXT(centroid(geo))
85984 MULTIPOLYGON 0 POINT(-114.87787186923 36.33101763469)
drop table t1;
select (asWKT(geomfromwkb((0x000000000140240000000000004024000000000000))));
(asWKT(geomfromwkb((0x000000000140240000000000004024000000000000))))
POINT(10 10)
select (asWKT(geomfromwkb((0x010100000000000000000024400000000000002440))));
(asWKT(geomfromwkb((0x010100000000000000000024400000000000002440))))
POINT(10 10)
mysql-test/t/gis.test
View file @
5150bd8f
...
...
@@ -360,4 +360,7 @@ t1 where object_id=85984;
drop
table
t1
;
select
(
asWKT
(
geomfromwkb
((
0x000000000140240000000000004024000000000000
))));
select
(
asWKT
(
geomfromwkb
((
0x010100000000000000000024400000000000002440
))));
# End of 4.1 tests
sql/field.cc
View file @
5150bd8f
...
...
@@ -5745,8 +5745,7 @@ void Field_blob::get_key_image(char *buff,uint length,
return
;
}
get_ptr
(
&
blob
);
gobj
=
Geometry
::
create_from_wkb
(
&
buffer
,
blob
+
SRID_SIZE
,
blob_length
-
SRID_SIZE
);
gobj
=
Geometry
::
construct
(
&
buffer
,
blob
,
blob_length
);
if
(
gobj
->
get_mbr
(
&
mbr
,
&
dummy
))
bzero
(
buff
,
SIZEOF_STORED_DOUBLE
*
4
);
else
...
...
@@ -6039,8 +6038,7 @@ void Field_geom::get_key_image(char *buff, uint length, CHARSET_INFO *cs,
return
;
}
get_ptr
(
&
blob
);
gobj
=
Geometry
::
create_from_wkb
(
&
buffer
,
blob
+
SRID_SIZE
,
blob_length
-
SRID_SIZE
);
gobj
=
Geometry
::
construct
(
&
buffer
,
blob
,
blob_length
);
if
(
gobj
->
get_mbr
(
&
mbr
,
&
dummy
))
bzero
(
buff
,
SIZEOF_STORED_DOUBLE
*
4
);
else
...
...
@@ -6100,7 +6098,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs)
uint32
wkb_type
;
if
(
length
<
SRID_SIZE
+
WKB_HEADER_SIZE
+
SIZEOF_STORED_DOUBLE
*
2
)
goto
err
;
wkb_type
=
uint4korr
(
from
+
WKB_HEADER_SIZE
);
wkb_type
=
uint4korr
(
from
+
SRID_SIZE
+
1
);
if
(
wkb_type
<
(
uint32
)
Geometry
::
wkb_point
||
wkb_type
>
(
uint32
)
Geometry
::
wkb_end
)
return
-
1
;
...
...
sql/item_geofunc.cc
View file @
5150bd8f
...
...
@@ -78,8 +78,7 @@ String *Item_func_geometry_from_wkb::val_str(String *str)
str
->
q_append
(
srid
);
if
((
null_value
=
(
args
[
0
]
->
null_value
||
!
Geometry
::
create_from_wkb
(
&
buffer
,
wkb
->
ptr
(),
wkb
->
length
())
||
str
->
append
(
*
wkb
))))
!
Geometry
::
create_from_wkb
(
&
buffer
,
wkb
->
ptr
(),
wkb
->
length
(),
str
))))
return
0
;
return
str
;
}
...
...
@@ -96,8 +95,7 @@ String *Item_func_as_wkt::val_str(String *str)
if
((
null_value
=
(
args
[
0
]
->
null_value
||
!
(
geom
=
Geometry
::
create_from_wkb
(
&
buffer
,
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
)))))
!
(
geom
=
Geometry
::
construct
(
&
buffer
,
swkb
->
ptr
(),
swkb
->
length
())))))
return
0
;
str
->
length
(
0
);
...
...
@@ -123,8 +121,7 @@ String *Item_func_as_wkb::val_str(String *str)
if
((
null_value
=
(
args
[
0
]
->
null_value
||
!
(
Geometry
::
create_from_wkb
(
&
buffer
,
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
)))))
!
(
Geometry
::
construct
(
&
buffer
,
swkb
->
ptr
(),
swkb
->
length
())))))
return
0
;
str
->
copy
(
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
,
...
...
@@ -142,8 +139,7 @@ String *Item_func_geometry_type::val_str(String *str)
if
((
null_value
=
(
args
[
0
]
->
null_value
||
!
(
geom
=
Geometry
::
create_from_wkb
(
&
buffer
,
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
)))))
!
(
geom
=
Geometry
::
construct
(
&
buffer
,
swkb
->
ptr
(),
swkb
->
length
())))))
return
0
;
/* String will not move */
str
->
copy
(
geom
->
get_class_info
()
->
m_name
.
str
,
...
...
@@ -164,8 +160,7 @@ String *Item_func_envelope::val_str(String *str)
if
((
null_value
=
args
[
0
]
->
null_value
||
!
(
geom
=
Geometry
::
create_from_wkb
(
&
buffer
,
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
))))
!
(
geom
=
Geometry
::
construct
(
&
buffer
,
swkb
->
ptr
(),
swkb
->
length
()))))
return
0
;
srid
=
uint4korr
(
swkb
->
ptr
());
...
...
@@ -188,8 +183,7 @@ String *Item_func_centroid::val_str(String *str)
uint32
srid
;
if
((
null_value
=
args
[
0
]
->
null_value
||
!
(
geom
=
Geometry
::
create_from_wkb
(
&
buffer
,
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
))))
!
(
geom
=
Geometry
::
construct
(
&
buffer
,
swkb
->
ptr
(),
swkb
->
length
()))))
return
0
;
str
->
set_charset
(
&
my_charset_bin
);
...
...
@@ -218,8 +212,7 @@ String *Item_func_spatial_decomp::val_str(String *str)
if
((
null_value
=
(
args
[
0
]
->
null_value
||
!
(
geom
=
Geometry
::
create_from_wkb
(
&
buffer
,
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
)))))
!
(
geom
=
Geometry
::
construct
(
&
buffer
,
swkb
->
ptr
(),
swkb
->
length
())))))
return
0
;
srid
=
uint4korr
(
swkb
->
ptr
());
...
...
@@ -267,8 +260,7 @@ String *Item_func_spatial_decomp_n::val_str(String *str)
if
((
null_value
=
(
args
[
0
]
->
null_value
||
args
[
1
]
->
null_value
||
!
(
geom
=
Geometry
::
create_from_wkb
(
&
buffer
,
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
)))))
!
(
geom
=
Geometry
::
construct
(
&
buffer
,
swkb
->
ptr
(),
swkb
->
length
())))))
return
0
;
str
->
set_charset
(
&
my_charset_bin
);
...
...
@@ -475,10 +467,8 @@ longlong Item_func_spatial_rel::val_int()
if
((
null_value
=
(
args
[
0
]
->
null_value
||
args
[
1
]
->
null_value
||
!
(
g1
=
Geometry
::
create_from_wkb
(
&
buffer1
,
res1
->
ptr
()
+
SRID_SIZE
,
res1
->
length
()
-
SRID_SIZE
))
||
!
(
g2
=
Geometry
::
create_from_wkb
(
&
buffer2
,
res2
->
ptr
()
+
SRID_SIZE
,
res2
->
length
()
-
SRID_SIZE
))
||
!
(
g1
=
Geometry
::
construct
(
&
buffer1
,
res1
->
ptr
(),
res1
->
length
()))
||
!
(
g2
=
Geometry
::
construct
(
&
buffer2
,
res2
->
ptr
(),
res2
->
length
()))
||
g1
->
get_mbr
(
&
mbr1
,
&
dummy
)
||
g2
->
get_mbr
(
&
mbr2
,
&
dummy
))))
return
0
;
...
...
@@ -543,8 +533,7 @@ longlong Item_func_isclosed::val_int()
null_value
=
(
!
swkb
||
args
[
0
]
->
null_value
||
!
(
geom
=
Geometry
::
create_from_wkb
(
&
buffer
,
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
))
||
Geometry
::
construct
(
&
buffer
,
swkb
->
ptr
(),
swkb
->
length
()))
||
geom
->
is_closed
(
&
isclosed
));
return
(
longlong
)
isclosed
;
...
...
@@ -566,9 +555,7 @@ longlong Item_func_dimension::val_int()
null_value
=
(
!
swkb
||
args
[
0
]
->
null_value
||
!
(
geom
=
Geometry
::
create_from_wkb
(
&
buffer
,
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
))
||
!
(
geom
=
Geometry
::
construct
(
&
buffer
,
swkb
->
ptr
(),
swkb
->
length
()))
||
geom
->
dimension
(
&
dim
,
&
dummy
));
return
(
longlong
)
dim
;
}
...
...
@@ -583,9 +570,8 @@ longlong Item_func_numinteriorring::val_int()
Geometry
*
geom
;
null_value
=
(
!
swkb
||
!
(
geom
=
Geometry
::
create_from_wkb
(
&
buffer
,
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
))
||
!
(
geom
=
Geometry
::
construct
(
&
buffer
,
swkb
->
ptr
(),
swkb
->
length
()))
||
geom
->
num_interior_ring
(
&
num
));
return
(
longlong
)
num
;
}
...
...
@@ -600,9 +586,8 @@ longlong Item_func_numgeometries::val_int()
Geometry
*
geom
;
null_value
=
(
!
swkb
||
!
(
geom
=
Geometry
::
create_from_wkb
(
&
buffer
,
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
))
||
!
(
geom
=
Geometry
::
construct
(
&
buffer
,
swkb
->
ptr
(),
swkb
->
length
()))
||
geom
->
num_geometries
(
&
num
));
return
(
longlong
)
num
;
}
...
...
@@ -618,9 +603,8 @@ longlong Item_func_numpoints::val_int()
null_value
=
(
!
swkb
||
args
[
0
]
->
null_value
||
!
(
geom
=
Geometry
::
create_from_wkb
(
&
buffer
,
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
))
||
!
(
geom
=
Geometry
::
construct
(
&
buffer
,
swkb
->
ptr
(),
swkb
->
length
()))
||
geom
->
num_points
(
&
num
));
return
(
longlong
)
num
;
}
...
...
@@ -635,9 +619,8 @@ double Item_func_x::val()
Geometry
*
geom
;
null_value
=
(
!
swkb
||
!
(
geom
=
Geometry
::
create_from_wkb
(
&
buffer
,
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
))
||
!
(
geom
=
Geometry
::
construct
(
&
buffer
,
swkb
->
ptr
(),
swkb
->
length
()))
||
geom
->
get_x
(
&
res
));
return
res
;
}
...
...
@@ -652,9 +635,8 @@ double Item_func_y::val()
Geometry
*
geom
;
null_value
=
(
!
swkb
||
!
(
geom
=
Geometry
::
create_from_wkb
(
&
buffer
,
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
))
||
!
(
geom
=
Geometry
::
construct
(
&
buffer
,
swkb
->
ptr
(),
swkb
->
length
()))
||
geom
->
get_y
(
&
res
));
return
res
;
}
...
...
@@ -670,9 +652,8 @@ double Item_func_area::val()
const
char
*
dummy
;
null_value
=
(
!
swkb
||
!
(
geom
=
Geometry
::
create_from_wkb
(
&
buffer
,
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
))
||
!
(
geom
=
Geometry
::
construct
(
&
buffer
,
swkb
->
ptr
(),
swkb
->
length
()))
||
geom
->
area
(
&
res
,
&
dummy
));
return
res
;
}
...
...
@@ -686,9 +667,8 @@ double Item_func_glength::val()
Geometry
*
geom
;
null_value
=
(
!
swkb
||
!
(
geom
=
Geometry
::
create_from_wkb
(
&
buffer
,
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
))
||
!
(
geom
=
Geometry
::
construct
(
&
buffer
,
swkb
->
ptr
(),
swkb
->
length
()))
||
geom
->
length
(
&
res
));
return
res
;
}
...
...
@@ -700,9 +680,8 @@ longlong Item_func_srid::val_int()
Geometry_buffer
buffer
;
null_value
=
(
!
swkb
||
!
Geometry
::
create_from_wkb
(
&
buffer
,
swkb
->
ptr
()
+
SRID_SIZE
,
swkb
->
length
()
-
SRID_SIZE
));
!
Geometry
::
construct
(
&
buffer
,
swkb
->
ptr
(),
swkb
->
length
()));
if
(
null_value
)
return
0
;
...
...
sql/spatial.cc
View file @
5150bd8f
This diff is collapsed.
Click to expand it.
sql/spatial.h
View file @
5150bd8f
...
...
@@ -202,6 +202,10 @@ 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
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
;
...
...
@@ -231,11 +235,13 @@ public:
return
my_reinterpret_cast
(
Geometry
*
)(
buffer
);
}
static
Geometry
*
c
reate_from_wkb
(
Geometry_buffer
*
buffer
,
static
Geometry
*
c
onstruct
(
Geometry_buffer
*
buffer
,
const
char
*
data
,
uint32
data_len
);
static
Geometry
*
create_from_wkt
(
Geometry_buffer
*
buffer
,
Gis_read_stream
*
trs
,
String
*
wkt
,
bool
init_stream
=
1
);
static
int
Geometry
::
create_from_wkb
(
Geometry_buffer
*
buffer
,
const
char
*
wkb
,
uint32
len
,
String
*
res
);
int
as_wkt
(
String
*
wkt
,
const
char
**
end
)
{
uint32
len
=
get_class_info
()
->
m_name
.
length
;
...
...
@@ -249,7 +255,7 @@ public:
return
0
;
}
inline
void
init_from_wkb
(
const
char
*
data
,
uint32
data_len
)
inline
void
set_data_ptr
(
const
char
*
data
,
uint32
data_len
)
{
m_data
=
data
;
m_data_end
=
data
+
data_len
;
...
...
@@ -293,6 +299,7 @@ class Gis_point: public Geometry
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
);
bool
get_data_as_wkt
(
String
*
txt
,
const
char
**
end
)
const
;
bool
get_mbr
(
MBR
*
mbr
,
const
char
**
end
)
const
;
...
...
@@ -339,6 +346,7 @@ class Gis_line_string: public Geometry
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
);
bool
get_data_as_wkt
(
String
*
txt
,
const
char
**
end
)
const
;
bool
get_mbr
(
MBR
*
mbr
,
const
char
**
end
)
const
;
int
length
(
double
*
len
)
const
;
...
...
@@ -364,6 +372,7 @@ class Gis_polygon: public Geometry
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
);
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
;
...
...
@@ -389,6 +398,7 @@ class Gis_multi_point: public Geometry
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
);
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
;
...
...
@@ -410,6 +420,7 @@ class Gis_multi_line_string: public Geometry
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
);
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
;
...
...
@@ -433,6 +444,7 @@ class Gis_multi_polygon: public Geometry
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
);
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
;
...
...
@@ -456,6 +468,7 @@ class Gis_geometry_collection: public Geometry
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
);
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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment