Exemplo n.º 1
0
        public Task When_a_road_segment_was_imported()
        {
            var geometry       = _fixture.Create <MultiLineString>();
            var european_roads = _fixture.CreateMany <ImportedRoadSegmentEuropeanRoadAttributes>().ToArray();
            var numbered_roads = _fixture.CreateMany <ImportedRoadSegmentNumberedRoadAttributes>().ToArray();
            var national_roads = _fixture.CreateMany <ImportedRoadSegmentNationalRoadAttributes>().ToArray();
            var lanes          = _fixture.CreateMany <ImportedRoadSegmentLaneAttributes>().ToArray();
            var widths         = _fixture.CreateMany <ImportedRoadSegmentWidthAttributes>().ToArray();
            var hardenings     = _fixture.CreateMany <ImportedRoadSegmentSurfaceAttributes>().ToArray();
            var content        = new PolyLineMShapeContent(Be.Vlaanderen.Basisregisters.Shaperon.Geometries.GeometryTranslator.FromGeometryMultiLineString(geometry));

            return(new RoadNetworkInfoProjection()
                   .Scenario()
                   .Given(
                       new BeganRoadNetworkImport(),
                       new ImportedRoadSegment
            {
                Id = _fixture.Create <int>(),
                StartNodeId = _fixture.Create <int>(),
                EndNodeId = _fixture.Create <int>(),
                Geometry = GeometryTranslator.Translate(geometry),
                GeometryVersion = _fixture.Create <int>(),
                MaintenanceAuthority = _fixture.Create <MaintenanceAuthority>(),
                GeometryDrawMethod = _fixture.Create <RoadSegmentGeometryDrawMethod>(),
                Morphology = _fixture.Create <RoadSegmentMorphology>(),
                Status = _fixture.Create <RoadSegmentStatus>(),
                Category = _fixture.Create <RoadSegmentCategory>(),
                AccessRestriction = _fixture.Create <RoadSegmentAccessRestriction>(),
                LeftSide = _fixture.Create <ImportedRoadSegmentSideAttributes>(),
                RightSide = _fixture.Create <ImportedRoadSegmentSideAttributes>(),
                PartOfEuropeanRoads = european_roads,
                PartOfNationalRoads = national_roads,
                PartOfNumberedRoads = numbered_roads,
                Lanes = lanes,
                Widths = widths,
                Surfaces = hardenings,
                Version = _fixture.Create <int>(),
                RecordingDate = _fixture.Create <DateTime>(),
                Origin = _fixture.Create <ImportedOriginProperties>()
            }
                       )
                   .Expect(
                       new RoadNetworkInfo {
                Id = 0,
                CompletedImport = false,
                OrganizationCount = 0,
                RoadNodeCount = 0,
                TotalRoadNodeShapeLength = 0,
                RoadSegmentCount = 1,
                RoadSegmentSurfaceAttributeCount = hardenings.Length,
                RoadSegmentLaneAttributeCount = lanes.Length,
                RoadSegmentWidthAttributeCount = widths.Length,
                RoadSegmentEuropeanRoadAttributeCount = european_roads.Length,
                RoadSegmentNationalRoadAttributeCount = national_roads.Length,
                RoadSegmentNumberedRoadAttributeCount = numbered_roads.Length,
                TotalRoadSegmentShapeLength = ShapeRecord.HeaderLength.Plus(content.ContentLength).ToInt32(),
                GradeSeparatedJunctionCount = 0
            }
                       ));
        }
