OpenStreetMapx.jl使用子网路由

发布于 2025-02-11 17:35:32 字数 161 浏览 0 评论 0原文

我正在使用OpenStreetMapx.jl库来计算我的OSM网络点之间的路由。

有什么方法可以获得将结果限制为预定义子网络的路径的方法?

例如,我想计算两个点之间的路线,但仅使用次级道路。

是否可以?

I am using OpenstreetmapX.jl library to calculate routes between to points of my OSM network.

Is there any way to obtain such routes limiting the results to paths of a predefined sub network?

For instance, I would like to calculate the route between two points but only using secondary roadways.

Is it possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨后咖啡店 2025-02-18 17:35:32

您很可能想创建一个单独的mapData来处理此类数据。有一个不错的工具 osmfilter ,在将数据导入到Julia之前,可以过滤特定的路由类型。
这样,您可以拥有地图数据的单独表示形式。

但是,如果要直接在mapdata对象上操作,则可以将距离权重设置为Inf,并且它将迫使路由算法避免使用此类边缘或返回INF路线长度。

假设您拥有来自教程的地图:

using OpenStreetMapX, Graphs
map_file_path = joinpath(dirname(pathof(OpenStreetMapX)),"..","test/data/reno_east3.osm")
mx = get_map_data(map_file_path, use_cache=false);

比过滤二级途径要多:

m2 = deepcopy(mx)
edgs = collect(edges(mx.g))[findall(!=(4), mx.class)]
setindex!.(Ref(m2.w), Inf, src.(edgs), dst.(edgs))

现在所选路由在MXM2之间会有所不同:

julia> shortest_route(mx,    3073938243, 3101115892)
([3073938243, 3073938154, 140340636, 140340638, 3101117891, 3101115892], 549.9261168024648, 32.32592992211371)

julia> shortest_route(m2,    3073938243, 3101115892)
([3073938243, 140533189, 140533195, 3101115892], 617.4395184717641, 54.94654519330738)

Most likely you would like to create a separate MapData object for processing such data. There is a nice tool osmfilter that allows to filter out specific route types before importing data to Julia.
In this way you can have separate representations of your map data.

However, if you want to operate directly on the MapData object you could set the distance weights to Inf and which would force the routing algorithm to avoid such edges or return Inf route length.

Suppose you have the map from the tutorials:

using OpenStreetMapX, Graphs
map_file_path = joinpath(dirname(pathof(OpenStreetMapX)),"..","test/data/reno_east3.osm")
mx = get_map_data(map_file_path, use_cache=false);

Than you could do to filter out secondary routes:

m2 = deepcopy(mx)
edgs = collect(edges(mx.g))[findall(!=(4), mx.class)]
setindex!.(Ref(m2.w), Inf, src.(edgs), dst.(edgs))

Now the selected route will differ between mx and m2:

julia> shortest_route(mx,    3073938243, 3101115892)
([3073938243, 3073938154, 140340636, 140340638, 3101117891, 3101115892], 549.9261168024648, 32.32592992211371)

julia> shortest_route(m2,    3073938243, 3101115892)
([3073938243, 140533189, 140533195, 3101115892], 617.4395184717641, 54.94654519330738)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文