Select to view content in your preferred language

Swift TravelMode Restrictions

449
2
05-31-2024 02:32 PM
RonFessler
New Contributor

I'm using ARCGIS 100.15. I'm trying to use travel mode restrictions by adding height and weight restrictions. In iOS it is not routing correctly and is routing over a bridge which violates the restrictions. I know the route is incorrect, because we also have an Android app with the exact same restrictions and the route on Android avoids the bridge as expected. Does anyone know why this is not working on iOS?

Sample code of defining restrictions below:

        routeTask.defaultRouteParameters { (params: AGSRouteParameters?, error: Error?) -> Void in
            guard error == nil, let params = params else {
                print("Loading default parameters failed with error : \(String(describing: error?.localizedDescription))")
                return completion(nil, error)
            }
            params.returnStops = true
            params.returnRoutes = true
            params.setStops(stops)
            params.findBestSequence = false
            params.preserveFirstStop = true
            params.preserveLastStop = true
            
            params.travelMode?.attributeParameterValues.forEach({ attribute in
                if attribute.attributeName == "HeightRestriction" && attribute.parameterName == "Vehicle Height"  {
                    attribute.parameterValue = 480
                    print("Assigning height value \(attribute.parameterValue ?? "nil").")
                }
                
                if attribute.attributeName == "WeightRestriction" && attribute.parameterName == "Vehicle Weight" {
                    attribute.parameterValue = 888888
                    print("Assigning weight value \(attribute.parameterValue ?? "nil").")
                }
            })
            
            print("Returning defaultParameters successfully.")
            completion(params, nil)
        }

 

0 Kudos
2 Replies
vishnuvardhandevineni
New Contributor

Hi Ron,

We need to give parameterValue as a Double value like Double(88888). Weight Restriction or Height Restriction are not accepting integer values.

0 Kudos
Ting
by Esri Contributor
Esri Contributor

Hi Ron, let me know if you have success with the suggestion above. 🙂

0 Kudos