Pitney Bowes MapXtreme User Manual
Page 378

Chapter 20: Routing
Updating a Request Using Routing Data
MapXtreme v7.1
385
Developer Guide
•
SegmentRelativeSpeedUpdate - Updates the speed of the segment with a change in speed.
The following sample shows how to increase the speed by 5 miles per hour (Velocity(5,
VelocityUnit.Mph)) for the specified route segment (T1256):
Public Shared Sub New_SegmentRelativeSpeedUpdate()
’ Create the velocity object
Dim velocity As Velocity = New Velocity(5, VelocityUnit.Mph)
’ Increase the speed by 5 mph.
Dim update As SegmentRelativeSpeedUpdate = New
SegmentRelativeSpeedUpdate("T1256", velocity)
End Sub
•
SegmentPercentageSpeedUpdate - Updates the speed of the segment with percentage of the
default speed.
The following sample shows how to increase the speed for the specified route segment by 20
percent (“S1256”, 20):
Public Shared Sub New_SegmentPercentageSpeedUpdate()
’ Increase the speed by 20 percent.
Dim update As SegmentPercentageSpeedUpdate = New
SegmentPercentageSpeedUpdate("S1256", 20)
End Sub
Using Transient Update to Modify a Point
After you get a route response, you may realize that the result contains some locations (points)
where you know traffic is slower or faster. You can use a transient update to set the speed of the
road segments closest to the point, recalculating the route for more accurate results. Use the
following classes to perform the various point transient updates:
•
PointSpeedUpdate - Updates the speed of the closest segment to the point with a new speed.
The following sample shows how to define a new speed of 50 miles per hour (Velocity(50,
VelocityUnit.Mph)) for the road closest to the defined point (pt):
Public Shared Sub New_PointSpeedUpdate()
’ Create a point
Dim coordSys As MapInfo.Geometry.CoordSys =
Session.Current.CoordSysFactory.CreateFromPrjString("1, 104")
Dim dpt As MapInfo.Geometry.DPoint = New MapInfo.Geometry.DPoint(-74,
42)
Dim pt As MapInfo.Geometry.Point = New
MapInfo.Geometry.Point(coordSys, dpt)
’ Create the velocity object
Dim velocity As Velocity = New Velocity(50, VelocityUnit.Mph)
’ Create the update object
Dim update As PointSpeedUpdate = New PointSpeedUpdate(pt, velocity)
End Sub