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)); }
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 StaticCoordinateOperationCompiler.StepCompilationResult CompileInverse(StaticCoordinateOperationCompiler.StepCompilationParameters stepParameters) { Contract.Requires(stepParameters != null); if (!stepParameters.CoordinateOperationInfo.IsInverseOfDefinition || !stepParameters.CoordinateOperationInfo.HasInverse) { return(null); } var inverseOperationInfo = stepParameters.CoordinateOperationInfo.GetInverse(); if (null == inverseOperationInfo) { return(null); } var expectedOutputUnits = stepParameters.RelatedOutputCrsUnit ?? stepParameters.RelatedInputCrsUnit ?? stepParameters.InputUnit; var forwardCompiledStep = CompileForwardToTransform(new StaticCoordinateOperationCompiler.StepCompilationParameters( inverseOperationInfo, expectedOutputUnits, stepParameters.RelatedOutputCrs, stepParameters.RelatedInputCrs )); if (null == forwardCompiledStep) { return(null); } var forwardCompiledOperation = forwardCompiledStep.Transformation; if (!forwardCompiledOperation.HasInverse) { return(null); } var inverseCompiledOperation = forwardCompiledOperation.GetInverse(); var resultTransformation = inverseCompiledOperation; // make sure that the input units are correct var unitConversion = StaticCoordinateOperationCompiler.CreateCoordinateUnitConversion(stepParameters.InputUnit, forwardCompiledStep.OutputUnit); if (null != unitConversion) { resultTransformation = new ConcatenatedTransformation(new[] { unitConversion, resultTransformation }); } return(new StaticCoordinateOperationCompiler.StepCompilationResult( stepParameters, expectedOutputUnits, resultTransformation )); }
private static StaticCoordinateOperationCompiler.StepCompilationResult CreateGeocentricTranslation(TransformationCompilationParams opData) { Contract.Requires(opData != null); var xParam = new KeywordNamedParameterSelector("XAXIS", "X"); var yParam = new KeywordNamedParameterSelector("YAXIS", "Y"); var zParam = new KeywordNamedParameterSelector("ZAXIS", "Z"); opData.ParameterLookup.Assign(xParam, yParam, zParam); Vector3 delta; if (!TryCreateVector3(xParam.Selection, yParam.Selection, zParam.Selection, out delta)) { return(null); } if (opData.StepParams.RelatedInputCrs is ICrsGeocentric && opData.StepParams.RelatedOutputCrs is ICrsGeocentric) { // assume the units are correct return(new StaticCoordinateOperationCompiler.StepCompilationResult( opData.StepParams, opData.StepParams.RelatedOutputCrsUnit ?? opData.StepParams.RelatedInputCrsUnit ?? opData.StepParams.InputUnit, new GeocentricTranslation(delta))); } // TODO: need to handle unit here var inputSpheroid = opData.StepParams.RelatedInputSpheroid; if (null == inputSpheroid) { return(null); } // TODO: may even need to convert units while translating // TODO: need to handle unit here var outputSpheroid = opData.StepParams.RelatedOutputSpheroid; if (null == outputSpheroid) { return(null); } ITransformation transformation = new GeographicGeocentricTranslation(inputSpheroid, delta, outputSpheroid); 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 CreateTunisiaMiningGrid(TransformationCompilationParams opData) { Contract.Requires(opData != null); ITransformation transformation = new TunisiaMiningGrid(); var conv = StaticCoordinateOperationCompiler.CreateCoordinateUnitConversion(opData.StepParams.InputUnit, OgcAngularUnit.DefaultGrads); if (null != conv) { transformation = new ConcatenatedTransformation(new[] { conv, transformation }); } return(new StaticCoordinateOperationCompiler.StepCompilationResult( opData.StepParams, OgcLinearUnit.DefaultKilometer, transformation)); }
private static StaticCoordinateOperationCompiler.StepCompilationResult CreateMadridToEd50Polynomial(TransformationCompilationParams opData) { Contract.Requires(opData != null); var a0Param = new FullMatchParameterSelector("A0"); var a1Param = new FullMatchParameterSelector("A1"); var a2Param = new FullMatchParameterSelector("A2"); var a3Param = new FullMatchParameterSelector("A3"); var b00Param = new FullMatchParameterSelector("B00"); var b0Param = new FullMatchParameterSelector("B0"); var b1Param = new FullMatchParameterSelector("B1"); var b2Param = new FullMatchParameterSelector("B2"); var b3Param = new FullMatchParameterSelector("B3"); opData.ParameterLookup.Assign(a0Param, a1Param, a2Param, a3Param, b00Param, b0Param, b1Param, b2Param, b3Param); double a0, a1, a2, a3, b00, b0, b1, b2, b3; TryGetCoefficientValue(a0Param.Selection, out a0); TryGetCoefficientValue(a1Param.Selection, out a1); TryGetCoefficientValue(a2Param.Selection, out a2); TryGetCoefficientValue(a3Param.Selection, out a3); TryGetCoefficientValue(b00Param.Selection, out b00); TryGetCoefficientValue(b0Param.Selection, out b0); TryGetCoefficientValue(b1Param.Selection, out b1); TryGetCoefficientValue(b2Param.Selection, out b2); TryGetCoefficientValue(b3Param.Selection, out b3); ITransformation transformation = new MadridEd50Polynomial(a0, a1, a2, a3, b00, b0, b1, b2, b3); var conv = StaticCoordinateOperationCompiler.CreateCoordinateUnitConversion(opData.StepParams.InputUnit, OgcAngularUnit.DefaultDegrees); if (null != conv) { transformation = new ConcatenatedTransformation(new[] { conv, transformation }); } return(new StaticCoordinateOperationCompiler.StepCompilationResult( opData.StepParams, OgcAngularUnit.DefaultDegrees, transformation)); }
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)); }