首先理解一下基準面
基準面是在特定區域內與地球表面極爲吻合的橢球體。橢球體表面上的點與地球表面上的特定位置相匹配,也就是對橢球體進行定位,該點也被稱作基準面的原點,原點是固定的,所有其他點由其計算獲得。基準面的座標系原點往往距地心有一定偏移(有的也在地心,如WGS1984),如西安80的基準面和北京54的基準面,因爲原點不同,所以不同的基準面上,同一個點的座標是不相同的。
利用ArcEngine創建一個座標系或者基準面的是SpatialReferenceClass類,
該類實現了ISpatialReferenceFactory接口,該接口定義了創建座標系,基準面等方法和屬性;在利用 ISpatialReferenceFactory創建座標系的時候往往需要一個int類型的參數,這個int其實就是這些座標系的代號,如我們熟悉的4326就是WGS1984.
同一基準面的座標轉換
對於同一基準面,我們可以肯定一點就是同一位置經緯度座標是一樣的,而不同的就是計算成平面座標的時候可能有所不同,因爲算法不一樣,在這裏我只是將經緯度座標轉成平面的座標。
private IPoint GetProjectPoint(IPoint pPoint, boolpBool)
{
ISpatialReferenceFactory pSpatialReferenceEnvironment = new SpatialReferenceEnvironment();
ISpatialReference pFormSpatialReference = pSpatialReferenceEnvironment.Creat eGeographicCoordinateSystem((int)esriGeoCS3Type.esriSRGeo_Xian1980)'//西安80
ISpatialReference pToSpatialReference =
pSpatialReferenceEnvironemnt.CreateProjectedCoordinateSystem((int)esriSRProjCS4Type.esriSRProjCS_Xian1980_3_Degree_GK_Zone_34);//西安80
if (pBool == true)//球面轉平面
{
IGeometry pGeo = (IGeometry)pPoint;
pGeo.SpatialReference = pFromSpatialReference;
pGeo.Project(pToSpatialReference);
return pPoint;
}
else //平面轉球面
{
IGeometry pGeo = (IGeometry)pPoint;
pGeo.SpatialReference = pToSpatialReference;
pGeo.Project(pFromSpatialReference);
return pPoint;
}
}