private Inverse(GeographicGeocentricTransformation geographicGeocentric, GeocentricGeographicTransformation geocentricGeographic, GeocentricTransformationGeographicWrapper coreWrapper)
     : base(geographicGeocentric, geocentricGeographic)
 {
     Contract.Requires(coreWrapper != null);
     Contract.Requires(coreWrapper.GeocentricCore.HasInverse);
     Contract.Requires(geographicGeocentric != null);
     Contract.Requires(geocentricGeographic != null);
     _coreWrapper      = coreWrapper;
     _inverseOperation = coreWrapper.GeocentricCore.GetInverse();
 }
            public static Inverse BuildInverse(GeocentricTransformationGeographicWrapper coreWrapper)
            {
                Contract.Requires(coreWrapper != null);
                Contract.Requires(coreWrapper.GeocentricToGeographic.HasInverse);
                Contract.Requires(coreWrapper.GeographicToGeocentric.HasInverse);
                Contract.Ensures(Contract.Result <Inverse>() != null);
                var geographicToGeocentric = coreWrapper.GeocentricToGeographic.GetInverse();

                Contract.Assume(coreWrapper.GeographicToGeocentric.HasInverse);
                var geocentricToGeographic = coreWrapper.GeographicToGeocentric.GetInverse();

                return(new Inverse(geographicToGeocentric, geocentricToGeographic, coreWrapper));
            }
        private static StaticCoordinateOperationCompiler.StepCompilationResult CreateMolodenskyBadekas(TransformationCompilationParams opData)
        {
            Contract.Requires(opData != null);
            var xTransParam = new KeywordNamedParameterSelector("XAXIS", "TRANS");
            var yTransParam = new KeywordNamedParameterSelector("YAXIS", "TRANS");
            var zTransParam = new KeywordNamedParameterSelector("ZAXIS", "TRANS");
            var xRotParam = new KeywordNamedParameterSelector("XAXIS", "ROT");
            var yRotParam = new KeywordNamedParameterSelector("YAXIS", "ROT");
            var zRotParam = new KeywordNamedParameterSelector("ZAXIS", "ROT");
            var scaleParam = new KeywordNamedParameterSelector("SCALE");
            var ord1Param = new KeywordNamedParameterSelector("ORDINATE1");
            var ord2Param = new KeywordNamedParameterSelector("ORDINATE2");
            var ord3Param = new KeywordNamedParameterSelector("ORDINATE3");

            if (!opData.ParameterLookup.Assign(xTransParam, yTransParam, zTransParam, xRotParam, yRotParam, zRotParam, scaleParam, ord1Param, ord2Param, ord3Param))
                return null;

            Vector3 translation, rotation;
            Point3 ordinate;
            double scale;

            if (!TryCreateVector3(xTransParam.Selection, yTransParam.Selection, zTransParam.Selection, out translation))
                return null;
            if (!TryCreateVector3(xRotParam.Selection, yRotParam.Selection, zRotParam.Selection, OgcAngularUnit.DefaultRadians, out rotation))
                return null;
            if (!TryCreatePoint3(ord1Param.Selection, ord2Param.Selection, ord3Param.Selection, out ordinate))
                return null;
            if (!NamedParameter.TryGetDouble(scaleParam.Selection, out scale))
                return null;

            var molodensky = new MolodenskyBadekasTransformation(translation, rotation, ordinate, scale);

            if (opData.StepParams.RelatedInputCrs is ICrsGeocentric && opData.StepParams.RelatedOutputCrs is ICrsGeocentric)
                return new StaticCoordinateOperationCompiler.StepCompilationResult(
                    opData.StepParams,
                    opData.StepParams.RelatedOutputCrsUnit ?? opData.StepParams.RelatedInputCrsUnit ?? opData.StepParams.InputUnit,
                    molodensky);

            // TODO: need to handle units here
            var spheroidFrom = opData.StepParams.RelatedInputSpheroid;
            if (null == spheroidFrom)
                return null;

            // TODO: need to handle units here
            var spheroidTo = opData.StepParams.RelatedOutputSpheroid;
            if (null == spheroidTo)
                return null;

            ITransformation transformation = new GeocentricTransformationGeographicWrapper(spheroidFrom, spheroidTo, molodensky);
            var conv = StaticCoordinateOperationCompiler.CreateCoordinateUnitConversion(opData.StepParams.InputUnit, OgcAngularUnit.DefaultRadians);
            if (null != conv)
                transformation = new ConcatenatedTransformation(new[] { conv, transformation });

            return new StaticCoordinateOperationCompiler.StepCompilationResult(
                opData.StepParams,
                OgcAngularUnit.DefaultRadians,
                transformation);
        }
        private static StaticCoordinateOperationCompiler.StepCompilationResult CreateHelmertStep(TransformationCompilationParams opData, Helmert7Transformation helmert)
        {
            Contract.Requires(opData != null);
            Contract.Requires(helmert != null);
            if (opData.StepParams.RelatedInputCrs is ICrsGeocentric && opData.StepParams.RelatedOutputCrs is ICrsGeocentric)
                return new StaticCoordinateOperationCompiler.StepCompilationResult(
                    opData.StepParams,
                    opData.StepParams.RelatedOutputCrsUnit ?? opData.StepParams.RelatedInputCrsUnit ?? opData.StepParams.InputUnit,
                    helmert);

            var spheroidFrom = ExtractSpheroid(opData.StepParams.RelatedInputCrs) ?? ExtractSpheroid(opData.StepParams.RelatedOutputCrs);
            if (null == spheroidFrom)
                return null;

            var spheroidTo = ExtractSpheroid(opData.StepParams.RelatedOutputCrs) ?? spheroidFrom;

            ITransformation transformation = new GeocentricTransformationGeographicWrapper(spheroidFrom, spheroidTo, helmert);
            var unitConversion = StaticCoordinateOperationCompiler.CreateCoordinateUnitConversion(opData.StepParams.InputUnit, OgcAngularUnit.DefaultRadians);
            if (null != unitConversion)
                transformation = new ConcatenatedTransformation(new[] { unitConversion, transformation });

            return new StaticCoordinateOperationCompiler.StepCompilationResult(
                opData.StepParams,
                OgcAngularUnit.DefaultRadians,
                transformation);
        }
 public static Inverse BuildInverse(GeocentricTransformationGeographicWrapper coreWrapper)
 {
     Contract.Requires(coreWrapper != null);
     Contract.Requires(coreWrapper.GeocentricToGeographic.HasInverse);
     Contract.Requires(coreWrapper.GeographicToGeocentric.HasInverse);
     Contract.Ensures(Contract.Result<Inverse>() != null);
     var geographicToGeocentric = coreWrapper.GeocentricToGeographic.GetInverse();
     Contract.Assume(coreWrapper.GeographicToGeocentric.HasInverse);
     var geocentricToGeographic = coreWrapper.GeographicToGeocentric.GetInverse();
     return new Inverse(geographicToGeocentric, geocentricToGeographic, coreWrapper);
 }
 private Inverse(GeographicGeocentricTransformation geographicGeocentric, GeocentricGeographicTransformation geocentricGeographic, GeocentricTransformationGeographicWrapper coreWrapper)
     : base(geographicGeocentric, geocentricGeographic)
 {
     Contract.Requires(coreWrapper != null);
     Contract.Requires(coreWrapper.GeocentricCore.HasInverse);
     Contract.Requires(geographicGeocentric != null);
     Contract.Requires(geocentricGeographic != null);
     _coreWrapper = coreWrapper;
     _inverseOperation = coreWrapper.GeocentricCore.GetInverse();
 }