YouTube | Facebook | Twitter  Feed

トポロジの構築

2016/9/1 (木)

Public Sub CreateTopology()
 
Dim pWSFact As IWorkspaceFactory
Set pWSFact = New AccessWorkspaceFactory
 
Dim pWor As IWorkspace
Set pWor = pWSFact.OpenFromFile("D:\WorkSpace\Personal Geodatabase.mdb", 0)
 
Dim pFWS As IFeatureWorkspace
Set pFWS = pWor
 
Dim pDS As IDataset
Set pDS = pFWS.OpenFeatureDataset("Dataset")
 
Dim pTopoCont As ITopologyContainer
Set pTopoCont = pDS
 
'Create the topology
Dim pTopo As ITopology
Set pTopo = pTopoCont.CreateTopology("Topology", pTopoCont.DefaultClusterTolerance, -1, "")
 
Dim pFCC As IFeatureClassContainer
Set pFCC = pDS
 
Dim pFC As IFeatureClass
Set pFC = pFCC.ClassByName("Roads")
 
'Add the feature class to the topology
pTopo.AddClass pFC, 5, 1, 1, False
 
'Create the first rule
Dim pRule As ITopologyRule
Dim pRuleCont As ITopologyRuleContainer
Set pRule = New TopologyRule
pRule.TopologyRuleType = esriTRTLineNoOverlap
pRule.OriginClassID = pFC.ObjectClassID
pRule.AllOriginSubtypes = True
pRule.Name = "Roads No Overlap"
 
'Add the rule to the topology
Set pRuleCont = pTopo
pRuleCont.AddRule pRule
 
'Create the second rule
Set pRule = New TopologyRule
pRule.TopologyRuleType = esriTRTLineNoDangles
pRule.OriginClassID = pFC.ObjectClassID
pRule.AllOriginSubtypes = True
pRule.Name = "Roads No Dangles"
 
'Add the rule to the topology
If pRuleCont.CanAddRule(pRule) Then pRuleCont.AddRule pRule
 
End Sub

関連記事

  • この記事を書いた人

羽田 康祐

Twitter#一日一図法を連載中。GIS上級技術者、Esri認定インストラクター、CompTIA CTT+ Classroom Trainer、潜水士、元PADIダイブマスター、四アマ。 代表著書『地図リテラシー入門―地図の正しい読み方・描き方がわかる』 GIS を使った自己紹介はこちら。ESRIジャパン(株)所属、発言は個人の見解です。

-プログラミング, ArcGIS
-,