MicrosoftDocs / mslearn-your-first-iot-central-app

Sample code for Microsoft Learn module "Build your first IoT Central app"
MIT License
14 stars 41 forks source link

GetRouteDirections failing due to coordinates being formated with commas in certain cultures #1

Open darenm opened 4 years ago

darenm commented 4 years ago

The truck does not correctly process commands to go to specific customer due to culture-specfic formatting of the coordinates. GetRouteDirections returns an error message:

The provided coordinates in query are invalid, out of range, or not in the expected format

Current code - depends on CurrentCulture - coordinates are incorrectly formatted as numbers with comma (,) as decimal separator

var req = new RouteRequestDirections 
    { 
        Query = $"{currentLat},{currentLon}:{destinationLat},{destinationLon}" 
    };

Corrected code - depends on InvariantCulture - coordinates are formatted as numbers with dot (.) as decimal separator

var req = new RouteRequestDirections 
    { 
        Query = FormattableString.Invariant($"{currentLat},{currentLon}:{destinationLat},{destinationLon}") 
    };
abeckDev commented 4 years ago

Same here. Thanks for the hint! @PeterTurcan PR #2 from @darenm will resolve this issue.

Can you may review and merge it?