Share via


Waypoint.CalculatedLocation Property

Waypoint.CalculatedLocation Property

Represents the actual location (Location object) used for the specified waypoint when calculating the route. Ignored on input.


Public CalculatedLocation As Location


[C#]

public Location CalculatedLocation;

Remarks

  • For City and, in some cases, Normal snap types (SnapType enumerations), the route may be snapped when the route is calculated to a location other than the one passed in the Location property.

  • If the location used in the calculated route is the same as the one passed as the Location property, CalculatedLocation is null on output.

Example

[Visual Basic]

'Route between two locations, but specify that the
'end snaps to the edge of the city
Dim startLocation As New Location()
Dim endLocation As New Location()
startLocation.LatLong = New LatLong()
endLocation.LatLong = New LatLong()
startLocation.LatLong.Latitude = 40
startLocation.LatLong.Longitude = -120
endLocation.LatLong.Latitude = 41
endLocation.LatLong.Longitude = -121

Dim routeSegmentsSpec(1) As SegmentSpecification
routeSegmentsSpec(0) = New SegmentSpecification()
routeSegmentsSpec(0).Waypoint = New Waypoint()
routeSegmentsSpec(0).Waypoint.Name = "Start"
routeSegmentsSpec(0).Waypoint.Location = startLocation
routeSegmentsSpec(1) = New SegmentSpecification()
routeSegmentsSpec(1).Waypoint = New Waypoint()
routeSegmentsSpec(1).Waypoint.Name = "End"
routeSegmentsSpec(1).Waypoint.Snap = SnapType.City
routeSegmentsSpec(1).Waypoint.Location = endLocation

Dim routeSpec As New RouteSpecification()
routeSpec.DataSourceName = "MapPoint.NA"
routeSpec.Segments = routeSegmentsSpec

Dim myRoute As Route
myRoute = routeService.CalculateRoute(routeSpec)

'Output the start and end locations that were used
Console.WriteLine("Start: " + myRoute.Itinerary.Segments(0).Waypoint.Location.LatLong.Latitude.ToString() _
 + ", " + myRoute.Itinerary.Segments(0).Waypoint.Location.LatLong.Longitude.ToString())
Console.WriteLine("End: " + myRoute.Itinerary.Segments(1).Waypoint.CalculatedLocation.LatLong.Latitude.ToString() _
 + ", " + myRoute.Itinerary.Segments(1).Waypoint.CalculatedLocation.LatLong.Longitude.ToString())



[C#]

//Route between two locations, but specify that the
//end snaps to the edge of the city
Location startLocation = new Location();
Location endLocation = new Location();
startLocation.LatLong = new LatLong();
endLocation.LatLong = new LatLong();
startLocation.LatLong.Latitude = 40;
startLocation.LatLong.Longitude = -120;
endLocation.LatLong.Latitude = 41;
endLocation.LatLong.Longitude = -121;

SegmentSpecification[] routeSegmentsSpec = new SegmentSpecification[2];
routeSegmentsSpec[0] = new SegmentSpecification();
routeSegmentsSpec[0].Waypoint = new Waypoint();
routeSegmentsSpec[0].Waypoint.Name = "Start";
routeSegmentsSpec[0].Waypoint.Location = startLocation;
routeSegmentsSpec[1] = new SegmentSpecification();
routeSegmentsSpec[1].Waypoint = new Waypoint();
routeSegmentsSpec[1].Waypoint.Name = "End";
routeSegmentsSpec[1].Waypoint.Snap = SnapType.City;
routeSegmentsSpec[1].Waypoint.Location = endLocation;

RouteSpecification routeSpec = new RouteSpecification();
routeSpec.DataSourceName = "MapPoint.NA";
routeSpec.Segments = routeSegmentsSpec;

Route myRoute;
myRoute = routeService.CalculateRoute(routeSpec);

//Output the start and end locations that were used
Console.WriteLine("Start: " + myRoute.Itinerary.Segments[0].Waypoint.Location.LatLong.Latitude.ToString() 
 + ", " + myRoute.Itinerary.Segments[0].Waypoint.Location.LatLong.Longitude.ToString());
Console.WriteLine("End: " + myRoute.Itinerary.Segments[1].Waypoint.CalculatedLocation.LatLong.Latitude.ToString() 
 + ", " + myRoute.Itinerary.Segments[1].Waypoint.CalculatedLocation.LatLong.Longitude.ToString());


See Also

  Waypoint Class   |   Location Class   |   SnapType Enumeration   |   Waypoint.Location Property