对于刚刚在道路尽头的环(如cul de sac灯泡),使用“创建路线”工具,找到MMonotonicity值为4或更高的道路 .
2)在道路网络中查找悬空节点:使用此代码
using System;
using System.Collections.Generic;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Carto;
using System.Windows.Forms;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.EditorExt;
namespace KalkulatorAddin
{
public class TestButton : ESRI.ArcGIS.Desktop.AddIns.Button
{
public TestButton()
{
}
protected override void OnClick()
{
try
{
Test();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
protected override void OnUpdate()
{
}
public void Test()
{
var fSel = ArcMap.Document.FocusMap.get_Layer(0) as IFeatureSelection;
fSel.Clear();
var dangleOids = GetDangleOids();
if (dangleOids.Count > 0)
{
var oidarray = dangleOids.ToArray();
fSel.SelectionSet.AddList(dangleOids.Count, ref oidarray[0]);
}
((IActiveView)ArcMap.Document.FocusMap).Refresh();
}
private List<int> GetDangleOids()
{
UID topoUiD = new UID();
topoUiD.Value = "esriEditorExt.TopologyExtension";
var topoExt = ArcMap.Application.FindExtensionByCLSID(topoUiD) as ITopologyExtension;
var mapTopology = topoExt.CurrentTopology as IMapTopology;
if (mapTopology == null)
throw new Exception("map topology not found");
//assume just one class in the map topology
var extent = ((IGeoDataset)mapTopology.get_Class(0)).Extent;
mapTopology.Cache.Build(extent, false);
var dangleOids = new List<int>();
var nodes = mapTopology.Cache.Nodes;
nodes.Reset();
ITopologyNode node;
while ((node = nodes.Next()) != null)
{
// sometimes degree is referred to as valence
if (node.Degree == 1)
{
var parents = node.Parents;
parents.Reset();
int oid = parents.Next().m_FID;
if (!dangleOids.Contains(oid))
dangleOids.Add(oid);
}
}
return dangleOids;
}
}
}
1 回答
1) Finding Loops in Road Network: 对于形成3/4环的道路,使用弯曲度公式(线端/长度之间的距离) . Python公式是:
对于刚刚在道路尽头的环(如cul de sac灯泡),使用“创建路线”工具,找到MMonotonicity值为4或更高的道路 .
2)在道路网络中查找悬空节点:使用此代码