示例#1
0
        public RoadSegment(RoadSegmentId id, MultiLineString geometry, RoadNodeId start, RoadNodeId end, AttributeHash attributeHash)
        {
            if (geometry == null)
            {
                throw new ArgumentNullException(nameof(geometry));
            }
            if (start == end)
            {
                throw new ArgumentException("The start and end can not be the same road node.", nameof(start));
            }

            Id            = id;
            Geometry      = geometry;
            Start         = start;
            End           = end;
            AttributeHash = attributeHash;
        }
        public RoadSegmentTests()
        {
            var fixture = new Fixture();

            fixture.CustomizePolylineM();
            fixture.CustomizeRoadNodeId();
            fixture.CustomizeRoadSegmentId();
            fixture.CustomizeRoadSegmentCategory();
            fixture.CustomizeRoadSegmentMorphology();
            fixture.CustomizeRoadSegmentStatus();
            fixture.CustomizeRoadSegmentAccessRestriction();
            fixture.CustomizeOrganizationId();
            fixture.CustomizeAttributeHash();
            _id            = fixture.Create <RoadSegmentId>();
            _start         = fixture.Create <RoadNodeId>();
            _end           = fixture.Create <RoadNodeId>();
            _geometry      = fixture.Create <MultiLineString>();
            _attributeHash = fixture.Create <AttributeHash>();
            _sut           = new RoadSegment(_id, _geometry, _start, _end, _attributeHash);
        }
示例#3
0
        public RoadNetworkView RestoreFromSnapshot(Messages.RoadNetworkSnapshot snapshot)
        {
            if (snapshot == null)
            {
                throw new ArgumentNullException(nameof(snapshot));
            }

            return(new RoadNetworkView(
                       snapshot.Nodes.ToImmutableDictionary(node => new RoadNodeId(node.Id),
                                                            node => new RoadNode(new RoadNodeId(node.Id), GeometryTranslator.Translate(node.Geometry))),
                       snapshot.Segments.ToImmutableDictionary(segment => new RoadSegmentId(segment.Id),
                                                               segment => new RoadSegment(new RoadSegmentId(segment.Id),
                                                                                          GeometryTranslator.Translate(segment.Geometry), new RoadNodeId(segment.StartNodeId),
                                                                                          new RoadNodeId(segment.EndNodeId), AttributeHash.FromHashCode(segment.AttributeHash))),
                       new RoadNodeId(snapshot.MaximumNodeId),
                       new RoadSegmentId(snapshot.MaximumSegmentId),
                       new GradeSeparatedJunctionId(snapshot.MaximumGradeSeparatedJunctionId),
                       new AttributeId(snapshot.MaximumEuropeanRoadAttributeId),
                       new AttributeId(snapshot.MaximumNationalRoadAttributeId),
                       new AttributeId(snapshot.MaximumNumberedRoadAttributeId),
                       new AttributeId(snapshot.MaximumLaneAttributeId),
                       new AttributeId(snapshot.MaximumWidthAttributeId),
                       new AttributeId(snapshot.MaximumSurfaceAttributeId),
                       snapshot.SegmentReusableLaneAttributeIdentifiers.ToImmutableDictionary(
                           segment => new RoadSegmentId(segment.SegmentId),
                           segment => (IReadOnlyList <AttributeId>)segment.ReusableAttributeIdentifiers
                           .Select(identifier => new AttributeId(identifier)).ToArray()),
                       snapshot.SegmentReusableWidthAttributeIdentifiers.ToImmutableDictionary(
                           segment => new RoadSegmentId(segment.SegmentId),
                           segment => (IReadOnlyList <AttributeId>)segment.ReusableAttributeIdentifiers
                           .Select(identifier => new AttributeId(identifier)).ToArray()),
                       snapshot.SegmentReusableSurfaceAttributeIdentifiers.ToImmutableDictionary(
                           segment => new RoadSegmentId(segment.SegmentId),
                           segment => (IReadOnlyList <AttributeId>)segment.ReusableAttributeIdentifiers
                           .Select(identifier => new AttributeId(identifier)).ToArray())
                       ));
        }