コード例 #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;
 }
コード例 #2
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)))
                       ));
        }
コード例 #3
0
            public RoadSegmentId Next()
            {
                var next = _current.Next();

                _current = next;
                return(next);
            }
コード例 #4
0
        private AddRoadSegmentToNumberedRoad Translate(Messages.AddRoadSegmentToNumberedRoad command, IRequestedChangeIdentityTranslator translator)
        {
            var permanent = _nextNumberedRoadAttributeId();
            var temporary = new AttributeId(command.TemporaryAttributeId);

            var           segmentId = new RoadSegmentId(command.SegmentId);
            RoadSegmentId?temporarySegmentId;

            if (translator.TryTranslateToPermanent(segmentId, out var permanentSegmentId))
            {
                temporarySegmentId = segmentId;
                segmentId          = permanentSegmentId;
            }
            else
            {
                temporarySegmentId = null;
            }

            var number    = NumberedRoadNumber.Parse(command.Ident8);
            var direction = RoadSegmentNumberedRoadDirection.Parse(command.Direction);
            var ordinal   = new RoadSegmentNumberedRoadOrdinal(command.Ordinal);

            return(new AddRoadSegmentToNumberedRoad
                   (
                       permanent,
                       temporary,
                       segmentId,
                       temporarySegmentId,
                       number,
                       direction,
                       ordinal
                   ));
        }
コード例 #5
0
 public AddRoadSegment(
     RecordNumber recordNumber,
     RoadSegmentId temporaryId,
     RoadNodeId startNodeId,
     RoadNodeId endNodeId,
     OrganizationId maintenanceAuthority,
     RoadSegmentGeometryDrawMethod geometryDrawMethod,
     RoadSegmentMorphology morphology,
     RoadSegmentStatus status,
     RoadSegmentCategory category,
     RoadSegmentAccessRestriction accessRestriction,
     CrabStreetnameId?leftSideStreetNameId,
     CrabStreetnameId?rightSideStreetNameId)
 {
     RecordNumber         = recordNumber;
     TemporaryId          = temporaryId;
     StartNodeId          = startNodeId;
     EndNodeId            = endNodeId;
     Geometry             = null;
     MaintenanceAuthority = maintenanceAuthority;
     GeometryDrawMethod   = geometryDrawMethod ?? throw new ArgumentNullException(nameof(geometryDrawMethod));
     Morphology           = morphology ?? throw new ArgumentNullException(nameof(morphology));
     Status                = status ?? throw new ArgumentNullException(nameof(status));
     Category              = category ?? throw new ArgumentNullException(nameof(category));
     AccessRestriction     = accessRestriction ?? throw new ArgumentNullException(nameof(accessRestriction));
     LeftSideStreetNameId  = leftSideStreetNameId;
     RightSideStreetNameId = rightSideStreetNameId;
     Lanes    = new RoadSegmentLaneAttribute[0];
     Widths   = new RoadSegmentWidthAttribute[0];
     Surfaces = new RoadSegmentSurfaceAttribute[0];
 }
コード例 #6
0
 private AddRoadSegment(
     RecordNumber recordNumber,
     RoadSegmentId temporaryId,
     RoadNodeId startNodeId,
     RoadNodeId endNodeId,
     MultiLineString geometry,
     OrganizationId maintenanceAuthority,
     RoadSegmentGeometryDrawMethod geometryDrawMethod,
     RoadSegmentMorphology morphology,
     RoadSegmentStatus status,
     RoadSegmentCategory category,
     RoadSegmentAccessRestriction accessRestriction,
     CrabStreetnameId?leftSideStreetNameId,
     CrabStreetnameId?rightSideStreetNameId,
     IReadOnlyList <RoadSegmentLaneAttribute> lanes,
     IReadOnlyList <RoadSegmentWidthAttribute> widths,
     IReadOnlyList <RoadSegmentSurfaceAttribute> surfaces)
 {
     RecordNumber         = recordNumber;
     TemporaryId          = temporaryId;
     StartNodeId          = startNodeId;
     EndNodeId            = endNodeId;
     Geometry             = geometry;
     MaintenanceAuthority = maintenanceAuthority;
     GeometryDrawMethod   = geometryDrawMethod;
     Morphology           = morphology;
     Status                = status;
     Category              = category;
     AccessRestriction     = accessRestriction;
     LeftSideStreetNameId  = leftSideStreetNameId;
     RightSideStreetNameId = rightSideStreetNameId;
     Lanes    = lanes;
     Widths   = widths;
     Surfaces = surfaces;
 }
