码迷,mamicode.com
首页 > 其他好文 > 详细

Engine中如何进行七参数投影转换?

时间:2016-02-23 15:53:16      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

来自:http://zhihu.esrichina.com.cn/?/question/6858

解决办法】:
首先创建自定义geotransformation,然后用IGeometry.ProjectEx进行投影转换。参考代码(以wgs1984转到Xian80为例):

private void func1ToolStripMenuItem_Click(object sender, EventArgs e) 
{ 
Type t = Type.GetTypeFromProgID(esriGeometry.SpatialReferenceEnvironment); 
System.Object obj = Activator.CreateInstance(t); 
ISpatialReferenceFactory srFact = obj as ISpatialReferenceFactory; 
IGeographicCoordinateSystem wgs84GCS = srFact.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984); 
IProjectedCoordinateSystem xian80PCS = srFact.CreateProjectedCoordinateSystem((int)esriSRProjCS4Type.esriSRProjCS_Xian1980_3_Degree_GK_CM_102E); 

IGeoTransformation geoTrans = CreateGeoTransformation((ISpatialReference)wgs84GCS, (ISpatialReference)xian80PCS); 

IWorkspaceFactory wksfac = new FileGDBWorkspaceFactoryClass(); 
IFeatureWorkspace feawks = wksfac.OpenFromFile(@E:TEST.gdb,0) as IFeatureWorkspace; 
IFeatureClass fc = feawks.OpenFeatureClass(POINT); 
IFeature fea = fc.Search(null, false).NextFeature(); 
IGeometry5 geometry; 
IPoint point = fea.ShapeCopy as IPoint; 
geometry = point as IGeometry5; 
geometry.SpatialReference = wgs84GCS; 

geometry.ProjectEx(xian80PCS, esriTransformDirection.esriTransformForward, geoTrans, false, 0.0, 0.0); 
point = geometry as IPoint; 
MessageBox.Show(point.X.ToString(),point.Y.ToString()); 
} 

private IGeoTransformation CreateGeoTransformation(ISpatialReference pInputSR, ISpatialReference pOutputSR) 
{ 
IGeoTransformation pGeoTrans; 
pGeoTrans = new CoordinateFrameTransformationClass(); 

((ICoordinateFrameTransformation)pGeoTrans).PutSpatialReferences(pInputSR, pOutputSR); 
((ICoordinateFrameTransformation)pGeoTrans).PutParameters(p1, p2, p3, p4, p5, p6, p7); 

return pGeoTrans; 
}

Engine中如何进行七参数投影转换?

标签:

原文地址:http://www.cnblogs.com/gisoracle/p/5210047.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!