0

pgRouting pgr_drivingDistance函数仅返回路网顶点的 id,但不返回特定行驶时间内道路边缘的 id。
为了找到这条路边,我创建了查询:

SELECT all_roads.id, the_geom
    FROM
        (
            SELECT e.id, e.the_geom
            FROM tmp_ddist dd,
                tmp_edge e
            WHERE
                e.target = dd.vertex 
        UNION
            SELECT e.id, e.the_geom
            FROM tmp_ddist dd,
                tmp_edge e
            WHERE
                e.source = dd.vertex 
        ) all_roads
    GROUP BY all_roads.id, the_geom
    HAVING COUNT(all_roads.id) = 2

基本上,它会在pgr_drivingDistance函数生成的集合中找到具有源顶点和目标顶点的道路边缘,并仅返回在该集合中同时具有源顶点和目标顶点的那些边缘。

有没有办法优化这个查询?

4

1 回答 1

0

你可以试试这样,看看这是否有帮助:

SELECT all_roads.id, the_geom
  FROM
    (
        SELECT e.id, e.the_geom
        FROM tmp_ddist dd,
            tmp_edge e
        WHERE
            e.target = dd.vertex 
    UNION
        SELECT e2.id, e2.the_geom
        FROM tmp_ddist dd2,
            tmp_edge e2
        WHERE
            e2.source = dd2.vertex AND
            e2.id <> e.id
    ) all_roads
GROUP BY all_roads.id, the_geom
HAVING COUNT(all_roads.id) = 2

我很想知道查询之间的基准测试。

于 2014-11-10T12:43:41.730 回答