예제 #1
0
        public void Creation2()
        {
            var vertices = new[]
            {
                new [] { new double[] { 1, 2, 3 }, new double[] { 2, 2, 4 } },
                new [] { new double[] { 3, 3, 5 }, new double[] { 3, 4, 6 } }
            };
            var arcs   = new [] { new AlignmentGeometryResponseArc(0, 0, 0, 1, 1, 0, 1, 0, 0, true) };
            var labels = new [] { new AlignmentGeometryResponseLabel(1, 2, 3, 4), };

            var response = new AlignmentDesignGeometryResponse(DesignProfilerRequestResult.OK, vertices, arcs, labels);

            response.Should().NotBeNull();

            response.RequestResult.Should().Be(DesignProfilerRequestResult.OK);
            response.Vertices.Should().BeEquivalentTo(vertices);
            response.Labels.Should().BeEquivalentTo(labels);
        }
예제 #2
0
        public void WithData()
        {
            var response = new AlignmentDesignGeometryResponse
            {
                RequestResult = DesignProfilerRequestResult.OK,
                Vertices      = new[]
                {
                    new [] { new double[] { 0, 1, 0 }, new double[] { 2, 3, 1 } },
                    new [] { new double[] { 0, 2, 0 }, new double[] { 4, 5, 1 } }
                },
                Labels = new[] {
                    new AlignmentGeometryResponseLabel(0.0, 1.0, 1.1, 0.5),
                    new AlignmentGeometryResponseLabel(100.0, 1.01, 1.11, 0.75)
                },
            };

            var result = SimpleBinarizableInstanceTester.TestClass(response, "Custom AlignmentDesignGeometryResponse not same after round trip serialisation");

            result.member.Should().BeEquivalentTo(response);
        }
