Dear All,
I am not able to do offline routing with my network data. I am using latest ArcGIS SDK for iOS and developing in Objective C.
Initializing routeTask as shown below. "network.geodatabase" is the geodatabase included in the bundle. And "Network_ND" is under .tn folder which also included in the bundle.
self.routeTask = [AGSRouteTask routeTaskWithDatabaseName:@"network" network:@"Network_ND" error:&error];
// assign delegate to this view controller
self.routeTask.delegate = self;
self.routeTaskParams = [AGSRouteTaskParameters routeTaskParameters];
// kick off asynchronous method to retrieve default parameters
// for the route task
[self.routeTask retrieveDefaultRouteTaskParameters];
I get below error after requesting retrieveDefaultRouteTaskParameters
Error Domain=com.esri.arcgis.runtime.error Code=10004 "Cannot retrieve route task parameters." UserInfo=0x7f8061529f40
And when I try to solve route after adding two points, I get below error.
Error Domain=com.esri.arcgis.runtime.error Code=10004 "Route task internal error." UserInfo=0x7f80616ed380 {NSLocalizedDescription=Route task internal error.}
But if I try by changing the code as shown below, I neither get any error nor any output. Neither the didSolveWithResult event is fired nor the didFailSolveWithError event.
self.routeTask = [AGSRouteTask routeTaskWithDatabaseName:@"network.geodatabase" network:@"Network_ND" error:&error];
// assign delegate to this view controller
self.routeTask.delegate = self;
self.routeTaskParams = [AGSRouteTaskParameters routeTaskParameters];
// kick off asynchronous method to retrieve default parameters
// for the route task
[self.routeTask retrieveDefaultRouteTaskParameters];
Please throw some pointers on how to solve this issue.
Regards
Muzammil
Solved! Go to Solution.
Hi Muzammil,
Thanks for sending me the sample project.
So, you were really close. The problem is that Xcode was not copying the Network_ND files to a .tn subfolder when building the target. Rather they were sitting at the top-level, right next to the .geodatabase file.
So, use the following code (pretty much your original code without .geodatabase in the name, but it's good practice that we check explicitly for an error):
NSError* error = nil;
self.routeTask = [AGSRouteTask routeTaskWithDatabaseName:@"network_projected" network:@"Projected_Network_ND" error:&error];
if (!error) {
// assign delegate to this view controller
self.routeTask.delegate = self;
// kick off asynchronous method to retrieve default parameters
// for the route task
[self.routeTask retrieveDefaultRouteTaskParameters];
} else {
NSLog(@"Could not open local network dataset: %@", error.localizedDescription);
}
Also, no need to set up parameters at this point since the didRetrieveDetrieveDefaultRouteTaskParameters handler will do that.
You must now modify your target properties to specify where to copy the _ND files. See the following screenshots.
1: Create a new Copy Files build phase with the + button at the top of the Build Phases list:
2: Expand the new Copy Files phase, set the subpath to a .tn folder (in your case, "network_projected.tn") and click the + at the bottom of the phase to add files:
3: Add the files to the Copy Files phase:
It should end up looking like this:
Run your project and you should see default parameters being retrieved OK.
It seems that if you provide a database name that can't be found, no error is returned. That seems like a bug to me, which I've reported to the iOS team. Even without that, Xcode would have had to be configured as above, but it might have saved some confusion!
Hope this helps!
Cheers,
Nick.
P.S. For anyone following along, please note that the network dataset name in this reply is slightly modified from the original question.
Hi Muzammil,
If the folder is named network.tn, then that looks correct to me.
Can you check whether error is populated with an error object after the call to routeTaskWithDatabaseName?
Thanks,
Nick.
Dear Nick,
1. If the routeTaskWithDatabaseName is assigned as "network", then
After the call to routeTaskWithDatabaseName, the error object has following error.
error | NSError * | domain: @"com.esri.arcgis.runtime.error" - code: 10004 |
_userInfo | NSDictionary * | 1 key/value pair |
[0] | (null) | @"NSLocalizedDescription" : @"Cannot open network." |
key | __NSCFConstantString * | @"NSLocalizedDescription" |
value | __NSCFString * | @"Cannot open network." |
2. But if the routeTaskWithDatabaseName is assigned as "network.geodatabase", then
there is no error, i.e., error object is nil. But routing does not work, though (neither success nor failed event is fired).
Regards
Muzammil
Hi Muzammil,
Thanks for sending me the sample project.
So, you were really close. The problem is that Xcode was not copying the Network_ND files to a .tn subfolder when building the target. Rather they were sitting at the top-level, right next to the .geodatabase file.
So, use the following code (pretty much your original code without .geodatabase in the name, but it's good practice that we check explicitly for an error):
NSError* error = nil;
self.routeTask = [AGSRouteTask routeTaskWithDatabaseName:@"network_projected" network:@"Projected_Network_ND" error:&error];
if (!error) {
// assign delegate to this view controller
self.routeTask.delegate = self;
// kick off asynchronous method to retrieve default parameters
// for the route task
[self.routeTask retrieveDefaultRouteTaskParameters];
} else {
NSLog(@"Could not open local network dataset: %@", error.localizedDescription);
}
Also, no need to set up parameters at this point since the didRetrieveDetrieveDefaultRouteTaskParameters handler will do that.
You must now modify your target properties to specify where to copy the _ND files. See the following screenshots.
1: Create a new Copy Files build phase with the + button at the top of the Build Phases list:
2: Expand the new Copy Files phase, set the subpath to a .tn folder (in your case, "network_projected.tn") and click the + at the bottom of the phase to add files:
3: Add the files to the Copy Files phase:
It should end up looking like this:
Run your project and you should see default parameters being retrieved OK.
It seems that if you provide a database name that can't be found, no error is returned. That seems like a bug to me, which I've reported to the iOS team. Even without that, Xcode would have had to be configured as above, but it might have saved some confusion!
Hope this helps!
Cheers,
Nick.
P.S. For anyone following along, please note that the network dataset name in this reply is slightly modified from the original question.