📄 gis.test
字号:
36.334484,-114.923281 36.334146,-114.92564 36.331504,-114.9407236.319282,-114.945348 36.314812,-114.948091 36.314762,-114.95175536.316211,-114.952446 36.313883,-114.952644 36.309488,-114.94472536.313083,-114.93706 36.32043,-114.932478 36.323497,-114.92455636.327708,-114.922608 36.329715,-114.92009 36.328695,-114.91210536.323566,-114.901647 36.317952,-114.897436 36.313968,-114.89534436.309573,-114.891699 36.304398,-114.890569 36.303551,-114.88635636.302702,-114.885141 36.301351,-114.885709 36.297391,-114.89249936.290893,-114.902142 36.288974,-114.904941 36.288838,-114.90530836.289845,-114.906325 36.290395,-114.909916 36.289549,-114.91452736.287535,-114.918797 36.284423,-114.922982 36.279731,-114.92411336.277282,-114.924057 36.275817,-114.927733 36.27053,-114.92935436.269029,-114.929354 36.269029,-114.950856 36.268715,-114.95076836.264324,-114.960206 36.264293,-114.960301 36.268943,-115.00666236.268929,-115.008583 36.265619,-115.00665 36.264247,-115.00665936.246873,-115.006659 36.246873,-115.006838 36.247697,-115.01076436.247774,-115.015609 36.25113,-115.015765 36.254505,-115.02951736.254619,-115.038573 36.249317,-115.038573 36.249317,-115.02340336.25841,-115.023873 36.258994,-115.031845 36.259829,-115.0318336.261053,-115.025561 36.261095,-115.036417 36.274632,-115.03372936.276041,-115.032217 36.274851,-115.029845 36.273959,-115.02993436.274966,-115.025763 36.274896,-115.025406 36.281044,-115.02873136.284471,-115.036497 36.290377,-115.042071 36.291039,-115.02675936.298478,-115.008995 36.301966,-115.006363 36.305435),(-115.07983536.244369,-115.079735 36.260186,-115.076435 36.262369,-115.06975836.265,-115.070235 36.268757,-115.064542 36.268655,-115.06184336.269857,-115.062676 36.270693,-115.06305 36.272344,-115.05905136.281023,-115.05918 36.283008,-115.060591 36.285246,-115.06191336.290022,-115.062499 36.306353,-115.062499 36.306353,-115.06091836.30642,-115.06112 36.289779,-115.05713 36.2825,-115.05731436.279446,-115.060779 36.274659,-115.061366 36.27209,-115.05785836.26557,-115.055805 36.262883,-115.054688 36.262874,-115.04733536.25037,-115.044234 36.24637,-115.052434 36.24047,-115.06173436.23507,-115.061934 36.22677,-115.061934 36.22677,-115.06149136.225267,-115.062024 36.218194,-115.060134 36.218278,-115.06013336.210771,-115.057833 36.210771,-115.057433 36.196271,-115.06223336.196271,-115.062233 36.190371,-115.062233 36.190371,-115.06553336.190371,-115.071333 36.188571,-115.098331 36.188275,-115.09833136.188275,-115.098435 36.237569,-115.097535 36.240369,-115.09753536.240369,-115.093235 36.240369,-115.089135 36.240469,-115.08313536.240569,-115.083135 36.240569,-115.07983536.244369)))')),('85998',GeomFromText('MULTIPOLYGON(((-115.33310736.264587,-115.333168 36.280638,-115.333168 36.280638,-115.3222636.280643,-115.322538 36.274311,-115.327222 36.274258,-115.3273336.263026,-115.330675 36.262984,-115.332132 36.264673,-115.33310736.264587),(-115.247239 36.247066,-115.247438 36.218267,-115.24743836.218267,-115.278525 36.219263,-115.278525 36.219263,-115.30154536.219559,-115.332748 36.219197,-115.332757 36.220041,-115.33275736.220041,-115.332895 36.233514,-115.349023 36.233479,-115.35148936.234475,-115.353681 36.237021,-115.357106 36.239789,-115.3651936.243331,-115.368156 36.243487,-115.367389 36.244902,-115.36455336.246014,-115.359219 36.24616,-115.356186 36.248025,-115.35334736.248004,-115.350813 36.249507,-115.339673 36.25387,-115.33306936.255018,-115.333069 36.255018,-115.333042 36.247767,-115.27903936.248666,-115.263639 36.247466,-115.263839 36.252766,-115.26143936.252666,-115.261439 36.247366,-115.247239 36.247066)))'));select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) fromt1 where object_id=85998;select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) fromt1 where object_id=85984;drop table t1;create table t1 (fl geometry not null);--error 1416insert into t1 values (1);--error 1416insert into t1 values (1.11);--error 1416insert into t1 values ("qwerty");--error 1048insert into t1 values (pointfromtext('point(1,1)'));drop table t1;select (asWKT(geomfromwkb((0x000000000140240000000000004024000000000000))));select (asWKT(geomfromwkb((0x010100000000000000000024400000000000002440))));--enable_metadatacreate table t1 (g GEOMETRY);select * from t1;select asbinary(g) from t1;--disable_metadatadrop table t1;create table t1 (a TEXT, b GEOMETRY NOT NULL, SPATIAL KEY(b));alter table t1 disable keys;--error 1263load data infile '../std_data_ln/bad_gis_data.dat' into table t1;alter table t1 enable keys;drop table t1;## Bug #26038: is null and bad data#create table t1 (a int, b blob);insert into t1 values (1, ''), (2, NULL), (3, '1');select * from t1;select geometryfromtext(b) IS NULL, geometryfromwkb(b) IS NULL, astext(b) IS NULL, aswkb(b) IS NULL, geometrytype(b) IS NULL, centroid(b) IS NULL, envelope(b) IS NULL, startpoint(b) IS NULL, endpoint(b) IS NULL, exteriorring(b) IS NULL, pointn(b, 1) IS NULL, geometryn(b, 1) IS NULL, interiorringn(b, 1) IS NULL, multipoint(b) IS NULL, isempty(b) IS NULL, issimple(b) IS NULL, isclosed(b) IS NULL, dimension(b) IS NULL, numgeometries(b) IS NULL, numinteriorrings(b) IS NULL, numpoints(b) IS NULL, area(b) IS NULL, glength(b) IS NULL, srid(b) IS NULL, x(b) IS NULL, y(b) IS NULLfrom t1;select within(b, b) IS NULL, contains(b, b) IS NULL, overlaps(b, b) IS NULL, equals(b, b) IS NULL, disjoint(b, b) IS NULL, touches(b, b) IS NULL, intersects(b, b) IS NULL, crosses(b, b) IS NULLfrom t1;select point(b, b) IS NULL, linestring(b) IS NULL, polygon(b) IS NULL, multipoint(b) IS NULL, multilinestring(b) IS NULL, multipolygon(b) IS NULL, geometrycollection(b) IS NULLfrom t1;drop table t1;## Bug #27164: Crash when mixing InnoDB and MyISAM Geospatial tables#CREATE TABLE t1(a POINT) ENGINE=MyISAM;INSERT INTO t1 VALUES (NULL);SELECT * FROM t1;DROP TABLE t1;--echo End of 4.1 tests## Bug #12281 (Geometry: crash in trigger)#create table t1 (s1 geometry not null,s2 char(100));create trigger t1_bu before update on t1 for each row set new.s1 = null;--error 1048insert into t1 values (null,null);drop table t1;## Bug #10499 (function creation with GEOMETRY datatype)#--disable_warningsdrop procedure if exists fn3;--enable_warningscreate function fn3 () returns point return GeomFromText("point(1 1)"); show create function fn3;select astext(fn3());drop function fn3;## Bug #12267 (primary key over GIS)#create table t1(pt POINT);alter table t1 add primary key pti(pt);drop table t1;create table t1(pt GEOMETRY);--error 1170alter table t1 add primary key pti(pt);alter table t1 add primary key pti(pt(20));drop table t1;create table t1 select GeomFromText('point(1 1)');desc t1;drop table t1;## Bug #20691 (DEFAULT over NOT NULL field)#create table t1 (g geometry not null);--error ER_CANT_CREATE_GEOMETRY_OBJECTinsert into t1 values(default);drop table t1;## Bug #27300: create view with geometry functions lost columns types #CREATE TABLE t1 (a GEOMETRY);CREATE VIEW v1 AS SELECT GeomFromwkb(ASBINARY(a)) FROM t1;CREATE VIEW v2 AS SELECT a FROM t1;DESCRIBE v1;DESCRIBE v2;DROP VIEW v1,v2;DROP TABLE t1;## Bug#24563: MBROverlaps does not seem to function propertly# Bug#54888: MBROverlaps missing in 5.1?## Test all MBR* functions and their non-MBR-prefixed aliases,# using shifted squares to verify the spatial relations.create table t1 (name VARCHAR(100), square GEOMETRY);INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))'));INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))'));INSERT INTO t1 VALUES("big", GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))'));INSERT INTO t1 VALUES("up", GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))'));INSERT INTO t1 VALUES("up2", GeomFromText('POLYGON (( 0 2, 0 4, 2 4, 2 2, 0 2))'));INSERT INTO t1 VALUES("up3", GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))'));INSERT INTO t1 VALUES("down", GeomFromText('POLYGON (( 0 -1, 0 1, 2 1, 2 -1, 0 -1))'));INSERT INTO t1 VALUES("down2", GeomFromText('POLYGON (( 0 -2, 0 0, 2 0, 2 -2, 0 -2))'));INSERT INTO t1 VALUES("down3", GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))'));INSERT INTO t1 VALUES("right", GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))'));INSERT INTO t1 VALUES("right2", GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))'));INSERT INTO t1 VALUES("right3", GeomFromText('POLYGON (( 3 0, 3 2, 5 2, 5 0, 3 0))'));INSERT INTO t1 VALUES("left", GeomFromText('POLYGON (( -1 0, -1 2, 1 2, 1 0, -1 0))'));INSERT INTO t1 VALUES("left2", GeomFromText('POLYGON (( -2 0, -2 2, 0 2, 0 0, -2 0))'));INSERT INTO t1 VALUES("left3", GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))'));SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrcontains FROM t1 a1 JOIN t1 a2 ON MBRContains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrdisjoint FROM t1 a1 JOIN t1 a2 ON MBRDisjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrequal FROM t1 a1 JOIN t1 a2 ON MBREqual( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrintersect FROM t1 a1 JOIN t1 a2 ON MBRIntersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbroverlaps FROM t1 a1 JOIN t1 a2 ON MBROverlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrtouches FROM t1 a1 JOIN t1 a2 ON MBRTouches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS equals FROM t1 a1 JOIN t1 a2 ON Equals( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS intersect FROM t1 a1 JOIN t1 a2 ON Intersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS overlaps FROM t1 a1 JOIN t1 a2 ON Overlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS touches FROM t1 a1 JOIN t1 a2 ON Touches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;# Overlaps needs a few more tests, with point and line dimensionsSET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))');SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))');SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))');SET @horiz3 = GeomFromText('POLYGON ((2 0, 3 0, 2 0))');SET @point1 = GeomFromText('POLYGON ((0 0))');SET @point2 = GeomFromText('POLYGON ((-2 0))');SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @vert1) GROUP BY a1.name;SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @horiz1) GROUP BY a1.name;SELECT Overlaps(@horiz1, @vert1) FROM DUAL;SELECT Overlaps(@horiz1, @horiz2) FROM DUAL;SELECT Overlaps(@horiz1, @horiz3) FROM DUAL;SELECT Overlaps(@horiz1, @point1) FROM DUAL;SELECT Overlaps(@horiz1, @point2) FROM DUAL;DROP TABLE t1;## Bug#28763: Selecting geometry fields in UNION caused server crash.#create table t1(f1 geometry, f2 point, f3 linestring);select f1 from t1 union select f1 from t1;insert into t1 (f2,f3) values (GeomFromText('POINT(1 1)'), GeomFromText('LINESTRING(0 0,1 1,2 2)'));select AsText(f2),AsText(f3) from t1;select AsText(a) from (select f2 as a from t1 union select f3 from t1) t;create table t2 as select f2 as a from t1 union select f3 from t1;desc t2;select AsText(a) from t2; drop table t1, t2;## Bug #29166: MYsql crash when query is run## The test query itself is not logged : too large output.# The real test is the second query : see if the first hasn't crashed the# server--disable_query_log--disable_result_logSELECT AsText(GeometryFromText(CONCAT( 'MULTIPOLYGON(((', REPEAT ('-0.00000000001234567890123456789012 -0.123456789012345678,', 1000), '-0.00000000001234567890123456789012 -0.123456789012345678', ')))'))) AS a;--enable_result_log--enable_query_logSELECT 1;--echo End of 5.0 tests
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -