예제 #1
0
        public async Task <EniroRoutingResult> RoutingAsync(RoutingParameters routingParameters)
        {
            var queryString = "/api/route?";

            switch (routingParameters.Pref)
            {
            case PrefEnum.Fastest:
                queryString += "pref=fastest";
                break;

            case PrefEnum.Shortest:
                queryString += "pref=shortest";
                break;

            default:
                queryString += "pref=fastest";
                break;
            }

            queryString += $"&waypoints={routingParameters.From.X.ToString(CultureInfo.InvariantCulture)},{routingParameters.From.Y.ToString(CultureInfo.InvariantCulture)};{routingParameters.To.X.ToString(CultureInfo.InvariantCulture)},{routingParameters.To.Y.ToString(CultureInfo.InvariantCulture)}";
            queryString += $"&instr=true";
            queryString += $"&geo=true";
            queryString += $"&res=200";
            foreach (Avoid avoid in Enum.GetValues(typeof(Avoid)))
            {
                if ((routingParameters.Avoid & avoid) != 0) // Skip Avoid.None
                {
                    queryString += $"&avoid={avoid}";
                }
            }

            queryString += $"&contentType=json";
            if (!string.IsNullOrWhiteSpace(_eniroMapClientConfiguration.PartnerId))
            {
                queryString += $"&partnerId={_eniroMapClientConfiguration.PartnerId}";
            }

            var apiResult = await _httpClient.GetStringAsync(queryString);

            return(JsonConvert.DeserializeObject <EniroRoutingResult>(apiResult));
        }
예제 #2
0
 public Task <EniroRoutingResult> RoutingAsync(RoutingParameters routingParameters)
 {
     return(_eniroHttpClient.RoutingAsync(routingParameters));
 }