Hi everyone , My name’s Simone Zanda
i am trying to integrate the public transport service inside the profile
foot.lua, (foot + bus)
in process_way(profile, way, result,relation_data) I can find all the ways that
have the relation <tag k = "route" v = "bus" /> I thought I would change the
mode.walking to mode.driving and everything is working.
my problem is that I would like to exchange profiles only when there is a node
<tag k = "highway" v = "bus_stop" /> <tag k="public_transport" v="platform”/>
I would like to have the route like this:
Start point mode.walking -> bus_stop. -> mode.driving -> bus_stop. -> Stop
point mode.walking
This is my process_way
function process_way(profile, way, result,relation_data)
local data = {
-- prefetch tags
highway = way:get_value_by_key('highway'),
bridge = way:get_value_by_key('bridge'),
route = way:get_value_by_key('route'),
leisure = way:get_value_by_key('leisure'),
man_made = way:get_value_by_key('man_made'),
railway = way:get_value_by_key('railway'),
platform = way:get_value_by_key('platform'),
amenity = way:get_value_by_key('amenity'),
public_transport = way:get_value_by_key('public_transport'),
-- bus = get_from_rel(relations, way, "route", 'bus', "route"),
}
if next(data) == nil then -- is the data table empty?
return
end
result.forward_mode = mode.walking
result.backward_mode = mode.walking
local rel_id_list = relation_data:get_relations(way)
-- iterate over them
for i, rel_id in ipairs(rel_id_list) do
-- get the relation object
local rel = relation_data:relation(rel_id)
-- find the type of relation
local reltype = rel:get_value_by_key("type")
-- is the relation a route?relation
if reltype == 'route' then
local route = rel:get_value_by_key("route")
local route_name = rel:get_value_by_key("name")
if route and ( route == 'bus' or route == 'tram' ) then
-- let's be sure we've done something
local street_name = way:get_value_by_key("name")
print('route',route_name,'on',street_name)
-- adjust the weight and rate
result.forward_speed = 45
result.backward_speed = 45
result.forward_rate = 10.0
result.backward_rate = 10.0
result.forward_mode = mode.driving
result.backward_mode = mode.driving
return result
end
end
end
local handlers = Sequence {
-- set the default mode for this profile. if can be changed later
-- in case it turns we're e.g. on a ferry
WayHandlers.default_mode,
-- check various tags that could indicate that the way is not
-- routable. this includes things like status=impassable,
-- toll=yes and oneway=reversible
WayHandlers.blocked_ways,
-- access tags, e.g: motorcar, motor_vehicle, vehicle
WayHandlers.access,
-- check whether forward/backward directons are routable
WayHandlers.oneway,
-- check whether forward/backward directons are routable
WayHandlers.destinations,
-- check whether we're using a special transport mode
WayHandlers.ferries,
WayHandlers.movables,
-- compute speed taking into account way type, maxspeed tags, etc.
WayHandlers.speed,
WayHandlers.surface,
-- handle turn lanes and road classification, used for guidance
-- handle turn lanes and road classification, used for guidance
WayHandlers.classification,
-- handle various other flags
WayHandlers.roundabouts,
WayHandlers.startpoint,
-- set name, ref and pronunciation
WayHandlers.names,
-- set weight properties of the way
WayHandlers.weights
}
WayHandlers.run(profile,way,result,data,handlers)
end
All the best
Simone Zanda
_______________________________________________
OSRM-talk mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/osrm-talk