Beispiel #1
0
        public void TestOrientationFrcFoW()
        {
            var data = new byte[1];

            data[0] = 127;

            // orientation-frc-fow.
            OrientationConverter.Encode(Orientation.FirstToSecond, data, 0, 0);
            FunctionalRoadClassConvertor.Encode(FunctionalRoadClass.Frc3, data, 0, 2);
            FormOfWayConvertor.Encode(FormOfWay.Roundabout, data, 0, 5);
            Assert.AreEqual(92, data[0]);

            // frc-orientation-fow.
            data[0] = 127;
            FunctionalRoadClassConvertor.Encode(FunctionalRoadClass.Frc3, data, 0, 2);
            OrientationConverter.Encode(Orientation.FirstToSecond, data, 0, 0);
            FormOfWayConvertor.Encode(FormOfWay.Roundabout, data, 0, 5);
            Assert.AreEqual(92, data[0]);

            // frc-fow-orientation.
            data[0] = 127;
            FunctionalRoadClassConvertor.Encode(FunctionalRoadClass.Frc3, data, 0, 2);
            FormOfWayConvertor.Encode(FormOfWay.Roundabout, data, 0, 5);
            OrientationConverter.Encode(Orientation.FirstToSecond, data, 0, 0);
            Assert.AreEqual(92, data[0]);
        }
Beispiel #2
0
        /// <summary>
        /// Encodes a point along line location.
        /// </summary>
        public static byte[] Encode(PointAlongLineLocation location)
        {
            var data = new byte[17];

            var header = new Header();

            header.Version       = 3;
            header.HasAttributes = true;
            header.ArF0          = false;
            header.IsPoint       = true;
            header.ArF1          = false;
            HeaderConvertor.Encode(data, 0, header);
            CoordinateConverter.Encode(location.First.Coordinate, data, 1);
            FunctionalRoadClassConvertor.Encode(location.First.FuntionalRoadClass.Value, data, 7, 2);
            FormOfWayConvertor.Encode(location.First.FormOfWay.Value, data, 7, 5);
            FunctionalRoadClassConvertor.Encode(location.First.LowestFunctionalRoadClassToNext.Value, data, 8, 0);
            BearingConvertor.Encode(BearingConvertor.EncodeAngleToBearing(location.First.Bearing.Value), data, 8, 3);
            data[9] = DistanceToNextConvertor.Encode(location.First.DistanceToNext);

            CoordinateConverter.EncodeRelative(location.First.Coordinate, location.Last.Coordinate, data, 10);
            FunctionalRoadClassConvertor.Encode(location.Last.FuntionalRoadClass.Value, data, 14, 2);
            FormOfWayConvertor.Encode(location.Last.FormOfWay.Value, data, 14, 5);
            BearingConvertor.Encode(BearingConvertor.EncodeAngleToBearing(location.Last.Bearing.Value), data, 15, 3);

            OrientationConverter.Encode(location.Orientation.Value, data, 7, 0);
            SideOfRoadConverter.Encode(location.SideOfRoad.Value, data, 14, 0);
            if (location.PositiveOffsetPercentage.HasValue)
            { // positive offset percentage is present.
                OffsetConvertor.Encode(location.PositiveOffsetPercentage.Value, data, 16);
            }

            return(data);
        }
Beispiel #3
0
            public override bool ShouldAutorotateToInterfaceOrientation(UIInterfaceOrientation toInterfaceOrientation)
            {
                var requestedOrientation  = OrientationConverter.ToDisplayOrientation(toInterfaceOrientation);
                var supportedOrientations = (_gameViewController as iOSGameViewController).SupportedOrientations;

                return((supportedOrientations & requestedOrientation) != 0);
            }
Beispiel #4
0
        /// <summary>
        /// Decodes the given data into a location reference.
        /// </summary>
        public static PointAlongLineLocation Decode(byte[] data)
        {
            var pointAlongLine = new PointAlongLineLocation();

            // decode first location reference point.
            var first = new LocationReferencePoint();

            first.Coordinate         = CoordinateConverter.Decode(data, 1);
            first.FuntionalRoadClass = FunctionalRoadClassConvertor.Decode(data, 7, 2);
            first.FormOfWay          = FormOfWayConvertor.Decode(data, 7, 5);
            first.LowestFunctionalRoadClassToNext = FunctionalRoadClassConvertor.Decode(data, 8, 0);
            first.Bearing        = BearingConvertor.DecodeAngleFromBearing(BearingConvertor.Decode(data, 8, 3));
            first.DistanceToNext = DistanceToNextConvertor.Decode(data[9]);

            // decode second location reference point.
            var last = new LocationReferencePoint();

            last.Coordinate         = CoordinateConverter.DecodeRelative(first.Coordinate, data, 10);
            last.FuntionalRoadClass = FunctionalRoadClassConvertor.Decode(data, 14, 2);
            last.FormOfWay          = FormOfWayConvertor.Decode(data, 14, 5);
            last.Bearing            = BearingConvertor.DecodeAngleFromBearing(BearingConvertor.Decode(data, 15, 3));

            pointAlongLine.First       = first;
            pointAlongLine.Orientation = OrientationConverter.Decode(data, 7, 0);
            pointAlongLine.SideOfRoad  = SideOfRoadConverter.Decode(data, 14, 0);
            pointAlongLine.PositiveOffsetPercentage = OffsetConvertor.Decode(data, 16);
            pointAlongLine.Last = last;

            return(pointAlongLine);
        }
    public Robot InitializeRobot(string position)
    {
        string[] parsedPositions = position.Split(" ");
        int      x           = int.Parse(parsedPositions[0]);
        int      y           = int.Parse(parsedPositions[1]);
        float    orientation = OrientationConverter.CardinalToDegrees(parsedPositions[2]);

        Robot robot = new Robot(x, y, orientation);

        return(robot);
    }
        public void TestDecoding1()
        {
            Assert.Catch <ArgumentOutOfRangeException>(() =>
            {
                OrientationConverter.Decode(new byte[] { 0 }, 10);
            });

            Assert.AreEqual(Orientation.NoOrientation, OrientationConverter.Decode(new byte[] { 0 }, 0, 0));
            Assert.AreEqual(Orientation.FirstToSecond, OrientationConverter.Decode(new byte[] { 1 }, 0, 6));
            Assert.AreEqual(Orientation.SecondToFirst, OrientationConverter.Decode(new byte[] { 2 }, 0, 6));
            Assert.AreEqual(Orientation.BothDirections, OrientationConverter.Decode(new byte[] { 3 }, 0, 6));
        }
