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
9d51588e
Commit
9d51588e
authored
Jun 14, 2011
by
Alexey Botchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Precision spatial function tests added.
parent
e88c96d2
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
424 additions
and
0 deletions
+424
-0
mysql-test/r/gis-precise.result
mysql-test/r/gis-precise.result
+204
-0
mysql-test/r/gis-rt-precise.result
mysql-test/r/gis-rt-precise.result
+49
-0
mysql-test/t/gis-precise.test
mysql-test/t/gis-precise.test
+107
-0
mysql-test/t/gis-rt-precise.test
mysql-test/t/gis-rt-precise.test
+64
-0
No files found.
mysql-test/r/gis-precise.result
0 → 100644
View file @
9d51588e
This diff is collapsed.
Click to expand it.
mysql-test/r/gis-rt-precise.result
0 → 100644
View file @
9d51588e
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
g GEOMETRY NOT NULL,
SPATIAL KEY(g)
) ENGINE=MyISAM;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`fid` int(11) NOT NULL AUTO_INCREMENT,
`g` geometry NOT NULL,
PRIMARY KEY (`fid`),
SPATIAL KEY `g` (`g`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT count(*) FROM t1;
count(*)
150
EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE ST_Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 140))'));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range g g 34 NULL 8 Using where
SELECT fid, AsText(g) FROM t1 WHERE ST_Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
fid AsText(g)
11 LINESTRING(140 140,160 160)
DROP TABLE t1;
CREATE TABLE t1 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
g GEOMETRY NOT NULL
) ENGINE=MyISAM;
ALTER TABLE t1 ADD SPATIAL KEY(g);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`fid` int(11) NOT NULL AUTO_INCREMENT,
`g` geometry NOT NULL,
PRIMARY KEY (`fid`),
SPATIAL KEY `g` (`g`)
) ENGINE=MyISAM AUTO_INCREMENT=101 DEFAULT CHARSET=latin1
SELECT count(*) FROM t1;
count(*)
100
EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE ST_Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 40))'));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range g g 34 NULL 1 Using where
SELECT fid, AsText(g) FROM t1 WHERE ST_Within(g,
GeomFromText('Polygon((40 40,60 40,60 60,40 40))'));
fid AsText(g)
DROP TABLE t1;
End of 5.5 tests.
mysql-test/t/gis-precise.test
0 → 100644
View file @
9d51588e
--
source
include
/
have_geometry
.
inc
#
# Spatial objects
#
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
;
--
enable_warnings
select
1
,
ST_Intersects
(
GeomFromText
(
'POLYGON((0 0,20 0,20 20,0 20,0 0))'
),
GeomFromText
(
'POLYGON((10 10,30 10,30 30,10 30,10 10))'
));
select
0
,
ST_Intersects
(
GeomFromText
(
'POLYGON((0 0,20 10,10 30, 0 0))'
),
GeomFromText
(
'POLYGON((10 40, 40 50, 20 70, 10 40))'
));
select
1
,
ST_Intersects
(
GeomFromText
(
'POLYGON((0 0,20 10,10 30, 0 0))'
),
GeomFromText
(
'POINT(10 10)'
));
select
1
,
ST_Intersects
(
GeomFromText
(
'POLYGON((0 0,20 10,10 30, 0 0))'
),
GeomFromText
(
'POLYGON((10 10,30 20,20 40, 10 10))'
));
select
0
,
ST_Within
(
GeomFromText
(
'POLYGON((0 0,20 10,10 30, 0 0))'
),
GeomFromText
(
'POLYGON((10 10,30 20,20 40, 10 10))'
));
select
1
,
ST_Within
(
GeomFromText
(
'POLYGON((1 1,20 10,10 30, 1 1))'
),
GeomFromText
(
'POLYGON((0 0,30 5,10 40, 0 0))'
));
create
table
t1
(
g
point
);
insert
into
t1
values
(
GeomFromText
(
'POINT(2 2)'
)),
(
GeomFromText
(
'POINT(2 4)'
)),
(
GeomFromText
(
'POINT(2 6)'
)),
(
GeomFromText
(
'POINT(2 8)'
)),
(
GeomFromText
(
'POINT(4 2)'
)),
(
GeomFromText
(
'POINT(4 4)'
)),
(
GeomFromText
(
'POINT(4 6)'
)),
(
GeomFromText
(
'POINT(4 8)'
)),
(
GeomFromText
(
'POINT(6 2)'
)),
(
GeomFromText
(
'POINT(6 4)'
)),
(
GeomFromText
(
'POINT(6 6)'
)),
(
GeomFromText
(
'POINT(6 8)'
)),
(
GeomFromText
(
'POINT(8 2)'
)),
(
GeomFromText
(
'POINT(8 4)'
)),
(
GeomFromText
(
'POINT(8 6)'
)),
(
GeomFromText
(
'POINT(8 8)'
));
select
astext
(
g
)
from
t1
where
ST_Within
(
g
,
GeomFromText
(
'POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'
));
select
'Contains'
;
select
astext
(
g
)
from
t1
where
ST_Contains
(
GeomFromText
(
'POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'
),
g
);
select
'Intersects'
;
select
astext
(
g
)
from
t1
where
ST_Intersects
(
GeomFromText
(
'POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'
),
g
);
select
'Contains'
;
select
astext
(
g
)
from
t1
where
ST_Contains
(
GeomFromText
(
'POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'
),
g
);
select
'Contains2'
;
select
astext
(
g
)
from
t1
where
ST_Contains
(
GeomFromText
(
'POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1), (5.01 3.01, 6 5, 9 5, 8 3, 5.01 3.01))'
),
g
);
DROP
TABLE
t1
;
select
0
,
ST_Within
(
GeomFromText
(
'LINESTRING(15 15, 50 50, 60 60)'
),
GeomFromText
(
'POLYGON((10 10,30 20,20 40, 10 10))'
));
select
1
,
ST_Within
(
GeomFromText
(
'LINESTRING(15 15, 16 16)'
),
GeomFromText
(
'POLYGON((10 10,30 20,20 40, 10 10))'
));
select
1
,
ST_Intersects
(
GeomFromText
(
'LINESTRING(15 15, 50 50)'
),
GeomFromText
(
'LINESTRING(50 15, 15 50)'
));
select
0
,
ST_Intersects
(
GeomFromText
(
'LINESTRING(15 15, 50 50)'
),
GeomFromText
(
'LINESTRING(16 16, 51 51)'
));
select
1
,
ST_Intersects
(
GeomFromText
(
'POLYGON((0 0, 50 45, 40 50, 0 0))'
),
GeomFromText
(
'POLYGON((50 5, 55 10, 0 45, 50 5))'
));
select
astext
(
ST_Union
(
geometryfromtext
(
'point(1 1)'
),
geometryfromtext
(
'polygon((0 0, 2 0, 1 2, 0 0))'
)));
select
astext
(
ST_Intersection
(
geometryfromtext
(
'point(1 1)'
),
geometryfromtext
(
'polygon((0 0, 2 0, 1 2, 0 0))'
)));
select
ST_Intersects
(
GeomFromText
(
'POLYGON((0 0, 50 45, 40 50, 0 0))'
),
GeomFromText
(
'POLYGON((50 5, 55 10, 0 45, 50 5))'
));
select
ST_contains
(
GeomFromText
(
'MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)), ((6 6, 6 11, 11 11, 11 6, 6 6)))'
),
GeomFromText
(
'POINT(5 10)'
));
select
ST_Disjoint
(
GeomFromText
(
'POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'
),
GeomFromText
(
'POLYGON((10 10, 10 15, 15 15, 15 10, 10 10))'
));
select
ST_Disjoint
(
GeomFromText
(
'POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'
),
GeomFromText
(
'POLYGON((10 10, 10 4, 4 4, 4 10, 10 10))'
));
select
ST_Overlaps
(
GeomFromText
(
'POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'
),
GeomFromText
(
'POLYGON((10 10, 10 4, 4 4, 4 10, 10 10))'
));
select
ST_Overlaps
(
GeomFromText
(
'POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'
),
GeomFromText
(
'POLYGON((1 1, 1 4, 4 4, 4 1, 1 1))'
));
# Distance tests
select
ST_DISTANCE
(
geomfromtext
(
'polygon((0 0, 1 2, 2 1, 0 0))'
),
geomfromtext
(
'polygon((2 2, 3 4, 4 3, 2 2))'
));
select
ST_DISTANCE
(
geomfromtext
(
'polygon((0 0, 1 2, 2 1, 0 0))'
),
geomfromtext
(
'linestring(0 1, 1 0)'
));
select
ST_DISTANCE
(
geomfromtext
(
'polygon((0 0, 3 6, 6 3, 0 0))'
),
geomfromtext
(
'polygon((2 2, 3 4, 4 3, 2 2))'
));
select
ST_DISTANCE
(
geomfromtext
(
'polygon((0 0, 3 6, 6 3, 0 0),(2 2, 3 4, 4 3, 2 2))'
),
geomfromtext
(
'point(3 3)'
));
select
ST_DISTANCE
(
geomfromtext
(
'linestring(0 0, 3 6, 6 3, 0 0)'
),
geomfromtext
(
'polygon((2 2, 3 4, 4 3, 2 2))'
));
# Operations tests
select
astext
(
ST_Intersection
(
GeomFromText
(
'POLYGON((0 0, 50 45, 40 50, 0 0))'
),
GeomFromText
(
'POLYGON((50 5, 55 10, 0 45, 50 5))'
)));
select
astext
(
ST_Intersection
(
GeomFromText
(
'LINESTRING(0 0, 50 45, 40 50, 0 0)'
),
GeomFromText
(
'LINESTRING(50 5, 55 10, 0 45, 50 5)'
)));
select
astext
(
ST_Intersection
(
GeomFromText
(
'LINESTRING(0 0, 50 45, 40 50)'
),
GeomFromText
(
'LINESTRING(50 5, 55 10, 0 45)'
)));
select
astext
(
ST_Intersection
(
GeomFromText
(
'POLYGON((0 0, 50 45, 40 50, 0 0))'
),
GeomFromText
(
'POINT(20 20)'
)));
select
astext
(
ST_Intersection
(
GeomFromText
(
'POLYGON((0 0, 50 45, 40 50, 0 0))'
),
GeomFromText
(
'LINESTRING(-10 -10, 200 200)'
)));
select
astext
(
ST_Intersection
(
GeomFromText
(
'POLYGON((0 0, 50 45, 40 50, 0 0))'
),
GeomFromText
(
'LINESTRING(-10 -10, 200 200, 199 201, -11 -9)'
)));
select
astext
(
ST_UNION
(
GeomFromText
(
'POLYGON((0 0, 50 45, 40 50, 0 0))'
),
GeomFromText
(
'LINESTRING(-10 -10, 200 200, 199 201, -11 -9)'
)));
select
astext
(
ST_intersection
(
geomfromtext
(
'polygon((0 0, 1 0, 0 1, 0 0))'
),
geomfromtext
(
'polygon((0 0, 1 1, 0 2, 0 0))'
)));
select
astext
(
ST_symdifference
(
geomfromtext
(
'polygon((0 0, 1 0, 0 1, 0 0))'
),
geomfromtext
(
'polygon((0 0, 1 1, 0 2, 0 0))'
)));
select
astext
(
ST_UNION
(
GeomFromText
(
'POLYGON((0 0, 50 45, 40 50, 0 0))'
),
GeomFromText
(
'LINESTRING(-10 -10, 200 200, 199 201, -11 -9)'
)));
# Buffer() tests
select
astext
(
ST_buffer
(
geometryfromtext
(
'point(1 1)'
),
1
));
create
table
t1
(
geom
geometrycollection
);
insert
into
t1
values
(
geomfromtext
(
'POLYGON((0 0, 10 10, 0 8, 0 0))'
));
insert
into
t1
values
(
geomfromtext
(
'POLYGON((1 1, 10 10, 0 8, 1 1))'
));
select
astext
(
geom
),
area
(
geom
),
area
(
ST_buffer
(
geom
,
2
))
from
t1
;
select
astext
(
ST_buffer
(
geom
,
2
))
from
t1
;
set
@
geom
=
geomfromtext
(
'LINESTRING(2 1, 4 2, 2 3, 2 5)'
);
set
@
buff
=
ST_buffer
(
@
geom
,
1
);
select
astext
(
@
buff
);
# cleanup
DROP
TABLE
t1
;
#Touches tests
select
st_touches
(
geomfromtext
(
'point(0 0)'
),
geomfromtext
(
'point(1 1)'
));
select
st_touches
(
geomfromtext
(
'point(1 1)'
),
geomfromtext
(
'point(1 1)'
));
select
st_touches
(
geomfromtext
(
'polygon((0 0, 2 2, 0 4, 0 0))'
),
geomfromtext
(
'point(1 1)'
));
select
st_touches
(
geomfromtext
(
'polygon((0 0, 2 2, 0 4, 0 0))'
),
geomfromtext
(
'point(1 0)'
));
select
st_touches
(
geomfromtext
(
'polygon((0 0, 2 2, 0 4, 0 0))'
),
geomfromtext
(
'point(1 2)'
));
select
st_touches
(
geomfromtext
(
'polygon((0 0, 2 2, 0 4, 0 0))'
),
geomfromtext
(
'polygon((1 1.2, 1 0, 2 0, 1 1.2))'
));
select
st_touches
(
geomfromtext
(
'polygon((0 0, 2 2, 0 4, 0 0))'
),
geomfromtext
(
'polygon((1 1, 1 0, 2 0, 1 1))'
));
#Equals test
SELECT
ST_Equals
(
PolyFromText
(
'POLYGON((67 13, 67 18, 67 18, 59 18, 59 13, 67 13) )'
),
PolyFromText
(
'POLYGON((67 13, 67 18, 59 19, 59 13, 59 13, 67 13) )'
))
as
result
;
SELECT
ST_Equals
(
PolyFromText
(
'POLYGON((67 13, 67 18, 67 18, 59 18, 59 13, 67 13) )'
),
PolyFromText
(
'POLYGON((67 13, 67 18, 59 18, 59 13, 59 13, 67 13) )'
))
as
result
;
SELECT
ST_Equals
(
PointFromText
(
'POINT (12 13)'
),
PointFromText
(
'POINT (12 13)'
))
as
result
;
mysql-test/t/gis-rt-precise.test
0 → 100644
View file @
9d51588e
--
source
include
/
have_geometry
.
inc
#
# test of rtree (using with spatial data)
#
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
;
--
enable_warnings
CREATE
TABLE
t1
(
fid
INT
NOT
NULL
AUTO_INCREMENT
PRIMARY
KEY
,
g
GEOMETRY
NOT
NULL
,
SPATIAL
KEY
(
g
)
)
ENGINE
=
MyISAM
;
SHOW
CREATE
TABLE
t1
;
--
disable_query_log
let
$
1
=
150
;
let
$
2
=
150
;
while
(
$
1
)
{
eval
INSERT
INTO
t1
(
g
)
VALUES
(
GeomFromText
(
'LineString($1 $1, $2 $2)'
));
dec
$
1
;
inc
$
2
;
}
--
enable_query_log
SELECT
count
(
*
)
FROM
t1
;
EXPLAIN
SELECT
fid
,
AsText
(
g
)
FROM
t1
WHERE
ST_Within
(
g
,
GeomFromText
(
'Polygon((140 140,160 140,160 160,140 140))'
));
SELECT
fid
,
AsText
(
g
)
FROM
t1
WHERE
ST_Within
(
g
,
GeomFromText
(
'Polygon((140 140,160 140,160 160,140 160,140 140))'
));
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
fid
INT
NOT
NULL
AUTO_INCREMENT
PRIMARY
KEY
,
g
GEOMETRY
NOT
NULL
)
ENGINE
=
MyISAM
;
--
disable_query_log
let
$
1
=
10
;
while
(
$
1
)
{
let
$
2
=
10
;
while
(
$
2
)
{
eval
INSERT
INTO
t1
(
g
)
VALUES
(
LineString
(
Point
(
$
1
*
10
-
9
,
$
2
*
10
-
9
),
Point
(
$
1
*
10
,
$
2
*
10
)));
dec
$
2
;
}
dec
$
1
;
}
--
enable_query_log
ALTER
TABLE
t1
ADD
SPATIAL
KEY
(
g
);
SHOW
CREATE
TABLE
t1
;
SELECT
count
(
*
)
FROM
t1
;
EXPLAIN
SELECT
fid
,
AsText
(
g
)
FROM
t1
WHERE
ST_Within
(
g
,
GeomFromText
(
'Polygon((40 40,60 40,60 60,40 40))'
));
SELECT
fid
,
AsText
(
g
)
FROM
t1
WHERE
ST_Within
(
g
,
GeomFromText
(
'Polygon((40 40,60 40,60 60,40 40))'
));
DROP
TABLE
t1
;
--
echo
End
of
5.5
tests
.
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