[CP] [GIS] query range shoud be linked by or
This commit is contained in:
@ -3226,3 +3226,85 @@ Outputs & filters:
|
||||
select id, min, max, st_astext(line_geo) from spatial_point_in_line ignore index(geom_idx_1) where ST_Contains(line_geo, LineString(Point(80, 0), Point(91, 0)));
|
||||
id min max st_astext(line_geo)
|
||||
2 80 100 LINESTRING(80 0,100 0)
|
||||
drop table t1;
|
||||
create table t1 (c1 int primary key, g GEOMETRY NOT NULL SRID 4326, SPATIAL INDEX(g));
|
||||
insert into t1 values (1, ST_GeomFromText('POINT(1 1)', 4326));
|
||||
insert into t1 values (2, ST_GeomFromText('POINT(-1 1)', 4326));
|
||||
insert into t1 values (3, ST_GeomFromText('POINT(-1 -1)', 4326));
|
||||
insert into t1 values (4, ST_GeomFromText('POINT(1 -1)', 4326));
|
||||
insert into t1 values (5, ST_GeomFromText('POLYGON((0 0, 1 0, 1 -1, 0 -1, 0 0))', 4326));
|
||||
insert into t1 values (6, ST_GeomFromText('LINESTRING(-1 -1, 3 3)', 4326));
|
||||
insert into t1 values (7, ST_GeomFromText('POLYGON((1 1, -1 1, -1 -1, 1 -1, 1 1))', 4326));
|
||||
insert into t1 values (8, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326));
|
||||
insert into t1 values (9, ST_GeomFromText('POINT(0 0)', 4326));
|
||||
select /*+ index(t1 g) */ c1, ST_AsText(g) FROM t1 where ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326)) or (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326)) and ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
|
||||
c1 ST_AsText(g)
|
||||
1 POINT(1 1)
|
||||
4 POINT(1 -1)
|
||||
5 POLYGON((0 0,1 0,1 -1,0 -1,0 0))
|
||||
7 POLYGON((1 1,-1 1,-1 -1,1 -1,1 1))
|
||||
8 POLYGON((0 0,0 2,2 2,2 0,0 0))
|
||||
select /*+ full(t1) */ c1, ST_AsText(g) FROM t1 where ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326)) or (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326)) and ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
|
||||
c1 ST_AsText(g)
|
||||
1 POINT(1 1)
|
||||
4 POINT(1 -1)
|
||||
5 POLYGON((0 0,1 0,1 -1,0 -1,0 0))
|
||||
7 POLYGON((1 1,-1 1,-1 -1,1 -1,1 1))
|
||||
8 POLYGON((0 0,0 2,2 2,2 0,0 0))
|
||||
select /*+ index(t1 g) */ c1, ST_AsText(g) FROM t1 where ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
|
||||
and (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
|
||||
or ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
|
||||
c1 ST_AsText(g)
|
||||
1 POINT(1 1)
|
||||
5 POLYGON((0 0,1 0,1 -1,0 -1,0 0))
|
||||
7 POLYGON((1 1,-1 1,-1 -1,1 -1,1 1))
|
||||
8 POLYGON((0 0,0 2,2 2,2 0,0 0))
|
||||
select /*+ full(t1) */ c1, ST_AsText(g) FROM t1 where ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
|
||||
and (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
|
||||
or ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
|
||||
c1 ST_AsText(g)
|
||||
1 POINT(1 1)
|
||||
5 POLYGON((0 0,1 0,1 -1,0 -1,0 0))
|
||||
7 POLYGON((1 1,-1 1,-1 -1,1 -1,1 1))
|
||||
8 POLYGON((0 0,0 2,2 2,2 0,0 0))
|
||||
select /*+ index(t1 g) */ c1, ST_AsText(g) FROM t1 where (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
|
||||
and ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 -2, 2 -2, 2 0, 0 0))', 4326)))
|
||||
or (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
|
||||
and ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
|
||||
c1 ST_AsText(g)
|
||||
1 POINT(1 1)
|
||||
4 POINT(1 -1)
|
||||
5 POLYGON((0 0,1 0,1 -1,0 -1,0 0))
|
||||
7 POLYGON((1 1,-1 1,-1 -1,1 -1,1 1))
|
||||
8 POLYGON((0 0,0 2,2 2,2 0,0 0))
|
||||
select /*+ full(t1) */ c1, ST_AsText(g) FROM t1 where (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
|
||||
and ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 -2, 2 -2, 2 0, 0 0))', 4326)))
|
||||
or (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
|
||||
and ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
|
||||
c1 ST_AsText(g)
|
||||
1 POINT(1 1)
|
||||
4 POINT(1 -1)
|
||||
5 POLYGON((0 0,1 0,1 -1,0 -1,0 0))
|
||||
7 POLYGON((1 1,-1 1,-1 -1,1 -1,1 1))
|
||||
8 POLYGON((0 0,0 2,2 2,2 0,0 0))
|
||||
select /*+ index(t1 g) */ c1, ST_AsText(g) FROM t1 where (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
|
||||
or ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 -2, 2 -2, 2 0, 0 0))', 4326)))
|
||||
and (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
|
||||
or ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
|
||||
c1 ST_AsText(g)
|
||||
5 POLYGON((0 0,1 0,1 -1,0 -1,0 0))
|
||||
6 LINESTRING(-1 -1,3 3)
|
||||
7 POLYGON((1 1,-1 1,-1 -1,1 -1,1 1))
|
||||
8 POLYGON((0 0,0 2,2 2,2 0,0 0))
|
||||
9 POINT(0 0)
|
||||
select /*+ full(t1) */ c1, ST_AsText(g) FROM t1 where (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
|
||||
or ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 -2, 2 -2, 2 0, 0 0))', 4326)))
|
||||
and (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
|
||||
or ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
|
||||
c1 ST_AsText(g)
|
||||
5 POLYGON((0 0,1 0,1 -1,0 -1,0 0))
|
||||
6 LINESTRING(-1 -1,3 3)
|
||||
7 POLYGON((1 1,-1 1,-1 -1,1 -1,1 1))
|
||||
8 POLYGON((0 0,0 2,2 2,2 0,0 0))
|
||||
9 POINT(0 0)
|
||||
drop table t1;
|
||||
|
||||
@ -510,3 +510,52 @@ insert into spatial_point_in_line (min, max, line_geo) values
|
||||
select id, min, max, st_astext(line_geo) from spatial_point_in_line where ST_Contains(line_geo, LineString(Point(80, 0), Point(91, 0)));
|
||||
explain select id, min, max, st_astext(line_geo) from spatial_point_in_line where ST_Contains(line_geo, LineString(Point(80, 0), Point(91, 0)));
|
||||
select id, min, max, st_astext(line_geo) from spatial_point_in_line ignore index(geom_idx_1) where ST_Contains(line_geo, LineString(Point(80, 0), Point(91, 0)));
|
||||
--error 0,1051
|
||||
drop table t1;
|
||||
create table t1 (c1 int primary key, g GEOMETRY NOT NULL SRID 4326, SPATIAL INDEX(g));
|
||||
|
||||
insert into t1 values (1, ST_GeomFromText('POINT(1 1)', 4326));
|
||||
insert into t1 values (2, ST_GeomFromText('POINT(-1 1)', 4326));
|
||||
insert into t1 values (3, ST_GeomFromText('POINT(-1 -1)', 4326));
|
||||
insert into t1 values (4, ST_GeomFromText('POINT(1 -1)', 4326));
|
||||
insert into t1 values (5, ST_GeomFromText('POLYGON((0 0, 1 0, 1 -1, 0 -1, 0 0))', 4326));
|
||||
insert into t1 values (6, ST_GeomFromText('LINESTRING(-1 -1, 3 3)', 4326));
|
||||
insert into t1 values (7, ST_GeomFromText('POLYGON((1 1, -1 1, -1 -1, 1 -1, 1 1))', 4326));
|
||||
insert into t1 values (8, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326));
|
||||
insert into t1 values (9, ST_GeomFromText('POINT(0 0)', 4326));
|
||||
|
||||
# c1 or (c2 and c3)
|
||||
select /*+ index(t1 g) */ c1, ST_AsText(g) FROM t1 where ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326)) or (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326)) and ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
|
||||
select /*+ full(t1) */ c1, ST_AsText(g) FROM t1 where ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326)) or (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326)) and ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
|
||||
|
||||
#c1 and (c2 or c3)
|
||||
select /*+ index(t1 g) */ c1, ST_AsText(g) FROM t1 where ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
|
||||
and (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
|
||||
or ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
|
||||
select /*+ full(t1) */ c1, ST_AsText(g) FROM t1 where ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
|
||||
and (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
|
||||
or ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
|
||||
|
||||
# (c1 and c2) or (c3 and c4)
|
||||
select /*+ index(t1 g) */ c1, ST_AsText(g) FROM t1 where (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
|
||||
and ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 -2, 2 -2, 2 0, 0 0))', 4326)))
|
||||
or (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
|
||||
and ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
|
||||
|
||||
select /*+ full(t1) */ c1, ST_AsText(g) FROM t1 where (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
|
||||
and ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 -2, 2 -2, 2 0, 0 0))', 4326)))
|
||||
or (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
|
||||
and ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
|
||||
|
||||
# (c1 or c2) and (c3 or c4)
|
||||
select /*+ index(t1 g) */ c1, ST_AsText(g) FROM t1 where (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
|
||||
or ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 -2, 2 -2, 2 0, 0 0))', 4326)))
|
||||
and (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
|
||||
or ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
|
||||
|
||||
select /*+ full(t1) */ c1, ST_AsText(g) FROM t1 where (ST_Intersects(g, ST_GeomFromText('POINT(1 -1)', 4326))
|
||||
or ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 -2, 2 -2, 2 0, 0 0))', 4326)))
|
||||
and (ST_Intersects(g, ST_GeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))', 4326))
|
||||
or ST_Intersects(g, ST_GeomFromText('POINT(1 1)', 4326)));
|
||||
|
||||
drop table t1;
|
||||
|
||||
Reference in New Issue
Block a user