Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for DurationInTraffic #157

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/Google.Maps/AvoidHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Google.Maps
Expand Down
3 changes: 0 additions & 3 deletions src/Google.Maps/BaseRequest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Google.Maps
{
Expand Down
8 changes: 1 addition & 7 deletions src/Google.Maps/Common/IServiceResponse.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Google.Maps.Common
namespace Google.Maps.Common
{
public interface IServiceResponse
{
Expand Down
1 change: 0 additions & 1 deletion src/Google.Maps/ComponentFilter.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Google.Maps
{
Expand Down
1 change: 0 additions & 1 deletion src/Google.Maps/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Google.Maps
Expand Down
8 changes: 4 additions & 4 deletions src/Google.Maps/Direction/DirectionLeg.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json;

namespace Google.Maps.Direction
{
Expand All @@ -13,6 +10,9 @@ public class DirectionLeg

[JsonProperty("duration")]
public ValueText Duration { get; set; }

[JsonProperty("duration_in_traffic")]
public ValueText DurationInTraffic { get; set; }

[JsonProperty("distance")]
public ValueText Distance { get; set; }
Expand Down
11 changes: 10 additions & 1 deletion src/Google.Maps/Direction/DirectionRequest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
using Google.Maps;
using System.ComponentModel;

namespace Google.Maps.Direction
Expand All @@ -24,6 +23,15 @@ public class DirectionRequest : BaseRequest
[DefaultValue(TravelMode.driving)]
public TravelMode Mode { get; set; }


/// <summary>
/// Specifies the assumptions to use when calculating time in traffic. This setting affects the value returned in the duration_in_traffic field in the response,
/// which contains the predicted time in traffic based on historical averages. The traffic_model parameter may only be specified for driving directions where
/// the request includes a departure_time, and only if the request includes an API key or a Google Maps Platform Premium Plan client ID.
/// </summary>
[DefaultValue(TrafficModel.best_guess)]
public TrafficModel TrafficModel { get; set; }

/// <summary>
/// (optional) Directions may be calculated that adhere to certain restrictions.
/// </summary>
Expand Down Expand Up @@ -119,6 +127,7 @@ public override Uri ToUri()
.Append("origin", (Origin == null ? (string)null : Origin.GetAsUrlParameter()))
.Append("destination", (Destination == null ? (string)null : Destination.GetAsUrlParameter()))
.Append("mode", (Mode != TravelMode.driving ? Mode.ToString() : (string)null))
.Append("traffic_model", (TrafficModel!=TrafficModel.best_guess ? TrafficModel.ToString():(string)null))
.Append("departure_time", (DepartureTime == null ? null : DepartureTime.Value.ToString()))
.Append("arrival_time", (ArrivalTime == null ? null : ArrivalTime.Value.ToString()))
.Append("waypoints", WaypointsToUri())
Expand Down
6 changes: 1 addition & 5 deletions src/Google.Maps/Direction/DirectionResponse.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

using Newtonsoft.Json;
using Newtonsoft.Json;
using Google.Maps.Common;

namespace Google.Maps.Direction
Expand Down
5 changes: 1 addition & 4 deletions src/Google.Maps/Direction/DirectionRoute.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json;

namespace Google.Maps.Direction
{
Expand Down
5 changes: 3 additions & 2 deletions src/Google.Maps/Direction/DirectionStep.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;

namespace Google.Maps.Direction
Expand All @@ -23,6 +21,9 @@ public class DirectionStep
[JsonProperty("duration")]
public ValueText Duration { get; set; }

[JsonProperty("duration_in_traffic")]
public ValueText DurationInTraffic { get; set; }

[Obsolete("maneuver is obsolete", false)]
public string Maneuver { get; set; }

Expand Down
6 changes: 1 addition & 5 deletions src/Google.Maps/Direction/DirectionTransitDetails.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json;

namespace Google.Maps.Direction
{
Expand Down
4 changes: 0 additions & 4 deletions src/Google.Maps/Direction/GeocodedWaypoint.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using Google.Maps.Shared;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Google.Maps.Direction
{
Expand Down
6 changes: 1 addition & 5 deletions src/Google.Maps/Direction/LineInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json;


namespace Google.Maps.Direction
Expand Down
5 changes: 1 addition & 4 deletions src/Google.Maps/Direction/Polyline.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json;

namespace Google.Maps.Direction
{
Expand Down
6 changes: 1 addition & 5 deletions src/Google.Maps/Direction/Stop.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json;

namespace Google.Maps.Direction
{
Expand Down
6 changes: 1 addition & 5 deletions src/Google.Maps/Direction/Time.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json;

namespace Google.Maps.Direction
{
Expand Down
6 changes: 1 addition & 5 deletions src/Google.Maps/Direction/TransitAgency .cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json;


namespace Google.Maps.Direction
Expand Down
5 changes: 1 addition & 4 deletions src/Google.Maps/Direction/VehicleInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json;

namespace Google.Maps.Direction
{
Expand Down
1 change: 0 additions & 1 deletion src/Google.Maps/DistanceMatrix/DistanceMatrixRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Google.Maps;
using System.Text;
using System.Linq;

Expand Down
4 changes: 1 addition & 3 deletions src/Google.Maps/DistanceMatrix/DistanceMatrixResponse.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json;
using Google.Maps.Common;

namespace Google.Maps.DistanceMatrix
Expand Down
4 changes: 0 additions & 4 deletions src/Google.Maps/ExceptionHelper.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Google.Maps
{
Expand Down
6 changes: 1 addition & 5 deletions src/Google.Maps/GMapsImageFormats.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Google.Maps
namespace Google.Maps
{
/// <summary>
/// Represents the different image formats available from the Google Maps API.
Expand Down
1 change: 0 additions & 1 deletion src/Google.Maps/Geocoding/GeocodeResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

using Google.Maps.Common;
using Newtonsoft.Json;
using System;

namespace Google.Maps.Geocoding
{
Expand Down
1 change: 0 additions & 1 deletion src/Google.Maps/Geocoding/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

using Newtonsoft.Json;
using System;
using Google.Maps.Shared;

namespace Google.Maps.Geocoding
Expand Down
10 changes: 5 additions & 5 deletions src/Google.Maps/Google.Maps.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net461;netstandard1.3</TargetFrameworks>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>latest</LangVersion>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>sn.snk</AssemblyOriginatorKeyFile>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<DelaySign>False</DelaySign>
<Configurations>Debug;Release;Release_PathDiagnostics</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='net461'">
<DefineConstants>HAS_SYSTEMDRAWING</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Net.Http" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
</Project>
4 changes: 1 addition & 3 deletions src/Google.Maps/Internal/ConvertUtil.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Linq;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace Google.Maps.Internal
Expand Down
2 changes: 0 additions & 2 deletions src/Google.Maps/Internal/QueryStringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
* limitations under the License.
*/

using System;

namespace Google.Maps.Internal
{
internal class QueryStringBuilder
Expand Down
3 changes: 1 addition & 2 deletions src/Google.Maps/Internal/RequestUtils.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;

Expand Down
6 changes: 1 addition & 5 deletions src/Google.Maps/Internal/StringCaseExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Linq;

namespace Google.Maps.Internal
{
Expand Down
2 changes: 0 additions & 2 deletions src/Google.Maps/Internal/ValueTextComparer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Google.Maps
{
Expand Down
1 change: 0 additions & 1 deletion src/Google.Maps/JsonEnumTypeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

using System;
using Google.Maps.Geocoding;
using Google.Maps.Shared;
using Newtonsoft.Json;

Expand Down
2 changes: 0 additions & 2 deletions src/Google.Maps/LatLngComparer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Google.Maps
{
Expand Down
6 changes: 1 addition & 5 deletions src/Google.Maps/Location.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Google.Maps
namespace Google.Maps
{
/// <summary>
/// A general free-text location, usually for specifying an address or particular place for Google Maps.
Expand Down
4 changes: 1 addition & 3 deletions src/Google.Maps/MapMarker.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;

namespace Google.Maps
Expand Down
4 changes: 1 addition & 3 deletions src/Google.Maps/MapMarkersCollection.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;

namespace Google.Maps
{
Expand Down
6 changes: 1 addition & 5 deletions src/Google.Maps/MapTypes.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Google.Maps
namespace Google.Maps
{
/// <summary>
/// The available map types for the current Google Maps API.
Expand Down
6 changes: 1 addition & 5 deletions src/Google.Maps/MarkerSizes.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Google.Maps
namespace Google.Maps
{
/// <summary>
/// The set of marker sizes available for the current Google Maps API.
Expand Down
4 changes: 1 addition & 3 deletions src/Google.Maps/Path.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;

namespace Google.Maps
Expand Down
Loading