Example #1
0
        private static StaticCoordinateOperationCompiler.StepCompilationResult CreateGeographicTopocentric(TransformationCompilationParams opData)
        {
            Contract.Requires(opData != null);
            var outputUnit = opData.StepParams.RelatedOutputCrsUnit;

            if (null == outputUnit)
            {
                return(null);
            }

            var latParam = new KeywordNamedParameterSelector("LAT");
            var lonParam = new KeywordNamedParameterSelector("LON");
            var hParam   = new KeywordNamedParameterSelector("H");

            opData.ParameterLookup.Assign(latParam, lonParam, hParam);

            GeographicHeightCoordinate origin;

            if (!TryCreateGeographicHeightCoordinate(latParam.Selection, lonParam.Selection, hParam.Selection, OgcAngularUnit.DefaultRadians, opData.StepParams.RelatedOutputCrsUnit, out origin))
            {
                origin = GeographicHeightCoordinate.Zero;
            }

            var spheroidIn = opData.StepParams.ConvertRelatedInputSpheroidUnit(outputUnit);

            if (null == spheroidIn)
            {
                return(null);
            }

            var spheroidOut = opData.StepParams.ConvertRelatedOutputSpheroidUnit(outputUnit);

            if (null == spheroidOut)
            {
                return(null);
            }

            var geographicGeocentric = new GeographicGeocentricTransformation(spheroidIn);
            var topocentricOrigin    = geographicGeocentric.TransformValue(origin);

            var transformations = new List <ITransformation>()
            {
                geographicGeocentric,
                new GeocentricTopocentricTransformation(topocentricOrigin, spheroidOut)
            };

            var inputUnitConversion = StaticCoordinateOperationCompiler.CreateCoordinateUnitConversion(opData.StepParams.InputUnit, OgcAngularUnit.DefaultRadians);

            if (null != inputUnitConversion)
            {
                transformations.Insert(0, inputUnitConversion);
            }

            return(new StaticCoordinateOperationCompiler.StepCompilationResult(
                       opData.StepParams,
                       outputUnit,
                       new ConcatenatedTransformation(transformations)
                       ));
        }
 public GeocentricTransformationGeographicWrapper(GeographicGeocentricTransformation geographicGeocentric, GeocentricGeographicTransformation geocentricGeographic, ITransformation<Point3> core)
     : base(geographicGeocentric, geocentricGeographic)
 {
     if (null == core) throw new ArgumentNullException("core");
     Contract.Requires(geographicGeocentric != null);
     Contract.Requires(geocentricGeographic != null);
     _core = core;
 }
Example #3
0
        public void EpsgExample221InverseTest()
        {
            var transform  = new GeographicGeocentricTransformation(new SpheroidEquatorialInvF(6378137.000, 298.2572236));
            var inputValue = new Point3(3771793.968, 140253.342, 5124304.349);
            var expected   = new GeographicHeightCoordinate(0.939151102, 0.037167659, 73);

            var result = (transform.GetInverse() as ITransformation <Point3, GeographicCoordinate>).TransformValue(inputValue);

            Assert.AreEqual(expected.Latitude, result.Latitude, 0.0000000006);
            Assert.AreEqual(expected.Longitude, result.Longitude, 0.0000000002);
        }
        public void EpsgExample221InverseTest()
        {
            var transform = new GeographicGeocentricTransformation(new SpheroidEquatorialInvF(6378137.000, 298.2572236));
            var inputValue = new Point3(3771793.968, 140253.342, 5124304.349);
            var expected = new GeographicHeightCoordinate(0.939151102, 0.037167659, 73);

            var result = (transform.GetInverse() as ITransformation<Point3, GeographicCoordinate>).TransformValue(inputValue);

            Assert.AreEqual(expected.Latitude, result.Latitude, 0.0000000006);
            Assert.AreEqual(expected.Longitude, result.Longitude, 0.0000000002);
        }
