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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
d9b08701
Commit
d9b08701
authored
Mar 01, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test case for spatial objects.
parent
77f8757a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
418 additions
and
0 deletions
+418
-0
mysql-test/r/gis.result
mysql-test/r/gis.result
+310
-0
mysql-test/t/gis.test
mysql-test/t/gis.test
+108
-0
No files found.
mysql-test/r/gis.result
0 → 100644
View file @
d9b08701
DROP TABLE IF EXISTS pt, ls, p, mpt, mls, mp, gc, geo;
CREATE TABLE pt (fid INTEGER NOT NULL PRIMARY KEY, g POINT);
CREATE TABLE ls (fid INTEGER NOT NULL PRIMARY KEY, g LINESTRING);
CREATE TABLE p (fid INTEGER NOT NULL PRIMARY KEY, g POLYGON);
CREATE TABLE mpt (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOINT);
CREATE TABLE mls (fid INTEGER NOT NULL PRIMARY KEY, g MULTILINESTRING);
CREATE TABLE mp (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOLYGON);
CREATE TABLE gc (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRYCOLLECTION);
CREATE TABLE geo (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY);
INSERT INTO pt VALUES
(101, PointFromText('POINT(10 10)')),
(102, PointFromText('POINT(20 10)')),
(103, PointFromText('POINT(20 20)')),
(104, PointFromText('POINT(10 20)'));
INSERT INTO ls VALUES
(105, LineFromText('LINESTRING(0 0,0 10,10 0)')),
(106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
(107, LineString(Point(10, 10), Point(40, 10)));
INSERT INTO p VALUES
(108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
(109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
(110, Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))));
INSERT INTO mpt VALUES
(111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
(112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
(113, MultiPoint(Point(3, 6), Point(4, 10)));
INSERT INTO mls VALUES
(114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
(115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
(116, MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7))));
INSERT INTO mp VALUES
(117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
(118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
(119, MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))));
INSERT INTO gc VALUES
(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
(121, GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))));
INSERT into geo SELECT * FROM pt;
INSERT into geo SELECT * FROM ls;
INSERT into geo SELECT * FROM p;
INSERT into geo SELECT * FROM mpt;
INSERT into geo SELECT * FROM mls;
INSERT into geo SELECT * FROM mp;
INSERT into geo SELECT * FROM gc;
SELECT fid, AsText(g) FROM pt;
fid AsText(g)
101 POINT(10 10)
102 POINT(20 10)
103 POINT(20 20)
104 POINT(10 20)
SELECT fid, AsText(g) FROM ls;
fid AsText(g)
105 LINESTRING(0 0,0 10,10 0)
106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
107 LINESTRING(10 10,40 10)
SELECT fid, AsText(g) FROM p;
fid AsText(g)
108 POLYGON((10 10,20 10,20 20,10 20,10 10))
109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
110 POLYGON((0 0,30 0,30 30,0 0))
SELECT fid, AsText(g) FROM mpt;
fid AsText(g)
111 MULTIPOINT(0 0,10 10,10 20,20 20)
112 MULTIPOINT(1 1,11 11,11 21,21 21)
113 MULTIPOINT(3 6,4 10)
SELECT fid, AsText(g) FROM mls;
fid AsText(g)
114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
115 MULTILINESTRING((10 48,10 21,10 0))
116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
SELECT fid, AsText(g) FROM mp;
fid AsText(g)
117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
SELECT fid, AsText(g) FROM gc;
fid AsText(g)
120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
SELECT fid, AsText(g) FROM geo;
fid AsText(g)
101 POINT(10 10)
102 POINT(20 10)
103 POINT(20 20)
104 POINT(10 20)
105 LINESTRING(0 0,0 10,10 0)
106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
107 LINESTRING(10 10,40 10)
108 POLYGON((10 10,20 10,20 20,10 20,10 10))
109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
110 POLYGON((0 0,30 0,30 30,0 0))
111 MULTIPOINT(0 0,10 10,10 20,20 20)
112 MULTIPOINT(1 1,11 11,11 21,21 21)
113 MULTIPOINT(3 6,4 10)
114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
115 MULTILINESTRING((10 48,10 21,10 0))
116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
SELECT fid, Dimension(g) FROM geo;
fid Dimension(g)
101 0
102 0
103 0
104 0
105 1
106 1
107 1
108 2
109 2
110 2
111 0
112 0
113 0
114 1
115 1
116 1
117 2
118 2
119 2
120 1
121 1
SELECT fid, GeometryType(g) FROM geo;
fid GeometryType(g)
101 POINT
102 POINT
103 POINT
104 POINT
105 LINESTRING
106 LINESTRING
107 LINESTRING
108 POLYGON
109 POLYGON
110 POLYGON
111 MULTIPOINT
112 MULTIPOINT
113 MULTIPOINT
114 MULTILINESTRING
115 MULTILINESTRING
116 MULTILINESTRING
117 MULTIPOLYGON
118 MULTIPOLYGON
119 MULTIPOLYGON
120 GEOMETRYCOLLECTION
121 GEOMETRYCOLLECTION
SELECT fid, IsEmpty(g) FROM geo;
fid IsEmpty(g)
101 0
102 0
103 0
104 0
105 0
106 0
107 0
108 0
109 0
110 0
111 0
112 0
113 0
114 0
115 0
116 0
117 0
118 0
119 0
120 0
121 0
SELECT fid, AsText(Envelope(g)) FROM geo;
fid AsText(Envelope(g))
101 POLYGON((10 10,10 10,10 10,10 10,10 10))
102 POLYGON((20 10,20 10,20 10,20 10,20 10))
103 POLYGON((20 20,20 20,20 20,20 20,20 20))
104 POLYGON((10 20,10 20,10 20,10 20,10 20))
105 POLYGON((0 0,10 0,10 10,0 10,0 0))
106 POLYGON((10 10,20 10,20 20,10 20,10 10))
107 POLYGON((10 10,40 10,40 10,10 10,10 10))
108 POLYGON((10 10,20 10,20 20,10 20,10 10))
109 POLYGON((0 0,50 0,50 50,0 50,0 0))
110 POLYGON((0 0,30 0,30 30,0 30,0 0))
111 POLYGON((0 0,20 0,20 20,0 20,0 0))
112 POLYGON((1 1,21 1,21 21,1 21,1 1))
113 POLYGON((3 6,4 6,4 10,3 10,3 6))
114 POLYGON((10 0,16 0,16 48,10 48,10 0))
115 POLYGON((10 0,10 0,10 48,10 48,10 0))
116 POLYGON((1 2,21 2,21 8,1 8,1 2))
117 POLYGON((28 0,84 0,84 42,28 42,28 0))
118 POLYGON((28 0,84 0,84 42,28 42,28 0))
119 POLYGON((0 0,3 0,3 3,0 3,0 0))
120 POLYGON((0 0,10 0,10 10,0 10,0 0))
121 POLYGON((3 6,44 6,44 9,3 9,3 6))
SELECT fid, X(g) FROM pt;
fid X(g)
101 10
102 20
103 20
104 10
SELECT fid, Y(g) FROM pt;
fid Y(g)
101 10
102 10
103 20
104 20
SELECT fid, AsText(StartPoint(g)) FROM ls;
fid AsText(StartPoint(g))
105 POINT(0 0)
106 POINT(10 10)
107 POINT(10 10)
SELECT fid, AsText(EndPoint(g)) FROM ls;
fid AsText(EndPoint(g))
105 POINT(10 0)
106 POINT(10 10)
107 POINT(40 10)
SELECT fid, GLength(g) FROM ls;
fid GLength(g)
105 24.142135623731
106 40
107 30
SELECT fid, NumPoints(g) FROM ls;
fid NumPoints(g)
105 3
106 5
107 2
SELECT fid, AsText(PointN(g, 2)) FROM ls;
fid AsText(PointN(g, 2))
105 POINT(0 10)
106 POINT(20 10)
107 POINT(40 10)
SELECT fid, IsClosed(g) FROM ls;
fid IsClosed(g)
105 0
106 1
107 0
SELECT fid, AsText(Centroid(g)) FROM p;
fid AsText(Centroid(g))
108 POINT(15 15)
109 POINT(25.416666666667 25.416666666667)
110 POINT(20 10)
SELECT fid, Area(g) FROM p;
fid Area(g)
108 100
109 2400
110 450
SELECT fid, AsText(ExteriorRing(g)) FROM p;
fid AsText(ExteriorRing(g))
108 LINESTRING(10 10,20 10,20 20,10 20,10 10)
109 LINESTRING(0 0,50 0,50 50,0 50,0 0)
110 LINESTRING(0 0,30 0,30 30,0 0)
SELECT fid, NumInteriorRings(g) FROM p;
fid NumInteriorRings(g)
108 0
109 1
110 0
SELECT fid, AsText(InteriorRingN(g, 1)) FROM p;
fid AsText(InteriorRingN(g, 1))
108 NULL
109 LINESTRING(10 10,20 10,20 20,10 20,10 10)
110 NULL
SELECT fid, NumGeometries(g) from mpt;
fid NumGeometries(g)
111 4
112 4
113 2
SELECT fid, NumGeometries(g) from mls;
fid NumGeometries(g)
114 2
115 1
116 2
SELECT fid, NumGeometries(g) from mp;
fid NumGeometries(g)
117 2
118 2
119 1
SELECT fid, NumGeometries(g) from gc;
fid NumGeometries(g)
120 2
121 2
SELECT fid, AsText(GeometryN(g, 2)) from mpt;
fid AsText(GeometryN(g, 2))
111 POINT(10 10)
112 POINT(11 11)
113 POINT(4 10)
SELECT fid, AsText(GeometryN(g, 2)) from mls;
fid AsText(GeometryN(g, 2))
114 LINESTRING(16 0,16 23,16 48)
115 NULL
116 LINESTRING(2 5,5 8,21 7)
SELECT fid, AsText(GeometryN(g, 2)) from mp;
fid AsText(GeometryN(g, 2))
117 POLYGON((59 18,67 18,67 13,59 13,59 18))
118 POLYGON((59 18,67 18,67 13,59 13,59 18))
119 NULL
SELECT fid, AsText(GeometryN(g, 2)) from gc;
fid AsText(GeometryN(g, 2))
120 LINESTRING(0 0,10 10)
121 LINESTRING(3 6,7 9)
SELECT g1.fid as first, g2.fid as second,
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
FROM gc g1, gc g2 ORDER BY first, second;
first second w c o e d t i r
120 120 1 1 0 1 0 0 1 0
120 121 0 0 0 0 0 0 1 0
121 120 0 0 1 0 0 0 1 0
121 121 1 1 0 1 0 0 1 0
DROP TABLE pt, ls, p, mpt, mls, mp, gc, geo;
mysql-test/t/gis.test
0 → 100644
View file @
d9b08701
#
# Spatial objects
#
--
disable_warnings
DROP
TABLE
IF
EXISTS
pt
,
ls
,
p
,
mpt
,
mls
,
mp
,
gc
,
geo
;
--
enable_warnings
CREATE
TABLE
pt
(
fid
INTEGER
NOT
NULL
PRIMARY
KEY
,
g
POINT
);
CREATE
TABLE
ls
(
fid
INTEGER
NOT
NULL
PRIMARY
KEY
,
g
LINESTRING
);
CREATE
TABLE
p
(
fid
INTEGER
NOT
NULL
PRIMARY
KEY
,
g
POLYGON
);
CREATE
TABLE
mpt
(
fid
INTEGER
NOT
NULL
PRIMARY
KEY
,
g
MULTIPOINT
);
CREATE
TABLE
mls
(
fid
INTEGER
NOT
NULL
PRIMARY
KEY
,
g
MULTILINESTRING
);
CREATE
TABLE
mp
(
fid
INTEGER
NOT
NULL
PRIMARY
KEY
,
g
MULTIPOLYGON
);
CREATE
TABLE
gc
(
fid
INTEGER
NOT
NULL
PRIMARY
KEY
,
g
GEOMETRYCOLLECTION
);
CREATE
TABLE
geo
(
fid
INTEGER
NOT
NULL
PRIMARY
KEY
,
g
GEOMETRY
);
INSERT
INTO
pt
VALUES
(
101
,
PointFromText
(
'POINT(10 10)'
)),
(
102
,
PointFromText
(
'POINT(20 10)'
)),
(
103
,
PointFromText
(
'POINT(20 20)'
)),
(
104
,
PointFromText
(
'POINT(10 20)'
));
INSERT
INTO
ls
VALUES
(
105
,
LineFromText
(
'LINESTRING(0 0,0 10,10 0)'
)),
(
106
,
LineStringFromText
(
'LINESTRING(10 10,20 10,20 20,10 20,10 10)'
)),
(
107
,
LineString
(
Point
(
10
,
10
),
Point
(
40
,
10
)));
INSERT
INTO
p
VALUES
(
108
,
PolygonFromText
(
'POLYGON((10 10,20 10,20 20,10 20,10 10))'
)),
(
109
,
PolyFromText
(
'POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'
)),
(
110
,
Polygon
(
LineString
(
Point
(
0
,
0
),
Point
(
30
,
0
),
Point
(
30
,
30
),
Point
(
0
,
0
))));
INSERT
INTO
mpt
VALUES
(
111
,
MultiPointFromText
(
'MULTIPOINT(0 0,10 10,10 20,20 20)'
)),
(
112
,
MPointFromText
(
'MULTIPOINT(1 1,11 11,11 21,21 21)'
)),
(
113
,
MultiPoint
(
Point
(
3
,
6
),
Point
(
4
,
10
)));
INSERT
INTO
mls
VALUES
(
114
,
MultiLineStringFromText
(
'MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))'
)),
(
115
,
MLineFromText
(
'MULTILINESTRING((10 48,10 21,10 0))'
)),
(
116
,
MultiLineString
(
LineString
(
Point
(
1
,
2
),
Point
(
3
,
5
)),
LineString
(
Point
(
2
,
5
),
Point
(
5
,
8
),
Point
(
21
,
7
))));
INSERT
INTO
mp
VALUES
(
117
,
MultiPolygonFromText
(
'MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))'
)),
(
118
,
MPolyFromText
(
'MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))'
)),
(
119
,
MultiPolygon
(
Polygon
(
LineString
(
Point
(
0
,
3
),
Point
(
3
,
3
),
Point
(
3
,
0
),
Point
(
0
,
3
)))));
INSERT
INTO
gc
VALUES
(
120
,
GeomCollFromText
(
'GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))'
)),
(
121
,
GeometryCollection
(
Point
(
44
,
6
),
LineString
(
Point
(
3
,
6
),
Point
(
7
,
9
))));
INSERT
into
geo
SELECT
*
FROM
pt
;
INSERT
into
geo
SELECT
*
FROM
ls
;
INSERT
into
geo
SELECT
*
FROM
p
;
INSERT
into
geo
SELECT
*
FROM
mpt
;
INSERT
into
geo
SELECT
*
FROM
mls
;
INSERT
into
geo
SELECT
*
FROM
mp
;
INSERT
into
geo
SELECT
*
FROM
gc
;
SELECT
fid
,
AsText
(
g
)
FROM
pt
;
SELECT
fid
,
AsText
(
g
)
FROM
ls
;
SELECT
fid
,
AsText
(
g
)
FROM
p
;
SELECT
fid
,
AsText
(
g
)
FROM
mpt
;
SELECT
fid
,
AsText
(
g
)
FROM
mls
;
SELECT
fid
,
AsText
(
g
)
FROM
mp
;
SELECT
fid
,
AsText
(
g
)
FROM
gc
;
SELECT
fid
,
AsText
(
g
)
FROM
geo
;
SELECT
fid
,
Dimension
(
g
)
FROM
geo
;
SELECT
fid
,
GeometryType
(
g
)
FROM
geo
;
SELECT
fid
,
IsEmpty
(
g
)
FROM
geo
;
SELECT
fid
,
AsText
(
Envelope
(
g
))
FROM
geo
;
SELECT
fid
,
X
(
g
)
FROM
pt
;
SELECT
fid
,
Y
(
g
)
FROM
pt
;
SELECT
fid
,
AsText
(
StartPoint
(
g
))
FROM
ls
;
SELECT
fid
,
AsText
(
EndPoint
(
g
))
FROM
ls
;
SELECT
fid
,
GLength
(
g
)
FROM
ls
;
SELECT
fid
,
NumPoints
(
g
)
FROM
ls
;
SELECT
fid
,
AsText
(
PointN
(
g
,
2
))
FROM
ls
;
SELECT
fid
,
IsClosed
(
g
)
FROM
ls
;
SELECT
fid
,
AsText
(
Centroid
(
g
))
FROM
p
;
SELECT
fid
,
Area
(
g
)
FROM
p
;
SELECT
fid
,
AsText
(
ExteriorRing
(
g
))
FROM
p
;
SELECT
fid
,
NumInteriorRings
(
g
)
FROM
p
;
SELECT
fid
,
AsText
(
InteriorRingN
(
g
,
1
))
FROM
p
;
SELECT
fid
,
NumGeometries
(
g
)
from
mpt
;
SELECT
fid
,
NumGeometries
(
g
)
from
mls
;
SELECT
fid
,
NumGeometries
(
g
)
from
mp
;
SELECT
fid
,
NumGeometries
(
g
)
from
gc
;
SELECT
fid
,
AsText
(
GeometryN
(
g
,
2
))
from
mpt
;
SELECT
fid
,
AsText
(
GeometryN
(
g
,
2
))
from
mls
;
SELECT
fid
,
AsText
(
GeometryN
(
g
,
2
))
from
mp
;
SELECT
fid
,
AsText
(
GeometryN
(
g
,
2
))
from
gc
;
SELECT
g1
.
fid
as
first
,
g2
.
fid
as
second
,
Within
(
g1
.
g
,
g2
.
g
)
as
w
,
Contains
(
g1
.
g
,
g2
.
g
)
as
c
,
Overlaps
(
g1
.
g
,
g2
.
g
)
as
o
,
Equals
(
g1
.
g
,
g2
.
g
)
as
e
,
Disjoint
(
g1
.
g
,
g2
.
g
)
as
d
,
Touches
(
g1
.
g
,
g2
.
g
)
as
t
,
Intersects
(
g1
.
g
,
g2
.
g
)
as
i
,
Crosses
(
g1
.
g
,
g2
.
g
)
as
r
FROM
gc
g1
,
gc
g2
ORDER
BY
first
,
second
;
DROP
TABLE
pt
,
ls
,
p
,
mpt
,
mls
,
mp
,
gc
,
geo
;
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