Beispiel #1
0
        private INALayer CreateRouteAnalysisLayer(string sName, INetworkDataset pNetworkDataset)
        {
            INARouteSolver    solver   = new NARouteSolverClass();
            INASolverSettings settings = solver as INASolverSettings;
            INASolver         solver2  = solver as INASolver;

            solver.FindBestSequence  = true;
            solver.PreserveFirstStop = true;
            solver.PreserveLastStop  = false;
            solver.UseTimeWindows    = false;
            solver.OutputLines       = esriNAOutputLineType.esriNAOutputLineTrueShapeWithMeasure;
            IStringArray restrictionAttributeNames = settings.RestrictionAttributeNames;

            restrictionAttributeNames.Add("Oneway");
            settings.RestrictionAttributeNames = restrictionAttributeNames;
            IDatasetComponent component   = pNetworkDataset as IDatasetComponent;
            IDENetworkDataset dataElement = component.DataElement as IDENetworkDataset;
            INAContext        context     = solver2.CreateContext(dataElement, sName);

            (context as INAContextEdit).Bind(pNetworkDataset, new GPMessagesClass());
            INALayer layer = solver2.CreateLayer(context);

            (layer as ILayer).Name = sName;
            return(layer);
        }
        /// <summary>
        ///  根据网络数据集创建网络分析上下文
        /// </summary>
        /// <param name="networkDataset"></param>
        /// <returns></returns>
        private static INAContext CreateNAContext(INetworkDataset networkDataset)
        {
            IDENetworkDataset pDENetworkDataset = GetDENetworkDataset(networkDataset);
            INASolver         pNASolver         = new NARouteSolverClass();
            INAContextEdit    pNAContextEdit    = pNASolver.CreateContext(pDENetworkDataset, pNASolver.Name) as INAContextEdit;

            pNAContextEdit.Bind(networkDataset, new GPMessagesClass());
            return(pNAContextEdit as INAContext);
        }
Beispiel #3
0
        /// <summary>
        /// Create a new network analysis layer and set some solver settings
        /// </summary>
        private INALayer CreateRouteAnalysisLayer(String layerName, INetworkDataset networkDataset)
        {
            INARouteSolver    naRouteSolver    = new NARouteSolverClass();
            INASolverSettings naSolverSettings = naRouteSolver as INASolverSettings;
            INASolver         naSolver         = naRouteSolver as INASolver;

            //Get the NetworkDataset's Data Element
            IDatasetComponent datasetComponent = networkDataset as IDatasetComponent;
            IDENetworkDataset deNetworkDataset = datasetComponent.DataElement as IDENetworkDataset;

            //Create the NAContext and bind to it
            INAContext naContext;

            naContext = naSolver.CreateContext(deNetworkDataset, layerName);
            INAContextEdit naContextEdit = naContext as INAContextEdit;

            naContextEdit.Bind(networkDataset, new GPMessagesClass());

            //Create the NALayer
            INALayer naLayer;

            naLayer = naSolver.CreateLayer(naContext);
            (naLayer as ILayer).Name = layerName;

            //Set properties on the route solver interface
            naRouteSolver.FindBestSequence  = true;
            naRouteSolver.PreserveFirstStop = true;
            naRouteSolver.PreserveLastStop  = false;
            naRouteSolver.UseTimeWindows    = false;
            naRouteSolver.OutputLines       = esriNAOutputLineType.esriNAOutputLineTrueShapeWithMeasure;

            //Set some properties on the general INASolverSettings interface
            IStringArray restrictions = naSolverSettings.RestrictionAttributeNames;

            restrictions.Add("Oneway");
            naSolverSettings.RestrictionAttributeNames = restrictions;

            // Update the context based on the changes made to the solver settings
            naSolver.UpdateContext(naContext, deNetworkDataset, new GPMessagesClass());

            //Return the layer
            return(naLayer);
        }
Beispiel #4
0
 private INAContext CreateNAContext(INetworkDataset networkDataset)
 {
     IDENetworkDataset pDENetworkDataset = GetDENetworkDataset(networkDataset);
     INASolver pNASolver = new NARouteSolverClass();
     INAContextEdit pNAContextEdit = pNASolver.CreateContext(pDENetworkDataset, pNASolver.Name) as INAContextEdit;
     pNAContextEdit.Bind(networkDataset, new GPMessagesClass());
     return pNAContextEdit as INAContext;
 }
		/// <summary>
		/// Create a new network analysis layer and set some solver settings
		/// </summary>
		private INALayer CreateRouteAnalysisLayer(String layerName, INetworkDataset networkDataset)
		{
			INARouteSolver naRouteSolver = new NARouteSolverClass();
			INASolverSettings naSolverSettings = naRouteSolver as INASolverSettings;
			INASolver naSolver = naRouteSolver as INASolver;

			//Get the NetworkDataset's Data Element
			IDatasetComponent datasetComponent = networkDataset as IDatasetComponent;
			IDENetworkDataset deNetworkDataset = datasetComponent.DataElement as IDENetworkDataset;

			//Create the NAContext and bind to it
			INAContext naContext;
			naContext = naSolver.CreateContext(deNetworkDataset, layerName);
			INAContextEdit naContextEdit = naContext as INAContextEdit;
			naContextEdit.Bind(networkDataset, new GPMessagesClass());

			//Create the NALayer
			INALayer naLayer;
			naLayer = naSolver.CreateLayer(naContext);
			(naLayer as ILayer).Name = layerName;

			//Set properties on the route solver interface
			naRouteSolver.FindBestSequence = true;
			naRouteSolver.PreserveFirstStop = true;
			naRouteSolver.PreserveLastStop = false;
			naRouteSolver.UseTimeWindows = false;
			naRouteSolver.OutputLines = esriNAOutputLineType.esriNAOutputLineTrueShapeWithMeasure;

			//Set some properties on the general INASolverSettings interface
			IStringArray restrictions = naSolverSettings.RestrictionAttributeNames;
			restrictions.Add("Oneway");
			naSolverSettings.RestrictionAttributeNames = restrictions;

			// Update the context based on the changes made to the solver settings
			naSolver.UpdateContext(naContext, deNetworkDataset, new GPMessagesClass());

			//Return the layer
			return naLayer;
		}
Beispiel #6
0
        //创建解决器上下文
        public static INAContext CreateSolverContext(INetworkDataset networkDataset,string ServiceType)
        {
            //Get the Data Element
            IDENetworkDataset deNDS = GetDENetworkDataset(networkDataset);

            INASolver naSolver=null;
            switch (ServiceType)
            {
                case "路线":
                    naSolver = new NARouteSolverClass();
                    break;
                case "服务":
                    naSolver = new NAServiceAreaSolverClass();
                    break;
                case "设施":
                    naSolver = new NAClosestFacilitySolverClass();
                    break;
                case "费用":
                    naSolver = new NAODCostMatrixSolverClass();
                    break;
            }
             
            INAContextEdit contextEdit = naSolver.CreateContext(deNDS, naSolver.Name) as INAContextEdit;
            contextEdit.Bind(networkDataset, new GPMessagesClass());
            return contextEdit as INAContext;
        }