Beispiel #7
0
    public string GetPosition()
    {
        StringBuilder builder = new StringBuilder();

        builder.Append(x).Append(" ").Append(y).Append(" ").Append(OrientationConverter.DegreesToCardinal(orientation));
        if (lost)
        {
            builder.Append(" ").Append("LOST");
        }

        return(builder.ToString());
    }
        public void TestEncoding1()
        {
            var data = new byte[1];

            Assert.Catch <ArgumentOutOfRangeException>(() =>
            {
                OrientationConverter.Encode(Orientation.NoOrientation, data, 0, 10);
            });

            OrientationConverter.Encode(Orientation.NoOrientation, data, 0, 6);
            Assert.AreEqual(0, data[0]);
            OrientationConverter.Encode(Orientation.FirstToSecond, data, 0, 6);
            Assert.AreEqual(1, data[0]);
            OrientationConverter.Encode(Orientation.SecondToFirst, data, 0, 6);
            Assert.AreEqual(2, data[0]);
            OrientationConverter.Encode(Orientation.BothDirections, data, 0, 6);
            Assert.AreEqual(3, data[0]);
        }
Beispiel #9
0
        /// <summary>
        /// Decodes the given data into a location reference.
        /// </summary>
        public static PoiWithAccessPointLocation Decode(byte[] data)
        {
            // decode first location reference point.
            var first = new LocationReferencePoint();

            first.Coordinate = CoordinateConverter.Decode(data, 1);
            var orientation = OrientationConverter.Decode(data, 7, 0);

            first.FuntionalRoadClass = FunctionalRoadClassConvertor.Decode(data, 7, 2);
            first.FormOfWay          = FormOfWayConvertor.Decode(data, 7, 5);
            first.LowestFunctionalRoadClassToNext = FunctionalRoadClassConvertor.Decode(data, 8, 0);
            first.Bearing        = BearingConvertor.DecodeAngleFromBearing(BearingConvertor.Decode(data, 8, 3));
            first.DistanceToNext = DistanceToNextConvertor.Decode(data[9]);

            // decode last location reference point.
            var last = new LocationReferencePoint();

            // no last coordinates, identical to the first.
            last.Coordinate = CoordinateConverter.DecodeRelative(first.Coordinate, data, 10);
            var sideOfRoad = SideOfRoadConverter.Decode(data, 14, 0);

            last.FuntionalRoadClass = FunctionalRoadClassConvertor.Decode(data, 14, 2);
            last.FormOfWay          = FormOfWayConvertor.Decode(data, 14, 5);
            last.Bearing            = BearingConvertor.DecodeAngleFromBearing(BearingConvertor.Decode(data, 15, 3));

            // poi details.
            var coordinate = CoordinateConverter.DecodeRelative(first.Coordinate, data, 17);

            // create line location.
            var poiWithAccessPointLocation = new PoiWithAccessPointLocation();

            poiWithAccessPointLocation.First          = first;
            poiWithAccessPointLocation.Last           = last;
            poiWithAccessPointLocation.Coordinate     = coordinate;
            poiWithAccessPointLocation.Orientation    = orientation;
            poiWithAccessPointLocation.PositiveOffset = null;
            poiWithAccessPointLocation.SideOfRoad     = sideOfRoad;
            return(poiWithAccessPointLocation);
        }
Beispiel #10
0
        public void degreesToCardinalTest(float orientation, string expect)
        {
            string result = OrientationConverter.DegreesToCardinal(orientation);

            Assert.Equal(expect, result);
        }
Beispiel #11
0
        public void orintationTest(string orientation, float expect)
        {
            float result = OrientationConverter.CardinalToDegrees(orientation);

            Assert.Equal(expect, result);
        }
Beispiel #12
0
 public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations()
 {
     return(OrientationConverter.ToUIInterfaceOrientationMask((_gameViewController as iOSGameViewController).SupportedOrientations));
 }