コード例 #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);
        }
コード例 #2
0
        public void TestDecoding1()
        {
            Assert.Catch <ArgumentOutOfRangeException>(() =>
            {
                SideOfRoadConverter.Decode(new byte[] { 0 }, 10);
            });

            Assert.AreEqual(SideOfRoad.OnOrAbove, SideOfRoadConverter.Decode(new byte[] { 0 }, 0, 0));
            Assert.AreEqual(SideOfRoad.Right, SideOfRoadConverter.Decode(new byte[] { 1 }, 0, 6));
            Assert.AreEqual(SideOfRoad.Left, SideOfRoadConverter.Decode(new byte[] { 2 }, 0, 6));
            Assert.AreEqual(SideOfRoad.Both, SideOfRoadConverter.Decode(new byte[] { 3 }, 0, 6));
        }
コード例 #3
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);
        }