Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public void TestDecoding1()
        {
            Assert.Catch <ArgumentOutOfRangeException>(() =>
            {
                FormOfWayConvertor.Decode(new byte[] { 0 }, 6);
            });

            Assert.AreEqual(FormOfWay.Undefined, FormOfWayConvertor.Decode(new byte[] { 0 }, 0, 0));
            Assert.AreEqual(FormOfWay.Undefined, FormOfWayConvertor.Decode(new byte[] { 0 }, 5));
            Assert.AreEqual(FormOfWay.Motorway, FormOfWayConvertor.Decode(new byte[] { 1 }, 5));
            Assert.AreEqual(FormOfWay.MultipleCarriageWay, FormOfWayConvertor.Decode(new byte[] { 2 }, 5));
            Assert.AreEqual(FormOfWay.SingleCarriageWay, FormOfWayConvertor.Decode(new byte[] { 3 }, 5));
            Assert.AreEqual(FormOfWay.Roundabout, FormOfWayConvertor.Decode(new byte[] { 4 }, 5));
            Assert.AreEqual(FormOfWay.TrafficSquare, FormOfWayConvertor.Decode(new byte[] { 5 }, 5));
            Assert.AreEqual(FormOfWay.SlipRoad, FormOfWayConvertor.Decode(new byte[] { 6 }, 5));
            Assert.AreEqual(FormOfWay.Other, FormOfWayConvertor.Decode(new byte[] { 7 }, 5));

            Assert.AreEqual(FormOfWay.Undefined, FormOfWayConvertor.Decode(new byte[] { 0 }, 4));
            Assert.AreEqual(FormOfWay.Motorway, FormOfWayConvertor.Decode(new byte[] { 2 }, 4));
            Assert.AreEqual(FormOfWay.MultipleCarriageWay, FormOfWayConvertor.Decode(new byte[] { 4 }, 4));
            Assert.AreEqual(FormOfWay.SingleCarriageWay, FormOfWayConvertor.Decode(new byte[] { 6 }, 4));
            Assert.AreEqual(FormOfWay.Roundabout, FormOfWayConvertor.Decode(new byte[] { 8 }, 4));
            Assert.AreEqual(FormOfWay.TrafficSquare, FormOfWayConvertor.Decode(new byte[] { 10 }, 4));
            Assert.AreEqual(FormOfWay.SlipRoad, FormOfWayConvertor.Decode(new byte[] { 12 }, 4));
            Assert.AreEqual(FormOfWay.Other, FormOfWayConvertor.Decode(new byte[] { 14 }, 4));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Decodes the given data into a location reference.
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        protected override ClosedLineLocation Decode(byte[] data)
        {
            // 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]);

            // calculate the intermediate points count.
            var intermediateList = new List <LocationReferencePoint>();
            int intermediates    = (data.Length - 12) / 7;
            int location         = 10;
            var reference        = first.Coordinate; // the reference for the relative coordinates.

            for (int idx = 0; idx < intermediates; idx++)
            {
                // create an intermediate point.
                var intermediate = new LocationReferencePoint();
                intermediate.Coordinate = CoordinateConverter.DecodeRelative(reference, data, location);
                reference = intermediate.Coordinate;
                location  = location + 4;
                intermediate.FuntionalRoadClass = FunctionalRoadClassConvertor.Decode(data, location, 2);
                intermediate.FormOfWay          = FormOfWayConvertor.Decode(data, location, 5);
                location             = location + 1;
                intermediate.Bearing = BearingConvertor.DecodeAngleFromBearing(BearingConvertor.Decode(data, location, 3));
                intermediate.LowestFunctionalRoadClassToNext = FunctionalRoadClassConvertor.Decode(data, location, 0);
                location = location + 1;
                intermediate.DistanceToNext = DistanceToNextConvertor.Decode(data[location]);
                location = location + 1;

                intermediateList.Add(intermediate);
            }

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

            // no last coordinates, identical to the first.
            last.Coordinate         = first.Coordinate;
            last.FuntionalRoadClass = FunctionalRoadClassConvertor.Decode(data, location, 2);
            last.FormOfWay          = FormOfWayConvertor.Decode(data, location, 5);
            location = location + 1;
            last.LowestFunctionalRoadClassToNext = FunctionalRoadClassConvertor.Decode(data, location, 0);
            last.Bearing = BearingConvertor.DecodeAngleFromBearing(BearingConvertor.Decode(data, location, 3));
            location     = location + 1;

            // create line location.
            var lineLocation = new ClosedLineLocation();

            lineLocation.First        = first;
            lineLocation.Intermediate = intermediateList.ToArray();
            lineLocation.Last         = last;
            return(lineLocation);
        }
Exemplo n.º 4
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);
        }