You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.7 KiB
69 lines
2.7 KiB
using System; |
|
using System.Collections.Generic; |
|
using System.Text; |
|
using ESRI.ArcGIS.Geodatabase; |
|
using ESRI.ArcGIS.Geometry; |
|
using ESRI.ArcGIS.Carto; |
|
using ESRI.ArcGIS.esriSystem; |
|
using System.Runtime.InteropServices; |
|
using KGIS.Framework.AE.GaussCalculate; |
|
|
|
namespace Kingo.Plugin.General.Helper |
|
{ |
|
/// <summary> |
|
/// 计算椭球面积入口 |
|
/// </summary> |
|
public class ATEllipseArea |
|
{ |
|
//private ISpatialReference pSpatialReference; |
|
public ATEllipseArea() { } |
|
|
|
/// <summary> |
|
/// 获得单个多边形椭球面积 |
|
/// </summary> |
|
/// <param name="pIPolygon">多边形</param> |
|
/// <returns>该多边形面积</returns> |
|
public static double GetPolygonArea(IPolygon pIPolygon) |
|
{ |
|
try |
|
{ |
|
// 1、获得投影 |
|
String SphName = pIPolygon.SpatialReference.Name.ToString().ToUpper(); |
|
// 2、获得椭球 |
|
ICoordinate coordinate = CoordinateFactory.CreateCoordinate(); |
|
if (SphName.Contains("XIAN_1980") || SphName.Contains("XIAN1980")) |
|
{ |
|
coordinate = CoordinateFactory.CreateCoordinate((KGIS.Framework.AE.GaussCalculate.Spheroid)KGIS.Framework.AE.GaussCalculate.Spheroid.SphXian80); |
|
} |
|
else if (SphName.Contains("BEIJING_1954") || SphName.Contains("BEIJING1954")) |
|
{ |
|
coordinate = CoordinateFactory.CreateCoordinate((KGIS.Framework.AE.GaussCalculate.Spheroid)KGIS.Framework.AE.GaussCalculate.Spheroid.SphBeijing54); |
|
} |
|
else if (SphName.Contains("WGS_1984") || SphName.Contains("WGS1984")) |
|
{ |
|
coordinate = CoordinateFactory.CreateCoordinate((KGIS.Framework.AE.GaussCalculate.Spheroid)KGIS.Framework.AE.GaussCalculate.Spheroid.SphWGS84); |
|
} |
|
else if (SphName.Contains("CGCS_2000") || SphName.Contains("CGCS2000")) |
|
{ |
|
coordinate = CoordinateFactory.CreateCoordinate((KGIS.Framework.AE.GaussCalculate.Spheroid)KGIS.Framework.AE.GaussCalculate.Spheroid.SphCGCS2000); |
|
} |
|
else |
|
{ |
|
return -1; |
|
} |
|
// 3、计算面积 |
|
IGeometry pGeometry = pIPolygon as IGeometry; |
|
double PolygonArea = 0.0; |
|
// 4、保留两位小数 |
|
double a = coordinate.CalculateTerranArea(pGeometry); |
|
PolygonArea = Math.Round(a, 2, MidpointRounding.AwayFromZero); |
|
return PolygonArea; |
|
} |
|
catch (Exception ex) |
|
{ |
|
throw ex; |
|
} |
|
} |
|
|
|
} |
|
}
|
|
|