Esempio n. 1
0
        public void VerifyValid()
        {
            Fixture.CustomizePolylineM();

            var data = new Messages.AddRoadSegment
            {
                TemporaryId          = Fixture.Create <RoadSegmentId>(),
                StartNodeId          = Fixture.Create <RoadNodeId>(),
                EndNodeId            = Fixture.Create <RoadNodeId>(),
                Geometry             = GeometryTranslator.Translate(Fixture.Create <MultiLineString>()),
                MaintenanceAuthority = Fixture.Create <OrganizationId>(),
                GeometryDrawMethod   = Fixture.Create <RoadSegmentGeometryDrawMethod>(),
                Morphology           = Fixture.Create <RoadSegmentMorphology>(),
                Status                = Fixture.Create <RoadSegmentStatus>(),
                Category              = Fixture.Create <RoadSegmentCategory>(),
                AccessRestriction     = Fixture.Create <RoadSegmentAccessRestriction>(),
                LeftSideStreetNameId  = Fixture.Create <int?>(),
                RightSideStreetNameId = Fixture.Create <int?>(),
                Lanes    = Fixture.CreateMany <RequestedRoadSegmentLaneAttribute>().ToArray(),
                Widths   = Fixture.CreateMany <RequestedRoadSegmentWidthAttribute>().ToArray(),
                Surfaces = Fixture.CreateMany <RequestedRoadSegmentSurfaceAttribute>().ToArray(),
            };

            Validator.ValidateAndThrow(data);
        }
Esempio n. 2
0
        public void VerifyValid()
        {
            var data = GeometryTranslator.Translate(Fixture.Create <MultiLineString>());

            data.SpatialReferenceSystemIdentifier = SpatialReferenceSystemIdentifier.BelgeLambert1972.ToInt32();

            Validator.ValidateAndThrow(data);
        }
Esempio n. 3
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)))
                       ));
        }
Esempio n. 4
0
        public void TranslateTo(Messages.RejectedChange message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            message.AddRoadNode = new Messages.AddRoadNode
            {
                TemporaryId = TemporaryId,
                Type        = Type.ToString(),
                Geometry    = GeometryTranslator.Translate(Geometry)
            };
        }
Esempio n. 5
0
 public Messages.RoadNetworkSnapshot TakeSnapshot()
 {
     return(new Messages.RoadNetworkSnapshot
     {
         Nodes = _nodes.Select(node => new Messages.RoadNetworkSnapshotNode
         {
             Id = node.Value.Id.ToInt32(),
             Segments = node.Value.Segments.Select(segment => segment.ToInt32()).ToArray(),
             Geometry = GeometryTranslator.Translate(node.Value.Geometry)
         }).ToArray(),
         Segments = _segments.Select(segment => new Messages.RoadNetworkSnapshotSegment
         {
             Id = segment.Value.Id.ToInt32(),
             StartNodeId = segment.Value.Start.ToInt32(),
             EndNodeId = segment.Value.End.ToInt32(),
             Geometry = GeometryTranslator.Translate(segment.Value.Geometry),
             AttributeHash = segment.Value.AttributeHash.GetHashCode()
         }).ToArray(),
         MaximumNodeId = _maximumNodeId.ToInt32(),
         MaximumSegmentId = _maximumSegmentId.ToInt32(),
         MaximumGradeSeparatedJunctionId = _maximumGradeSeparatedJunctionId.ToInt32(),
         MaximumEuropeanRoadAttributeId = _maximumEuropeanRoadAttributeId.ToInt32(),
         MaximumNationalRoadAttributeId = _maximumNationalRoadAttributeId.ToInt32(),
         MaximumNumberedRoadAttributeId = _maximumNumberedRoadAttributeId.ToInt32(),
         MaximumLaneAttributeId = _maximumLaneAttributeId.ToInt32(),
         MaximumWidthAttributeId = _maximumWidthAttributeId.ToInt32(),
         MaximumSurfaceAttributeId = _maximumSurfaceAttributeId.ToInt32(),
         SegmentReusableLaneAttributeIdentifiers = _segmentReusableLaneAttributeIdentifiers.Select(segment =>
                                                                                                   new Messages.RoadNetworkSnapshotSegmentReusableAttributeIdentifiers
         {
             SegmentId = segment.Key.ToInt32(),
             ReusableAttributeIdentifiers = segment.Value.Select(lane => lane.ToInt32()).ToArray()
         }).ToArray(),
         SegmentReusableWidthAttributeIdentifiers = _segmentReusableWidthAttributeIdentifiers.Select(segment =>
                                                                                                     new Messages.RoadNetworkSnapshotSegmentReusableAttributeIdentifiers
         {
             SegmentId = segment.Key.ToInt32(),
             ReusableAttributeIdentifiers = segment.Value.Select(width => width.ToInt32()).ToArray()
         }).ToArray(),
         SegmentReusableSurfaceAttributeIdentifiers = _segmentReusableSurfaceAttributeIdentifiers.Select(segment =>
                                                                                                         new Messages.RoadNetworkSnapshotSegmentReusableAttributeIdentifiers
         {
             SegmentId = segment.Key.ToInt32(),
             ReusableAttributeIdentifiers = segment.Value.Select(surface => surface.ToInt32()).ToArray()
         }).ToArray()
     });
 }
Esempio n. 6
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));
        }