Answers:
我认为,出于以下几个原因,下面的代码是比所选答案更干净的解决方案。首先,没有表联接是必要的,因此每个街道属性都不需要对“ ON”子句进行补充;其次,如果存在多个不连续的具有所有相同的属性值,而ST_Dump在此解决方案中解决了该问题。
SELECT (ST_Dump(geom)).geom AS geom, "road_id", "road_type"
FROM (
SELECT ST_LineMerge(ST_Union(geom)) AS geom, "road_id", "road_type"
FROM "RoadCentreLines"
GROUP BY "road_id", "road_type"
) AS street_union
似乎可行
SELECT a."Road_ID",a."Road_Type", ST_LineMerge(ST_Collect(a.the_geom))
FROM "RoadCentreLines" as a
LEFT JOIN "RoadCentreLines" as b ON
ST_Touches(a.the_geom,b.the_geom)
AND a."Road_Type" = b."Road_Type"
AND a."Road_ID" = b."Road_ID"
GROUP BY ST_Touches(a.the_geom,b.the_geom), a."Road_Type", a."Road_ID"
只是吐口水,但我可以想到其他一些解决方案。我不知道它们是好是坏,只是他们是其他。
首先,如果道路类型很少,则可以使用类似的内容逐一进行:
WITH type As (SELECT "Road_ID" As id WHERE "Road_Type" = 'type')
SELECT ST_LineMerge (ST_Collect(the_geom))
FROM "RoadCentreLines"
WHERE ST_StartPoint(the_geom) && ST_EndPoint(the_geom) IS TRUE
AND "Road_ID" IN (SELECT id FROM type);
如果有很多类型,您也可以将上述大多数功能与Road_Type一起用作FOR循环中的变量。
我的最后一个想法涉及合并所有几何图形,然后使用ST_Line_Substring函数(Link-Link)调用道路类型,但这根本行不通。
祝你好运,Rob