Пример #1
0
        public void Creation3()
        {
            var f = new NFFFile(NFFFileType.SVLFile, NFFFileVersion.Version1_6);

            f.NFFFileType.Should().Be(NFFFileType.SVLFile);
            f.FileVersion.Should().Be(NFFFileVersion.Version1_6);
        }
Пример #2
0
        public void CreateDXFFromMasterAlignment(string fileName, string compareFileName)
        {
            var f      = NFFFile.CreateFromFile(Path.Combine("TestData", "Common", fileName));
            var master = f.GuidanceAlignments?.Where(x => x.IsMasterAlignment()).FirstOrDefault();

            master.Should().NotBeNull();

            var export = new ExportToDXF
            {
                AlignmentLabelingInterval = 10,
                Units = DistanceUnitsType.Meters
            };

            export.ConstructSVLCenterlineDXFAlignment(master, out var calcResult, out var MS).Should().BeTrue();
            calcResult.Should().Be(DesignProfilerRequestResult.OK);
            MS.Should().NotBeNull();

            // File.WriteAllBytes(Path.GetTempFileName() + fileName + ".MasterAlignment.DXF", MS.ToArray());

            // The Writer writes lines with environment line endings. Done this way we read the file with environment line endings and have
            // more accurate equality checking vs ReadAllBytes.
            var input = File.ReadAllLines(Path.Combine("TestData", "Common", compareFileName));
            var sb    = new StringBuilder();

            foreach (var s in input)
            {
                sb.Append(s + Environment.NewLine);
            }

            // Compare with known good file
            var goodFile = Encoding.UTF8.GetBytes(sb.ToString());

            MS.ToArray().Should().BeEquivalentTo(goodFile);
        }
Пример #3
0
        public void Creation2(NFFFileType fileType)
        {
            var f = new NFFFile(fileType);

            f.Should().NotBeNull();
            f.NFFFileType.Should().Be(fileType);
        }
Пример #4
0
        public void Creation4()
        {
            var f = new NFFFile(NFFFileType.SVLFile, NFFFileVersion.Version1_6, 100);

            f.NFFFileType.Should().Be(NFFFileType.SVLFile);
            f.FileVersion.Should().Be(NFFFileVersion.Version1_6);
            f.GridSize.Should().Be(100);
        }
Пример #5
0
        public void CreateFromFile(string fileName, NFFFileType fileType, NFFFileVersion fileVersion)
        {
            var f = NFFFile.CreateFromFile(Path.Combine("TestData", "Common", fileName));

            f.ErrorStatus.Should().Be(NFFErrorStatus.OK);

            f.NFFFileType.Should().Be(fileType);
            f.FileVersion.Should().Be(fileVersion);
        }
Пример #6
0
        public void Load_Files(string fileName)
        {
            var f = new NFFFile(NFFFileType.SVLFile);

            f.LoadFromFile(Path.Combine("TestData", "Common", fileName)).Should().Be(true);

            f.ErrorStatus.Should().Be(NFFErrorStatus.OK);
            f.GuidanceAlignments.Should().NotBeNull();
            f.GuidanceAlignments.Count.Should().BeGreaterThan(0);
        }
Пример #7
0
        /// <summary>
        /// Loads the content of an SVL file into a memory model for use
        /// </summary>
        public override DesignLoadResult LoadFromFile(string fileName, bool saveIndexFiles = true)
        {
            DesignLoadResult result;
            var nffFile = NFFFile.CreateFromFile(fileName);

            try
            {
                result = nffFile.GuidanceAlignments.Count > 0 ? DesignLoadResult.NoAlignmentsFound : DesignLoadResult.NoMasterAlignmentsFound;

                for (var i = 0; i < nffFile.GuidanceAlignments.Count; i++)
                {
                    if (nffFile.GuidanceAlignments[i].IsMasterAlignment())
                    {
                        _data = nffFile.GuidanceAlignments[i];

                        nffFile.GuidanceAlignments.RemoveAt(i);

                        if (_data != null)
                        {
                            _boundingBox = _data.BoundingBox();
                            result       = DesignLoadResult.Success;
                        }

                        break;
                    }
                }

                if (result == DesignLoadResult.NoAlignmentsFound)
                {
                    _log.LogDebug($"SVL file {fileName} contains no guidance alignments");
                }

                if (result == DesignLoadResult.NoMasterAlignmentsFound)
                {
                    _log.LogDebug($"SVL file {fileName} contains {nffFile.GuidanceAlignments.Count} alignments, none of which are master alignments");
                }
            }
            catch (Exception e)
            {
                _log.LogError(e, $"Exception in {nameof(LoadFromFile)}");
                result = DesignLoadResult.UnknownFailure;
            }

            return(result);
        }
Пример #8
0
        public void DetermineBoundary(string fileName, NFFFileType fileType, NFFFileVersion fileVersion)
        {
            var f = NFFFile.CreateFromFile(Path.Combine("TestData", "Common", fileName));

            f.ErrorStatus.Should().Be(NFFErrorStatus.OK);

            f.NFFFileType.Should().Be(fileType);
            f.FileVersion.Should().Be(fileVersion);

            var master       = f.GuidanceAlignments?.Where(x => x.IsMasterAlignment()).FirstOrDefault();
            var determinator = new SVLAlignmentBoundaryDeterminator(master, master.StartStation, master.EndStation, -1, 1);

            determinator.Should().NotBeNull();

            determinator.DetermineBoundary(out DesignProfilerRequestResult calcResult, out Fence fence);

            calcResult.Should().Be(DesignProfilerRequestResult.OK);
            fence.Should().NotBeNull();
        }
Пример #9
0
        public void Load_Dimensions2012_Milling()
        {
            var f = new NFFFile(NFFFileType.SVLFile);

            f.LoadFromFile(Path.Combine("TestData", "Common", "Milling - Milling.svl")).Should().Be(true);
        }
Пример #10
0
        public void Load_Dimensions2012_TopConRoad()
        {
            var f = new NFFFile(NFFFileType.SVLFile);

            f.LoadFromFile(Path.Combine("TestData", "Common", "Topcon Road - Topcon Phil.svl")).Should().Be(true);
        }
Пример #11
0
        public void Load_Dimensions2012_LargeSiteRoad()
        {
            var f = new NFFFile(NFFFileType.SVLFile);

            f.LoadFromFile(Path.Combine("TestData", "Common", "Large Sites Road - Trimble Road.svl")).Should().Be(true);
        }
Пример #12
0
        public void Load_CERA()
        {
            var f = new NFFFile(NFFFileType.SVLFile);

            f.LoadFromFile(Path.Combine("TestData", "Common", "CERA.SVL")).Should().Be(true);
        }
Пример #13
0
        public void Creation()
        {
            var f = new NFFFile();

            f.Should().NotBeNull();
        }