在pgRouting中的pgr_drivingDistance 函数能够帮我实现想要的工作。
pgr_drivingDistance - Returns the driving distance from a start node.
Synopsis
Using Dijkstra algorithm, extracts all the nodes that have costs less than or equal to the value distance. The edges extracted will conform the corresponding spanning tree.
pgr_drivingDistance(edges_sql, start_vid, distance)
pgr_drivingDistance(edges_sql, start_vid, distance, directed)
pgr_drivingDistance(edges_sql, start_vids, distance, directed, equicost)
RETURNS SET OF (seq, [start_vid,] node, edge, cost, agg_cost)
在构建好路网拓扑后,能够计算一定距离的所有节点。比如:通过该函数能够计算5公里能够到达的节点。在一个足够大的网络中,就能将距离转换成时间,也就是某时间内到达的节点。
SELECT
target as id,rc.geom
FROM
pgr_drivingDistance (
'SELECT gid as id, source, target, length as cost FROM road_china where st_intersects(st_transform(st_buffer(st_transform(st_geomfromtext(''POINT(120.18 30.30)'',4326),3857),1000*100