| 1 |
# Disabled on Windows ASAN due to https://bugs.llvm.org/show_bug.cgi?id=35365 |
| 2 |
--source include/not_asan_windows.inc |
| 3 |
|
| 4 |
# |
| 5 |
# Spatial objects |
| 6 |
# |
| 7 |
|
| 8 |
--disable_warnings |
| 9 |
DROP TABLE IF EXISTS t1; |
| 10 |
--enable_warnings |
| 11 |
|
| 12 |
select 1, ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 0,20 20,0 20,0 0))'), ST_GeomFromText('POLYGON((10 10,30 10,30 30,10 30,10 10))')); |
| 13 |
select 0, ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 40, 40 50, 20 70, 10 40))')); |
| 14 |
select 1, ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POINT(10 10)')); |
| 15 |
select 1, ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))')); |
| 16 |
select 0, ST_Within(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))')); |
| 17 |
select 1, ST_Within(ST_GeomFromText('POLYGON((1 1,20 10,10 30, 1 1))'), ST_GeomFromText('POLYGON((0 0,30 5,10 40, 0 0))')); |
| 18 |
|
| 19 |
|
| 20 |
create table t1 (g point)engine=innodb; |
| 21 |
insert into t1 values |
| 22 |
(ST_GeomFromText('POINT(2 2)')), (ST_GeomFromText('POINT(2 4)')), (ST_GeomFromText('POINT(2 6)')), (ST_GeomFromText('POINT(2 8)')), |
| 23 |
(ST_GeomFromText('POINT(4 2)')), (ST_GeomFromText('POINT(4 4)')), (ST_GeomFromText('POINT(4 6)')), (ST_GeomFromText('POINT(4 8)')), |
| 24 |
(ST_GeomFromText('POINT(6 2)')), (ST_GeomFromText('POINT(6 4)')), (ST_GeomFromText('POINT(6 6)')), (ST_GeomFromText('POINT(6 8)')), |
| 25 |
(ST_GeomFromText('POINT(8 2)')), (ST_GeomFromText('POINT(8 4)')), (ST_GeomFromText('POINT(8 6)')), (ST_GeomFromText('POINT(8 8)')); |
| 26 |
|
| 27 |
select ST_astext(g) from t1 where ST_Within(g, ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))')); |
| 28 |
select 'Contains'; |
| 29 |
select ST_astext(g) from t1 where ST_Contains(ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'), g); |
| 30 |
select 'Intersects'; |
| 31 |
select ST_astext(g) from t1 where ST_Intersects(ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'), g); |
| 32 |
select 'Contains'; |
| 33 |
select ST_astext(g) from t1 where ST_Contains(ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'), g); |
| 34 |
select 'Contains2'; |
| 35 |
select ST_astext(g) from t1 where ST_Contains(ST_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); |
| 36 |
|
| 37 |
DROP TABLE t1; |
| 38 |
|
| 39 |
select 0, ST_Within(ST_GeomFromText('LINESTRING(15 15, 50 50, 60 60)'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))')); |
| 40 |
select 1, ST_Within(ST_GeomFromText('LINESTRING(15 15, 16 16)'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))')); |
| 41 |
|
| 42 |
|
| 43 |
select 1, ST_Intersects(ST_GeomFromText('LINESTRING(15 15, 50 50)'), ST_GeomFromText('LINESTRING(50 15, 15 50)')); |
| 44 |
select 1, ST_Intersects(ST_GeomFromText('LINESTRING(15 15, 50 50)'), ST_GeomFromText('LINESTRING(16 16, 51 51)')); |
| 45 |
|
| 46 |
select 1, ST_Intersects(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))')); |
| 47 |
|
| 48 |
select ST_astext(ST_Union(ST_geometryfromtext('point(1 1)'), ST_geometryfromtext('polygon((0 0, 2 0, 1 2, 0 0))'))); |
| 49 |
select ST_astext(ST_Intersection(ST_geometryfromtext('point(1 1)'), ST_geometryfromtext('polygon((0 0, 2 0, 1 2, 0 0))'))); |
| 50 |
|
| 51 |
select ST_Intersects(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))')); |
| 52 |
select ST_contains(ST_GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)), ((6 6, 6 11, 11 11, 11 6, 6 6)))'), ST_GeomFromText('POINT(5 10)')); |
| 53 |
select ST_Disjoint(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 15, 15 15, 15 10, 10 10))')); |
| 54 |
select ST_Disjoint(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 4, 4 4, 4 10, 10 10))')); |
| 55 |
select ST_Overlaps(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 4, 4 4, 4 10, 10 10))')); |
| 56 |
select ST_Overlaps(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((1 1, 1 4, 4 4, 4 1, 1 1))')); |
| 57 |
|
| 58 |
# Distance tests |
| 59 |
select ST_DISTANCE(ST_geomfromtext('polygon((0 0, 1 2, 2 1, 0 0))'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))')); |
| 60 |
select ST_DISTANCE(ST_geomfromtext('polygon((0 0, 1 2, 2 1, 0 0))'), ST_geomfromtext('linestring(0 1, 1 0)')); |
| 61 |
select ST_DISTANCE(ST_geomfromtext('polygon((0 0, 3 6, 6 3, 0 0))'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))')); |
| 62 |
select ST_DISTANCE(ST_geomfromtext('polygon((0 0, 3 6, 6 3, 0 0),(2 2, 3 4, 4 3, 2 2))'), ST_geomfromtext('point(3 3)')); |
| 63 |
select ST_DISTANCE(ST_geomfromtext('linestring(0 0, 3 6, 6 3, 0 0)'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))')); |
| 64 |
|
| 65 |
|
| 66 |
# Operations tests |
| 67 |
select ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))'))); |
| 68 |
select ST_astext(ST_Intersection(ST_GeomFromText('LINESTRING(0 0, 50 45, 40 50, 0 0)'), ST_GeomFromText('LINESTRING(50 5, 55 10, 0 45, 50 5)'))); |
| 69 |
select ST_astext(ST_Intersection(ST_GeomFromText('LINESTRING(0 0, 50 45, 40 50)'), ST_GeomFromText('LINESTRING(50 5, 55 10, 0 45)'))); |
| 70 |
select ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POINT(20 20)'))); |
| 71 |
select ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200)'))); |
| 72 |
select ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)'))); |
| 73 |
select ST_astext(ST_UNION(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)'))); |
| 74 |
|
| 75 |
select ST_astext(ST_intersection(ST_geomfromtext('polygon((0 0, 1 0, 0 1, 0 0))'), ST_geomfromtext('polygon((0 0, 1 1, 0 2, 0 0))'))); |
| 76 |
|
| 77 |
select ST_astext(ST_symdifference(ST_geomfromtext('polygon((0 0, 1 0, 0 1, 0 0))'), ST_geomfromtext('polygon((0 0, 1 1, 0 2, 0 0))'))); |
| 78 |
select ST_astext(ST_UNION(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)'))); |
| 79 |
|
| 80 |
# Buffer() tests |
| 81 |
--replace_numeric_round 14 |
| 82 |
select ST_astext(ST_buffer(ST_geometryfromtext('point(1 1)'), 1)); |
| 83 |
create table t1(geom geometrycollection)engine=innodb; |
| 84 |
--error ER_CANT_CREATE_GEOMETRY_OBJECT |
| 85 |
insert into t1 values (ST_geomfromtext('POLYGON((0 0, 10 10, 0 8, 0 0))')); |
| 86 |
--error ER_CANT_CREATE_GEOMETRY_OBJECT |
| 87 |
insert into t1 values (ST_geomfromtext('POLYGON((1 1, 10 10, 0 8, 1 1))')); |
| 88 |
select ST_astext(geom), ST_area(geom),ST_area(ST_buffer(geom,2)) from t1; |
| 89 |
select ST_NUMPOINTS(ST_EXTERIORRING(ST_buffer(geom,2))) from t1; |
| 90 |
|
| 91 |
set @geom=ST_geomfromtext('LINESTRING(2 1, 4 2, 2 3, 2 5)'); |
| 92 |
set @buff=ST_buffer(@geom,1); |
| 93 |
select ST_NUMPOINTS(ST_EXTERIORRING(@buff)) from t1; |
| 94 |
|
| 95 |
# cleanup |
| 96 |
DROP TABLE t1; |
| 97 |
|
| 98 |
#ST_Touches tests |
| 99 |
select st_touches(ST_geomfromtext('point(0 0)'), ST_geomfromtext('point(1 1)')); |
| 100 |
select st_touches(ST_geomfromtext('point(1 1)'), ST_geomfromtext('point(1 1)')); |
| 101 |
select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 1)')); |
| 102 |
select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 0)')); |
| 103 |
select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 2)')); |
| 104 |
select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('polygon((1 1.2, 1 0, 2 0, 1 1.2))')); |
| 105 |
select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('polygon((1 1, 1 0, 2 0, 1 1))')); |
| 106 |
|
| 107 |
#Equals test |
| 108 |
SELECT ST_Equals(ST_PolyFromText('POLYGON((67 13, 67 18, 67 18, 59 18, 59 13, 67 13) )'),ST_PolyFromText('POLYGON((67 13, 67 18, 59 19, 59 13, 59 13, 67 13) )')) as result; |
| 109 |
SELECT ST_Equals(ST_PolyFromText('POLYGON((67 13, 67 18, 67 18, 59 18, 59 13, 67 13) )'),ST_PolyFromText('POLYGON((67 13, 67 18, 59 18, 59 13, 59 13, 67 13) )')) as result; |
| 110 |
SELECT ST_Equals(ST_PointFromText('POINT (12 13)'),ST_PointFromText('POINT (12 13)')) as result; |
| 111 |
|
| 112 |
|
| 113 |
--echo # |
| 114 |
--echo # BUG#11755628/47429: INTERSECTION FUNCTION CRASHED MYSQLD |
| 115 |
--echo # BUG#11759650/51979: UNION/INTERSECTION OF POLYGONS CRASHES MYSQL |
| 116 |
--echo # |
| 117 |
|
| 118 |
--echo # Invalid geometry in input. |
| 119 |
DO ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('POLYGON((525000 183300,525400 |
| 120 |
183300,525400 18370, 525000 183700,525000 183300))'), |
| 121 |
ST_geomfromtext('POLYGON((525298.67 183511.53,525296.57 |
| 122 |
183510.39,525296.42 183510.31,525289.11 183506.62,525283.17 |
| 123 |
183503.47,525280.98 183502.26,525278.63 183500.97,525278.39 |
| 124 |
183500.84,525276.79 183500,525260.7 183491.55,525263.95 |
| 125 |
183484.75,525265.58 183481.95,525278.97 183488.73,525276.5 |
| 126 |
183493.45,525275.5 183495.7,525280.35 183498.2,525282.3 |
| 127 |
183499.1,525282.2 183499.3,525283.55 183500,525301.75 |
| 128 |
183509.35,525304.45 183504.25,525307.85 183504.95,525304.5 |
| 129 |
183510.83,525302.81 183513.8,525298.67 183511.53),(525275.06 |
| 130 |
183489.89,525272.06 183488.37,525268.94 183494.51,525271.94 |
| 131 |
183496.03,525275.06 183489.89),(525263.26 183491.55,525266.15 |
| 132 |
183493.04,525269.88 183485.82,525266.99 183484.33,525263.26 |
| 133 |
183491.55))'))) st_u; |
| 134 |
|
| 135 |
SET @a=0x0000000001030000000200000005000000000000000000000000000000000000000000000000002440000000000000000000000000000024400000000000002440000000000000000000000000000024400000000000000000000000000000000000000000000000000000F03F000000000000F03F0000000000000040000000000000F03F00000000000000400000000000000040000000000000F03F0000000000000040000000000000F03F000000000000F03F; |
| 136 |
--error ER_GIS_INVALID_DATA |
| 137 |
SELECT ST_ASTEXT(ST_TOUCHES(@a, ST_GEOMFROMTEXT('point(0 0)'))) t; |
| 138 |
|
| 139 |
|
| 140 |
--source include/gis_debug.inc |