Example #5
0
        public void EpsgExample221Test()
        {
            var transform  = new GeographicGeocentricTransformation(new SpheroidEquatorialInvF(6378137.000, 298.2572236));
            var expected   = new Point3(3771793.968, 140253.342, 5124304.349);
            var inputValue = new GeographicHeightCoordinate(0.939151102, 0.037167659, 73);

            var result = transform.TransformValue(inputValue);

            Assert.AreEqual(expected.X, result.X, 0.003);
            Assert.AreEqual(expected.Y, result.Y, 0.0006);
            Assert.AreEqual(expected.Z, result.Z, 0.003);
        }
        public void EpsgExample221Test()
        {
            var transform = new GeographicGeocentricTransformation(new SpheroidEquatorialInvF(6378137.000, 298.2572236));
            var expected = new Point3(3771793.968, 140253.342, 5124304.349);
            var inputValue = new GeographicHeightCoordinate(0.939151102, 0.037167659, 73);

            var result = transform.TransformValue(inputValue);

            Assert.AreEqual(expected.X, result.X, 0.003);
            Assert.AreEqual(expected.Y, result.Y, 0.0006);
            Assert.AreEqual(expected.Z, result.Z, 0.003);
        }
        public void EpsgExample221WithoutHeightTest()
        {
            var transform = new GeographicGeocentricTransformation(new SpheroidEquatorialInvF(6378137.000, 298.2572236));
            var inputValue = new GeographicCoordinate(0.939151102, 0.037167659); // the actual point is 73 from the surface
            var expectedVector = new Vector3(3771793.968, 140253.342, 5124304.349);
            var expectedNormal = expectedVector.GetNormalized();

            var result = transform.TransformValue(new GeographicCoordinate(inputValue.Latitude, inputValue.Longitude));
            var resultVector = new Vector3(result); // so we can check that the normal is at least the same, as we remove height information
            var resultNormal = resultVector.GetNormalized();
            Assert.AreEqual(expectedNormal.X, resultNormal.X, 0.00000003);
            Assert.AreEqual(expectedNormal.Y, resultNormal.Y, 0.000000002);
            Assert.AreEqual(expectedNormal.Z, resultNormal.Z, 0.00000003);
            Assert.AreEqual(resultVector.GetMagnitude(), expectedVector.GetMagnitude() - 73.0, 0.0005); // it should be about 73 units from the expected height above the surface
        }
Example #8
0
        public void EpsgExample221WithoutHeightTest()
        {
            var transform      = new GeographicGeocentricTransformation(new SpheroidEquatorialInvF(6378137.000, 298.2572236));
            var inputValue     = new GeographicCoordinate(0.939151102, 0.037167659); // the actual point is 73 from the surface
            var expectedVector = new Vector3(3771793.968, 140253.342, 5124304.349);
            var expectedNormal = expectedVector.GetNormalized();

            var result       = transform.TransformValue(new GeographicCoordinate(inputValue.Latitude, inputValue.Longitude));
            var resultVector = new Vector3(result); // so we can check that the normal is at least the same, as we remove height information
            var resultNormal = resultVector.GetNormalized();

            Assert.AreEqual(expectedNormal.X, resultNormal.X, 0.00000003);
            Assert.AreEqual(expectedNormal.Y, resultNormal.Y, 0.000000002);
            Assert.AreEqual(expectedNormal.Z, resultNormal.Z, 0.00000003);
            Assert.AreEqual(resultVector.GetMagnitude(), expectedVector.GetMagnitude() - 73.0, 0.0005); // it should be about 73 units from the expected height above the surface
        }
 private Inverse(GeographicGeocentricTransformation geographicGeocentric, GeocentricGeographicTransformation geocentricGeographic, MolodenskyBadekasGeographicTransformation core)
     : base(geographicGeocentric, geocentricGeographic)
 {
     _core = core;
     Contract.Requires(core != null);
     Contract.Requires(core.MolodenskyBadekas.HasInverse);
     Contract.Requires(geographicGeocentric != null);
     Contract.Requires(geocentricGeographic != null);
     _mbInverse = _core.MolodenskyBadekas.GetInverse();
 }
        private static StaticCoordinateOperationCompiler.StepCompilationResult CreateGeographicTopocentric(TransformationCompilationParams opData)
        {
            Contract.Requires(opData != null);
            var outputUnit = opData.StepParams.RelatedOutputCrsUnit;
            if (null == outputUnit)
                return null;

            var latParam = new KeywordNamedParameterSelector("LAT");
            var lonParam = new KeywordNamedParameterSelector("LON");
            var hParam = new KeywordNamedParameterSelector("H");
            opData.ParameterLookup.Assign(latParam, lonParam, hParam);

            GeographicHeightCoordinate origin;
            if (!TryCreateGeographicHeightCoordinate(latParam.Selection, lonParam.Selection, hParam.Selection, OgcAngularUnit.DefaultRadians, opData.StepParams.RelatedOutputCrsUnit, out origin))
                origin = GeographicHeightCoordinate.Zero;

            var spheroidIn = opData.StepParams.ConvertRelatedInputSpheroidUnit(outputUnit);
            if (null == spheroidIn)
                return null;

            var spheroidOut = opData.StepParams.ConvertRelatedOutputSpheroidUnit(outputUnit);
            if (null == spheroidOut)
                return null;

            var geographicGeocentric = new GeographicGeocentricTransformation(spheroidIn);
            var topocentricOrigin = geographicGeocentric.TransformValue(origin);

            var transformations = new List<ITransformation>() {
                geographicGeocentric,
                new GeocentricTopocentricTransformation(topocentricOrigin, spheroidOut)
            };

            var inputUnitConversion = StaticCoordinateOperationCompiler.CreateCoordinateUnitConversion(opData.StepParams.InputUnit, OgcAngularUnit.DefaultRadians);
            if (null != inputUnitConversion)
                transformations.Insert(0, inputUnitConversion);

            return new StaticCoordinateOperationCompiler.StepCompilationResult(
                opData.StepParams,
                outputUnit,
                new ConcatenatedTransformation(transformations)
            );
        }
 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();
 }