Engine中如何实现ArcMap中的Transformations功能?

ArcMap中的Data Frame Properties中的Transformations功能在Engine中对应什么接口?
已邀请:

朱新颖

赞同来自:

【解决办法】:
将IMap转为IMapGeographicTransformations接口,然后通过IMapGeographicTransformations.GeographicTransformations获取IGeoTransformationOperationSet,通过IGeoTransformationOperationSet.Set将自定义的IGeoTransformation添加进去,然后将该mxd保存之后在ArcMap中打开就已经进行动态投影了。
测试代码:

ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
ISpatialReference spatialReference = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
spatialReference.SetFalseOriginAndUnits(-80.0000000232831, 39.9999999767169, 42949672.9);
//Destination spatial reference
IProjectedCoordinateSystem projectedCoordinateSystem = spatialReferenceFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1927UTM_19N);
//Define the XYDomain equivalent to SetFalseOriginAndUnits
projectedCoordinateSystem.SetDomain(500000, 600000, 5300000, 5600000);
//Create a Geotransformation (Datum transformation)
IGeoTransformation geoTransformation = spatialReferenceFactory.CreateGeoTransformation((int)esriSRGeoTransformationType.esriSRGeoTransformation_NAD1927_To_WGS1984_12) as IGeoTransformation;
IMapDocument mapDocument = new MapDocumentClass();

string filepath = @C:\Users\Administrator\Desktop\mxd\无标题1.mxd;
mapDocument.Open(filepath);

IMap map = axMapControl1.Map;
IMapGeographicTransformations mapGeographicTrans = map as IMapGeographicTransformations;
IGeoTransformationOperationSet geoTrans = mapGeographicTrans.GeographicTransformations;
geoTrans.Set(esriTransformDirection.esriTransformReverse, geoTransformation);
IMxdContents mxd = axMapControl1.Map as IMxdContents;
mapDocument.ReplaceContents(mxd);
mapDocument.Save(true, false);

要回复问题请先登录注册