コード例 #7
0
        private AddRoadSegmentToNationalRoad Translate(Messages.AddRoadSegmentToNationalRoad command, IRequestedChangeIdentityTranslator translator)
        {
            var permanent = _nextNationalRoadAttributeId();
            var temporary = new AttributeId(command.TemporaryAttributeId);

            var           segmentId = new RoadSegmentId(command.SegmentId);
            RoadSegmentId?temporarySegmentId;

            if (translator.TryTranslateToPermanent(segmentId, out var permanentSegmentId))
            {
                temporarySegmentId = segmentId;
                segmentId          = permanentSegmentId;
            }
            else
            {
                temporarySegmentId = null;
            }

            var number = NationalRoadNumber.Parse(command.Ident2);

            return(new AddRoadSegmentToNationalRoad
                   (
                       permanent,
                       temporary,
                       segmentId,
                       temporarySegmentId,
                       number
                   ));
        }
コード例 #8
0
ファイル: Problems.cs プロジェクト: yreynhout/road-registry
 public Problems RoadSegmentMissing(RoadSegmentId segmentId)
 {
     return(new Problems(
                _problems.Add(
                    new Error(nameof(RoadSegmentMissing),
                              new ProblemParameter("SegmentId", segmentId.ToInt32().ToString())))
                ));
 }
コード例 #9
0
ファイル: Problems.cs プロジェクト: yreynhout/road-registry
        // Road Segment Errors

        //public Errors RoadSegmentIdTaken() => new Errors(_errors.Add(new Error(nameof(RoadSegmentIdTaken))));

        public Problems RoadSegmentGeometryTaken(RoadSegmentId byOtherSegment)
        {
            return(new Problems(_problems.Add(
                                    new Error(
                                        nameof(RoadSegmentGeometryTaken),
                                        new ProblemParameter(
                                            "ByOtherSegment",
                                            byOtherSegment.ToInt32().ToString())))));
        }
コード例 #10
0
        private RoadNetworkView Given(Messages.RoadSegmentAdded @event)
        {
            var id    = new RoadSegmentId(@event.Id);
            var start = new RoadNodeId(@event.StartNodeId);
            var end   = new RoadNodeId(@event.EndNodeId);

            var attributeHash = AttributeHash.None
                                .With(RoadSegmentAccessRestriction.Parse(@event.AccessRestriction))
                                .With(RoadSegmentCategory.Parse(@event.Category))
                                .With(RoadSegmentMorphology.Parse(@event.Morphology))
                                .With(RoadSegmentStatus.Parse(@event.Status))
                                .WithLeftSide(@event.LeftSide.StreetNameId.HasValue
                    ? new CrabStreetnameId(@event.LeftSide.StreetNameId.Value)
                    : new CrabStreetnameId?())
                                .WithRightSide(@event.RightSide.StreetNameId.HasValue
                    ? new CrabStreetnameId(@event.RightSide.StreetNameId.Value)
                    : new CrabStreetnameId?())
                                .With(new OrganizationId(@event.MaintenanceAuthority.Code));

            var segment = new RoadSegment(
                id,
                GeometryTranslator.Translate(@event.Geometry),
                start,
                end,
                attributeHash);

            return(new RoadNetworkView(
                       _nodes
                       .TryReplace(start, node => node.ConnectWith(id))
                       .TryReplace(end, node => node.ConnectWith(id)),
                       _segments.Add(id, segment),
                       _maximumNodeId,
                       RoadSegmentId.Max(id, _maximumSegmentId),
                       _maximumGradeSeparatedJunctionId,
                       _maximumEuropeanRoadAttributeId,
                       _maximumNationalRoadAttributeId,
                       _maximumNumberedRoadAttributeId,
                       @event.Lanes.Length != 0
                    ? AttributeId.Max(
                           new AttributeId(@event.Lanes.Max(_ => _.AttributeId)),
                           _maximumLaneAttributeId)
                    : _maximumLaneAttributeId,
                       @event.Widths.Length != 0
                    ? AttributeId.Max(
                           new AttributeId(@event.Widths.Max(_ => _.AttributeId)),
                           _maximumWidthAttributeId)
                    : _maximumWidthAttributeId,
                       @event.Surfaces.Length != 0
                    ? AttributeId.Max(
                           new AttributeId(@event.Surfaces.Max(_ => _.AttributeId)),
                           _maximumSurfaceAttributeId)
                    : _maximumSurfaceAttributeId,
                       _segmentReusableLaneAttributeIdentifiers.AddOrMergeDistinct(id, @event.Lanes.Select(lane => new AttributeId(lane.AttributeId))),
                       _segmentReusableWidthAttributeIdentifiers.AddOrMergeDistinct(id, @event.Widths.Select(width => new AttributeId(width.AttributeId))),
                       _segmentReusableSurfaceAttributeIdentifiers.AddOrMergeDistinct(id, @event.Surfaces.Select(surface => new AttributeId(surface.AttributeId)))
                       ));
        }
