Exclude Transite Lines from route calculation

484
2
05-23-2019 02:40 AM
MassimoMazzanti
New Contributor III

Hello,

I'm developing an app in Visual Studio Xamarin environment with ArcGIS Runtime SDK for .NET.
This app use a Network Analysis service that I created from a GTFS network dataset.

Sometimes I want to exclude from the route calculation the public transport lines.
In ArcMap, when I use the Find Route tool in the Options tab of the Find Route dialog, I just uncheck "Use trip start" and the route is calculated correctly without transit lines.

In my app I try to replicate this behavior with the following code

...
RouteParameters routeParams = await solveRouteTask.CreateDefaultParametersAsync();

// set the routeParams.StartTime parameter only if _appSettings.useStarTime is true

if (_appSettings.useStartTime)
     routeParams.StartTime = DateTimeOffset.Now;
else
     routeParams.StartTime = null;
...

but it doesn't work, and the resulting route always takes into account transit lines.

Can anyone suggest a solution?

Many thanks

Massimo

0 Kudos
2 Replies
MelindaMorang
Esri Regular Contributor

A better way to accomplish this would be to create a network restriction that forbids travel on transit lines. Then, create a travel mode for walking with no transit.  When you publish your service, the user can select either the transit+walk travel mode or the walk-only travel mode.

MassimoMazzanti
New Contributor III
262/5000
Many thanks Melinda,
I was hoping that the problem could be solved programmatically, because I've already set up six travel mode for as many user profiles, and the solution you propose requires me to add six more travel modes.
For now I will certainly follow your suggestion.
Best regards
Massimo
0 Kudos