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 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 }
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 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) ); }