コード例 #11
0
 public AddRoadSegmentToEuropeanRoad(
     AttributeId temporaryAttributeId,
     RoadSegmentId segmentId,
     EuropeanRoadNumber number)
 {
     TemporaryAttributeId = temporaryAttributeId;
     SegmentId            = segmentId;
     Number = number;
 }
コード例 #12
0
 public AddRoadSegmentToNationalRoad(
     AttributeId temporaryAttributeId,
     RoadSegmentId segmentId,
     NationalRoadNumber number)
 {
     TemporaryAttributeId = temporaryAttributeId;
     SegmentId            = segmentId;
     Number = number;
 }
コード例 #13
0
ファイル: Problems.cs プロジェクト: yreynhout/road-registry
 public Problems RoadNodeTooClose(RoadSegmentId toOtherSegment)
 {
     return(new Problems(_problems.Add(
                             new Error(
                                 nameof(RoadNodeTooClose),
                                 new ProblemParameter(
                                     "ToOtherSegment",
                                     toOtherSegment.ToInt32().ToString())))
                         ));
 }
コード例 #14
0
 public ConnectedRoadNodeTests()
 {
     _fixture = new Fixture();
     _fixture.CustomizePoint();
     _id       = _fixture.Create <RoadNodeId>();
     _geometry = _fixture.Create <NetTopologySuite.Geometries.Point>();
     _link1    = _fixture.Create <RoadSegmentId>();
     _link2    = _fixture.Create <RoadSegmentId>();
     _sut      = new RoadNode(_id, _geometry).ConnectWith(_link1).ConnectWith(_link2);
 }
コード例 #15
0
 public AddGradeSeparatedJunction(
     GradeSeparatedJunctionId temporaryId,
     GradeSeparatedJunctionType type,
     RoadSegmentId upperSegmentId,
     RoadSegmentId lowerSegmentId)
 {
     TemporaryId    = temporaryId;
     Type           = type ?? throw new ArgumentNullException(nameof(type));
     UpperSegmentId = upperSegmentId;
     LowerSegmentId = lowerSegmentId;
 }
コード例 #16
0
        // road segment

        public static FileError IdentifierNotUnique(this IDbaseFileRecordProblemBuilder builder,
                                                    RoadSegmentId identifier,
                                                    RecordNumber takenByRecordNumber)
        {
            return(builder
                   .Error(nameof(IdentifierNotUnique))
                   .WithParameters(
                       new ProblemParameter("Identifier", identifier.ToString()),
                       new ProblemParameter("TakenByRecordNumber", takenByRecordNumber.ToString())
                       )
                   .Build());
        }
コード例 #17
0
 public AddRoadSegmentToNumberedRoad(
     AttributeId temporaryAttributeId,
     RoadSegmentId segmentId,
     NumberedRoadNumber number,
     RoadSegmentNumberedRoadDirection direction,
     RoadSegmentNumberedRoadOrdinal ordinal)
 {
     TemporaryAttributeId = temporaryAttributeId;
     SegmentId            = segmentId;
     Number    = number;
     Direction = direction;
     Ordinal   = ordinal;
 }
