Exemplo n.º 1
0
 private RoadNetworkView(
     ImmutableDictionary <RoadNodeId, RoadNode> nodes,
     ImmutableDictionary <RoadSegmentId, RoadSegment> segments,
     RoadNodeId maximumNodeId,
     RoadSegmentId maximumSegmentId,
     GradeSeparatedJunctionId maximumGradeSeparatedJunctionId,
     AttributeId maximumEuropeanRoadAttributeId,
     AttributeId maximumNationalRoadAttributeId,
     AttributeId maximumNumberedRoadAttributeId,
     AttributeId maximumLaneAttributeId,
     AttributeId maximumWidthAttributeId,
     AttributeId maximumSurfaceAttributeId,
     ImmutableDictionary <RoadSegmentId, IReadOnlyList <AttributeId> > segmentReusableLaneAttributeIdentifiers,
     ImmutableDictionary <RoadSegmentId, IReadOnlyList <AttributeId> > segmentReusableWidthAttributeIdentifiers,
     ImmutableDictionary <RoadSegmentId, IReadOnlyList <AttributeId> > segmentReusableSurfaceAttributeIdentifiers)
 {
     _nodes            = nodes;
     _segments         = segments;
     _maximumNodeId    = maximumNodeId;
     _maximumSegmentId = maximumSegmentId;
     _maximumGradeSeparatedJunctionId            = maximumGradeSeparatedJunctionId;
     _maximumEuropeanRoadAttributeId             = maximumEuropeanRoadAttributeId;
     _maximumNationalRoadAttributeId             = maximumNationalRoadAttributeId;
     _maximumNumberedRoadAttributeId             = maximumNumberedRoadAttributeId;
     _maximumLaneAttributeId                     = maximumLaneAttributeId;
     _maximumWidthAttributeId                    = maximumWidthAttributeId;
     _maximumSurfaceAttributeId                  = maximumSurfaceAttributeId;
     _segmentReusableLaneAttributeIdentifiers    = segmentReusableLaneAttributeIdentifiers;
     _segmentReusableWidthAttributeIdentifiers   = segmentReusableWidthAttributeIdentifiers;
     _segmentReusableSurfaceAttributeIdentifiers = segmentReusableSurfaceAttributeIdentifiers;
 }
Exemplo n.º 2
0
            public GradeSeparatedJunctionId Next()
            {
                var next = _current.Next();

                _current = next;
                return(next);
            }
 public AddGradeSeparatedJunction(
     GradeSeparatedJunctionId temporaryId,
     GradeSeparatedJunctionType type,
     RoadSegmentId upperSegmentId,
     RoadSegmentId lowerSegmentId)
 {
     TemporaryId    = temporaryId;
     Type           = type ?? throw new ArgumentNullException(nameof(type));
     UpperSegmentId = upperSegmentId;
     LowerSegmentId = lowerSegmentId;
 }
Exemplo n.º 4
0
        // grade separated junction

        public static FileError IdentifierNotUnique(this IDbaseFileRecordProblemBuilder builder,
                                                    GradeSeparatedJunctionId identifier,
                                                    RecordNumber takenByRecordNumber)
        {
            return(builder
                   .Error(nameof(IdentifierNotUnique))
                   .WithParameters(
                       new ProblemParameter("Identifier", identifier.ToString()),
                       new ProblemParameter("TakenByRecordNumber", takenByRecordNumber.ToString())
                       )
                   .Build());
        }
Exemplo n.º 5
0
        private RoadNetworkView With(AddGradeSeparatedJunction command)
        {
            var id = new GradeSeparatedJunctionId(command.Id);

            return(new RoadNetworkView(
                       _nodes,
                       _segments,
                       _maximumNodeId,
                       _maximumSegmentId,
                       GradeSeparatedJunctionId.Max(id, _maximumGradeSeparatedJunctionId),
                       _maximumEuropeanRoadAttributeId,
                       _maximumNationalRoadAttributeId,
                       _maximumNumberedRoadAttributeId,
                       _maximumLaneAttributeId,
                       _maximumWidthAttributeId,
                       _maximumSurfaceAttributeId,
                       _segmentReusableLaneAttributeIdentifiers,
                       _segmentReusableWidthAttributeIdentifiers,
                       _segmentReusableSurfaceAttributeIdentifiers));
        }
Exemplo n.º 6
0
        private RoadNetworkView Given(Messages.GradeSeparatedJunctionAdded @event)
        {
            var id = new GradeSeparatedJunctionId(@event.Id);

            return(new RoadNetworkView(
                       _nodes,
                       _segments,
                       _maximumNodeId,
                       _maximumSegmentId,
                       GradeSeparatedJunctionId.Max(id, _maximumGradeSeparatedJunctionId),
                       _maximumEuropeanRoadAttributeId,
                       _maximumNationalRoadAttributeId,
                       _maximumNumberedRoadAttributeId,
                       _maximumLaneAttributeId,
                       _maximumWidthAttributeId,
                       _maximumSurfaceAttributeId,
                       _segmentReusableLaneAttributeIdentifiers,
                       _segmentReusableWidthAttributeIdentifiers,
                       _segmentReusableSurfaceAttributeIdentifiers));
        }