예제 #3
0
        public void AlignmentMasterGeometryExecutor_ConvertGeometryCoordinatesFromNEEToLLE()
        {
            const int DECIMALS = 6;

            const string DIMENSIONS_2012_DC_CSIB = "QM0G000ZHC4000000000800BY7SN2W0EYST640036P3P1SV09C1G61CZZKJC976CNB295K7W7G30DA30A1N74ZJH1831E5V0CHJ60W295GMWT3E95154T3A85H5CRK9D94PJM1P9Q6R30E1C1E4Q173W9XDE923XGGHN8JR37B6RESPQ3ZHWW6YV5PFDGCTZYPWDSJEFE1G2THV3VAZVN28ECXY7ZNBYANFEG452TZZ3X2Q1GCYM8EWCRVGKWD5KANKTXA1MV0YWKRBKBAZYVXXJRM70WKCN2X1CX96TVXKFRW92YJBT5ZCFSVM37ZD5HKVFYYYMJVS05KA6TXFY6ZE4H6NQX8J3VAX79TTF82VPSV1KVR8W9V7BM1N3MEY5QHACSFNCK7VWPNY52RXGC1G9BPBS1QWA7ZVM6T2E0WMDY7P6CXJ68RB4CHJCDSVR6000047S29YVT08000";

            // Vertices...
            var vertex00 = new[] { 2718.0231, 1172.2012, 0.0 };
            var vertex01 = new[] { 2741.4501, 1167.0194999999999, 24.0 };

            var array0 = new[] { vertex00, vertex01 };

            var vertex10 = new[] { 2779.3216, 1165.5918, 62.0 };
            var vertex11 = new[] { 2783.4665, 1166.0165, 66.166666666666671 };
            var vertex12 = new[] { 2804.0533, 1169.1917, 87.000000000000028 };

            var array1 = new[] { vertex10, vertex11, vertex12 };

            var vertices = new[] { array0, array1 };

            // Arcs...
            var arc = new AlignmentGeometryResponseArc(
                2779.32169461374,
                1165.5918144869775,
                0.0,
                2741.4500927432855,
                1167.0194702485303,
                0.0,
                2765.9912,
                1314.9983,
                1E+308,
                false);

            // Labels...
            var labels = new List <AlignmentGeometryResponseLabel>();

            labels.Add(new AlignmentGeometryResponseLabel(0.0, 2718.0231, 1172.2012, 1.3264603040333998));
            labels.Add(new AlignmentGeometryResponseLabel(10.0, 2727.7340448735927, 1169.8277460683921, 1.3403457438206368));
            labels.Add(new AlignmentGeometryResponseLabel(20.0, 2737.5150349254664, 1167.723162636835, 1.3819858321379428));
            labels.Add(new AlignmentGeometryResponseLabel(30.0, 2773.3363657610616, 1165.178246135564, -1.5218089644060191));
            labels.Add(new AlignmentGeometryResponseLabel(40.0, 2763.3394425012643, 1165.0217412244106, 4.6947096761067844));
            labels.Add(new AlignmentGeometryResponseLabel(50.0, 2753.3543004659637, 1165.5315519582812, 4.6280430094401517));
            labels.Add(new AlignmentGeometryResponseLabel(60.0, 2743.4253016301927, 1166.7054133507629, 4.5613763427738521));
            labels.Add(new AlignmentGeometryResponseLabel(70.0, 2787.2690825623372, 1166.4921795439566, 1.7045881732707571));
            labels.Add(new AlignmentGeometryResponseLabel(80.0, 2797.1558966323028, 1168.0067255362799, 1.7365783469590923));
            labels.Add(new AlignmentGeometryResponseLabel(87.000000000000028, 2804.0533, 1169.1917, 1.7431112347917908));

            // Geometry...
            var geometry = new AlignmentDesignGeometryResponse(
                DesignProfilerRequestResult.OK,
                vertices,
                new[] { arc },
                labels.ToArray()
                );

            // ConvertCoordinates expected result mock...
            var llhCoords = new List <XYZ>();

            llhCoords.Add(new XYZ(-115.02044094250364, 36.207027940562334, -1.4714844137459045E-05));
            llhCoords.Add(new XYZ(-115.02018046014511, 36.2069812416702, 23.999985285190935));
            llhCoords.Add(new XYZ(-115.01975936894772, 36.206968365690287, 61.9999852852006));
            llhCoords.Add(new XYZ(-115.0197132818117, 36.206972191444656, 66.1666519518644));
            llhCoords.Add(new XYZ(-115.01948437671714, 36.207000796998031, 86.99998528517628));
            llhCoords.Add(new XYZ(-115.01975936789569, 36.206968365820806, -1.4714799397041221E-05));
            llhCoords.Add(new XYZ(-115.02018046022583, 36.2069812414021, -1.4714809066554202E-05));
            llhCoords.Add(new XYZ(0.0, 0.0, 0.0));
            llhCoords.Add(new XYZ(-115.02044094250364, 36.207027940562334, -1.4714844137459045E-05));
            llhCoords.Add(new XYZ(-115.02033296755739, 36.207006550676034, -1.4714828073727506E-05));
            llhCoords.Add(new XYZ(-115.02022421375355, 36.206987583500194, -1.4714813829446455E-05));
            llhCoords.Add(new XYZ(-115.01982591867552, 36.206964640908289, -1.4714796599646234E-05));
            llhCoords.Add(new XYZ(-115.01993707410817, 36.206963233554013, -1.4714795542728612E-05));
            llhCoords.Add(new XYZ(-115.02004809831355, 36.206967830348162, -1.4714798994903312E-05));
            llhCoords.Add(new XYZ(-115.02015849805876, 36.206978410869162, -1.4714806940834526E-05));
            llhCoords.Add(new XYZ(-115.01967100086553, 36.206976476671556, -1.4714805488259375E-05));
            llhCoords.Add(new XYZ(-115.01956106916795, 36.206990121295007, -1.4714815735321082E-05));
            llhCoords.Add(new XYZ(-115.01948437671714, 36.207000796998024, -1.4714823752735629E-05));

            var convertCoordinatesMock = new Mock <ICoreXWrapper>();

            var expectedCoordinateConversionResult = llhCoords.ToArray().ToCoreX_XYZ();

            convertCoordinatesMock.Setup(x => x.NEEToLLH(It.IsAny <string>(), It.IsAny <CoreXModels.XYZ[]>(), It.IsAny <CoreX.Types.ReturnAs>())).Returns(expectedCoordinateConversionResult);
            DIBuilder.Continue().Add(x => x.AddSingleton(convertCoordinatesMock.Object)).Complete();

            // Convert all coordinates from grid to lat/lon
            AlignmentMasterGeometryHelper.ConvertNEEToLLHCoords(DIMENSIONS_2012_DC_CSIB, geometry);

            geometry.Should().NotBeNull();
            geometry.Arcs.Should().NotBeNull();
            geometry.Labels.Should().NotBeNull();
            geometry.Vertices.Should().NotBeNull();

            geometry.Arcs.Should().HaveCount(1);
            geometry.Labels.Should().HaveCount(labels.Count);
            geometry.Vertices.Should().HaveCount(vertices.Length);

            var count = 0;

            // Vertices...
            for (var i = 0; i < geometry.Vertices.Length; i++)
            {
                geometry.Vertices[i].Should().HaveCount(vertices[i].Length);

                for (var n = 0; n < geometry.Vertices[i].Length; n++)
                {
                    geometry.Vertices[i][n].Should().HaveCount(vertices[i][n].Length);

                    geometry.Vertices[i][n][0].Should().BeApproximately(llhCoords[count].X, DECIMALS);
                    geometry.Vertices[i][n][1].Should().BeApproximately(llhCoords[count].Y, DECIMALS);
                    geometry.Vertices[i][n][2].Should().BeApproximately(llhCoords[count].Z, DECIMALS);

                    count++;
                }
            }

            // Arc...
            geometry.Arcs[0].X1.Should().BeApproximately(llhCoords[count].X, DECIMALS);
            geometry.Arcs[0].Y1.Should().BeApproximately(llhCoords[count].Y, DECIMALS);
            geometry.Arcs[0].Z1.Should().BeApproximately(llhCoords[count].Z, DECIMALS);

            count++;

            geometry.Arcs[0].X2.Should().BeApproximately(llhCoords[count].X, DECIMALS);
            geometry.Arcs[0].Y2.Should().BeApproximately(llhCoords[count].Y, DECIMALS);
            geometry.Arcs[0].Z2.Should().BeApproximately(llhCoords[count].Z, DECIMALS);

            count++;

            geometry.Arcs[0].XC.Should().BeApproximately(llhCoords[count].X, DECIMALS);
            geometry.Arcs[0].YC.Should().BeApproximately(llhCoords[count].Y, DECIMALS);
            geometry.Arcs[0].ZC.Should().BeApproximately(llhCoords[count].Z, DECIMALS);

            count++;

            // Labels...
            for (var n = 0; n < geometry.Labels.Length; n++)
            {
                geometry.Labels[n].X.Should().BeApproximately(llhCoords[count].X, DECIMALS);
                geometry.Labels[n].Y.Should().BeApproximately(llhCoords[count].Y, DECIMALS);

                count++;
            }
        }
