示例#1
0
        private Location GetNextSteplocationOnRoute()
        {
            Location next_location   = new Location();
            double   dis_to_next_seg = distance_on_loc(CurrentLocation,
                                                       route[curRouteIndex + 1]);

            // check if the potential next step is out of
            // the range of current segment.
            double dis_walk_500ms = walkingSpeed / 2;

            if (dis_walk_500ms < dis_to_next_seg)
            {
                // current segment.
                double bearing = Bearing(route[curRouteIndex],
                                         route[curRouteIndex + 1]);

                bearing = Bearing(CurrentLocation, route[curRouteIndex + 1]);

                next_location = FindPointAtDistanceFrom(CurrentLocation,
                                                        bearing,
                                                        dis_walk_500ms);
            }
            else
            {
                // move to the next segment.
                curRouteIndex++;

                // the end of whole track.
                if (curRouteIndex >= route.Count - 1)
                {
                    if (EndOfRouteBehavior == EndOfRouteBehavior.Reverse)
                    {
                        // loop
                        curRouteIndex = 0;
                    }
                    else if (EndOfRouteBehavior == EndOfRouteBehavior.Reverse)
                    { // reverse the walk AB --> BA -->AB.
                        route.Reverse();
                        return(route[curRouteIndex]);
                    }
                    else
                    {
                        RoutingMode   = RoutingMode.Stopped;
                        curRouteIndex = 0;
                        return(CurrentLocation);
                    }
                }

                double mode_dis = dis_walk_500ms - dis_to_next_seg;
                double bearing  = Bearing(route[curRouteIndex],
                                          route[curRouteIndex + 1]);

                next_location = FindPointAtDistanceFrom(
                    route[curRouteIndex],
                    bearing,
                    mode_dis);
            }

            return(next_location);
        }