public void ItShouldReturnLatIfMeterIsZero()
        {
            //Arrange
            double inputLat   = 71.639566053691;
            double inputMeter = 0;

            //Act
            double result = LocationCalculator.MoveY(inputLat, inputMeter);

            //Assert
            Assert.True(result == inputLat);
        }
예제 #2
0
        public static GeoPoint Move(GeoPoint startingPosition, IEnumerable <SantaMovement> movements)
        {
            GeoPoint currentPosition = startingPosition;
            GeoPoint newPosition     = new GeoPoint(0, 0);

            foreach (SantaMovement move in movements)
            {
                double xMeters = 0d;
                double yMeters = 0d;

                switch (move.Direction)
                {
                case "left":
                    xMeters -= move.Value;
                    break;

                case "right":
                    xMeters += move.Value;
                    break;

                case "up":
                    yMeters += move.Value;
                    break;

                case "down":
                    yMeters -= move.Value;
                    break;

                default:
                    throw new Exception("direction not supported");
                }

                newPosition.lon = LocationCalculator.MoveX(currentPosition.lon, xMeters, currentPosition.lat);
                newPosition.lat = LocationCalculator.MoveY(currentPosition.lat, yMeters);

                currentPosition = new GeoPoint(newPosition.lat, newPosition.lon);
            }

            return(currentPosition);
        }