Пример #1
0
        public static INetworkDataset GetNetworkDataset(IDatasetContainer2 datasetContainer, string ndName)
        {
            INetworkDataset networkDataset;

            try
            {
                networkDataset = datasetContainer.get_DatasetByName(esriDatasetType.esriDTNetworkDataset, ndName) as INetworkDataset;
            }
            catch (Exception e)
            {
                if (e.Message.Contains("0x80042603"))
                {
                    throw new Exception("Unable to read network dataset. Ensure that the installed version of the TransitEvaluator.dll matches the installed version of ArcGIS. GDB Exception: " + e.Message);
                }
                else
                {
                    throw e;
                }
            }

            if (networkDataset == null)
            {
                throw new Exception("NATestNetworkDataset: networkDataset should not be null");
            }

            return(networkDataset);
        }
 /// <summary>
 /// 打开网络数据集
 /// </summary>
 /// <param name="GDBfileName"></param>
 /// <param name="featureDatasetName"></param>
 /// <param name="sNDSName"></param>
 /// <returns></returns>
 public static INetworkDataset OpenNetworkDataset(string GDBfileName, string featureDatasetName, string sNDSName)
 {
     try
     {
         IWorkspace        pWorkspace        = OpenWorkspace(GDBfileName);
         IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
         if (pFeatureWorkspace == null)
         {
             return(null);
         }
         IFeatureDatasetExtensionContainer pFeatureDatasetExtensionContainer = pFeatureWorkspace.OpenFeatureDataset(featureDatasetName) as IFeatureDatasetExtensionContainer;
         if (pFeatureDatasetExtensionContainer == null)
         {
             return(null);
         }
         IDatasetContainer2 pDatasetContainer2 = pFeatureDatasetExtensionContainer.FindExtension(esriDatasetType.esriDTNetworkDataset) as IDatasetContainer2;
         INetworkDataset    pNetworkDataset    = pDatasetContainer2.get_DatasetByName(esriDatasetType.esriDTAny, sNDSName) as INetworkDataset;
         return(pNetworkDataset);
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         return(null);
     }
 }
Пример #3
0
        private INetworkDataset ShapefileToNetwork(IWorkspace shpWS, string name)
        {
            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.get_DatasetByName(esriDatasetType.esriDTNetworkDataset, name);
            INetworkDataset     networkDataset = dataset as INetworkDataset;

            return(networkDataset);
        }
Пример #4
0
        private void SetMemberVariables()
        {
            IFeatureWorkspace          pWorkspace = this.m_pWorkspace as IFeatureWorkspace;
            IWorkspaceExtensionManager manager    = this.m_pWorkspace as IWorkspaceExtensionManager;
            UID gUID = new UIDClass
            {
                Value = "esriGeoDatabase.NetworkDatasetWorkspaceExtension"
            };
            IDatasetContainer2 container = manager.FindExtension(gUID) as IDatasetContainer2;

            this.m_pNetworkDataset =
                container.get_DatasetByName(esriDatasetType.esriDTNetworkDataset, this.NETWORK_DATASET) as
                INetworkDataset;
            this.m_pInputStopsFClass = pWorkspace.OpenFeatureClass(this.INPUT_STOPS_FC);
        }
Пример #5
0
        public INetworkDataset OpenNetworkDataset(IWorkspace pWorkspace, string sNDSName)
        {
            IWorkspaceExtensionManager manager = pWorkspace as IWorkspaceExtensionManager;
            int extensionCount = manager.ExtensionCount;

            for (int i = 0; i < extensionCount; i++)
            {
                IWorkspaceExtension extension = manager.get_Extension(i);
                if (extension.Name.Equals("Network Dataset"))
                {
                    IDatasetContainer2 container = extension as IDatasetContainer2;
                    return
                        (container.get_DatasetByName(esriDatasetType.esriDTNetworkDataset, sNDSName) as INetworkDataset);
                }
            }
            return(null);
        }
Пример #6
0
        private INetworkDataset OpenNetworkDataset(IWorkspace networkDatasetWorkspace, string networkDatasetName, string featureDatasetName)
        {
            if (networkDatasetWorkspace == null || networkDatasetName == "" || featureDatasetName == null)
            {
                return(null);
            }
            IDatasetContainer2 datasetContainer2 = null;
            IFeatureWorkspace  featureWorkspace  = networkDatasetWorkspace as IFeatureWorkspace;

            featureDataset = featureWorkspace.OpenFeatureDataset(featureDatasetName);
            IFeatureDatasetExtensionContainer featureDatasetExtensionContainer = featureDataset as IFeatureDatasetExtensionContainer;
            IFeatureDatasetExtension          featureDatasetExtension          = featureDatasetExtensionContainer.FindExtension(esriDatasetType.esriDTNetworkDataset);

            datasetContainer2 = featureDatasetExtension as IDatasetContainer3;
            if (datasetContainer2 == null)
            {
                return(null);
            }
            IDataset dataset = datasetContainer2.get_DatasetByName(esriDatasetType.esriDTNetworkDataset, networkDatasetName);

            return(dataset as INetworkDataset);
        }
Пример #7
0
        public static INetworkDataset GetNetworkDataset(IDatasetContainer2 datasetContainer, string ndName)
        {
            INetworkDataset networkDataset;
            try
            {
                networkDataset = datasetContainer.get_DatasetByName(esriDatasetType.esriDTNetworkDataset, ndName) as INetworkDataset;
            }
            catch (Exception e)
            {
                if (e.Message.Contains("0x80042603"))
                {
                    throw new Exception("Unable to read network dataset. Ensure that the installed version of the TransitEvaluator.dll matches the installed version of ArcGIS. GDB Exception: " + e.Message);
                }
                else
                {
                    throw e;
                }
            }
            
            if (networkDataset == null)
                throw new Exception("NATestNetworkDataset: networkDataset should not be null");

            return networkDataset;
        }