Exemplo n.º 2
0
        public Task When_road_segments_are_imported()
        {
            var random = new Random();
            var data   = _fixture
                         .CreateMany <ImportedRoadSegment>(random.Next(1, 10))
                         .Select(importedRoadSegment =>
            {
                var geometry = GeometryTranslator.Translate(importedRoadSegment.Geometry);
                var polyLineMShapeContent = new PolyLineMShapeContent(Be.Vlaanderen.Basisregisters.Shaperon.Geometries.GeometryTranslator.FromGeometryMultiLineString(geometry));

                var expected = new RoadSegmentRecord
                {
                    Id = importedRoadSegment.Id,
                    ShapeRecordContent       = polyLineMShapeContent.ToBytes(_services.MemoryStreamManager, Encoding.UTF8),
                    ShapeRecordContentLength = polyLineMShapeContent.ContentLength.ToInt32(),
                    BoundingBox = RoadSegmentBoundingBox.From(polyLineMShapeContent.Shape),
                    DbaseRecord = new RoadSegmentDbaseRecord
                    {
                        WS_OIDN   = { Value = importedRoadSegment.Id },
                        WS_UIDN   = { Value = importedRoadSegment.Id + "_" + importedRoadSegment.Version },
                        WS_GIDN   = { Value = importedRoadSegment.Id + "_" + importedRoadSegment.GeometryVersion },
                        B_WK_OIDN = { Value = importedRoadSegment.StartNodeId },
                        E_WK_OIDN = { Value = importedRoadSegment.EndNodeId },
                        STATUS    = { Value = RoadSegmentStatus.Parse(importedRoadSegment.Status).Translation.Identifier },
                        LBLSTATUS = { Value = RoadSegmentStatus.Parse(importedRoadSegment.Status).Translation.Name },
                        MORF      = { Value = RoadSegmentMorphology.Parse(importedRoadSegment.Morphology).Translation.Identifier },
                        LBLMORF   = { Value = RoadSegmentMorphology.Parse(importedRoadSegment.Morphology).Translation.Name },
                        WEGCAT    = { Value = RoadSegmentCategory.Parse(importedRoadSegment.Category).Translation.Identifier },
                        LBLWEGCAT = { Value = RoadSegmentCategory.Parse(importedRoadSegment.Category).Translation.Name },
                        LSTRNMID  = { Value = importedRoadSegment.LeftSide.StreetNameId },
                        LSTRNM    = { Value = importedRoadSegment.LeftSide.StreetName },
                        RSTRNMID  = { Value = importedRoadSegment.RightSide.StreetNameId },
                        RSTRNM    = { Value = importedRoadSegment.RightSide.StreetName },
                        BEHEER    = { Value = importedRoadSegment.MaintenanceAuthority.Code },
                        LBLBEHEER = { Value = importedRoadSegment.MaintenanceAuthority.Name },
                        METHODE   = { Value = RoadSegmentGeometryDrawMethod.Parse(importedRoadSegment.GeometryDrawMethod).Translation.Identifier },
                        LBLMETHOD = { Value = RoadSegmentGeometryDrawMethod.Parse(importedRoadSegment.GeometryDrawMethod).Translation.Name },
                        OPNDATUM  = { Value = importedRoadSegment.RecordingDate },
                        BEGINTIJD = { Value = importedRoadSegment.Origin.Since },
                        BEGINORG  = { Value = importedRoadSegment.Origin.OrganizationId },
                        LBLBGNORG = { Value = importedRoadSegment.Origin.Organization },
                        TGBEP     = { Value = RoadSegmentAccessRestriction.Parse(importedRoadSegment.AccessRestriction).Translation.Identifier },
                        LBLTGBEP  = { Value = RoadSegmentAccessRestriction.Parse(importedRoadSegment.AccessRestriction).Translation.Name }
                    }.ToBytes(_services.MemoryStreamManager, Encoding.UTF8)
                };
                return(new { importedRoadSegment, expected });
            }).ToList();

            return(new RoadSegmentRecordProjection(_services.MemoryStreamManager, Encoding.UTF8)
                   .Scenario()
                   .Given(data.Select(d => d.importedRoadSegment))
                   .Expect(data.Select(d => d.expected)));
        }
