This commit is contained in:
Ricky Brundritt 2018-03-09 16:04:27 -08:00
Родитель ece86cd1ff
Коммит 3fa5670c70
8 изменённых файлов: 74 добавлений и 21 удалений

Просмотреть файл

@ -1,3 +1,6 @@
* Async support added to SnapToRoadRequest, thus allowing up to 1,000 points to be snapped in a single request.
## Version 1.1.3 - 2/21/2018
* Fix globalization issue with coordinate to string conversion in route and imagery requests.

Просмотреть файл

@ -245,6 +245,7 @@ Requests a that requests an isochrone (drive time polygon). Inherits from the Ba
| DistanceUnits | [DistanceUnitType](#DistanceUnitType) | The units in which the maxTime value is specified. |
| MaxDistance | double | The maximum travel distance in the specified distance units in which the isochrone polygon is generated. Cannot be set when maxTime is set. |
| MaxTime | double | The maximum travel time in the specified time units in which the isochrone polygon is generated. Cannot be set when maxDistance is set. Maximum value is 120 minutes. |
| Optimize | [RouteOptimizationType](#RouteOptimizationType) | Specifies what parameters to use to optimize the isochrone route. One of the following values:<br/><br/>• distance: The route is calculated to minimize the distance. Traffic information is not used. Use with maxDistance.<br/>• time [default]: The route is calculated to minimize the time. Traffic information is not used. Use with maxTime.<br/>• timeWithTraffic: The route is calculated to minimize the time and uses current or predictive traffic information depending on if a dateTime value is specified. Use with maxTime. |
| TimeUnit | [TimeUnitType](#TimeUnitType) | The units in which the maxTime value is specified. Default: **Seconds** |
| TravelMode | [TravelModeType](#TravelModeType) | The mode of travel for the route. Default: Driving. |
| Waypoint | [SimplyWaypoint](#SimplyWaypoint) | The point around which the isochrone will be calculated. |

Просмотреть файл

@ -1,6 +1,6 @@
![Bing Maps Logo](https://github.com/Microsoft/Bing-Maps-V8-TypeScript-Definitions/blob/master/images/BingMapsLogoTeal.png)
[![NuGet](https://img.shields.io/badge/NuGet-1.1.3-blue.svg)](https://www.nuget.org/packages/BingMapsRESTToolkit)
[![NuGet](https://img.shields.io/badge/NuGet-1.1.4-blue.svg)](https://www.nuget.org/packages/BingMapsRESTToolkit)
[![license](https://img.shields.io/badge/license-MIT-yellow.svg)](https://github.com/Microsoft/BingMapsRESTToolkit/blob/master/LICENSE.md)
# Bing Maps REST Toolkit for .NET

Просмотреть файл

@ -586,6 +586,7 @@ namespace RESTToolkitTestApp
Points = new List<Coordinate>()
{
new Coordinate(47.590868, -122.336729),
new Coordinate(47.594994, -122.334263),
new Coordinate(47.601604, -122.336042),
new Coordinate(47.60849, -122.34241),
new Coordinate(47.610568, -122.345064)

Просмотреть файл

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>1.1.3</Version>
<Version>1.1.4</Version>
<Authors>Microsoft</Authors>
<Company>Microsoft</Company>
<Description>A toolkit that makes it easy to access the Bing Maps REST services from .NET</Description>
@ -13,8 +13,8 @@
<PackageTags>Microsoft "Bing Maps" Maps GIS Map Geospatial VB C# .NET REST</PackageTags>
<PackageReleaseNotes>See the changelog here: https://github.com/Microsoft/BingMapsRESTToolkit/blob/master/CHANGELOG.md</PackageReleaseNotes>
<PackageId>BingMapsRESTToolkit</PackageId>
<AssemblyVersion>1.1.3.0</AssemblyVersion>
<FileVersion>1.1.3.0</FileVersion>
<AssemblyVersion>1.1.4.0</AssemblyVersion>
<FileVersion>1.1.4.0</FileVersion>
<AssemblyName>BingMapsRESTToolkit</AssemblyName>
<RootNamespace>BingMapsRESTToolkit</RootNamespace>
</PropertyGroup>
@ -136,7 +136,6 @@
<Folder Include="Models\CustomMapStyles\" />
<Folder Include="Models\ResponseModels\" />
<Folder Include="Internal\" />
<Folder Include="Requests\" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -26,5 +26,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.3.0")]
[assembly: AssemblyFileVersion("1.1.3.0")]
[assembly: AssemblyVersion("1.1.4.0")]
[assembly: AssemblyFileVersion("1.1.4.0")]

Просмотреть файл

@ -23,7 +23,6 @@
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Threading.Tasks;
@ -42,6 +41,7 @@ namespace BingMapsRESTToolkit
/// </summary>
public IsochroneRequest(): base()
{
Optimize = RouteOptimizationType.Time;
TimeUnit = TimeUnitType.Second;
DistanceUnit = DistanceUnitType.Kilometers;
TravelMode = TravelModeType.Driving;
@ -66,6 +66,14 @@ namespace BingMapsRESTToolkit
/// </summary>
public double MaxDistance { get; set; }
/// <summary>
/// Specifies what parameters to use to optimize the isochrone route. One of the following values:
/// • distance: The route is calculated to minimize the distance. Traffic information is not used. Use with maxDistance.
/// • time [default]: The route is calculated to minimize the time. Traffic information is not used. Use with maxTime.
/// • timeWithTraffic: The route is calculated to minimize the time and uses current or predictive traffic information depending on if a dateTime value is specified. Use with maxTime.
/// </summary>
public RouteOptimizationType Optimize { get; set; }
/// <summary>
/// The units in which the maxTime value is specified. Default: Seconds
/// </summary>
@ -171,8 +179,11 @@ namespace BingMapsRESTToolkit
sb.AppendFormat(DateTimeFormatInfo.InvariantInfo, "&dt={0:G}", DateTime.Value);
}
//TODO: in the future expose the optimize option and add support for timeWithTraffic.
sb.AppendFormat("&optimize={0}", Enum.GetName(typeof(RouteOptimizationType), RouteOptimizationType.Time));
//Can only optimize based on time or time with traffic when generating time based isochrones.
if(Optimize != RouteOptimizationType.Time && Optimize != RouteOptimizationType.TimeWithTraffic)
{
Optimize = RouteOptimizationType.Time;
}
}
else if (MaxDistance > 0)
{
@ -182,13 +193,20 @@ namespace BingMapsRESTToolkit
}
sb.AppendFormat("&maxDistance={0}&distanceUnit={1}", MaxDistance, EnumHelper.DistanceUnitTypeToString(DistanceUnit));
sb.AppendFormat("&optimize={0}", Enum.GetName(typeof(RouteOptimizationType), RouteOptimizationType.Distance));
//Can only optimize based on distance when generating distance based isochrones.
if (Optimize != RouteOptimizationType.Distance)
{
Optimize = RouteOptimizationType.Distance;
}
}
else
{
throw new Exception("A max time or distance must be specified.");
}
sb.AppendFormat("&optimize={0}", Enum.GetName(typeof(RouteOptimizationType), Optimize));
//TODO: uncomment when/if avoid is supported.
//if (TravelMode == TravelModeType.Driving)
//{

Просмотреть файл

@ -35,6 +35,27 @@ namespace BingMapsRESTToolkit
/// </summary>
public class SnapToRoadRequest : BaseRestRequest
{
#region Private Properties
//TODO: Update max points in the future as these may increase. Monitor documentation.
/// <summary>
/// Maximum number of points supported in an asynchronous Snap to road request.
/// </summary>
private int maxAsyncPoints = 1000;
/// <summary>
/// Maximum number of points supported in a synchronous Snap to road request.
/// </summary>
private int maxSyncPoints = 100;
/// <summary>
/// The maximium distance in KM allowed between points.
/// </summary>
private double maxDistanceKmBetweenPoints = 2.5;
#endregion
#region Constructor
/// <summary>
@ -105,25 +126,22 @@ namespace BingMapsRESTToolkit
return await ServiceHelper.MakeAsyncPostRequest<Route>(requestUrl, requestBody, remainingTimeCallback);
}
/// <summary>
/// Gets the request URL to perform a query to snap points to roads. This method will only generate an post URL.
/// </summary>
/// <returns>A request URL to perform a query to snap points to roads.</returns>
public override string GetRequestUrl()
{
if (Points == null)
//https://dev.virtualearth.net/REST/v1/Routes/SnapToRoad?key=BingMapsKey
if (Points == null || Points.Count < 1)
{
throw new Exception("Points not specified.");
}
else if (Points.Count < 1)
else if (Points.Count > maxAsyncPoints)
{
throw new Exception("Not enough Points specified.");
}
else if (Points.Count > 100)
{
throw new Exception("More than 100 Points specified.");
throw new Exception(string.Format("More than {0} Points specified.", maxAsyncPoints));
}
if(TravelMode == TravelModeType.Transit)
@ -131,7 +149,20 @@ namespace BingMapsRESTToolkit
throw new Exception("Transit is not supported by SnapToRoad API.");
}
//https://dev.virtualearth.net/REST/v1/Routes/SnapToRoad?key=BingMapsKey
for(int i = 1; i < Points.Count; i++)
{
var d = SpatialTools.HaversineDistance(Points[i - 1], Points[i], DistanceUnitType.Kilometers);
if (d > maxDistanceKmBetweenPoints)
{
throw new Exception(string.Format("The distance between point {0} and point {1} is greater than {2} kilometers.", i-1, i, maxDistanceKmBetweenPoints));
}
}
if(Points.Count > maxSyncPoints)
{
//Make an async request.
return this.Domain + "Routes/SnapToRoadAsync?key=" + this.BingMapsKey;
}
return this.Domain + "Routes/SnapToRoad?key=" + this.BingMapsKey;
}