コード例 #18
0
ファイル: Problems.cs プロジェクト: yreynhout/road-registry
 public Problems FakeRoadNodeConnectedSegmentsDoNotDiffer(RoadSegmentId segment1, RoadSegmentId segment2)
 {
     return(new Problems(
                _problems.Add(
                    new Error(nameof(FakeRoadNodeConnectedSegmentsDoNotDiffer),
                              new ProblemParameter(
                                  "SegmentId",
                                  segment1.ToInt32().ToString()),
                              new ProblemParameter(
                                  "SegmentId",
                                  segment2.ToInt32().ToString())))
                ));
 }
コード例 #19
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;
        }
コード例 #20
0
        public TranslatedChanges Translate(ZipArchiveEntry entry, IDbaseRecordEnumerator <RoadSegmentLaneChangeDbaseRecord> records, TranslatedChanges changes)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }
            if (changes == null)
            {
                throw new ArgumentNullException(nameof(changes));
            }

            while (records.MoveNext())
            {
                var record = records.Current;
                if (record != null)
                {
                    switch (record.RECORDTYPE.Value)
                    {
                    case RecordType.EqualIdentifier:
                    case RecordType.AddedIdentifier:
                    case RecordType.ModifiedIdentifier:
                        var segmentId = new RoadSegmentId(record.WS_OIDN.Value);
                        if (changes.TryFindAddRoadSegment(segmentId, out var change))
                        {
                            var lane = new RoadSegmentLaneAttribute(
                                new AttributeId(record.RS_OIDN.Value),
                                new RoadSegmentLaneCount(record.AANTAL.Value),
                                RoadSegmentLaneDirection.ByIdentifier[record.RICHTING.Value],
                                RoadSegmentPosition.FromDouble(record.VANPOSITIE.Value),
                                RoadSegmentPosition.FromDouble(record.TOTPOSITIE.Value)
                                );
                            changes = changes.Replace(change, change.WithLane(lane));
                        }
                        break;
                    }
                }
            }

            return(changes);
        }
コード例 #21
0
        public TranslatedChanges Translate(ZipArchiveEntry entry, IDbaseRecordEnumerator <RoadSegmentWidthChangeDbaseRecord> records, TranslatedChanges changes)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }
            if (changes == null)
            {
                throw new ArgumentNullException(nameof(changes));
            }

            while (records.MoveNext())
            {
                var record = records.Current;
                if (record != null)
                {
                    switch (record.RECORDTYPE.Value)
                    {
                    case RecordType.EqualIdentifier:
                    case RecordType.AddedIdentifier:
                    case RecordType.ModifiedIdentifier:
                        var segmentId = new RoadSegmentId(record.WS_OIDN.Value);
                        if (changes.TryFindAddRoadSegment(segmentId, out var before))
                        {
                            var width = new RoadSegmentWidthAttribute(
                                new AttributeId(record.WB_OIDN.Value),
                                new RoadSegmentWidth(record.BREEDTE.Value),
                                RoadSegmentPosition.FromDouble(record.VANPOSITIE.Value),
                                RoadSegmentPosition.FromDouble(record.TOTPOSITIE.Value)
                                );
                            changes = changes.Replace(before, before.WithWidth(width));
                        }
                        break;
                    }
                }
            }

            return(changes);
        }
コード例 #22
0
        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);
        }
コード例 #23
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));
        }