Exemplo n.º 3
0
        public Task When_road_nodes_were_imported()
        {
            var imported_nodes = Enumerable
                                 .Range(0, new Random().Next(10))
                                 .Select(index => new ImportedRoadNode
            {
                Id       = _fixture.Create <int>(),
                Type     = _fixture.Create <RoadNodeType>(),
                Geometry = GeometryTranslator.Translate(_fixture.Create <NetTopologySuite.Geometries.Point>()),
                Origin   = _fixture.Create <ImportedOriginProperties>()
            })
                                 .ToArray();
            var givens = Array.ConvertAll(imported_nodes, imported => (object)imported);

            return(new RoadNetworkInfoProjection()
                   .Scenario()
                   .Given(
                       new BeganRoadNetworkImport()
                       )
                   .Given(givens)
                   .Expect(
                       new RoadNetworkInfo
            {
                Id = 0,
                CompletedImport = false,
                OrganizationCount = 0,
                RoadNodeCount = imported_nodes.Length,
                TotalRoadNodeShapeLength = imported_nodes.Aggregate(
                    new WordLength(0),
                    (current, imported) =>
                    current
                    .Plus(
                        new PointShapeContent(Be.Vlaanderen.Basisregisters.Shaperon.Geometries.GeometryTranslator.FromGeometryPoint(GeometryTranslator.Translate(imported.Geometry)))
                        .ContentLength
                        .Plus(ShapeRecord.HeaderLength))
                    ).ToInt32(),
                RoadSegmentCount = 0,
                RoadSegmentSurfaceAttributeCount = 0,
                RoadSegmentLaneAttributeCount = 0,
                RoadSegmentWidthAttributeCount = 0,
                RoadSegmentEuropeanRoadAttributeCount = 0,
                RoadSegmentNationalRoadAttributeCount = 0,
                RoadSegmentNumberedRoadAttributeCount = 0,
                TotalRoadSegmentShapeLength = 0,
                GradeSeparatedJunctionCount = 0
            }
                       ));
        }
        public Task When_road_nodes_were_imported()
        {
            var data = _fixture
                       .CreateMany <ImportedRoadNode>(new Random().Next(1, 100))
                       .Select(@event =>
            {
                var point             = GeometryTranslator.Translate(@event.Geometry);
                var pointShapeContent = new PointShapeContent(
                    Be.Vlaanderen.Basisregisters.Shaperon.Geometries.GeometryTranslator.FromGeometryPoint(
                        new NetTopologySuite.Geometries.Point(point.X, point.Y)
                        )
                    );
                var expectedRecord = new RoadNodeRecord
                {
                    Id          = @event.Id,
                    DbaseRecord = new RoadNodeDbaseRecord
                    {
                        WK_OIDN = { Value = @event.Id },
                        WK_UIDN = { Value = @event.Id + "_" + @event.Version },
                        TYPE    = { Value = RoadNodeType.Parse(@event.Type).Translation.Identifier },
                        LBLTYPE =
                        {
                            Value = RoadNodeType.Parse(@event.Type).Translation.Name
                        },
                        BEGINTIJD = { Value = @event.Origin.Since },
                        BEGINORG  = { Value = @event.Origin.OrganizationId },
                        LBLBGNORG = { Value = @event.Origin.Organization }
                    }.ToBytes(_services.MemoryStreamManager, Encoding.UTF8),
                    ShapeRecordContent       = pointShapeContent.ToBytes(_services.MemoryStreamManager, Encoding.UTF8),
                    ShapeRecordContentLength = pointShapeContent.ContentLength.ToInt32(),
                    BoundingBox = RoadNodeBoundingBox.From(pointShapeContent.Shape)
                };

                return(new
                {
                    ImportedRoadNode = @event,
                    ExpectedRecord = expectedRecord
                });
            }).ToList();

            return(new RoadNodeRecordProjection(new RecyclableMemoryStreamManager(), Encoding.UTF8)
                   .Scenario()
                   .Given(data.Select(d => d.ImportedRoadNode))
                   .Expect(data.Select(d => d.ExpectedRecord)));
        }
Exemplo n.º 5
0
        public Task When_a_road_node_was_imported()
        {
            var geometry = _fixture.Create <NetTopologySuite.Geometries.Point>();

            return(new RoadNetworkInfoProjection()
                   .Scenario()
                   .Given(
                       new BeganRoadNetworkImport(),
                       new ImportedRoadNode
            {
                Id = _fixture.Create <int>(),
                Type = _fixture.Create <RoadNodeType>(),
                Geometry = GeometryTranslator.Translate(geometry),
                Origin = _fixture.Create <ImportedOriginProperties>()
            }
                       )
                   .Expect(
                       new RoadNetworkInfo
            {
                Id = 0,
                CompletedImport = false,
                OrganizationCount = 0,
                RoadNodeCount = 1,
                TotalRoadNodeShapeLength = ShapeRecord.HeaderLength
                                           .Plus(new PointShapeContent(Be.Vlaanderen.Basisregisters.Shaperon.Geometries.GeometryTranslator.FromGeometryPoint(geometry)).ContentLength).ToInt32(),
                RoadSegmentCount = 0,
                RoadSegmentSurfaceAttributeCount = 0,
                RoadSegmentLaneAttributeCount = 0,
                RoadSegmentWidthAttributeCount = 0,
                RoadSegmentEuropeanRoadAttributeCount = 0,
                RoadSegmentNationalRoadAttributeCount = 0,
                RoadSegmentNumberedRoadAttributeCount = 0,
                TotalRoadSegmentShapeLength = 0,
                GradeSeparatedJunctionCount = 0
            }
                       ));
        }
