コード例 #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);
        }
コード例 #2
0
        public void StartNodeMustNotBeEndNodeId()
        {
            var id   = Fixture.Create <RoadNodeId>();
            var data = new Messages.AddRoadSegment
            {
                StartNodeId = id, EndNodeId = id
            };

            Validator.ShouldHaveValidationErrorFor(c => c.EndNodeId, data);
        }
コード例 #3
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
                   ));
        }