/// <summary>
/// 地理坐标系 转 投影坐标系
/// </summary>
/// <param name="GCSgeo"></param>
/// <param name="GCSType">地理坐标系编号</param>
/// <param name="PRJType">投影坐标系编号</param>
/// <returns></returns>
private IGeometry GCStoPRJ(IGeometry GCSgeo, int GCSType, int PRJType)
{
IGeometry prjgeo = null;
if (GCSgeo.GeometryType == esriGeometryType.esriGeometryPolygon)
{
IPolygon polygon = new PolygonClass();
polygon = GCSgeo as IPolygon;
ISpatialReferenceFactory pSRF = new SpatialReferenceEnvironmentClass();
polygon.SpatialReference = pSRF.CreateGeographicCoordinateSystem(GCSType);
polygon.Project(pSRF.CreateProjectedCoordinateSystem(PRJType));
prjgeo = polygon as IGeometry;
}
else if (GCSgeo.GeometryType == esriGeometryType.esriGeometryLine)
{
IPolyline polyline = new PolylineClass();
polyline = GCSgeo as IPolyline;
ISpatialReferenceFactory pSRF = new SpatialReferenceEnvironmentClass();
polyline.SpatialReference = pSRF.CreateGeographicCoordinateSystem(GCSType);
polyline.Project(pSRF.CreateProjectedCoordinateSystem(PRJType));
prjgeo = polyline as IGeometry;
}
else if (GCSgeo.GeometryType == esriGeometryType.esriGeometryPoint)
{
IPoint point = new PointClass();
point = GCSgeo as IPoint;
ISpatialReferenceFactory pSRF = new SpatialReferenceEnvironmentClass();
point.SpatialReference = pSRF.CreateGeographicCoordinateSystem(GCSType);
point.Project(pSRF.CreateProjectedCoordinateSystem(PRJType));
prjgeo = point as IGeometry;
}
return prjgeo;
}
/// <summary>
/// 投影坐标系 转 地理坐标系
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="GCSType">地理坐标系编号</param>
/// <param name="PRJType">投影坐标系编号</param>
/// <returns></returns>
private IGeometry PRJtoGCS(IGeometry PRJgeo, int GCSType, int PRJType)
{
IGeometry prjgeo = null;
if (PRJgeo.GeometryType == esriGeometryType.esriGeometryPolygon)
{
IPolygon polygon = new PolygonClass();
polygon = PRJgeo as IPolygon;
ISpatialReferenceFactory pSRF = new SpatialReferenceEnvironmentClass();
polygon.SpatialReference = pSRF.CreateProjectedCoordinateSystem(PRJType);
polygon.Project(pSRF.CreateGeographicCoordinateSystem(GCSType));
prjgeo = polygon as IGeometry;
}
else if (PRJgeo.GeometryType == esriGeometryType.esriGeometryLine)
{
IPolyline polyline = new PolylineClass();
polyline = PRJgeo as IPolyline;
ISpatialReferenceFactory pSRF = new SpatialReferenceEnvironmentClass();
polyline.SpatialReference = pSRF.CreateProjectedCoordinateSystem(PRJType);
polyline.Project(pSRF.CreateGeographicCoordinateSystem(GCSType));
prjgeo = polyline as IGeometry;
}
else if (PRJgeo.GeometryType == esriGeometryType.esriGeometryPoint)
{
IPoint point = new PointClass();
point = PRJgeo as IPoint;
ISpatialReferenceFactory pSRF = new SpatialReferenceEnvironmentClass();
point.SpatialReference = pSRF.CreateProjectedCoordinateSystem(PRJType);
point.Project(pSRF.CreateGeographicCoordinateSystem(GCSType));
prjgeo = point as IGeometry;
}
return prjgeo;
}