Esempio n. 1
0
 public NavStackNode(string type, string subtype, CoordinateDto location, int floor, int toFloor)
 {
     this.type = type;
     this.subtype = subtype;
     this.location = location;
     this.floor = floor;
     this.toFloor = toFloor;
 }
Esempio n. 2
0
        public RouteDto addOutdoorTransisiton(NavType type, CoordinateDto location, int floor)
        {
            string subtype = NavStackNode.TYPE_WALKING;

            switch (type)
            {
                case NavType.Walking:
                    subtype = NavStackNode.TYPE_WALKING;
                    break;
            }

            NavStackNode vert = new NavStackNode(NavStackNode.TYPE_OUTDOOR, subtype, location, floor, 0);
            navStack.Add(vert);

            return this;
        }
Esempio n. 3
0
        /// <summary>
        /// Add the next coordinate to the path and get the turn code that it took to get there:
        /// 
        ///    -2 = right 90 deg
        ///    -1 = right 45 deg
        ///     0 = straight (no change in vector)
        ///     1 = left 45 deg
        ///     2 = left 90 deg
        /// 
        /// </summary>
        /// <param name="newCoordiante"></param>
        /// <returns></returns>
        public string getNext(CoordinateDto newCoordiante)
        {
            int deltaX = newCoordiante.X - _lastCoordinate.X;
            int deltaY = newCoordiante.Y - _lastCoordinate.Y;
            _lastCoordinate = newCoordiante;

            string key = deltaX + "" + deltaY;

            // if we did not have to turn to get this coordinate, return 0
            if (key.Equals(_turns[_currentIndex]))
            {
                return NavStackNode.TYPE_STRAIGHT;
            }

            // look to the right and to the left of our last position by one
            // until we find the new one
            for (int i = 1; i < _turns.Count(); i++)
            {
                int right = wrapIndex(_currentIndex + i);
                int left = wrapIndex(_currentIndex - i);

                if (key.Equals(_turns[right]))
                {
                    _currentIndex = right;
                    return i == 1 ? NavStackNode.TYPE_ANGLE_LEFT : NavStackNode.TYPE_LEFT;
                }

                if (key.Equals(_turns[left]))
                {
                    _currentIndex = left;
                    return i == 1 ? NavStackNode.TYPE_ANGLE_RIGHT : NavStackNode.TYPE_RIGHT;
                }
            }

            return NavStackNode.TYPE_STRAIGHT;
        }
Esempio n. 4
0
        public RouteDto addVerticalTransisiton(NavType type, CoordinateDto location, int floor, int toFloor)
        {
            string subtype = "";

            string direction = (floor - toFloor) > 0 ? "-down" : "-up";

            switch (type)
            {
                case NavType.Stair:
                    subtype = NavStackNode.TYPE_STAIRS;
                    break;
                case NavType.Elevator:
                    subtype = NavStackNode.TYPE_ELEVATOR;
                    break;
                case NavType.Escalator:
                    subtype = NavStackNode.TYPE_ESCALATOR;
                    break;
            }

            subtype += (floor - toFloor) > 0 ? "-down" : "-up";

            NavStackNode vert = new NavStackNode(NavStackNode.TYPE_VERTICAL, subtype, location, floor, toFloor);
            navStack.Add(vert);

            return this;
        }
Esempio n. 5
0
 private double distance(CoordinateDto c1, CoordinateDto c2)
 {
     return Math.Sqrt(Math.Pow(c1.X - c2.X, 2) + Math.Pow(c1.Y - c2.Y, 2));
 }
Esempio n. 6
0
 /// <summary>
 /// Constructs a new TurnWheel and initializes the vector form the first two points
 /// </summary>
 /// <param name="c1"></param>
 /// <param name="c2"></param>
 public TurnWheel(CoordinateDto c1, CoordinateDto c2)
 {
     _lastCoordinate = c1;
     getNext(c2);
 }