AGSRouteTask doesn't get default params (offline)

301
1
12-29-2016 09:26 AM
TércyoStorck1
New Contributor III

Hi,

I have an application that downloads a zip file that contains the network files, and save it in Documents application folder.

The problem is that some networks don't have the _ND_historical_traffic inside .tn folder. When this happens and i try to get the default params, i get the issue bellow:

Error Domain=com.esri.arcgis.runtime.error Code=3072
"The transportation network data files could not be opened, and may be missing."
UserInfo={
    Additional Message=Network_index::open_file_sections_,
    NSLocalizedFailureReason=Network_index::open_file_sections_,
    NSLocalizedDescription=The transportation network data files could not be opened,
    and may be missing.
}

Here my code:

let folderPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
let gdbPath = folderPath.appending("/network/data.geodatabase")
        
self.routeTask = AGSRouteTask(fileURLToDatabase: URL(string:gdbPath)!, networkName: "network_ND")
        
self.getDefaultParameters()
func getDefaultParameters() {
    self.routeTask.defaultRouteParameters(completion: {(params: AGSRouteParameters?, error: Error?) -> Void in
        if let error = error {
            print(error)
        }
        else {
            self.params = params
        }
    })
}
0 Kudos
1 Reply
YueWu1
by Esri Regular Contributor
Esri Regular Contributor

Hi Tércyo,

Based on my understanding, this is more related to a tn file issue when you generate the Network Dataset from ArcMap. I did a test on ArcMap 10.2.2 to generate a Network Dataset, even though I choose do not use traffic data and it turns out when I create the Runtime Content I still have this "historical_traffic" file under the .tn folder and its 0 kb. 


Here is a screenshot to show: https://s24.postimg.org/6uyyhncut/historical_traffic.jpg 

Therefore, I would say behind the code there is probably a mechanism to check the file to decide if there is any value for "defaultRouteParameters". All you need to do is make sure this "historical_traffic" file in there even it is empty. 

You can try to generate a new Runtime Content and you will see the "historical_traffic" file will always in the .tn folder.

Hope this can help.

0 Kudos