コード例 #24
0
 public AddRoadSegment(RoadSegmentId id,
                       RoadSegmentId temporaryId,
                       RoadNodeId startNodeId,
                       RoadNodeId?temporaryStartNodeId,
                       RoadNodeId endNodeId,
                       RoadNodeId?temporaryEndNodeId,
                       MultiLineString geometry,
                       OrganizationId maintenanceAuthority,
                       RoadSegmentGeometryDrawMethod geometryDrawMethod,
                       RoadSegmentMorphology morphology,
                       RoadSegmentStatus status,
                       RoadSegmentCategory category,
                       RoadSegmentAccessRestriction accessRestriction,
                       CrabStreetnameId?leftSideStreetNameId,
                       CrabStreetnameId?rightSideStreetNameId,
                       IReadOnlyList <RoadSegmentLaneAttribute> lanes,
                       IReadOnlyList <RoadSegmentWidthAttribute> widths,
                       IReadOnlyList <RoadSegmentSurfaceAttribute> surfaces)
 {
     Id                    = id;
     TemporaryId           = temporaryId;
     StartNodeId           = startNodeId;
     TemporaryStartNodeId  = temporaryStartNodeId;
     EndNodeId             = endNodeId;
     TemporaryEndNodeId    = temporaryEndNodeId;
     Geometry              = geometry ?? throw new ArgumentNullException(nameof(geometry));
     MaintenanceAuthority  = maintenanceAuthority;
     GeometryDrawMethod    = geometryDrawMethod ?? throw new ArgumentNullException(nameof(geometryDrawMethod));
     Morphology            = morphology ?? throw new ArgumentNullException(nameof(morphology));
     Status                = status ?? throw new ArgumentNullException(nameof(status));
     Category              = category ?? throw new ArgumentNullException(nameof(category));
     AccessRestriction     = accessRestriction ?? throw new ArgumentNullException(nameof(accessRestriction));
     LeftSideStreetNameId  = leftSideStreetNameId;
     RightSideStreetNameId = rightSideStreetNameId;
     Lanes                 = lanes ?? throw new ArgumentNullException(nameof(lanes));
     Widths                = widths ?? throw new ArgumentNullException(nameof(widths));
     Surfaces              = surfaces ?? throw new ArgumentNullException(nameof(surfaces));
 }
