v_telange

DownStream Trace Problem

Discussion created by v_telange on Nov 24, 2010
DownStream Trace Problem

I have occured problem on downstream trace on desktop code. if we used below code to trace, then tool is working but some features were not selected. ArcFM tool working fine.

private void GetGraphicsDataSet(int X, int Y, string strTraceType, string strPhasesToTraceEnum, string strProtectiveDevices, DataTable dtBarriersTable, bool bDrawComplex)
{
IMxDocument pDoc = pApplication.Document as IMxDocument;
IMap pMap = pDoc.FocusMap;

IPoint pPoint = pDoc.ActiveView.ScreenDisplay.DisplayTransformatio n.ToMapPoint(X, Y);
if (pPoint != null)
{
ITopologicalOperator pTopo = pPoint as ITopologicalOperator;
IPolygon pPolygon = pTopo.Buffer(5) as IPolygon;

ISpatialFilter pSFilter = new SpatialFilterClass();
pSFilter.Geometry = pPolygon as IGeometry;
pSFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

IFeatureLayer pFLayer = null;
IFeature pFeature = null;

UID pUID = new UIDClass();
pUID.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";
IEnumLayer pEnumLayer = pMap.get_Layers(pUID, true);
pFLayer = pEnumLayer.Next() as IFeatureLayer;

//while (pFLayer != null)
//{
// int i = pFLayer.FeatureClass.FeatureClassID;
// pFLayer = pEnumLayer.Next() as IFeatureLayer;
//}

IFeatureDataset pFeatureDataset = pFLayer.FeatureClass.FeatureDataset;
INetworkCollection pNetworkCollection = pFeatureDataset as INetworkCollection;
IGeometricNetwork pGeometricNetwork = pNetworkCollection.get_GeometricNetwork(0);

while (pFLayer != null)
{
if (pFLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
{
if (pFLayer.FeatureClass.FeatureCount(pSFilter) > 0)
{
IFeatureCursor pFCursor = pFLayer.Search(pSFilter, false);
pFeature = pFCursor.NextFeature();
break;
}
}
else if (pFLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint)
{
int FeatureClassID = pFLayer.FeatureClass.FeatureClassID;
}
pFLayer = pEnumLayer.Next() as IFeatureLayer;
}

//Draw Complex Boolean
IMMNetworkAnalysisExtForFramework pNetworkAnalysisExt = new MMNetworkAnalysisExtForFrameworkClass();
pNetworkAnalysisExt.DrawComplex = bDrawComplex;
pNetworkAnalysisExt.SelectionSemantics = mmESRIAnalysisOptions.mmESRIAnalysisOnAllFeatures;

//Assign Barriers
//if (dtBarriersTable != null)
//{
// IMMNetworkFeatureID[] pNetworkFeatureID = SetEdgeBarriers(dtBarriersTable);
// pNetworkAnalysisExt.EdgeBarriers = pNetworkFeatureID;
//}

//Mention Protective Devices
IMMElectricTraceSettingsEx pTraceSettings = new MMElectricTraceSettingsClass();
pTraceSettings.RespectESRIBarriers = false;

//Assign Protective Devices
if (strProtectiveDevices.Length > 0)
{
string[] strLayerNamesInSDE = strProtectiveDevices.Split('$');

int[] ProtectiveDeviceIDs = new int[strLayerNamesInSDE.Length - 1];
for (int i = 0; i < strLayerNamesInSDE.Length - 1; i++)
{
ProtectiveDeviceIDs[i] = GetFeatureClassIDByWorkspace(strLayerNamesInSDE[i]);
}

pTraceSettings.ProtectiveDeviceClassIDs = ProtectiveDeviceIDs;
pTraceSettings.UseFeederManagerCircuitSources = true;
pTraceSettings.UseFeederManagerProtectiveDevices = false;
}

if (pFeature != null)
{
INetElements pNetElements = pGeometricNetwork.Network as INetElements;
int startEID = pNetElements.GetEID(pFLayer.FeatureClass.FeatureCl assID, pFeature.OID, -1, esriElementType.esriETEdge);

//int test = pNetElements.GetEID(145, 9, -1, esriElementType.esriETEdge);
IEnumNetEID pJunctionEIDs = null, pEdgeEIDs = null;
IMMElectricNetworkTracing pTracing = new MMFeederTracerClass();
switch (strTraceType)
{
case "Upstream":
{
pTracing.TraceUpstream(pGeometricNetwork, pNetworkAnalysisExt, pTraceSettings, startEID, esriElementType.esriETEdge,
GetPhasesToTrace(strPhasesToTraceEnum), out pJunctionEIDs, out pEdgeEIDs);
break;
}
case "Upstream Protective":
{
pTracing.FindUpstreamProtectiveDevices(pGeometricN etwork, pNetworkAnalysisExt, pTraceSettings, startEID, esriElementType.esriETEdge,
GetPhasesToTrace(strPhasesToTraceEnum), out pJunctionEIDs, out pEdgeEIDs);
break;
}
case "Downstream":
{
pTracing.TraceDownstream(pGeometricNetwork, pNetworkAnalysisExt, pTraceSettings, startEID, esriElementType.esriETEdge,
GetPhasesToTrace(strPhasesToTraceEnum), out pJunctionEIDs, out pEdgeEIDs);
break;
}
case "Downstream Protective":
{
pTracing.FindDownstreamProtectiveDevices(pGeometri cNetwork, pNetworkAnalysisExt, pTraceSettings, startEID, esriElementType.esriETEdge,
GetPhasesToTrace(strPhasesToTraceEnum), out pJunctionEIDs, out pEdgeEIDs);
break;
}
case "Distribution":
{
pTracing.DistributionCircuitTrace(pGeometricNetwor k, pNetworkAnalysisExt, pTraceSettings, startEID, esriElementType.esriETEdge,
GetPhasesToTrace(strPhasesToTraceEnum), out pJunctionEIDs, out pEdgeEIDs);
break;
}

}
SelectTraceResults(pMap, pJunctionEIDs, pEdgeEIDs);
pDoc.ActiveView.Refresh();
}
}
}

#region Function to know user selected Phase
private mmPhasesToTrace GetPhasesToTrace(string strPhasesToTraceEnum)
{
switch (strPhasesToTraceEnum)
{
case "0":
return mmPhasesToTrace.mmPTT_Any;
case "1":
return mmPhasesToTrace.mmPTT_A;
case "2":
return mmPhasesToTrace.mmPTT_B;
case "3":
return mmPhasesToTrace.mmPTT_C;
case "4":
return mmPhasesToTrace.mmPTT_AB;
case "5":
return mmPhasesToTrace.mmPTT_AC;
case "6":
return mmPhasesToTrace.mmPTT_BC;
case "7":
return mmPhasesToTrace.mmPTT_ABC;
case "8":
return mmPhasesToTrace.mmPTT_AtLeastA;
case "9":
return mmPhasesToTrace.mmPTT_AtLeastB;
case "10":
return mmPhasesToTrace.mmPTT_AtLeastC;
case "11":
return mmPhasesToTrace.mmPTT_AtLeastAB;
case "12":
return mmPhasesToTrace.mmPTT_AtLeastAC;
case "13":
return mmPhasesToTrace.mmPTT_AtLeastBC;
case "14":
return mmPhasesToTrace.mmPTT_AnySinglePhase;
case "15":
return mmPhasesToTrace.mmPTT_AnyTwoPhase;
default:
return mmPhasesToTrace.mmPTT_Any;
}
} .

Outcomes