Share via


RouteServiceSoap.CalculateSimpleRoute Method

RouteServiceSoap.CalculateSimpleRoute Method

Calculates the itinerary of a route based on an array of latitude and longitude


Public Function CalculateSimpleRoute ( 
  ByVal latLongs As LatLong(),
  ByVal dataSourceName As System.String, 
  ByVal preference As SegmentPreference )
  As Route


[C#]

public Route CalculateSimpleRoute
  ( LatLong[] latLongs ,
  System.String dataSourceName ,
  SegmentPreference preference );

Parameters

  • latLongs
    An array of up to 50 latitude and longitude coordinates (LatLong[] objects); that is, the start point, intermediate stops, and end point of the route.
  • dataSourceName
    A string representing the name of the data source (DataSource.Name property) in which the latitude and longitude coordinates are located. String.
  • preference
    The preference (SegmentPreference enumeration) as to how the route should be calculated.

Remarks

  • The order of the stops in the route itinerary matches the order of the latitude and longitude coordinates passed in the latLongs array.

  • When CalculateSimpleRoute is called, the Route.Itinerary Property is generated. The resulting Route.Itinerary object contains the directions, map view representations, and summary information about the route.

  • The dataSourceName parameter must represent a data source with a DataSource.Capability property value of CanRoute.

  • For more information about MapPoint Web Service data sources, see MapPoint Web Service Data Sources and Capabilities.

  • To retrieve a list of data sources and their capabilities, use the CommonServiceSoap.GetDataSourceInfo method.

  • Routing is limited to areas for which the specified data source has street and/or major road information. For more information, see MapPoint.BR Data Source, MapPoint.EU Data Source, and MapPoint.NA Data Source.

  • The total distance of a route cannot be longer than 50,000 kilometers; otherwise, a SOAP fault is returned.

  • To calculate a route based on specified route segments and other preferences, use the RouteServiceSoap.CalculateRoute method.

  • When a RouteSpecification object is returned from the RouteServiceSoap.CalculateSimpleRoute method, the DriverProfile property contains the default values of 9:00 A.M. to 5:00 P.M.

Example

[Visual Basic]

'Calculate a route between two latitude and longitude coordinates 
'and print instructions
Dim latLongs(1) As LatLong
latLongs(0) = New LatLong()
latLongs(0).Latitude = 40
latLongs(0).Longitude = -120
latLongs(1) = New LatLong()
latLongs(1).Latitude = 41
latLongs(1).Longitude = -121

Dim routeService As New RouteServiceSoap()
Dim myRoute As Route
myRoute = routeService.CalculateSimpleRoute(latLongs, "MapPoint.NA", SegmentPreference.Quickest)

Dim i As Integer
For i = 0 To myRoute.Itinerary.Segments(0).Directions.Length - 1
 Console.WriteLine(myRoute.Itinerary.Segments(0).Directions(i).Instruction)
Next i



[C#]

//Calculate a route between two latitude and longitude coordinates
//and print instructions 
LatLong[] latLongs = new LatLong[2];
latLongs[0] = new LatLong();
latLongs[0].Latitude = 40;
latLongs[0].Longitude = -120;
latLongs[1] = new LatLong();
latLongs[1].Latitude = 41;
latLongs[1].Longitude = -121;

RouteServiceSoap routeService = new RouteServiceSoap();
Route myRoute;
myRoute = routeService.CalculateSimpleRoute(latLongs, "MapPoint.NA", SegmentPreference.Quickest);

for(int i = 0; i < myRoute.Itinerary.Segments[0].Directions.Length ; i++)
{
 Console.WriteLine(myRoute.Itinerary.Segments[0].Directions[i].Instruction);
}


See Also

  RouteServiceSoap Class   |   Route Class   |   LatLong Class   |   DataSource Class   |   SegmentPreference Enumeration