Finding the Starting Point of a Route
Nico Bontenbal shares a method for determining the starting point of a route by examining the pixels in the map image using Window API calls
Read the full article here: http://www.mp2kmag.com/articles.asp?...starting.point
http://www.mp2kmag.com/images/articles/nico/map2.gif
an alternative algorithm for finding the intersection route
Nico and I have communicated re the algorithm below privately, but I wished to make it public in hopes of obtaining some comments from others. It's in visual foxpro (which looks enough like VB that no one familiar with VB should have any trouble with it), and it's a function which returns a location object which represents the intersection points of 2 adjacent route segments.
In my limited testing it has worked well for me, but there's nothing like testing by others, so please do and let me know what you think.
Chip Orange
(corange@psc.state.fl.us or acorange@comcast.net)
---------
FUNCTION FindIntersection
* return the location object of an intersection of 2 roads, each represented by a location object somewhere on the road.
LPARAMETER oOrgLoc, oLoc, nMaxSecs
LOCAL oRoute, lnSeparation, lnLastSeparation
* now, walk the end point of our route back towards us until it stops moving
lnStartSecs = Seconds()
oRoute = goMap.ActiveRoute
lnSeparation = oOrgLoc.DistanceTo(oLoc)
lnLastSeparation = 100000
DO WHILE Abs(lnSeparation-lnLastSeparation) > 0.001 AND ;
Seconds()-lnStartSecs < nMaxSecs
oRoute.Clear
oRoute.Waypoints.Add( oOrgLoc)
oRoute.Waypoints.Add( oLoc)
oRoute.Calculate
lnLastSeparation = lnSeparation
* now move the end point closer to us by using the location object of the 2nd route segment as the next end point.
oLoc = oRoute.Directions(2).Location
lnSeparation = oOrgLoc.DistanceTo(oLoc)
* and now, if it hasn't moved much, it's as close to us on the MapPoint road as it's likely to get.
ENDDO
RETURN oLoc
Finding Starting Point of Route
DistanceTo will only be any good if you have no waypoint other than start and finish in the route(unless your using 2004 and this bug been Fixed??? Can anyone tell us)
Otherwise it should be fairly easy to iterate away from the centre point ( the location of the segment) until both ends are found, i.e there is no iteration that does not increase the distance from the route.
PC