OSM 渡轮线路导航

huangapple go评论64阅读模式
英文:

OSM routing on ferry lines

问题

我正在建立一个工具,旨在显示和存储公共交通出行信息。我目前已经实现了火车、公交和飞机出行的功能,现在想要添加渡轮。

对于公交,我目前使用OSRM。对于火车,我使用了一种自定义版本的OSRM,它使用轨道而不是道路。对于飞机,我只是在机场之间绘制大圆弧。

我在渡轮方面有点困惑。在开放街图上,它们被存储为relationsways,但我不知道如何仅找到两点之间的部分。

有没有人有办法解决这个问题?

英文:

I am building a tool that aims to display and store public transport trips. I currently have train, bus and air travel working, and I would like to add ferry.

For Bus, I currently use the OSRM. For train, I use a custom version of the OSRM that uses tracks instead of roads. And for air, I simply plot a geodesic between the airports.

I am at a bit of a loss concerning the ferries. In OSM, they are stored as either relations or ways, but I don't know how I could find only the part between 2 points.

Would anyone have an idea of how to get this ?

答案1

得分: 0


api_version = 4

Set = require('lib/set')
Sequence = require('lib/sequence')
Handlers = require("lib/way_handlers")

function setup()
  local ferry_speed = 30  -- ferry speed in km/h
  return {
    properties = {
      weight_name                   = 'duration',
      max_speed_for_map_matching    = 30/3.6,  -- kmph -> m/s
      call_tagless_node_function    = false,
      use_turn_restrictions         = false,
    },

    default_mode            = mode.ferry,
    default_speed           = ferry_speed,
    oneway_handling         = 'ignore',  -- allow traversal in both directions

    -- Only allow ways tagged as ferry route
    access_tag_whitelist = Set {
      'ferry'
    },

    speeds = Sequence {
      route = {
        ferry = ferry_speed,
      }
    },
  }
end

function process_node(profile, node, result)
  -- empty, ferry routes are mainly defined by ways, not nodes
end

function process_way(profile, way, result)
  -- only consider ways tagged with 'route=ferry'
  local is_ferry = way:get_value_by_key('route')
  if is_ferry == 'ferry' then
    result.forward_mode = mode.ferry
    result.backward_mode = mode.ferry
    result.forward_speed = profile.default_speed
    result.backward_speed = profile.default_speed
  else
    result.forward_mode = mode.inaccessible
    result.backward_mode = mode.inaccessible
  end
end

return {
  setup = setup,
  process_way =  process_way,
  process_node = process_node,
}

英文:

I ended up running another OSRM server with a ferry.lua like so :


api_version = 4

Set = require('lib/set')
Sequence = require('lib/sequence')
Handlers = require("lib/way_handlers")

function setup()
  local ferry_speed = 30  -- ferry speed in km/h
  return {
    properties = {
      weight_name                   = 'duration',
      max_speed_for_map_matching    = 30/3.6,  -- kmph -> m/s
      call_tagless_node_function    = false,
      use_turn_restrictions         = false,
    },

    default_mode            = mode.ferry,
    default_speed           = ferry_speed,
    oneway_handling         = 'ignore',  -- allow traversal in both directions

    -- Only allow ways tagged as ferry route
    access_tag_whitelist = Set {
      'ferry'
    },

    speeds = Sequence {
      route = {
        ferry = ferry_speed,
      }
    },
  }
end

function process_node(profile, node, result)
  -- empty, ferry routes are mainly defined by ways, not nodes
end

function process_way(profile, way, result)
  -- only consider ways tagged with 'route=ferry'
  local is_ferry = way:get_value_by_key('route')
  if is_ferry == 'ferry' then
    result.forward_mode = mode.ferry
    result.backward_mode = mode.ferry
    result.forward_speed = profile.default_speed
    result.backward_speed = profile.default_speed
  else
    result.forward_mode = mode.inaccessible
    result.backward_mode = mode.inaccessible
  end
end

return {
  setup = setup,
  process_way =  process_way,
  process_node = process_node,
}

huangapple
  • 本文由 发表于 2023年6月27日 18:50:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76564108.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定