Ejemplo n.º 1
0
 public StaticCoordinateOperationCompiler.StepCompilationResult Compile(StaticCoordinateOperationCompiler.StepCompilationParameters stepParameters)
 {
     if (stepParameters == null)
     {
         throw new ArgumentNullException("stepParameters");
     }
     Contract.EndContractBlock();
     return(CompileInverse(stepParameters)
            ?? CompileForwards(stepParameters));
 }
Ejemplo n.º 2
0
 public TransformationCompilationParams(
     StaticCoordinateOperationCompiler.StepCompilationParameters stepParams,
     NamedParameterLookup parameterLookup,
     string operationName
     )
 {
     Contract.Requires(stepParams != null);
     Contract.Requires(parameterLookup != null);
     Contract.Requires(!String.IsNullOrEmpty(operationName));
     StepParams      = stepParams;
     ParameterLookup = parameterLookup;
     OperationName   = operationName;
 }
Ejemplo n.º 3
0
        private StaticCoordinateOperationCompiler.StepCompilationResult CompileForwardToTransform(StaticCoordinateOperationCompiler.StepCompilationParameters stepParameters)
        {
            Contract.Requires(stepParameters != null);
            string operationName = null;
            IEnumerable <INamedParameter> parameters = null;

            var parameterizedOperation = stepParameters.CoordinateOperationInfo as IParameterizedCoordinateOperationInfo;

            if (null != parameterizedOperation)
            {
                if (null != parameterizedOperation.Method)
                {
                    operationName = parameterizedOperation.Method.Name;
                }
                parameters = parameterizedOperation.Parameters;
            }

            if (String.IsNullOrEmpty(operationName))
            {
                operationName = stepParameters.CoordinateOperationInfo.Name;
            }
            if (String.IsNullOrEmpty(operationName))
            {
                return(null);
            }

            var parameterLookup   = new NamedParameterLookup(parameters ?? Enumerable.Empty <INamedParameter>());
            var compilationParams = new TransformationCompilationParams(stepParameters, parameterLookup, operationName);

            var normalizedName = _coordinateOperationNameComparer.Normalize(compilationParams.OperationName);

            if (normalizedName.StartsWith("POSITIONVECTORTRANSFORMATION"))
            {
                return(CreatePositionVectorTransformation(compilationParams));
            }
            if (normalizedName.StartsWith("COORDINATEFRAMEROTATION"))
            {
                return(CreateCoordinateFrameRotationTransformation(compilationParams));
            }
            if (normalizedName.StartsWith("MOLODENSKYBADEKAS"))
            {
                return(CreateMolodenskyBadekas(compilationParams));
            }
            if (normalizedName.Equals("GEOGRAPHICOFFSET") || (normalizedName.StartsWith("GEOGRAPHIC") && normalizedName.EndsWith("OFFSET")))
            {
                return(CreateGeographicOffset(compilationParams));
            }
            if (normalizedName.StartsWith("GEOCENTRICTRANSLATION"))
            {
                return(CreateGeocentricTranslation(compilationParams));
            }
            if (normalizedName.Equals("VERTICALOFFSET"))
            {
                return(CreateVerticalOffset(compilationParams));
            }
            if (normalizedName.Equals("MADRIDTOED50POLYNOMIAL"))
            {
                return(CreateMadridToEd50Polynomial(compilationParams));
            }
            if (normalizedName.Equals("SIMILARITYTRANSFORMATION"))
            {
                return(CreateSimilarityTransformation(compilationParams));
            }
            if (normalizedName.Equals("AFFINEPARAMETRICTRANSFORMATION"))
            {
                return(CreateAffineParametricTransformation(compilationParams));
            }
            if (normalizedName.Equals("GEOGRAPHIC3DTO2DCONVERSION") || normalizedName.Equals("GEOGRAPHIC2DTO3DCONVERSION"))
            {
                return(CreateGeographicDimensionChange(compilationParams));
            }
            if (normalizedName.Equals("TUNISIAMININGGRID"))
            {
                return(CreateTunisiaMiningGrid(compilationParams));
            }
            if (normalizedName.StartsWith("GEOCENTRICTOPOCENTRIC"))
            {
                return(CreateGeocentricTopocentric(compilationParams));
            }
            if (normalizedName.StartsWith("GEOGRAPHICTOPOCENTRIC"))
            {
                return(CreateGeographicTopocentric(compilationParams));
            }
            if (normalizedName.StartsWith("VERTICALPERSPECTIVE"))
            {
                return(CreateVerticalPerspective(compilationParams));
            }
            return(null);
        }
Ejemplo n.º 4
0
        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
                       ));
        }
Ejemplo n.º 5
0
        private StaticCoordinateOperationCompiler.StepCompilationResult CompileForwards(StaticCoordinateOperationCompiler.StepCompilationParameters stepParameters)
        {
            Contract.Requires(stepParameters != null);
            var forwardCompiledStep = CompileForwardToTransform(stepParameters);

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

            return(new StaticCoordinateOperationCompiler.StepCompilationResult(
                       stepParameters,
                       forwardCompiledStep.OutputUnit,
                       forwardCompiledStep.Transformation
                       ));
        }