2004-05-27 17:31:30 +02:00
|
|
|
-- source include/have_geometry.inc
|
|
|
|
|
2003-03-12 13:52:02 +01:00
|
|
|
#
|
|
|
|
# test of rtree (using with spatial data)
|
|
|
|
#
|
|
|
|
--disable_warnings
|
|
|
|
DROP TABLE IF EXISTS t1, t2;
|
|
|
|
--enable_warnings
|
|
|
|
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
g GEOMETRY NOT NULL,
|
|
|
|
SPATIAL KEY(g)
|
2003-12-10 05:31:42 +01:00
|
|
|
) ENGINE=MyISAM;
|
2003-03-12 13:52:02 +01:00
|
|
|
|
|
|
|
SHOW CREATE TABLE t1;
|
|
|
|
|
|
|
|
let $1=150;
|
|
|
|
let $2=150;
|
|
|
|
while ($1)
|
|
|
|
{
|
|
|
|
eval INSERT INTO t1 (g) VALUES (GeomFromText('LineString($1 $1, $2 $2)'));
|
|
|
|
dec $1;
|
|
|
|
inc $2;
|
|
|
|
}
|
|
|
|
|
|
|
|
SELECT count(*) FROM t1;
|
2003-03-18 14:01:38 +01:00
|
|
|
EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
|
|
|
|
SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
|
2003-03-12 13:52:02 +01:00
|
|
|
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
CREATE TABLE t2 (
|
|
|
|
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
g GEOMETRY NOT NULL
|
2003-12-10 05:31:42 +01:00
|
|
|
) ENGINE=MyISAM;
|
2003-03-12 13:52:02 +01:00
|
|
|
|
|
|
|
let $1=10;
|
|
|
|
while ($1)
|
|
|
|
{
|
|
|
|
let $2=10;
|
|
|
|
while ($2)
|
|
|
|
{
|
2003-03-18 14:01:38 +01:00
|
|
|
eval INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10))));
|
2003-03-12 13:52:02 +01:00
|
|
|
dec $2;
|
|
|
|
}
|
|
|
|
dec $1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ALTER TABLE t2 ADD SPATIAL KEY(g);
|
|
|
|
SHOW CREATE TABLE t2;
|
|
|
|
SELECT count(*) FROM t2;
|
|
|
|
EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g,
|
|
|
|
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
|
|
|
|
SELECT fid, AsText(g) FROM t2 WHERE Within(g,
|
|
|
|
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
|
|
|
|
|
|
|
|
let $1=10;
|
|
|
|
while ($1)
|
|
|
|
{
|
|
|
|
let $2=10;
|
|
|
|
while ($2)
|
|
|
|
{
|
2003-03-18 14:01:38 +01:00
|
|
|
eval DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10)))));
|
2003-03-12 13:52:02 +01:00
|
|
|
SELECT count(*) FROM t2;
|
|
|
|
dec $2;
|
|
|
|
}
|
|
|
|
dec $1;
|
|
|
|
}
|
|
|
|
|
|
|
|
DROP TABLE t2;
|
2004-02-19 14:22:38 +01:00
|
|
|
|
|
|
|
drop table if exists t1;
|
|
|
|
CREATE TABLE t1 (a geometry NOT NULL, SPATIAL (a));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
|
|
|
|
check table t1;
|
|
|
|
analyze table t1;
|
|
|
|
drop table t1;
|
|
|
|
|
2004-04-08 12:58:06 +02:00
|
|
|
#
|
|
|
|
# The following crashed gis
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
g GEOMETRY NOT NULL,
|
|
|
|
SPATIAL KEY(g)
|
|
|
|
) ENGINE=MyISAM;
|
|
|
|
|
|
|
|
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(1 2, 2 3)')),(GeomFromText('LineString(1 2, 2 4)'));
|
|
|
|
#select * from t1 where g<GeomFromText('LineString(1 2, 2 3)');
|
|
|
|
drop table t1;
|