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.
73 lines
2.6 KiB
73 lines
2.6 KiB
using System; |
|
using System.Collections.Generic; |
|
using System.Linq; |
|
using System.Text; |
|
using ESRI.ArcGIS.esriSystem; |
|
using ESRI.ArcGIS.Geometry; |
|
|
|
namespace Kingo.RuleCheck.CheckHelper |
|
{ |
|
/// <summary> |
|
/// 合并图形类 |
|
/// </summary> |
|
public class UnionGeometry |
|
{ |
|
private IGeometryCollection m_pGeometryCollection = new GeometryBagClass(); |
|
|
|
public IGeometryCollection GeometryCollection |
|
{ |
|
get { return m_pGeometryCollection; } |
|
} |
|
|
|
/// <summary> |
|
/// 添加图形 |
|
/// </summary> |
|
/// <param name="pGeometry"></param> |
|
/// <returns></returns> |
|
public bool AddGeometry(IGeometry pGeometry) |
|
{ |
|
object missing = Type.Missing; |
|
IClone pClone = pGeometry as IClone; |
|
IGeometry pTemp = pClone.Clone() as IGeometry; |
|
m_pGeometryCollection.AddGeometry(pTemp, ref missing, ref missing); |
|
return true; |
|
} |
|
|
|
/// <summary> |
|
/// 合并图形 |
|
/// </summary> |
|
/// <returns></returns> |
|
public IGeometry ConstructUnion() |
|
{ |
|
if (m_pGeometryCollection.GeometryCount == 0) return null; |
|
if (m_pGeometryCollection.GeometryCount == 1) return m_pGeometryCollection.get_Geometry(0); |
|
if (m_pGeometryCollection.get_Geometry(0).GeometryType == esriGeometryType.esriGeometryPolygon) |
|
{ |
|
ITopologicalOperator4 pTopologicalOperator4 = new PolygonClass(); |
|
pTopologicalOperator4.ConstructUnion(m_pGeometryCollection as IEnumGeometry); |
|
|
|
ITopologicalOperator2 pTopo2 = pTopologicalOperator4 as ITopologicalOperator2; |
|
pTopo2.IsKnownSimple_2 = false; |
|
pTopo2.Simplify(); |
|
|
|
return pTopo2 as IGeometry; |
|
} |
|
else if (m_pGeometryCollection.get_Geometry(0).GeometryType == esriGeometryType.esriGeometryPolyline) |
|
{ |
|
ITopologicalOperator3 pTopologicalOperator3 = new PolylineClass(); |
|
pTopologicalOperator3.ConstructUnion(m_pGeometryCollection as IEnumGeometry); |
|
return pTopologicalOperator3 as IGeometry; |
|
} |
|
else if (m_pGeometryCollection.get_Geometry(0).GeometryType == esriGeometryType.esriGeometryPoint) |
|
{ |
|
ITopologicalOperator2 pTopologicalOperator2 = new MultipointClass(); |
|
pTopologicalOperator2.ConstructUnion(m_pGeometryCollection as IEnumGeometry); |
|
return pTopologicalOperator2 as IGeometry; |
|
} |
|
else |
|
{ |
|
return null; |
|
} |
|
} |
|
} |
|
}
|
|
|