Exemplo n.º 6
0
        public Task When_road_segments_were_imported()
        {
            var imported_segments = Enumerable
                                    .Range(0, new Random().Next(10))
                                    .Select(index => new ImportedRoadSegment
            {
                Id                   = _fixture.Create <int>(),
                StartNodeId          = _fixture.Create <int>(),
                EndNodeId            = _fixture.Create <int>(),
                Geometry             = GeometryTranslator.Translate(_fixture.Create <MultiLineString>()),
                GeometryVersion      = _fixture.Create <int>(),
                MaintenanceAuthority = _fixture.Create <MaintenanceAuthority>(),
                GeometryDrawMethod   = _fixture.Create <RoadSegmentGeometryDrawMethod>(),
                Morphology           = _fixture.Create <RoadSegmentMorphology>(),
                Status               = _fixture.Create <RoadSegmentStatus>(),
                Category             = _fixture.Create <RoadSegmentCategory>(),
                AccessRestriction    = _fixture.Create <RoadSegmentAccessRestriction>(),
                LeftSide             = _fixture.Create <ImportedRoadSegmentSideAttributes>(),
                RightSide            = _fixture.Create <ImportedRoadSegmentSideAttributes>(),
                PartOfEuropeanRoads  = _fixture.CreateMany <ImportedRoadSegmentEuropeanRoadAttributes>().ToArray(),
                PartOfNationalRoads  = _fixture.CreateMany <ImportedRoadSegmentNationalRoadAttributes>().ToArray(),
                PartOfNumberedRoads  = _fixture.CreateMany <ImportedRoadSegmentNumberedRoadAttributes>().ToArray(),
                Lanes                = _fixture.CreateMany <ImportedRoadSegmentLaneAttributes>().ToArray(),
                Widths               = _fixture.CreateMany <ImportedRoadSegmentWidthAttributes>().ToArray(),
                Surfaces             = _fixture.CreateMany <ImportedRoadSegmentSurfaceAttributes>().ToArray(),
                Version              = _fixture.Create <int>(),
                RecordingDate        = _fixture.Create <DateTime>(),
                Origin               = _fixture.Create <ImportedOriginProperties>()
            })
                                    .ToArray();
            var givens = Array.ConvertAll(imported_segments, imported => (object)imported);
            var reader = new WellKnownBinaryReader();

            return(new RoadNetworkInfoProjection()
                   .Scenario()
                   .Given(
                       new BeganRoadNetworkImport()
                       )
                   .Given(givens)
                   .Expect(
                       new RoadNetworkInfo
            {
                Id = 0,
                CompletedImport = false,
                OrganizationCount = 0,
                RoadNodeCount = 0,
                TotalRoadNodeShapeLength = 0,
                RoadSegmentCount = imported_segments.Length,
                RoadSegmentSurfaceAttributeCount = imported_segments.Aggregate(0,
                                                                               (current, imported) => current + imported.Surfaces.Length),
                RoadSegmentLaneAttributeCount = imported_segments.Aggregate(0,
                                                                            (current, imported) => current + imported.Lanes.Length),
                RoadSegmentWidthAttributeCount = imported_segments.Aggregate(0,
                                                                             (current, imported) => current + imported.Widths.Length),
                RoadSegmentEuropeanRoadAttributeCount = imported_segments.Aggregate(0,
                                                                                    (current, imported) => current + imported.PartOfEuropeanRoads.Length),
                RoadSegmentNationalRoadAttributeCount = imported_segments.Aggregate(0,
                                                                                    (current, imported) => current + imported.PartOfNationalRoads.Length),
                RoadSegmentNumberedRoadAttributeCount = imported_segments.Aggregate(0,
                                                                                    (current, imported) => current + imported.PartOfNumberedRoads.Length),
                TotalRoadSegmentShapeLength = imported_segments.Aggregate(new WordLength(0),
                                                                          (current, imported) => current
                                                                          .Plus(
                                                                              new PolyLineMShapeContent(
                                                                                  Be.Vlaanderen.Basisregisters.Shaperon.Geometries.GeometryTranslator.FromGeometryMultiLineString(
                                                                                      GeometryTranslator.Translate(imported.Geometry)
                                                                                      )
                                                                                  )
                                                                              .ContentLength
                                                                              .Plus(ShapeRecord.HeaderLength)
                                                                              )
                                                                          )
                                              .ToInt32(),
                GradeSeparatedJunctionCount = 0
            }
                       ));
        }