Skip to content

Commit 5a88fa8

Browse files
committed
improve
1 parent 0c9686b commit 5a88fa8

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

201904/20190421_01.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,35 @@ st_astext | POLYGON((120.080290328964 69.0017473017801,119.781778114247 69.00174
182182
..............
183183
```
184184

185+
5、输入任意一个泰森多边形ID搜索与之相邻的泰森多边形。
186+
187+
```
188+
select st_collect(tc.poy)
189+
from tc,
190+
(select * from tc where id=80) t
191+
where st_intersects(tc.poy, t.poy)
192+
and GeometryType(ST_Intersection(tc.poy, t.poy)) <> 'POINT'
193+
;
194+
```
195+
196+
![pic](20190421_01_pic_008.jpg)
197+
198+
只有一个点相邻也会认为相邻,所以需要使用GeometryType过滤.
199+
200+
```
201+
digoal=# select st_intersects(poyx, poyy), GeometryType(ST_Intersection(poyx, poyy)) from
202+
(values(
203+
ST_MakePolygon(ST_GeomFromText('LINESTRING(1 2, 2 2, 2 3, 1 2)'))
204+
,
205+
ST_MakePolygon(ST_GeomFromText('LINESTRING(2 2, 3 2, 3 3, 2 2)'))
206+
)) as t (poyx, poyy)
207+
;
208+
st_intersects | geometrytype
209+
---------------+--------------
210+
t | POINT
211+
(1 row)
212+
```
213+
185214
## 参考
186215
https://en.wikipedia.org/wiki/Voronoi_diagram
187216

201904/20190421_01_pic_008.jpg

45.7 KB
Loading

0 commit comments

Comments
 (0)