OsmSharp / ui

The UI components.
http://osmsharp.com/
GNU General Public License v2.0
139 stars 91 forks source link

RailWay Routing support #243

Closed sadaqatbukhari closed 8 years ago

sadaqatbukhari commented 9 years ago

Hi, I don't know is it right or wrong place to ask this question...

I need to route rail instead of car or bus, could you please guide me how to add that Rail or PVS support in OSM.

Regards, Sadaqat

xivk commented 9 years ago

You need to implement a custom vehicle class:

https://github.com/OsmSharp/OsmSharp/blob/master/OsmSharp.Routing/Vehicles/MotorVehicle.cs

And add a new routing interpreter that supports railways:

https://github.com/OsmSharp/OsmSharp/blob/master/OsmSharp.Routing/Osm/Interpreter/OsmRoutingInterpreter.cs

sadaqatbukhari commented 9 years ago

Hi, Thanks,

I have created new class for "RailWay : MotorVehicle" it is inherited from MotorVehicle.

AccessibleTags.Add("funicular", string.Empty); AccessibleTags.Add("light_rail", string.Empty); AccessibleTags.Add("miniature", string.Empty); AccessibleTags.Add("monorail", string.Empty); AccessibleTags.Add("narrow_gauge", string.Empty); AccessibleTags.Add("preserved", string.Empty); AccessibleTags.Add("railway", string.Empty); AccessibleTags.Add("subway", string.Empty); AccessibleTags.Add("tram", string.Empty); AccessibleTags.Add("station", string.Empty); AccessibleTags.Add("rail", string.Empty);

        VehicleTypes.Add("train"); // ... and also a generic motor vehicle.
        VehicleTypes.Add("railway"); // a motor vehicle is a generic vehicle.
        VehicleTypes.Add("train"); // ... and also a generic motor vehicle.
        VehicleTypes.Add("rail");

        VehicleTypes.Add("tram");

I have added railway in this function private void FillRelevantTags() { _relevantRoutingKeys = new HashSet { "oneway", "highway", "motor_vehicle", "bicycle", "foot", "access", "maxspeed", "junction", "type", "barrier","railway","rail" }; _relevantKeys = new HashSet { "name" }; } But it is still routing on road instead of train tracks, could you please guide me further what I have to do.

Thanks, Sadaqat

felicss commented 8 years ago

Anyone found a solution to this problem yet?

xivk commented 8 years ago

For those who also want this, I created a small example here:

https://github.com/osmsharp/routing/tree/examples/railways