c#,arcengine,Arcobjects建立拓扑的完整例子
来源:互联网 发布:数据保密协议 编辑:程序博客网 时间:2024/05/16 10:35
public void ValidateTopology(ITopology topology, IEnvelope envelope)
{
// Get the dirty area within the provided envelope.
IPolygon locationPolygon = new PolygonClass();
ISegmentCollection segmentCollection = (ISegmentCollection)locationPolygon;
segmentCollection.SetRectangle(envelope);
IPolygon polygon = topology.get_DirtyArea(locationPolygon);
// If a dirty area exists, validate the topology.
if (!polygon.IsEmpty)
{
// Define the area to validate and validate the topology.
IEnvelope areaToValidate = polygon.Envelope;
IEnvelope areaValidated = topology.ValidateTopology(areaToValidate);
}
}
public void AddRuleToTopology(ITopology topology, esriTopologyRuleType ruleType,
String ruleName, IFeatureClass originClass, int originSubtype, IFeatureClass
destinationClass, int destinationSubtype)
{
// Create a new topology rule.
ITopologyRule topologyRule = new TopologyRuleClass();
topologyRule.TopologyRuleType = ruleType;
topologyRule.Name = ruleName;
topologyRule.OriginClassID = originClass.FeatureClassID;
topologyRule.AllOriginSubtypes = false;
topologyRule.OriginSubtype = originSubtype;
topologyRule.DestinationClassID = destinationClass.FeatureClassID;
topologyRule.AllDestinationSubtypes = false;
topologyRule.DestinationSubtype = destinationSubtype;
// Cast the topology to the ITopologyRuleContainer interface and add the rule.
ITopologyRuleContainer topologyRuleContainer = (ITopologyRuleContainer)
topology;
if (topologyRuleContainer.get_CanAddRule(topologyRule))
{
topologyRuleContainer.AddRule(topologyRule);
}
else
{
throw new ArgumentException("Could not add specified rule to the topology.")
;
}
}
public void AddRuleToTopology(ITopology topology, esriTopologyRuleType ruleType,
String ruleName, IFeatureClass featureClass)
{
// Create a new topology rule.
ITopologyRule topologyRule = new TopologyRuleClass();
topologyRule.TopologyRuleType = ruleType;
topologyRule.Name = ruleName;
topologyRule.OriginClassID = featureClass.FeatureClassID;
topologyRule.AllOriginSubtypes = true;
// Cast the topology to the ITopologyRuleContainer interface and add the rule.
ITopologyRuleContainer topologyRuleContainer = (ITopologyRuleContainer)
topology;
if (topologyRuleContainer.get_CanAddRule(topologyRule))
{
topologyRuleContainer.AddRule(topologyRule);
}
else
{
throw new ArgumentException("Could not add specified rule to the topology.")
;
}
}
public void ValidateTopology(ITopology topology, IEnvelope envelope)
{
// Get the dirty area within the provided envelope.
IPolygon locationPolygon = new PolygonClass();
ISegmentCollection segmentCollection = (ISegmentCollection)locationPolygon;
segmentCollection.SetRectangle(envelope);
IPolygon polygon = topology.get_DirtyArea(locationPolygon);
// If a dirty area exists, validate the topology.
if (!polygon.IsEmpty)
{
// Define the area to validate and validate the topology.
IEnvelope areaToValidate = polygon.Envelope;
IEnvelope areaValidated = topology.ValidateTopology(areaToValidate);
}
}
public void CreateTopology()
{
// Open the workspace and the required datasets.
IWorkspaceFactory workspaceFactory = new FileGDBWorkspaceFactoryClass();
IWorkspace workspace = workspaceFactory.OpenFromFile(@
"C:/arcgis/ArcTutor/BuildingaGeodatabase/Montgomery.gdb", 0);
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
IFeatureDataset featureDataset = featureWorkspace.OpenFeatureDataset(
"Landbase");
IFeatureClass blocksFC = featureWorkspace.OpenFeatureClass("Blocks");
IFeatureClass parcelsFC = featureWorkspace.OpenFeatureClass("Parcels");
// Attempt to acquire an exclusive schema lock on the feature dataset.
ISchemaLock schemaLock = (ISchemaLock)featureDataset;
try
{
schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
// Create the topology.
ITopologyContainer2 topologyContainer = (ITopologyContainer2)featureDataset;
ITopology topology = topologyContainer.CreateTopology("Landbase_Topology",
topologyContainer.DefaultClusterTolerance, - 1, "");
// Add feature classes and rules to the topology.
topology.AddClass(blocksFC, 5, 1, 1, false);
topology.AddClass(parcelsFC, 5, 1, 1, false);
AddRuleToTopology(topology, esriTopologyRuleType.esriTRTAreaNoOverlap,
"No Block Overlap", blocksFC);
AddRuleToTopology(topology,
esriTopologyRuleType.esriTRTAreaCoveredByAreaClass,
"ResParcels Covered by ResBlocks", parcelsFC, 1, blocksFC, 1);
// Get an envelope with the topology's extents and validate the topology.
IGeoDataset geoDataset = (IGeoDataset)topology;
IEnvelope envelope = geoDataset.Extent;
ValidateTopology(topology, envelope);
}
catch (COMException comExc)
{
throw new Exception(String.Format(
"Error creating topology: {0} Message: {1}", comExc.ErrorCode,
comExc.Message), comExc);
}
finally
{
schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
}
}
- c#,arcengine,Arcobjects建立拓扑的完整例子
- 关于C#+ArcEngine拓扑检查问题的解决方案
- ArcEngine中拓扑的使用
- ArcEngine中拓扑的使用
- ArcEngine的拓扑检查类
- flex拓扑图(完整例子)
- AVL树的建立完整C代码
- ArcEngine的拓扑分析之ITopologicalOperator
- ArcEngine 拓扑中 数据锁的使用
- ArcEngine的拓扑分析之ITopologicalOperator
- ArcEngine的拓扑分析之ITopologicalOperator
- c访问mysql的完整例子
- c访问mysql的完整例子
- c访问mysql的完整例子
- c访问mysql的完整例子
- 拓扑排序算法原理以及完整的C代码实现
- arcobjects,arcengine处理自相交对象
- arcobjects,arcengine中克隆一个对象Clone
- 男人感悟100条
- SQL字符串函数
- csdn里的小窝~~~
- 数据缓冲区对象管理器
- PSP游戏开放环境的建立
- c#,arcengine,Arcobjects建立拓扑的完整例子
- 卸载XP下 SQL server2000 终极版
- VC++FindSource问题
- 应用程序框架的模型
- 制作SupeSite采集器
- 你好!
- 好心情
- 《计算机系统要素》配套软件和资料下载 - sn@keGu@ng - CSDNBlog
- [转载]最小的Linux系统制作过程详解