2017-04-22 157 views
0

是否有一种简洁的方式来查找所有不仅与主圆交叉而且与主圆相交的中心。如何找到所有以其圆心为中心的圆圈

enter image description here

+0

你的意思是几何型圆形,还是Postgis类型的CircularString或CurvePolygon?这可能是[dba.se]的更好匹配。您可以将其标记并要求版主移动它。 –

回答

0

当然这很简单。您需要使用@@center获取中心点,然后使用@>使用包含。

SELECT 
    x AS r_value, 
    circle('0,0', x) @> @@ circle('2,3', 1) AS contains 
FROM generate_series(1,5) AS gs(x); 

- 或 -

SELECT 
    x AS r_value, 
    circle('0,0', x) @> center(circle('2,3', 1)) AS contains 
FROM generate_series(1,5) AS gs(x); 

这种蛮力测试圈与原点的中心,与[1,5]半径是否包含circle('2,3',1)中心。

有关更多信息,请参阅geometry functions上的文档。

0
select * from circles a , circles b 
where st_intersects(a.geom,st_centroid(b.geom)) 

另外,您可以通过在where子句中添加条件来过滤结果。我假设主要圈子的名字。

select * from circles a , circles b 
where st_intersects(a.geom,st_centroid(b.geom)) and a.circle_name = 'Main Circle';