private void CreateGeometricNetwork(IFeatureWorkspace pfeatws)
{
IFeatureDataset pfeatDs= pfeatws.OpenFeatureDataset("Electrical");
IFeatureDatasetName pdsname = pfeatDs as IFeatureDatasetName;
//first create NetworkLoader Object
INetworkLoader2 pNetLoad = new NetworkLoaderClass();
//name of the network
pNetLoad.NetworkName = "Electric_net";
//set the type of Network either utility or street
pNetLoad.NetworkType = esriNetworkType.esriNTUtilityNetwork;
pNetLoad.FeatureDatasetName =(IDatasetName) pfeatDs.FullName;
if (pNetLoad.CanUseFeatureClass("cable") == esriNetworkLoaderFeatureClassCheck.esriNLFCCValid)
{
pNetLoad.AddFeatureClass("cable", esriFeatureType.esriFTComplexEdge, null, false);
}
if (pNetLoad.CanUseFeatureClass("Distribution_Transformer") == esriNetworkLoaderFeatureClassCheck.esriNLFCCValid)
{
pNetLoad.AddFeatureClass("Distribution_Transformer", esriFeatureType.esriFTComplexJunction, null, false);
}
INetworkLoaderProps pnetloadProp=(INetworkLoaderProps)pNetLoad;
string defField = pnetloadProp.DefaultEnabledField;
//Ancillary role
string defAncRole = pnetloadProp.DefaultAncillaryRoleField;
esriNetworkLoaderFieldCheck fldChk = pNetLoad.CheckAncillaryRoleField("Distribution_Transformer", defAncRole);
switch (fldChk)
{
case esriNetworkLoaderFieldCheck.esriNLFCValid:
case esriNetworkLoaderFieldCheck.esriNLFCNotFound:
pNetLoad.PutAncillaryRole("Distribution_Transformer", esriNetworkClassAncillaryRole.esriNCARSourceSink, defAncRole);
break;
//default:
// MessageBox.Show("");
// break;
}
pNetLoad.SnapTolerance = pNetLoad.MinSnapTolerance;
pNetLoad.LoadNetwork();
//pNetLoad.AddWeight("weight_test", esriWeightType.esriWTDouble, 0);
}