コード例 #25
0
        public ZipArchiveProblems Validate(ZipArchiveEntry entry, IDbaseRecordEnumerator <RoadSegmentChangeDbaseRecord> 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 <RoadSegmentId, 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.WS_OIDN.HasValue)
                            {
                                if (record.WS_OIDN.Value == 0)
                                {
                                    problems += recordContext.IdentifierZero();
                                }
                                else
                                {
                                    var identifier = new RoadSegmentId(record.WS_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.WS_OIDN.Field);
                            }

                            if (!record.TGBEP.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.TGBEP.Field);
                            }
                            else if (!RoadSegmentAccessRestriction.ByIdentifier.ContainsKey(record.TGBEP.Value))
                            {
                                problems += recordContext.RoadSegmentAccessRestrictionMismatch(record.TGBEP.Value);
                            }

                            if (!record.STATUS.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.STATUS.Field);
                            }
                            else if (!RoadSegmentStatus.ByIdentifier.ContainsKey(record.STATUS.Value))
                            {
                                problems += recordContext.RoadSegmentStatusMismatch(record.STATUS.Value);
                            }

                            if (!record.WEGCAT.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.WEGCAT.Field);
                            }
                            else if (!RoadSegmentCategory.ByIdentifier.ContainsKey(record.WEGCAT.Value))
                            {
                                problems += recordContext.RoadSegmentCategoryMismatch(record.WEGCAT.Value);
                            }

                            if (!record.METHODE.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.METHODE.Field);
                            }
                            else if (!RoadSegmentGeometryDrawMethod.ByIdentifier.ContainsKey(record.METHODE.Value))
                            {
                                problems += recordContext.RoadSegmentGeometryDrawMethodMismatch(record.METHODE.Value);
                            }

                            if (!record.MORFOLOGIE.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.MORFOLOGIE.Field);
                            }
                            else if (!RoadSegmentMorphology.ByIdentifier.ContainsKey(record.MORFOLOGIE.Value))
                            {
                                problems += recordContext.RoadSegmentMorphologyMismatch(record.MORFOLOGIE.Value);
                            }

                            if (!record.B_WK_OIDN.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.B_WK_OIDN.Field);
                            }
                            else if (!RoadNodeId.Accepts(record.B_WK_OIDN.Value))
                            {
                                problems += recordContext.BeginRoadNodeIdOutOfRange(record.B_WK_OIDN.Value);
                            }

                            if (!record.E_WK_OIDN.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.E_WK_OIDN.Field);
                            }
                            else if (!RoadNodeId.Accepts(record.E_WK_OIDN.Value))
                            {
                                problems += recordContext.EndRoadNodeIdOutOfRange(record.E_WK_OIDN.Value);
                            }

                            if (!record.BEHEERDER.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.BEHEERDER.Field);
                            }
                        }
                        moved = records.MoveNext();
                    }
                }
                else
                {
                    problems += entry.HasNoDbaseRecords(false);
                }
            }
            catch (Exception exception)
            {
                problems += entry.AtDbaseRecord(records.CurrentRecordNumber).HasDbaseRecordFormatError(exception);
            }

            return(problems);
        }
        public ZipArchiveProblems Validate(ZipArchiveEntry entry, IDbaseRecordEnumerator <NationalRoadChangeDbaseRecord> 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 <AttributeId, 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.NW_OIDN.HasValue)
                            {
                                if (record.NW_OIDN.Value == 0)
                                {
                                    problems += recordContext.IdentifierZero();
                                }
                                else
                                {
                                    var identifier = new AttributeId(record.NW_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.NW_OIDN.Field);
                            }

                            if (record.IDENT2.Value == null)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.IDENT2.Field);
                            }
                            else if (!NationalRoadNumber.CanParse(record.IDENT2.Value))
                            {
                                problems += recordContext.NotNationalRoadNumber(record.IDENT2.Value);
                            }

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

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

            return(problems);
        }
        public ZipArchiveProblems Validate(ZipArchiveEntry entry, IDbaseRecordEnumerator <RoadSegmentLaneChangeDbaseRecord> 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 <AttributeId, 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.RS_OIDN.HasValue)
                            {
                                if (record.RS_OIDN.Value == 0)
                                {
                                    problems += recordContext.IdentifierZero();
                                }
                                else
                                {
                                    var identifier = new AttributeId(record.RS_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.RS_OIDN.Field);
                            }

                            if (!record.AANTAL.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.AANTAL.Field);
                            }
                            else if (!RoadSegmentLaneCount.Accepts(record.AANTAL.Value))
                            {
                                problems += recordContext.LaneCountOutOfRange(record.AANTAL.Value);
                            }

                            if (!record.RICHTING.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.RICHTING.Field);
                            }
                            else if (!RoadSegmentLaneDirection.ByIdentifier.ContainsKey(record.RICHTING.Value))
                            {
                                problems += recordContext.LaneDirectionMismatch(record.RICHTING.Value);
                            }

                            if (!record.VANPOSITIE.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.VANPOSITIE.Field);
                            }
                            else if (!RoadSegmentPosition.Accepts(record.VANPOSITIE.Value))
                            {
                                problems += recordContext.FromPositionOutOfRange(record.VANPOSITIE.Value);
                            }

                            if (!record.TOTPOSITIE.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.TOTPOSITIE.Field);
                            }
                            else if (!RoadSegmentPosition.Accepts(record.TOTPOSITIE.Value))
                            {
                                problems += recordContext.ToPositionOutOfRange(record.TOTPOSITIE.Value);
                            }

                            if (!record.WS_OIDN.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.WS_OIDN.Field);
                            }
                            else if (!RoadSegmentId.Accepts(record.WS_OIDN.Value))
                            {
                                problems += recordContext.RoadSegmentIdOutOfRange(record.WS_OIDN.Value);
                            }
                        }
                        moved = records.MoveNext();
                    }
                }
                else
                {
                    problems += entry.HasNoDbaseRecords(false);
                }
            }
            catch (Exception exception)
            {
                problems += entry.AtDbaseRecord(records.CurrentRecordNumber).HasDbaseRecordFormatError(exception);
            }

            return(problems);
        }
コード例 #28
0
 public bool TryFindAddRoadSegment(RoadSegmentId id, out AddRoadSegment change)
 {
     change = this.OfType <AddRoadSegment>().SingleOrDefault(_ => _.TemporaryId == id);
     return(change != null);
 }
コード例 #29
0
 public bool TryTranslateToRoadSegmentId(RecordNumber number, out RoadSegmentId translated)
 {
     return(_mapToRoadSegmentId.TryGetValue(number, out translated));
 }
