错误 52 参数 1: 无法从“ref 地下管网管理系统.IJunctionFlag[]”转换为“ref ESRI.ArcGIS.NetworkAnalysis

qq_39453206 2018-04-20 09:47:35
private void toolStripButtonSolver_Click(object sender, EventArgs e)
{
try
{
//首先清除已有的分析结果
ClearElements(axMapControl1.ActiveView, "Result");

//为追踪任务解决器设置进行分析的管点
IJunctionFlag[] arrayJunctionFlag = new IJunctionFlag[listJunctionFlags.Count];
for (int i = 0; i < listJunctionFlags.Count; i++)
arrayJunctionFlag[i] = listJunctionFlags[i];
traceFlowSolverGEN.PutJunctionOrigins(ref arrayJunctionFlag);
//为追踪任务解决器设置进行分析的管线
IEdgeFlag[] arrayEdgeFlag = new IEdgeFlag[listEdgeFlags.Count];
for (int j = 0; j < listEdgeFlags.Count; j++)
arrayEdgeFlag[j] = listEdgeFlags[j];
traceFlowSolverGEN.PutEdgeOrigins(ref arrayEdgeFlag);
//为追踪任务解决器设置进行分析的管点障碍或管线障碍
INetElementBarriersGEN netElementBarriersGEN = new NetElementBarriersClass();
netElementBarriersGEN.Network = geometricNetwork.Network;
//如果目前有管点障碍,则加入分析器中
if (listJunctionBarrierEIDs.Count > 0)
{
int[] junctionBarrierEIDs = new int[listJunctionBarrierEIDs.Count];
for (int u = 0; u < junctionBarrierEIDs.Length; u++)
junctionBarrierEIDs[u] = listJunctionBarrierEIDs[u];
netElementBarriersGEN.ElementType = esriElementType.esriETJunction;
netElementBarriersGEN.SetBarriersByEID(ref junctionBarrierEIDs);
netSolver.set_ElementBarriers(esriElementType.esriETJunction, netElementBarriersGEN as INetElementBarriers);
}
//否则将管点障碍设置为空
else
netSolver.set_ElementBarriers(esriElementType.esriETJunction, null);
//如果目前有管线障碍,则加入分析器中
if (listEdgeBarrierEIDs.Count > 0)
{
int[] edgeBarrierEIDs = new int[listEdgeBarrierEIDs.Count];
for (int u = 0; u < edgeBarrierEIDs.Length; u++)
edgeBarrierEIDs[u] = listEdgeBarrierEIDs[u];
netElementBarriersGEN.ElementType = esriElementType.esriETEdge;
netElementBarriersGEN.SetBarriersByEID(ref edgeBarrierEIDs);
netSolver.set_ElementBarriers(esriElementType.esriETEdge, netElementBarriersGEN as INetElementBarriers);
}
//否则将管线障碍设置为空
else
netSolver.set_ElementBarriers(esriElementType.esriETEdge, null);
//定义相关变量
IEnumNetEID junctionEIDs = new EnumNetEIDArrayClass();
IEnumNetEID edgeEIDs = new EnumNetEIDArrayClass();
int count = -1;
object[] segmentCosts = null;
object pTotalCost = null;

switch (toolStripComboBoxTraceTasks.SelectedIndex)
{
//查找共同祖先
case 0:
traceFlowSolverGEN.FindCommonAncestors(esriFlowElements.esriFEJunctionsAndEdges,
out junctionEIDs, out edgeEIDs);
toolStripStatusLabel.Text = "";
break;
//查找相连接的网络要素
case 1:
traceFlowSolverGEN.FindFlowElements(esriFlowMethod.esriFMConnected, esriFlowElements.esriFEJunctionsAndEdges,
out junctionEIDs, out edgeEIDs);
toolStripStatusLabel.Text = "";
break;
//查找网络中的环
case 2:
traceFlowSolverGEN.FindCircuits(esriFlowElements.esriFEJunctionsAndEdges, out junctionEIDs, out edgeEIDs);
toolStripStatusLabel.Text = "";
break;
//查找未连接的网络要素
case 3:
traceFlowSolverGEN.FindFlowUnreachedElements(esriFlowMethod.esriFMConnected, esriFlowElements.esriFEJunctionsAndEdges,
out junctionEIDs, out edgeEIDs);
toolStripStatusLabel.Text = "";
break;
//查找上游路径。同时获取网络追踪的耗费。
case 4:
count = GetSegmentCounts();
segmentCosts = new object[count];
traceFlowSolverGEN.FindSource(esriFlowMethod.esriFMUpstream, esriShortestPathObjFn.esriSPObjFnMinSum,
out junctionEIDs, out edgeEIDs, count, ref segmentCosts);
toolStripStatusLabel.Text = "网络追踪的总耗费为:" + GetSegmentCosts(segmentCosts).ToString();
break;
//查找路径。同时获取网络追踪的耗费。count比所有标识的总数少1个。当同时存在JunctionFlag和EdgeFlag时,该功能不可用。
case 5:
if (listJunctionFlags.Count > 0 && listEdgeFlags.Count > 0)
break;
else if (listJunctionFlags.Count > 0)
count = listJunctionFlags.Count - 1;
else if (listEdgeFlags.Count > 0)
count = listEdgeFlags.Count - 1;
else
break;
segmentCosts = new object[count];
traceFlowSolverGEN.FindPath(esriFlowMethod.esriFMConnected, esriShortestPathObjFn.esriSPObjFnMinSum,
out junctionEIDs, out edgeEIDs, count, ref segmentCosts);
toolStripStatusLabel.Text = "网络追踪的总耗费为:" + GetSegmentCosts(segmentCosts).ToString();
break;
//下游追踪
case 6:
traceFlowSolverGEN.FindFlowElements(esriFlowMethod.esriFMDownstream, esriFlowElements.esriFEJunctionsAndEdges,
out junctionEIDs, out edgeEIDs);
toolStripStatusLabel.Text = "";
break;
//查找上游路径累积消耗。同时获取网络追踪的耗费。
case 7:
pTotalCost = new object();
traceFlowSolverGEN.FindAccumulation(esriFlowMethod.esriFMUpstream, esriFlowElements.esriFEJunctionsAndEdges,
out junctionEIDs, out edgeEIDs, out pTotalCost);
toolStripStatusLabel.Text = "网络追踪的总耗费为:" + pTotalCost.ToString();
break;
//上游追踪。
case 8:
count = GetSegmentCounts();
segmentCosts = new object[count];
traceFlowSolverGEN.FindSource(esriFlowMethod.esriFMUpstream, esriShortestPathObjFn.esriSPObjFnMinSum,
out junctionEIDs, out edgeEIDs, count, ref segmentCosts);
toolStripStatusLabel.Text = "";
break;
}
//绘制分析结果
DrawTraceResults(junctionEIDs, edgeEIDs, GetColorByRGBValue(255, 0, 0));
}
catch { }
标记处出现错误 错误 52 参数 1: 无法从“ref 地下管网管理系统.IJunctionFlag[]”转换为“ref ESRI.ArcGIS.NetworkAnalysis.IJunctionFlag[]” 菜鸟一只 跪求各位大神帮帮忙

...全文
584 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

249

社区成员

发帖
与我相关
我的任务
社区描述
其他产品/厂家
社区管理员
  • 其他
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