Exemplo n.º 1
0
 public AddRoadNode(RoadNodeId id, RoadNodeId temporaryId, RoadNodeType type, Point geometry)
 {
     Id          = id;
     TemporaryId = temporaryId;
     Type        = type ?? throw new ArgumentNullException(nameof(type));
     Geometry    = geometry ?? throw new ArgumentNullException(nameof(geometry));
 }
Exemplo n.º 2
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];
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
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.º 5
0
            public RoadNodeId Next()
            {
                var next = _current.Next();

                _current = next;
                return(next);
            }
Exemplo n.º 6
0
 private AddRoadNode(RecordNumber recordNumber, RoadNodeId temporaryId, RoadNodeType type, NetTopologySuite.Geometries.Point geometry)
 {
     RecordNumber = recordNumber;
     TemporaryId  = temporaryId;
     Type         = type;
     Geometry     = geometry;
 }
Exemplo n.º 7
0
 public AddRoadNode(RecordNumber recordNumber, RoadNodeId temporaryId, RoadNodeType type)
 {
     RecordNumber = recordNumber;
     TemporaryId  = temporaryId;
     Type         = type ?? throw new ArgumentNullException(nameof(type));
     Geometry     = null;
 }
Exemplo n.º 8
0
 public FullyDisconnectedRoadNodeTests()
 {
     _fixture = new Fixture();
     _fixture.CustomizePoint();
     _id       = _fixture.Create <RoadNodeId>();
     _geometry = _fixture.Create <NetTopologySuite.Geometries.Point>();
     _sut      = new RoadNode(_id, _geometry);
 }
Exemplo n.º 9
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)))
                       ));
        }
Exemplo n.º 10
0
        // Road Node Errors

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

        public Problems RoadNodeGeometryTaken(RoadNodeId byOtherNode)
        {
            return(new Problems(_problems.Add(
                                    new Error(
                                        nameof(RoadNodeGeometryTaken),
                                        new ProblemParameter(
                                            "ByOtherNode",
                                            byOtherNode.ToInt32().ToString())))
                                ));
        }
Exemplo n.º 11
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);
 }
Exemplo n.º 12
0
 public IEnumerable <RoadNodeId> SelectOppositeNode(RoadNodeId id)
 {
     if (Start == id)
     {
         yield return(End);
     }
     else if (End == id)
     {
         yield return(Start);
     }
 }
Exemplo n.º 13
0
        // road node

        public static FileError IdentifierNotUnique(this IDbaseFileRecordProblemBuilder builder,
                                                    RoadNodeId identifier,
                                                    RecordNumber takenByRecordNumber)
        {
            return(builder
                   .Error(nameof(IdentifierNotUnique))
                   .WithParameters(
                       new ProblemParameter("Identifier", identifier.ToString()),
                       new ProblemParameter("TakenByRecordNumber", takenByRecordNumber.ToString())
                       )
                   .Build());
        }
Exemplo n.º 14
0
        private AddRoadNode Translate(Messages.AddRoadNode command)
        {
            var permanent = _nextRoadNodeId();
            var temporary = new RoadNodeId(command.TemporaryId);

            return(new AddRoadNode
                   (
                       permanent,
                       temporary,
                       RoadNodeType.Parse(command.Type),
                       GeometryTranslator.Translate(command.Geometry)
                   ));
        }
Exemplo n.º 15
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;
        }
Exemplo n.º 16
0
        private RoadNetworkView With(AddRoadNode command)
        {
            var node = new RoadNode(command.Id, command.Geometry);

            return(new RoadNetworkView(
                       _nodes.Add(command.Id, node),
                       _segments,
                       RoadNodeId.Max(command.Id, _maximumNodeId),
                       _maximumSegmentId,
                       _maximumGradeSeparatedJunctionId,
                       _maximumEuropeanRoadAttributeId,
                       _maximumNationalRoadAttributeId,
                       _maximumNumberedRoadAttributeId,
                       _maximumLaneAttributeId,
                       _maximumWidthAttributeId,
                       _maximumSurfaceAttributeId,
                       _segmentReusableLaneAttributeIdentifiers,
                       _segmentReusableWidthAttributeIdentifiers,
                       _segmentReusableSurfaceAttributeIdentifiers));
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
0
        private RoadNetworkView Given(Messages.RoadNodeAdded @event)
        {
            var id   = new RoadNodeId(@event.Id);
            var node = new RoadNode(id, GeometryTranslator.Translate(@event.Geometry));

            return(new RoadNetworkView(
                       _nodes.Add(id, node),
                       _segments,
                       RoadNodeId.Max(id, _maximumNodeId),
                       _maximumSegmentId,
                       _maximumGradeSeparatedJunctionId,
                       _maximumEuropeanRoadAttributeId,
                       _maximumNationalRoadAttributeId,
                       _maximumNumberedRoadAttributeId,
                       _maximumLaneAttributeId,
                       _maximumWidthAttributeId,
                       _maximumSurfaceAttributeId,
                       _segmentReusableLaneAttributeIdentifiers,
                       _segmentReusableWidthAttributeIdentifiers,
                       _segmentReusableSurfaceAttributeIdentifiers));
        }
Exemplo n.º 19
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));
 }