コード例 #30
0
        private AddRoadSegment Translate(Messages.AddRoadSegment command, IRequestedChangeIdentityTranslator translator)
        {
            var permanent = _nextRoadSegmentId();
            var temporary = new RoadSegmentId(command.TemporaryId);

            var        startNodeId = new RoadNodeId(command.StartNodeId);
            RoadNodeId?temporaryStartNodeId;

            if (translator.TryTranslateToPermanent(startNodeId, out var permanentStartNodeId))
            {
                temporaryStartNodeId = startNodeId;
                startNodeId          = permanentStartNodeId;
            }
            else
            {
                temporaryStartNodeId = null;
            }

            var        endNodeId = new RoadNodeId(command.EndNodeId);
            RoadNodeId?temporaryEndNodeId;

            if (translator.TryTranslateToPermanent(endNodeId, out var permanentEndNodeId))
            {
                temporaryEndNodeId = endNodeId;
                endNodeId          = permanentEndNodeId;
            }
            else
            {
                temporaryEndNodeId = null;
            }

            var geometry             = GeometryTranslator.Translate(command.Geometry);
            var maintainer           = new OrganizationId(command.MaintenanceAuthority);
            var geometryDrawMethod   = RoadSegmentGeometryDrawMethod.Parse(command.GeometryDrawMethod);
            var morphology           = RoadSegmentMorphology.Parse(command.Morphology);
            var status               = RoadSegmentStatus.Parse(command.Status);
            var category             = RoadSegmentCategory.Parse(command.Category);
            var accessRestriction    = RoadSegmentAccessRestriction.Parse(command.AccessRestriction);
            var leftSideStreetNameId = command.LeftSideStreetNameId.HasValue
                ? new CrabStreetnameId(command.LeftSideStreetNameId.Value)
                : new CrabStreetnameId?();
            var rightSideStreetNameId = command.RightSideStreetNameId.HasValue
                ? new CrabStreetnameId(command.RightSideStreetNameId.Value)
                : new CrabStreetnameId?();
            var nextLaneAttributeId = _nextRoadSegmentLaneAttributeId(permanent);
            var laneAttributes      = Array.ConvertAll(
                command.Lanes,
                item => new RoadSegmentLaneAttribute(
                    nextLaneAttributeId(),
                    new AttributeId(item.AttributeId),
                    new RoadSegmentLaneCount(item.Count),
                    RoadSegmentLaneDirection.Parse(item.Direction),
                    new RoadSegmentPosition(item.FromPosition),
                    new RoadSegmentPosition(item.ToPosition),
                    new GeometryVersion(0)
                    )
                );
            var nextWidthAttributeId = _nextRoadSegmentWidthAttributeId(permanent);
            var widthAttributes      = Array.ConvertAll(
                command.Widths,
                item => new RoadSegmentWidthAttribute(
                    nextWidthAttributeId(),
                    new AttributeId(item.AttributeId),
                    new RoadSegmentWidth(item.Width),
                    new RoadSegmentPosition(item.FromPosition),
                    new RoadSegmentPosition(item.ToPosition),
                    new GeometryVersion(0)
                    )
                );
            var nextSurfaceAttributeId = _nextRoadSegmentSurfaceAttributeId(permanent);
            var surfaceAttributes      = Array.ConvertAll(
                command.Surfaces,
                item => new RoadSegmentSurfaceAttribute(
                    nextSurfaceAttributeId(),
                    new AttributeId(item.AttributeId),
                    RoadSegmentSurfaceType.Parse(item.Type),
                    new RoadSegmentPosition(item.FromPosition),
                    new RoadSegmentPosition(item.ToPosition),
                    new GeometryVersion(0)
                    )
                );

            return(new AddRoadSegment
                   (
                       permanent,
                       temporary,
                       startNodeId,
                       temporaryStartNodeId,
                       endNodeId,
                       temporaryEndNodeId,
                       geometry,
                       maintainer,
                       geometryDrawMethod,
                       morphology,
                       status,
                       category,
                       accessRestriction,
                       leftSideStreetNameId,
                       rightSideStreetNameId,
                       laneAttributes,
                       widthAttributes,
                       surfaceAttributes
                   ));
        }