private Helmert7Transformation ExtractHelmert7Transformation(EpsgCoordinateTransformInfo transform) { var method = transform.Method; Contract.Assume(method != null); var compiler = new StaticCoordinateOperationCompiler(); var compileRequest = new CoordinateOperationCrsPathInfo( new[] { transform.SourceCrs, transform.TargetCrs }, new[] { transform }); var compileResult = compiler.Compile(compileRequest); if (compileResult == null) { return(null); } var transformSteps = (compileResult as IEnumerable <ITransformation>) ?? ArrayUtil.CreateSingleElementArray(compileResult); var exposedSteps = transformSteps.Select(step => { if (step is GeocentricTransformationGeographicWrapper) { return(((GeocentricTransformationGeographicWrapper)step).GeocentricCore); } return(step); }); foreach (var step in exposedSteps) { if (step is Helmert7Transformation) { return(step as Helmert7Transformation); } if (step is GeocentricTranslation) { return(new Helmert7Transformation(((GeocentricTranslation)step).Delta)); } if (step is GeographicGeocentricTranslation) { return(new Helmert7Transformation(((GeographicGeocentricTranslation)step).Delta)); } } return(null); }
private Helmert7Transformation ExtractHelmert7Transformation(EpsgCoordinateTransformInfo transform) { var method = transform.Method; Contract.Assume(method != null); var compiler = new StaticCoordinateOperationCompiler(); var compileRequest = new CoordinateOperationCrsPathInfo( new[] { transform.SourceCrs, transform.TargetCrs }, new[] { transform }); var compileResult = compiler.Compile(compileRequest); if (compileResult == null) return null; var transformSteps = (compileResult as IEnumerable<ITransformation>) ?? ArrayUtil.CreateSingleElementArray(compileResult); var exposedSteps = transformSteps.Select(step => { if (step is GeocentricTransformationGeographicWrapper) { return ((GeocentricTransformationGeographicWrapper)step).GeocentricCore; } return step; }); foreach (var step in exposedSteps) { if (step is Helmert7Transformation) { return step as Helmert7Transformation; } if (step is GeocentricTranslation) { return new Helmert7Transformation(((GeocentricTranslation)step).Delta); } if (step is GeographicGeocentricTranslation) { return new Helmert7Transformation(((GeographicGeocentricTranslation)step).Delta); } } return null; }