Exemplo n.º 7
0
        private AddGradeSeparatedJunction Translate(Messages.AddGradeSeparatedJunction command, IRequestedChangeIdentityTranslator translator)
        {
            var permanent = _nextGradeSeparatedJunctionId();
            var temporary = new GradeSeparatedJunctionId(command.TemporaryId);

            var           upperSegmentId = new RoadSegmentId(command.UpperSegmentId);
            RoadSegmentId?temporaryUpperSegmentId;

            if (translator.TryTranslateToPermanent(upperSegmentId, out var permanentUpperSegmentId))
            {
                temporaryUpperSegmentId = upperSegmentId;
                upperSegmentId          = permanentUpperSegmentId;
            }
            else
            {
                temporaryUpperSegmentId = null;
            }

            var           lowerSegmentId = new RoadSegmentId(command.LowerSegmentId);
            RoadSegmentId?temporaryLowerSegmentId;

            if (translator.TryTranslateToPermanent(lowerSegmentId, out var permanentLowerSegmentId))
            {
                temporaryLowerSegmentId = lowerSegmentId;
                lowerSegmentId          = permanentLowerSegmentId;
            }
            else
            {
                temporaryLowerSegmentId = null;
            }

            return(new AddGradeSeparatedJunction(
                       permanent,
                       temporary,
                       GradeSeparatedJunctionType.Parse(command.Type),
                       upperSegmentId,
                       temporaryUpperSegmentId,
                       lowerSegmentId,
                       temporaryLowerSegmentId));
        }
Exemplo n.º 8
0
        public RoadNetworkView Given(Messages.ImportedGradeSeparatedJunction @event)
        {
            if (@event == null)
            {
                throw new ArgumentNullException(nameof(@event));
            }
            var id = new GradeSeparatedJunctionId(@event.Id);

            return(new RoadNetworkView(
                       _nodes,
                       _segments,
                       _maximumNodeId,
                       _maximumSegmentId,
                       GradeSeparatedJunctionId.Max(id, _maximumGradeSeparatedJunctionId),
                       _maximumEuropeanRoadAttributeId,
                       _maximumNationalRoadAttributeId,
                       _maximumNumberedRoadAttributeId,
                       _maximumLaneAttributeId,
                       _maximumWidthAttributeId,
                       _maximumSurfaceAttributeId,
                       _segmentReusableLaneAttributeIdentifiers,
                       _segmentReusableWidthAttributeIdentifiers,
                       _segmentReusableSurfaceAttributeIdentifiers));
        }
        public ZipArchiveProblems Validate(ZipArchiveEntry entry, IDbaseRecordEnumerator <GradeSeparatedJunctionChangeDbaseRecord> records)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }

            var problems = ZipArchiveProblems.None;

            try
            {
                var identifiers = new Dictionary <GradeSeparatedJunctionId, RecordNumber>();
                var moved       = records.MoveNext();
                if (moved)
                {
                    while (moved)
                    {
                        var recordContext = entry.AtDbaseRecord(records.CurrentRecordNumber);
                        var record        = records.Current;
                        if (record != null)
                        {
                            if (!record.RECORDTYPE.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.RECORDTYPE.Field);
                            }
                            else
                            {
                                if (!RecordType.ByIdentifier.ContainsKey(record.RECORDTYPE.Value))
                                {
                                    problems += recordContext.RecordTypeMismatch(record.RECORDTYPE.Value);
                                }
                            }
                            if (record.OK_OIDN.HasValue)
                            {
                                if (record.OK_OIDN.Value == 0)
                                {
                                    problems += recordContext.IdentifierZero();
                                }
                                else
                                {
                                    var identifier = new GradeSeparatedJunctionId(record.OK_OIDN.Value);
                                    if (identifiers.TryGetValue(identifier, out var takenByRecordNumber))
                                    {
                                        problems += recordContext.IdentifierNotUnique(
                                            identifier,
                                            takenByRecordNumber
                                            );
                                    }
                                    else
                                    {
                                        identifiers.Add(identifier, records.CurrentRecordNumber);
                                    }
                                }
                            }
                            else
                            {
                                problems += recordContext.RequiredFieldIsNull(record.OK_OIDN.Field);
                            }

                            if (record.TYPE.HasValue)
                            {
                                if (!GradeSeparatedJunctionType.ByIdentifier.ContainsKey(record.TYPE.Value))
                                {
                                    problems += recordContext.GradeSeparatedJunctionTypeMismatch(record.TYPE.Value);
                                }
                            }
                            else
                            {
                                problems += recordContext.RequiredFieldIsNull(record.TYPE.Field);
                            }

                            if (!record.BO_WS_OIDN.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.BO_WS_OIDN.Field);
                            }
                            else if (!RoadSegmentId.Accepts(record.BO_WS_OIDN.Value))
                            {
                                problems += recordContext.UpperRoadSegmentIdOutOfRange(record.BO_WS_OIDN.Value);
                            }

                            if (!record.ON_WS_OIDN.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.ON_WS_OIDN.Field);
                            }
                            else if (!RoadSegmentId.Accepts(record.ON_WS_OIDN.Value))
                            {
                                problems += recordContext.LowerRoadSegmentIdOutOfRange(record.ON_WS_OIDN.Value);
                            }

                            moved = records.MoveNext();
                        }
                    }
                }
                else
                {
                    problems += entry.HasNoDbaseRecords(true);
                }
            }
            catch (Exception exception)
            {
                problems += entry.AtDbaseRecord(records.CurrentRecordNumber).HasDbaseRecordFormatError(exception);
            }

            return(problems);
        }
Exemplo n.º 10
0
 public NextGradeSeparatedJunctionIdProvider(GradeSeparatedJunctionId current)
 {
     _current = current;
 }
Exemplo n.º 11
0
 public GradeSeparatedJunctionId TranslateToTemporaryOrId(GradeSeparatedJunctionId id)
 {
     return(_mapToTemporaryGradeSeparatedJunctionIdentifiers.TryGetValue(id, out var temporary)
         ? temporary
         : id);
 }
Exemplo n.º 12
0
 public bool TryTranslateToTemporary(GradeSeparatedJunctionId id, out GradeSeparatedJunctionId temporary)
 {
     return(_mapToTemporaryGradeSeparatedJunctionIdentifiers.TryGetValue(id, out temporary));
 }