从geodatabase feature dataset(fds)中获取网络数据集
IFeatureDatasetExtensionContainer fdsExtCont = fds as IFeatureDatasetExtensionContainer; IFeatureDatasetExtension fdsExt = fdsExtCont.FindExtension(esriDTNetworkDataset); IDatasetContainer2 dsCont = fdsExt as IDatasetContainer2; IDataset dataset = dsCont.DatasetByName(esriDTNetworkDataset, "Street_ND"); INetworkDataset networkDataset = dataset as INetworkDataset;
从shapefile workspace (de>shpWSde>)中获取网络数据集
从SDC workspace (de>sdcWSde>)中获取网络数据集IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactoryClass();
IFeatureWorkspace featureWorkspace = workspaceFactory.OpenFromFile(SHAPE_WORKSPACE, 0) as IFeatureWorkspace;IWorkspaceExtensionManager wsExtMgr = shpWS as IWorkspaceExtensionManager; UID myUID = new UIDClass(); myUID.Value= "esriGeoDatabase.NetworkDatasetWorkspaceExtension"; IWorkspaceExtension wsExt = wsExtMgr.FindExtension(myUID); IDatasetContainer2 dsCont = wsExt as IDatasetContainer2; IDataset dataset = dsCont.DatasetByName(esriDTNetworkDataset, "Street_ND"); INetworkDataset networkDataset = dataset as INetworkDataset;
IWorkspaceExtensionManager wsExtMgr = sdcWS as IWorkspaceExtensionManager;UID myUID = new UIDClass(); myUID.Value = "esriGeoDatabase.NetworkDatasetWorkspaceExtension"; IWorkspaceExtension wsExt = wsExtMgr.FindExtension(myUID); IDatasetContainer2 dsCont = wsExt as IDatasetContainer2; IDataset dataset = dsCont.DatasetByName(esriDTNetworkDataset, "Street_ND"); INetworkDataset networkDataset = dataset as INetworkDataset;