예제 #4
0
        public void Creation()
        {
            var response = new AlignmentDesignGeometryResponse();

            response.Should().NotBeNull();
        }
예제 #5
0
        /// <summary>
        /// Takes the response computed for the alignment, extracts all coordinates into a single list,
        /// converts all coordinates with a call to the coordinate conversion service and inserts the
        /// modified coordinates into the result.
        /// </summary>
        public static void ConvertNEEToLLHCoords(string csib, AlignmentDesignGeometryResponse geometryResponse)
        {
            var coords = new List <XYZ>();

            if ((geometryResponse.Vertices?.Length ?? 0) > 0)
            {
                coords.AddRange(geometryResponse.Vertices.SelectMany(x => x.Select(pt => new XYZ(x: pt[0], y: pt[1], z: 0.0))));
            }

            if ((geometryResponse.Arcs?.Length ?? 0) > 0)
            {
                coords.AddRange(geometryResponse.Arcs.SelectMany(x =>
                                                                 new[]
                {
                    new XYZ(x: x.X1, y: x.Y1, z: 0.0),
                    new XYZ(x: x.X2, y: x.Y2, z: 0.0),
                    new XYZ(x: x.XC, y: x.YC, z: 0.0)
                }
                                                                 ));
            }

            if ((geometryResponse.Labels?.Length ?? 0) > 0)
            {
                coords.AddRange(geometryResponse.Labels.Select(x => new XYZ(x: x.X, y: x.Y, z: 0.0)));
            }

            _log.LogDebug($"Assembled vertex & label coordinates before conversion to lat/lon: {string.Join(", ", coords)}");

            var convertedCoords = DIContext.Obtain <ICoreXWrapper>()
                                  .NEEToLLH(csib, coords.ToArray().ToCoreX_XYZ(), CoreX.Types.ReturnAs.Degrees)
                                  .ToTRex_XYZ();

            _log.LogDebug($"Assembled vertex & label coordinates after conversion to lat/lon: {string.Join(", ", convertedCoords)}");

            // Copy the converted coordinates to the geometry response ready for inclusion in the request result
            var index = 0;

            if ((geometryResponse.Vertices?.Length ?? 0) > 0)
            {
                for (var i = 0; i < geometryResponse.Vertices.Length; i++)
                {
                    for (var j = 0; j < geometryResponse.Vertices[i].Length; j++)
                    {
                        geometryResponse.Vertices[i][j] = new[] { convertedCoords[index].X, convertedCoords[index].Y, convertedCoords[index].Z };
                        index++;
                    }
                }
            }

            if ((geometryResponse.Arcs?.Length ?? 0) > 0)
            {
                for (var i = 0; i < geometryResponse.Arcs.Length; i++)
                {
                    geometryResponse.Arcs[i].X1 = convertedCoords[index].X;
                    geometryResponse.Arcs[i].Y1 = convertedCoords[index].Y;
                    geometryResponse.Arcs[i].Z1 = convertedCoords[index].Z;
                    index++;
                    geometryResponse.Arcs[i].X2 = convertedCoords[index].X;
                    geometryResponse.Arcs[i].Y2 = convertedCoords[index].Y;
                    geometryResponse.Arcs[i].Z2 = convertedCoords[index].Z;
                    index++;
                    geometryResponse.Arcs[i].XC = convertedCoords[index].X;
                    geometryResponse.Arcs[i].YC = convertedCoords[index].Y;
                    geometryResponse.Arcs[i].ZC = convertedCoords[index].Z;
                    index++;
                }
            }

            if ((geometryResponse.Labels?.Length ?? 0) > 0)
            {
                for (var i = 0; i < geometryResponse.Labels.Length; i++)
                {
                    geometryResponse.Labels[i].X = convertedCoords[index].X;
                    geometryResponse.Labels[i].Y = convertedCoords[index].Y;
                    index++;
                }
            }
        }