Example #1
0
        private StepCompilationResult CompileStep(StepCompilationParameters stepParams)
        {
            Contract.Requires(stepParams != null);

            var operations = ConcatenatedCoordinateOperationInfo.LinearizeOperations(stepParams.CoordinateOperationInfo).ToArray();

            if (operations.Length == 0)
            {
                return(null);
            }

            var currentUnit = stepParams.InputUnit;
            var partResults = new StepCompilationResult[operations.Length];

            for (int operationIndex = 0; operationIndex < operations.Length; operationIndex++)
            {
                Contract.Assume(operations[operationIndex] != null);
                var partResult = CompilePart(new StepCompilationParameters(
                                                 operations[operationIndex],
                                                 currentUnit,
                                                 stepParams.RelatedInputCrs,
                                                 stepParams.RelatedOutputCrs
                                                 ));

                if (null == partResult)
                {
                    return(null); // not supported
                }
                partResults[operationIndex] = partResult;
                currentUnit = partResult.OutputUnit;
            }

            ITransformation transformation = partResults.Length == 1
                ? partResults[0].Transformation
                : new ConcatenatedTransformation(Array.ConvertAll(partResults, x => x.Transformation));

            return(new StepCompilationResult(
                       stepParams,
                       currentUnit,
                       transformation));
        }
Example #2
0
            public Inverse(ConcatenatedCoordinateOperationInfo core)
            {
                Contract.Requires(core != null);

                _core = core;
            }
 public Inverse(ConcatenatedCoordinateOperationInfo core)
 {
     Contract.Requires(core != null);
     _core = core;
 }
Example #4
0
        public void SerializePrettyConcatMathTransformTest()
        {
            var input = new ConcatenatedCoordinateOperationInfo(
                new[] {
                    new CoordinateOperationInfo(
                        "Helmert 7 Parameter Transformation",
                        new INamedParameter[]{
                            new NamedParameter<double>("dx",1),
                            new NamedParameter<double>("dy",2),
                            new NamedParameter<double>("dz",3),
                            new NamedParameter<double>("rx",4),
                            new NamedParameter<double>("ry",5),
                            new NamedParameter<double>("rz",6),
                            new NamedParameter<double>("m", 7)
                        }
                    ),
                    new CoordinateOperationInfo(
                        "Thing 1",
                        new INamedParameter[]{
                            new NamedParameter<double>("semi major", 6378137),
                            new NamedParameter<double>("semi minor", 6356752.31414035)
                        },
                        new OgcCoordinateOperationMethodInfo(
                            "Ellipsoid To Geocentric"
                        )
                    ),
                    new CoordinateOperationInfo(
                        "Thing 3",
                        new INamedParameter[]{
                            new NamedParameter<double>("semi_major", 6378206.4),
                            new NamedParameter<double>("semi_minor", 6356583.8)
                        },
                        new OgcCoordinateOperationMethodInfo(
                            "Ellipsoid_To_Geocentric"
                        )
                    ).GetInverse()
                }
            );
            var expectedPretty = String.Join(Environment.NewLine, new[]{
                "CONCAT_MT[",
                "\tPARAM_MT[\"Helmert_7_Parameter_Transformation\",",
                "\t\tPARAMETER[\"dx\",1],",
                "\t\tPARAMETER[\"dy\",2],",
                "\t\tPARAMETER[\"dz\",3],",
                "\t\tPARAMETER[\"rx\",4],",
                "\t\tPARAMETER[\"ry\",5],",
                "\t\tPARAMETER[\"rz\",6],",
                "\t\tPARAMETER[\"m\",7]],",
                "\tPARAM_MT[\"Ellipsoid_To_Geocentric\",",
                "\t\tPARAMETER[\"semi_major\",6378137],",
                "\t\tPARAMETER[\"semi_minor\",6356752.31414035]],",
                "\tINVERSE_MT[",
                "\t\tPARAM_MT[\"Ellipsoid_To_Geocentric\",",
                "\t\t\tPARAMETER[\"semi_major\",6378206.4],",
                "\t\t\tPARAMETER[\"semi_minor\",6356583.8]]]]"
            });
            var expectedDefault = expectedPretty.Replace(Environment.NewLine, "").Replace("\t", "");

            Assert.AreEqual(expectedDefault, Default.Serialize(input));
            Assert.AreEqual(expectedPretty, Pretty.Serialize(input));
        }