我在SQL Server中有一个表,其中包含使用Geometry数据类型的路段: ID(int),Geom(几何),Name(varchar(150))
我想创建一个视图,其中包含作为路段交点的点,每个交叉点一个点,以及一个串联列,它结合了这样的名称" Main St @ George St @ Bob Street&# 34。
我已经开始创建不同的交叉点geoms,但我还没有找到如何聚合和连接每个街道名称的线索:
select geometry::STGeomFromText(t2.[g], 26917) as Geom
from
(
select distinct g
from
(
select r1.[geom].STIntersection(r2.[geom]).ToString() as [g]
from [Roads] r1 inner join
[Roads] r2 on
r1.[geom].STTouches(r2.[geom]) = 1
and r1.[ID] <> r2.[ID]
) t
) t2
答案 0 :(得分:0)
select
RoadA
, RoadB
, '@ ' + RoadA + ' @ ' +RoadB as Intersecion
, geometry::STGeomFromText(t2.[g], 26917) as Geom
from
(
select distinct g
, RoadA
, RoadB
from
(
select r1.[Geom].STIntersection(r2.[Geom]).ToString() as [g]
, r1.Name as RoadA
, r2.name as RoadB
from Roads r1 inner join
Roads r2 on
r1.[Geom].STTouches(r2.[Geom]) = 1
and r1.[ID] <> r2.[ID]
) t
) t2