Esempio n. 1
0
        private RoadNetworkView With(AddRoadSegment command)
        {
            var attributeHash = AttributeHash.None
                                .With(command.AccessRestriction)
                                .With(command.Category)
                                .With(command.Morphology)
                                .With(command.Status)
                                .WithLeftSide(command.LeftSideStreetNameId)
                                .WithRightSide(command.RightSideStreetNameId)
                                .With(command.MaintenanceAuthority);

            return(new RoadNetworkView(
                       _nodes
                       .TryReplace(command.StartNodeId, node => node.ConnectWith(command.Id))
                       .TryReplace(command.EndNodeId, node => node.ConnectWith(command.Id)),
                       _segments.Add(command.Id,
                                     new RoadSegment(command.Id, command.Geometry, command.StartNodeId, command.EndNodeId,
                                                     attributeHash)),
                       _maximumNodeId,
                       RoadSegmentId.Max(command.Id, _maximumSegmentId),
                       _maximumGradeSeparatedJunctionId,
                       _maximumEuropeanRoadAttributeId,
                       _maximumNationalRoadAttributeId,
                       _maximumNumberedRoadAttributeId,
                       _maximumLaneAttributeId,
                       _maximumWidthAttributeId,
                       _maximumSurfaceAttributeId,
                       _segmentReusableLaneAttributeIdentifiers.AddOrMergeDistinct(command.Id, command.Lanes.Select(lane => new AttributeId(lane.Id))),
                       _segmentReusableWidthAttributeIdentifiers.AddOrMergeDistinct(command.Id, command.Widths.Select(width => new AttributeId(width.Id))),
                       _segmentReusableSurfaceAttributeIdentifiers.AddOrMergeDistinct(command.Id, command.Surfaces.Select(surface => new AttributeId(surface.Id)))
                       ));
        }
        public RequestedChanges Append(AddRoadSegment change)
        {
            if (change == null)
            {
                throw new ArgumentNullException(nameof(change));
            }

            return(new RequestedChanges(
                       _changes.Add(change),
                       _mapToPermanentNodeIdentifiers,
                       _mapToTemporaryNodeIdentifiers,
                       _mapToPermanentSegmentIdentifiers.Add(change.TemporaryId, change.Id),
                       _mapToTemporarySegmentIdentifiers.Add(change.Id, change.TemporaryId),
                       _mapToPermanentGradeSeparatedJunctionIdentifiers,
                       _mapToTemporaryGradeSeparatedJunctionIdentifiers));
        }