Using arcobjects, I am trying to programmatically create a composite geotransformation and then use to project features with the geoprocessor. Found old VB6 code out there on the web, but I can't get it to work in C# .NET. When I try to use the projection tool in the geoprocessor, it fails and sends back a message saying "Invalid geographic transformation." The code I am using is below. Either I have built the composite transformation incorrectly, or, the geoprocessor cannot find it. Any ideas?
EDIT UPDATE:
private void createAndUseCompositeGeoTrans()
{
Geoprocessor gp = new Geoprocessor();
gp.OverwriteOutput = true;
object sev = 2;
object dt = "";
try
{
ISpatialReferenceFactory2 spatialReferenceFactory2 = new SpatialReferenceEnvironmentClass();
ISpatialReference in_spatialReference1 =
spatialReferenceFactory2.CreateSpatialReference(esriSRProjCSType.esriSRProjCS_NAD1983SPCS_WASouthFT.GetHashCode());
ISpatialReference out_spatialReference2
= spatialReferenceFactory2.CreateSpatialReference(esriSRProjCS2Type.esriSRProjCS_WGS1984SphereWebMercator.GetHashCode());
ICompositeGeoTransformation compGeoTrs = (ICompositeGeoTransformation)new CompositeGeoTransformation();
//NAD1983_To_WGS1984_1
IGeoTransformation geoTransformation_A = spatialReferenceFactory2.CreateGeoTransformation((int)esriSRGeoTransformationType.esriSRGeoTransformation_NAD1983_To_WGS1984_1) as IGeoTransformation;
compGeoTrs.Add(esriTransformDirection.esriTransformForward, geoTransformation_A);
// WGS_1984_Major_Auxiliary_Sphere_To_WGS_1984
IGeoTransformation geoTransformation_B = spatialReferenceFactory2.CreateGeoTransformation(108100) as IGeoTransformation;
compGeoTrs.Add(esriTransformDirection.esriTransformReverse, geoTransformation_B);
compGeoTrs.Name = "NAD1983_To_WGS_1984_Major_Auxiliary_Sphere";
IMapGeographicTransformations mapGeotrans = (IMapGeographicTransformations)map;
IGeoTransformationOperationSet geoTransOperationSet = mapGeotrans.GeographicTransformations;
geoTransOperationSet.Set(esriTransformDirection.esriTransformForward, compGeoTrs);
geoTransOperationSet.Set(esriTransformDirection.esriTransformReverse, compGeoTrs);
ESRI.ArcGIS.Carto.IActiveView activeView = (ESRI.ArcGIS.Carto.IActiveView)map;
activeView.Refresh();
ESRI.ArcGIS.DataManagementTools.Project projectTool = new ESRI.ArcGIS.DataManagementTools.Project();
projectTool.in_dataset = "C:\\projects\\clients\\Freeport\\CAD_Tool\\sampledata\\Point.shp";
projectTool.out_dataset = "C:\\projects\\clients\\Freeport\\CAD_Tool\\sampledata\\Test_002.shp"; ;
projectTool.in_coor_system = spatialReferenceFactory2.CreateProjectedCoordinateSystem(in_spatialReference1.FactoryCode);
projectTool.out_coor_system = spatialReferenceFactory2.CreateProjectedCoordinateSystem(out_spatialReference2.FactoryCode);
projectTool.transform_method = "NAD1983_To_WGS_1984_Major_Auxiliary_Sphere";
gp.Execute(projectTool, null);
}
catch (System.Runtime.InteropServices.COMException CE)
{
//throw CE;
printMsg(rTxtBx_console, CE.Message + "\n\nLast GP Message:\n" + gp.GetMessages(ref sev), MsgTypes.err);
}
catch (Exception E)
{
printMsg(rTxtBx_console, E.Message + "\n\nLast GP Message:\n" + gp.GetMessages(ref sev), MsgTypes.err);
}
}