Routing with Local Data

6359
24
08-24-2011 01:03 AM
JamesMcElroy
New Contributor
I want to do routing with local data instead of using a web service.  I've created my Network dataset and route layer successfully.  I exported it as a Map Pack and tried using that in the

_routeTask = new RouteTask("D:\\MyRoute.mpk");

line and then when I tried to run the

_routeTask.SolveAsync

command it returns failed with the error:
"An exception occurred during a WebClient request."
with an internal exception of:
"Unable to cast object of type 'System.Net.FileWebRequest' to type 'System.Net.HttpWebRequest'."

So obviously it's expecting a URL and not a filepath in the constructor of the RouteTask, which is interesting since the FindTask and the Locator both accept filepaths. 

What am I doing wrong here?  Did I go wrong with exporting as a map pack?

Thanks,

James
0 Kudos
24 Replies
JamesMcElroy
New Contributor
Hi Ralf,

The model does not run because there are not stops defined in the "Route/Stops" layer and there have to be 2 valid stops.  There aren't any stops defined because you told me to remove them :).  And even when I had stops in that layer when it ran it didn't create a result that could be exported.  Since I don't have a result I can't make a package.  But I've emailed you the mxd with all the data as well as the toolbox with the model I created.  If you don't get the email it's also on our FTP.  It's the file ArvadaRoute.7z.

Thanks,

James
0 Kudos
LeonKosiba
New Contributor
Hi James,

You�??re not doing anything wrong, at this time the Runtime does not support the RouteTask with local resources.  Routing is supported by geoprocessing model and then creating a Geoprocessing Package (gpk) with runtime support enabled from that model.  We are looking into adding this support in the future.


Thanks for the sample code, I was able to get a prototype running easily. 
When you talk about adding RouteTask in the future, what time frame are you thinking?  (making the 10.1 release, or be available in several years)
If I would want the route broken down into segments, instead of one long polyline, do you have any suggestions on how to do this? (so it would be similar to RouteTask)

Thanks
Leon
0 Kudos
MichaelErlich
New Contributor II
When using the gpk provided, I get a ServiceException with 'Unable to Complete Operation'.  There is no additional information or inner exception.

Here is the sample code I am using:

Geoprocessor gp = new Geoprocessor(_localGeoService.Tasks[0].Url);
List<GPParameter> parameters = new List<GPParameter>();
FeatureSet featureSet = new FeatureSet();

Graphic gr = new Graphic()
{
  Geometry = new MapPoint(-122.41430282592773, 37.79596625790735),
};
featureSet.Features.Add(gr);
gr = new Graphic()
{
  Geometry = new MapPoint(-122.44462251663208, 37.77892370057646),
};

featureSet.Features.Add(gr);
GPFeatureRecordSetLayer inputFeatures = new GPFeatureRecordSetLayer("Input_Locations", featureSet);
parameters.Add(inputFeatures);

featureSet = new FeatureSet();
inputFeatures = new GPFeatureRecordSetLayer("Input_Barriers", featureSet);
parameters.Add(inputFeatures);

GPExecuteResults results = gp.Execute(parameters);
0 Kudos
MichaelErlich
New Contributor II
Update:  If I don't add any parameters, it works ok.  So, I guess I need to now figure out in our own data how to allow parameters to be added to the request and provide adequate information in the response.
0 Kudos
BrooksShannon
New Contributor
Ok, the sample GPK is uploaded.  You should be able to get to it here:
https://betacommunity.esri.com/files/download.aspx/PointToPointWBarriers.gpk?d=0D08C5CF1E0B4D2380C5A...

Only members of the Beta Community will be able to access it.  Let me know if you have troubles.


Hey Ralf,

I hope things are going well! It was great seeing you down in Palm Springs at this year's dev summit.

I've been spending some time developing against the Runtime, and have decided to foray into network analysis.  Simple point-to-point routing is sufficient for me, so I've taken some interest in this thread - and your GPK example.  Unfortunately, I can't seem to get your sample tool to execute.  When I try to run in from within ArcMap, I receive the following:  "ERROR 000816: The tool is not valid."

Do you know what might be causing this?  I'm trying to execute the tool in 10.1 Prerelease ArcGIS Desktop "Basic".  (At the risk of sounding totally naive, could this be a version compatibility thing, since you created the GPK awhile back, pre-prerelease?)

Thanks!
Brooks
0 Kudos