根据网络弧段和网络结点表示的网络关系,构建拓扑逻辑图。在调用此接口之前,必须先设置结果数据集所在的数据源和数据集名称。

命名空间:  SuperMap.Analyst.SpatialAnalyst
程序集:  SuperMap.Analyst.SpatialAnalyst (in SuperMap.Analyst.SpatialAnalyst)
版本: dll

语法

C#
public virtual DatasetVector Build(
	NetworkEdge[] networkEdges,
	NetworkNode[] networkNodes,
	bool isMerger,
	double tolerance
)

参数

networkEdges
Type: array< SuperMap.Analyst.SpatialAnalyst..::.NetworkEdge >[]()[]
表示网络关系的网络弧段对象集合。
networkNodes
Type: array< SuperMap.Analyst.SpatialAnalyst..::.NetworkNode >[]()[]
表示网络关系的网络结点对象集合。
isMerger
Type: System..::.Boolean
是否设置合并空间位置上重复的网络弧段和网络结点对象。网络关系中,如果存在空间位置上的重复弧段和重复结点,如果设置此参数为true,则会提取一份公共的弧段关系构建逻辑图,在构建的拓扑逻辑图也含有空间位置上的重复弧段和结点。如果设置此参数为false,则计算拓扑逻辑图时对每条正确的网络拓扑关系都正常处理。
tolerance
Type: System..::.Double
节点容限,用于空间计算中节点对象比较。如果isMerge参数为true,则此参数有效,否则此参数无效。

返回值

构建成功返回存储拓扑逻辑图的二维网络数据集,否则,返回null。

示例

以下代码示范了通过网络弧段对象构建直角正交逻辑拓扑图

CopyC#
public bool TestOrthogonalSchema(Datasource datasource)
{
   if (datasource == null)
   {
       System.Console.WriteLine("数据源为空");
       return false;
   }
   String datasetName = "SrcNet";
   DatasetVector datasetNet = datasource.Datasets[datasetName] as DatasetVector;
   if (datasetNet == null)
   {
       System.Console.WriteLine("获取网络数据集失败");
       return false;
   }
   DatasetVector datasetNetNode = datasetNet.ChildDataset;
   if (datasetNetNode == null)
   {
       System.Console.WriteLine("获取网络数据集结点数据集失败");
       return false;
   }
   datasetNet.Open();
   datasetNetNode.Open();
   Recordset recordset = datasetNet.GetRecordset(false, CursorType.Static);
   if (recordset == null)
   {
       System.Console.WriteLine("查询记录集失败");
       return false;
   }
   Recordset recordsetNode = datasetNetNode.GetRecordset(false, CursorType.Static);
   if (recordsetNode == null)
   {
       recordset.Dispose();
       System.Console.WriteLine("查询记录集失败");
       return false;
   }
   // 获取网络弧段对象
   String edgeIDField = datasetNet.GetFieldNameBySign(FieldSign.EdgeID);
   String fromNodeIDField = datasetNet.GetFieldNameBySign(FieldSign.FNode);
   String toNodeIDField = datasetNet.GetFieldNameBySign(FieldSign.TNode);
   NetworkEdge[] networkEdges = new NetworkEdge[recordset.RecordCount];
   int i=0;
   while (!recordset.IsEOF)
   {
       NetworkEdge networkEdge = new NetworkEdge();
       networkEdge.NetworkEdgeID = new NetworkEdgeID();
       networkEdge.NetworkEdgeID.EdgeID = recordset.GetInt32(edgeIDField);
       networkEdge.NetworkEdgeID.FromNodeID = recordset.GetInt32(fromNodeIDField);
       networkEdge.NetworkEdgeID.ToNodeID = recordset.GetInt32(toNodeIDField);
       networkEdge.Edge = recordset.GetGeometry();
       networkEdges[i++] = networkEdge;
       recordset.MoveNext();
   }
   recordset.Dispose();
   // 获取网络结点对象
   String nodeIDField = datasetNet.GetFieldNameBySign(FieldSign.NodeID);
   NetworkNode[] networkNodes = new NetworkNode[recordsetNode.RecordCount];
   i = 0;
   while (!recordsetNode.IsEOF)
   {
       networkNodes[i] = new NetworkNode();
       networkNodes[i].NodeID = recordsetNode.GetInt32(nodeIDField);
       networkNodes[i].Node = recordsetNode.GetGeometry();
       i++;
       recordsetNode.MoveNext();
   }
   recordsetNode.Dispose();

   Boolean isMerge = false;
   double tolerance = 1e-8;
   TopologicalOrthogonalSchema orthogonalSchema = new TopologicalOrthogonalSchema();
   orthogonalSchema.OutputDatasetName = datasource.Datasets.GetAvailableDatasetName("ResultSchema");
   orthogonalSchema.OutputDatasource = datasource;
   DatasetVector resultDt = orthogonalSchema.Build(networkEdges, networkNodes, isMerge, tolerance);
   // 直角正交拓扑图对象释放
   orthogonalSchema.Dispose();

   // 释放网络弧段几何对象
   foreach(NetworkEdge networkEdge in networkEdges)
   {
       networkEdge.Edge.Dispose();
   }

   // 释放网络结点几何对象
   foreach (NetworkNode networkNode in networkNodes)
   {
       networkNode.Node.Dispose();
   }
   return resultDt != null;
}

版本信息

SuperMap iObjects .NET


请参见