Exemplo n.º 20
0
        public RoadNetworkView Given(Messages.ImportedRoadNode @event)
        {
            if (@event == null)
            {
                throw new ArgumentNullException(nameof(@event));
            }
            var id   = new RoadNodeId(@event.Id);
            var node = new RoadNode(id, GeometryTranslator.Translate(@event.Geometry));

            return(new RoadNetworkView(
                       _nodes.Add(id, node),
                       _segments,
                       RoadNodeId.Max(id, _maximumNodeId),
                       _maximumSegmentId, _maximumGradeSeparatedJunctionId,
                       _maximumEuropeanRoadAttributeId,
                       _maximumNationalRoadAttributeId,
                       _maximumNumberedRoadAttributeId,
                       _maximumLaneAttributeId,
                       _maximumWidthAttributeId,
                       _maximumSurfaceAttributeId,
                       _segmentReusableLaneAttributeIdentifiers,
                       _segmentReusableWidthAttributeIdentifiers,
                       _segmentReusableSurfaceAttributeIdentifiers));
        }
Exemplo n.º 21
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);
        }
Exemplo n.º 22
0
 public RoadNodeId TranslateToTemporaryOrId(RoadNodeId id)
 {
     return(_mapToTemporaryNodeIdentifiers.TryGetValue(id, out var temporary)
         ? temporary
         : id);
 }
Exemplo n.º 23
0
 public bool TryTranslateToTemporary(RoadNodeId id, out RoadNodeId temporary)
 {
     return(_mapToTemporaryNodeIdentifiers.TryGetValue(id, out temporary));
 }
Exemplo n.º 24
0
        public ZipArchiveProblems Validate(ZipArchiveEntry entry, IDbaseRecordEnumerator <RoadNodeChangeDbaseRecord> 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 <RoadNodeId, 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.WEGKNOOPID.HasValue)
                            {
                                if (record.WEGKNOOPID.Value == 0)
                                {
                                    problems += recordContext.IdentifierZero();
                                }
                                else
                                {
                                    var identifier = new RoadNodeId(record.WEGKNOOPID.Value);
                                    if (identifiers.TryGetValue(identifier, out var takenByRecordNumber))
                                    {
                                        problems += recordContext.IdentifierNotUnique(
                                            identifier,
                                            takenByRecordNumber
                                            );
                                    }
                                    else
                                    {
                                        identifiers.Add(identifier, records.CurrentRecordNumber);
                                    }
                                }
                            }
                            else
                            {
                                problems += recordContext.RequiredFieldIsNull(record.WEGKNOOPID.Field);
                            }

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

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

            return(problems);
        }
Exemplo n.º 25
0
 public RoadNode(RoadNodeId id, Point geometry)
 {
     Id        = id;
     Geometry  = geometry ?? throw new ArgumentNullException(nameof(geometry));
     _segments = ImmutableHashSet <RoadSegmentId> .Empty;
 }
Exemplo n.º 26
0
 public bool TryTranslateToRoadNodeId(RecordNumber number, out RoadNodeId translated)
 {
     return(_mapToRoadNodeId.TryGetValue(number, out translated));
 }
Exemplo n.º 27
0
 public bool TryFindAddRoadNode(RoadNodeId id, out AddRoadNode change)
 {
     change = this.OfType <AddRoadNode>().SingleOrDefault(_ => _.TemporaryId == id);
     return(change != null);
 }
Exemplo n.º 28
0
 private RoadNode(RoadNodeId id, Point geometry, ImmutableHashSet <RoadSegmentId> segments)
 {
     Id        = id;
     Geometry  = geometry;
     _segments = segments;
 }
Exemplo n.º 29
0
 public NextRoadNodeIdProvider(RoadNodeId current)
 {
     _current = current;
 }
Exemplo n.º 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
                   ));
        }