示例#1
0
        public static void GetPermittedAttributes(INALayer layer, out string[] impedences, out string[] restrictions,
                                                  out string[] hierarchies)
        {
            ArrayList       list           = new ArrayList();
            ArrayList       list2          = new ArrayList();
            ArrayList       list3          = new ArrayList();
            INetworkDataset networkDataset = layer.Context.NetworkDataset;

            for (int i = 0; i < networkDataset.AttributeCount; i++)
            {
                INetworkAttribute attribute = networkDataset.get_Attribute(i);
                if (attribute.UsageType == esriNetworkAttributeUsageType.esriNAUTCost)
                {
                    list.Add(attribute.Name);
                }
                else if (attribute.UsageType == esriNetworkAttributeUsageType.esriNAUTRestriction)
                {
                    list2.Add(attribute.Name);
                }
                else if (attribute.UsageType == esriNetworkAttributeUsageType.esriNAUTHierarchy)
                {
                    list3.Add(attribute.Name);
                }
            }
            impedences   = (string[])list.ToArray(typeof(string));
            restrictions = (string[])list2.ToArray(typeof(string));
            hierarchies  = (string[])list3.ToArray(typeof(string));
        }
示例#2
0
        private void Initialize()
        {
            this.CheckOutNetworkAnalystExtension();
            IFeatureWorkspace workspace =
                this.OpenWorkspace(Application.StartupPath + @"\..\..\..\..\Data\NetworkAnalyst") as IFeatureWorkspace;
            INetworkDataset pNetDataset = this.OpenNetworkDataset(workspace as IWorkspace, "Streets_nd");

            this.m_pNAContext = this.CreateSolverContext(pNetDataset);
            for (int i = 0; i < (pNetDataset.AttributeCount - 1); i++)
            {
                INetworkAttribute attribute = pNetDataset.get_Attribute(i);
                if (attribute.UsageType == esriNetworkAttributeUsageType.esriNAUTCost)
                {
                    this.cboCostAttribute.Items.Add(attribute.Name);
                    this.cboCostAttribute.SelectedIndex = 0;
                }
            }
            this.txtTargetFacility.Text = "1";
            this.txtCutOff.Text         = "";
            IFeatureClass pInputFC = workspace.OpenFeatureClass("BayAreaIncident");

            this.LoadNANetworkLocations("Incidents", pInputFC, 100.0);
            pInputFC = workspace.OpenFeatureClass("BayAreaLocations");
            this.LoadNANetworkLocations("Facilities", pInputFC, 100.0);
            INetworkLayer layer2 = new NetworkLayerClass
            {
                NetworkDataset = pNetDataset
            };
            ILayer layer = layer2 as ILayer;

            layer.Name = "Network Dataset";
            layer      = this.m_pNAContext.Solver.CreateLayer(this.m_pNAContext) as ILayer;
            layer.Name = this.m_pNAContext.Solver.DisplayName;
        }
示例#3
0
        /// <summary>
        /// Update the CheckedListBox control based on the network dataset attributes (checking the ones currently chosen by the solver)
        /// </summary>
        private void PopulateAttributeControl(CheckedListBox chklstBox, INetworkDataset networkDataset, IStringArray strArray, esriNetworkAttributeUsageType usageType)
        {
            chklstBox.Items.Clear();

            //  Loop through the network dataset attributes
            for (int i = 0; i < networkDataset.AttributeCount; i++)
            {
                INetworkAttribute networkAttribute = networkDataset.get_Attribute(i);
                if (networkAttribute.UsageType == usageType)
                {
                    string     attributeName = networkAttribute.Name;
                    CheckState checkState    = CheckState.Unchecked;

                    // If the attribute is in the strArray, it should be checked
                    for (int j = 0; j < strArray.Count; j++)
                    {
                        if (strArray.get_Element(j) == attributeName)
                        {
                            checkState = CheckState.Checked;
                        }
                    }

                    // Add the attribute to the control
                    chklstBox.Items.Add(attributeName, checkState);
                }
            }
        }
        public void Initialize(INetworkDataset networkDataset, IDENetworkDataset DataElement, INetworkSource netSource, IEvaluatedNetworkAttribute netAttribute)
        {
            // Initialize is called once per session (ArcMap session, ArcCatalog session, etc.) to initialize the evaluator for an associated network dataset
            m_networkDataset   = networkDataset;
            m_networkSource    = netSource;
            m_networkAttribute = netAttribute;

            Refresh();
        }
示例#5
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (this.txtName.Text.Length != 0)
     {
         this.inetworkAttribute_0           = new EvaluatedNetworkAttributeClass();
         this.inetworkAttribute_0.Name      = this.txtName.Text.Trim();
         this.inetworkAttribute_0.UsageType = (esriNetworkAttributeUsageType)this.cboUsageType.SelectedIndex;
         this.inetworkAttribute_0.Units     = this.method_1();
         this.inetworkAttribute_0.DataType  = this.method_2();
         base.DialogResult = DialogResult.OK;
     }
 }
        public void Initialize(INetworkDataset networkDataset, IDENetworkDataset DataElement, INetworkSource netSource, IEvaluatedNetworkAttribute netAttribute)
        {
            // Initialize is called once per session (ArcMap session, ArcCatalog session, etc.) to initialize the evaluator for an associated network dataset
            m_networkDataset   = networkDataset;
            m_networkSource    = netSource;
            m_networkAttribute = netAttribute;

            m_thisNetworkAttributeID = netAttribute.ID;
            m_baseNetworkAttributeID = -1;

            //The attribute name must begin with one or more non underscore characters followed by
            //an underscore character and then the name of the base cost attribute.
            //The underscore prior to the base attribute name should be the first underscore in the name.

            string thisAttributeName = netAttribute.Name;
            int    nPos     = thisAttributeName.IndexOf('_');
            int    nLastPos = thisAttributeName.Length - 1;

            string            baseNetAttributeName;
            INetworkAttribute baseNetAttribute = null;

            if (nPos > 0 && nPos < nLastPos)
            {
                baseNetAttributeName = thisAttributeName.Remove(0, nPos + 1);
                try
                {
                    baseNetAttribute = networkDataset.get_AttributeByName(baseNetAttributeName);
                }
                catch (COMException ex)
                {
                    baseNetAttribute = null;
                    string msg = string.Format("Base Attribute ({0}) not found. {1}.", baseNetAttributeName, ex.Message);
                    System.Diagnostics.Trace.WriteLine(msg, "Scale Subset Network Evaluator");
                }

                if (baseNetAttribute != null)
                {
                    if (baseNetAttribute.ID != m_thisNetworkAttributeID)
                    {
                        m_baseNetworkAttributeID = baseNetAttribute.ID;
                    }
                }
            }

            Refresh();
        }
示例#7
0
        /// <summary>
        /// Update the Impedance control based on the network dataset cost attributes
        /// </summary>
        private void PopulateImpedanceNameControl(ComboBox cboImpedance, INetworkDataset networkDataset, string impedanceName)
        {
            cboImpedance.Items.Clear();

            for (int i = 0; i < networkDataset.AttributeCount; i++)
            {
                INetworkAttribute networkAttribute = networkDataset.get_Attribute(i);
                if (networkAttribute.UsageType == esriNetworkAttributeUsageType.esriNAUTCost)
                {
                    cboImpedance.Items.Add(networkAttribute.Name);
                }
            }

            if (cboImpedance.Items.Count > 0)
            {
                cboImpedance.Text = impedanceName;
            }
        }
        public void Init(IServerObjectHelper pSOH)
        {
            IMapServer           mapServer           = pSOH.ServerObject as IMapServer;
            IMapServerDataAccess mapServerDataAccess = mapServer as IMapServerDataAccess;
            IMapServerInfo       mapServerInfo       = mapServer.GetServerInfo(mapServer.DefaultMapName);
            IMapLayerInfos       layerInfos          = mapServerInfo.MapLayerInfos;
            IMapLayerInfo        ndLayerInfo         = null;

            // Get the network dataset layer from current service
            for (var i = 0; i < layerInfos.Count; i++)
            {
                IMapLayerInfo layerInfo = layerInfos.Element[i];
                if (layerInfo.Type.Equals("Network Dataset Layer", StringComparison.InvariantCultureIgnoreCase))
                {
                    ndLayerInfo = layerInfo;
                    break;
                }
            }

            // Get the network dataset
            if (ndLayerInfo != null)
            {
                var dt = mapServerDataAccess.GetDataSource(mapServer.DefaultMapName, ndLayerInfo.ID);
                // Cast the dataset to required network dataset interface
                networkDataset = dt as INetworkDataset;
            }

            if (networkDataset != null)
            {
                // Open the streets feature class
                IDataset          dataSet    = networkDataset as IDataset;
                IFeatureWorkspace fWorkspace = dataSet.Workspace as IFeatureWorkspace;
                streetFC = fWorkspace.OpenFeatureClass(streetsName);

                // Get the Streets source ID
                INetworkSource streetNetworkSource = networkDataset.SourceByName[streetsName];
                streetsSourceID = streetNetworkSource.ID;

                // Get the TraveTime attribute ID
                INetworkAttribute travelTimeAttribute = networkDataset.AttributeByName[costAttributeName];
                travelTimeAttributeID = travelTimeAttribute.ID;
            }
        }
        /// <summary>
        /// Find and load the cost attributes into a combo box
        /// <summary>
        private void LoadCostAttributes(INetworkDataset networkDataset)
        {
            cbCostAttribute.Items.Clear();

            int attrCount = networkDataset.AttributeCount;

            for (int attrIndex = 0; attrIndex < attrCount; attrIndex++)
            {
                INetworkAttribute networkAttribute = networkDataset.get_Attribute(attrIndex);
                if (networkAttribute.UsageType == esriNetworkAttributeUsageType.esriNAUTCost)
                {
                    cbCostAttribute.Items.Add(networkAttribute.Name);
                }
            }

            if (cbCostAttribute.Items.Count > 0)
            {
                cbCostAttribute.SelectedIndex = 0;
            }
        }
示例#10
0
        private void frmNetworkPropertySheet_Load(object sender, EventArgs e)
        {
            int num2;

            string[]     strArray;
            ListViewItem item;

            this.lblNetworkName.Text = (this.inetworkDataset_0 as IDataset).Name;
            this.lblNetworkType.Text = this.method_0(this.inetworkDataset_0.NetworkType);
            INetworkQuery query = this.inetworkDataset_0 as INetworkQuery;
            string        str   = "";

            str = ((query.get_ElementCount(esriNetworkElementType.esriNETJunction).ToString() + "个连接点\r\n") +
                   query.get_ElementCount(esriNetworkElementType.esriNETEdge).ToString() + "条边\r\n") +
                  query.get_ElementCount(esriNetworkElementType.esriNETTurn).ToString() + "个转向\r\n";
            this.lblNetworkElements.Text = str;
            for (num2 = 0; num2 < this.inetworkDataset_0.SourceCount; num2++)
            {
                strArray = new string[3];
                INetworkSource source = this.inetworkDataset_0.get_Source(num2);
                strArray[0] = source.Name;
                strArray[1] = this.method_1(source.SourceType);
                strArray[2] = this.method_2(source.ElementType);
                item        = new ListViewItem(strArray);
                this.lsvSource.Items.Add(item);
                if (source.SourceType == esriNetworkSourceType.esriNSTEdgeFeature)
                {
                    strArray[0] = source.Name;
                    strArray[1] = "From End";
                    strArray[2] = (source as IEdgeFeatureSource).FromElevationFieldName;
                    item        = new ListViewItem(strArray);
                    this.lsvElevation.Items.Add(item);
                    strArray[1] = "To End";
                    strArray[2] = (source as IEdgeFeatureSource).ToElevationFieldName;
                    item        = new ListViewItem(strArray);
                    this.lsvElevation.Items.Add(item);
                    if (source.NetworkSourceDirections == null)
                    {
                    }
                }
                else if (source.SourceType == esriNetworkSourceType.esriNSTJunctionFeature)
                {
                    strArray[0] = source.Name;
                    strArray[1] = "";
                    strArray[2] = (source as IJunctionFeatureSource).ElevationFieldName;
                    item        = new ListViewItem(strArray);
                    this.lsvElevation.Items.Add(item);
                }
            }
            for (num2 = 0; num2 < this.inetworkDataset_0.AttributeCount; num2++)
            {
                strArray = new string[6];
                INetworkAttribute attribute = this.inetworkDataset_0.get_Attribute(num2);
                strArray[0] = "";
                strArray[1] = "";
                strArray[2] = attribute.Name;
                strArray[3] = CommonHelper.GetUsageTypeDescriptor(attribute.UsageType);
                strArray[4] = CommonHelper.GetNetworkUnitTypeDescriptor(attribute.Units);
                strArray[5] = CommonHelper.GetDataTypeDescriptor(attribute.DataType);
                item        = new ListViewItem(strArray);
                this.lsvAttributes.Items.Add(item);
            }
        }
		public void Initialize(INetworkDataset networkDataset, IDENetworkDataset DataElement, INetworkSource netSource, IEvaluatedNetworkAttribute netAttribute)
		{
			// Initialize is called once per session (ArcMap session, ArcCatalog session, etc.) to initialize the evaluator for an associated network dataset            
			m_networkDataset = networkDataset;
			m_networkSource = netSource;
			m_networkAttribute = netAttribute;

			m_thisNetworkAttributeID = netAttribute.ID;
			m_baseNetworkAttributeID = -1;

			//The attribute name must begin with one or more non underscore characters followed by
			//an underscore character and then the name of the base cost attribute.
			//The underscore prior to the base attribute name should be the first underscore in the name.

			string thisAttributeName = netAttribute.Name;
			int nPos = thisAttributeName.IndexOf('_');
			int nLastPos = thisAttributeName.Length - 1;

			string baseNetAttributeName;
			INetworkAttribute baseNetAttribute = null;

			if (nPos > 0 && nPos < nLastPos)
			{
				baseNetAttributeName = thisAttributeName.Remove(0, nPos + 1);
				try
				{
					baseNetAttribute = networkDataset.get_AttributeByName(baseNetAttributeName);
				}
				catch (COMException ex)
				{
					baseNetAttribute = null;
					string msg = string.Format("Base Attribute ({0}) not found. {1}.", baseNetAttributeName, ex.Message);
					System.Diagnostics.Trace.WriteLine(msg, "Scale Subset Network Evaluator");
				}

				if (baseNetAttribute != null)
				{
					if (baseNetAttribute.ID != m_thisNetworkAttributeID)
						m_baseNetworkAttributeID = baseNetAttribute.ID;
				}
			}

			Refresh();
		}
		public void Initialize(INetworkDataset networkDataset, IDENetworkDataset DataElement, INetworkSource netSource, IEvaluatedNetworkAttribute netAttribute)
		{
			// Initialize is called once per session (ArcMap session, ArcCatalog session, etc.) to initialize the evaluator for an associated network dataset            
			m_networkDataset = networkDataset;
			m_networkSource = netSource;
			m_networkAttribute = netAttribute;

			Refresh();
		}
示例#13
0
        /// <summary>
        /// Set controls based on the current NALayer settings
        /// This function takes the current NALayer and determines what type of solver it's pointing to
        /// and populates the corresponding controls and hides the tabs for the other solvers.
        /// </summary>
        private void PopulateControls(INALayer naLayer)
        {
            ILayer                      layer            = naLayer as ILayer;
            INAContext                  naContext        = naLayer.Context;
            INetworkDataset             networkDataset   = naContext.NetworkDataset;
            INALocator2                 naLocator        = naContext.Locator as INALocator2;
            INASolver                   naSolver         = naContext.Solver;
            INASolverSettings           naSolverSettings = naSolver as INASolverSettings2;
            INARouteSolver2             routeSolver      = naSolver as INARouteSolver2;
            INAClosestFacilitySolver    cfSolver         = naSolver as INAClosestFacilitySolver;
            INAODCostMatrixSolver       odSolver         = naSolver as INAODCostMatrixSolver;
            INAServiceAreaSolver2       saSolver         = naSolver as INAServiceAreaSolver2;
            INAVRPSolver                vrpSolver        = naSolver as INAVRPSolver;
            INALocationAllocationSolver laSolver         = naSolver as INALocationAllocationSolver;

            // Populate general Layer controls
            txtLayerName.Text          = layer.Name;
            txtMaxSearchTolerance.Text = naLocator.MaxSnapTolerance.ToString();
            cboMaxSearchToleranceUnits.SelectedIndex = Convert.ToInt32(naLocator.SnapToleranceUnits);

            // Populate controls for the particular solver

            if (routeSolver != null)  // ROUTE LAYER
            {
                // Remove unnecessary tabs
                tabPropPages.TabPages.Remove(tabClosestFacility);
                tabPropPages.TabPages.Remove(tabODCostMatrix);
                tabPropPages.TabPages.Remove(tabServiceArea);
                tabPropPages.TabPages.Remove(tabVRP);
                tabPropPages.TabPages.Remove(tabLocationAllocation);

                // INARouteSolver2
                chkRouteFindBestSequence.Checked  = routeSolver.FindBestSequence;
                chkRoutePreserveFirstStop.Checked = routeSolver.PreserveFirstStop;
                chkRoutePreserveLastStop.Checked  = routeSolver.PreserveLastStop;
                chkRouteUseTimeWindows.Checked    = routeSolver.UseTimeWindows;
                chkRouteUseStartTime.Checked      = routeSolver.UseStartTime;
                txtRouteStartTime.Text            = routeSolver.StartTime.ToShortTimeString();
                cboRouteOutputLines.SelectedIndex = System.Convert.ToInt32(routeSolver.OutputLines);

                // INASolverSettings
                PopulateImpedanceNameControl(cboRouteImpedance, networkDataset, naSolverSettings.ImpedanceAttributeName);
                chkRouteUseHierarchy.Enabled           = (naSolverSettings.HierarchyAttributeName.Length > 0);
                chkRouteUseHierarchy.Checked           = (chkRouteUseHierarchy.Enabled && naSolverSettings.UseHierarchy);
                chkRouteIgnoreInvalidLocations.Checked = naSolverSettings.IgnoreInvalidLocations;
                cboRouteRestrictUTurns.SelectedIndex   = System.Convert.ToInt32(naSolverSettings.RestrictUTurns);
                PopulateAttributeControl(chklstRouteAccumulateAttributeNames, networkDataset, naSolverSettings.AccumulateAttributeNames, esriNetworkAttributeUsageType.esriNAUTCost);
                PopulateAttributeControl(chklstRouteRestrictionAttributeNames, networkDataset, naSolverSettings.RestrictionAttributeNames, esriNetworkAttributeUsageType.esriNAUTRestriction);
            }
            else if (cfSolver != null)  // CLOSEST FACILITY LAYER
            {
                // Remove unnecessary tabs
                tabPropPages.TabPages.Remove(tabRoute);
                tabPropPages.TabPages.Remove(tabODCostMatrix);
                tabPropPages.TabPages.Remove(tabServiceArea);
                tabPropPages.TabPages.Remove(tabVRP);
                tabPropPages.TabPages.Remove(tabLocationAllocation);

                // INAClosestFacilitySolver
                txtCFDefaultCutoff.Text = GetStringFromObject(cfSolver.DefaultCutoff);
                txtCFDefaultTargetFacilityCount.Text = cfSolver.DefaultTargetFacilityCount.ToString();
                cboCFTravelDirection.SelectedIndex   = Convert.ToInt32(cfSolver.TravelDirection);
                cboCFOutputLines.SelectedIndex       = Convert.ToInt32(cfSolver.OutputLines);

                // INASolverSettings
                PopulateImpedanceNameControl(cboCFImpedance, networkDataset, naSolverSettings.ImpedanceAttributeName);
                chkCFUseHierarchy.Enabled           = (naSolverSettings.HierarchyAttributeName.Length > 0);
                chkCFUseHierarchy.Checked           = (chkCFUseHierarchy.Enabled && naSolverSettings.UseHierarchy);
                chkCFIgnoreInvalidLocations.Checked = naSolverSettings.IgnoreInvalidLocations;
                cboCFRestrictUTurns.SelectedIndex   = System.Convert.ToInt32(naSolverSettings.RestrictUTurns);
                PopulateAttributeControl(chklstCFAccumulateAttributeNames, networkDataset, naSolverSettings.AccumulateAttributeNames, esriNetworkAttributeUsageType.esriNAUTCost);
                PopulateAttributeControl(chklstCFRestrictionAttributeNames, networkDataset, naSolverSettings.RestrictionAttributeNames, esriNetworkAttributeUsageType.esriNAUTRestriction);
            }
            else if (odSolver != null) // OD COST MATRIX LAYER
            {
                // Remove unnecessary tabs
                tabPropPages.TabPages.Remove(tabRoute);
                tabPropPages.TabPages.Remove(tabClosestFacility);
                tabPropPages.TabPages.Remove(tabServiceArea);
                tabPropPages.TabPages.Remove(tabVRP);

                // INAODCostMatrixSolver
                txtODDefaultCutoff.Text = GetStringFromObject(odSolver.DefaultCutoff);
                txtODDefaultTargetDestinationCount.Text = GetStringFromObject(odSolver.DefaultTargetDestinationCount);
                cboODOutputLines.SelectedIndex          = Convert.ToInt32(odSolver.OutputLines);

                // INASolverSettings
                PopulateImpedanceNameControl(cboODImpedance, networkDataset, naSolverSettings.ImpedanceAttributeName);
                chkODUseHierarchy.Enabled           = (naSolverSettings.HierarchyAttributeName.Length > 0);
                chkODUseHierarchy.Checked           = (chkODUseHierarchy.Enabled && naSolverSettings.UseHierarchy);
                chkODIgnoreInvalidLocations.Checked = naSolverSettings.IgnoreInvalidLocations;
                cboODRestrictUTurns.SelectedIndex   = System.Convert.ToInt32(naSolverSettings.RestrictUTurns);
                PopulateAttributeControl(chklstODAccumulateAttributeNames, networkDataset, naSolverSettings.AccumulateAttributeNames, esriNetworkAttributeUsageType.esriNAUTCost);
                PopulateAttributeControl(chklstODRestrictionAttributeNames, networkDataset, naSolverSettings.RestrictionAttributeNames, esriNetworkAttributeUsageType.esriNAUTRestriction);
            }
            else if (saSolver != null)  //SERVICE AREA SOLVER
            {
                // Remove unnecessary tabs
                tabPropPages.TabPages.Remove(tabRoute);
                tabPropPages.TabPages.Remove(tabClosestFacility);
                tabPropPages.TabPages.Remove(tabODCostMatrix);
                tabPropPages.TabPages.Remove(tabVRP);
                tabPropPages.TabPages.Remove(tabLocationAllocation);

                // INAServiceAreaSolver2
                txtSADefaultBreaks.Text = "";
                for (int iBreak = 0; iBreak < saSolver.DefaultBreaks.Count; iBreak++)
                {
                    txtSADefaultBreaks.Text = txtSADefaultBreaks.Text + " " + saSolver.DefaultBreaks.get_Element(iBreak).ToString();
                }
                cboSATravelDirection.SelectedIndex = Convert.ToInt32(saSolver.TravelDirection);

                cboSAOutputPolygons.SelectedIndex           = -1;
                cboSAOutputPolygons.SelectedIndex           = Convert.ToInt32(saSolver.OutputPolygons);
                chkSAOverlapPolygons.Checked                = saSolver.OverlapPolygons;
                chkSASplitPolygonsAtBreaks.Checked          = saSolver.SplitPolygonsAtBreaks;
                chkSAMergeSimilarPolygonRanges.Checked      = saSolver.MergeSimilarPolygonRanges;
                chkSATrimOuterPolygon.Checked               = saSolver.TrimOuterPolygon;
                txtSATrimPolygonDistance.Text               = saSolver.TrimPolygonDistance.ToString();
                cboSATrimPolygonDistanceUnits.SelectedIndex = Convert.ToInt32(saSolver.TrimPolygonDistanceUnits);

                cboSAOutputLines.SelectedIndex  = -1;
                cboSAOutputLines.SelectedIndex  = Convert.ToInt32(saSolver.OutputLines);
                chkSAOverlapLines.Checked       = saSolver.OverlapLines;
                chkSASplitLinesAtBreaks.Checked = saSolver.SplitLinesAtBreaks;
                chkSAIncludeSourceInformationOnLines.Checked = saSolver.IncludeSourceInformationOnLines;

                // INASolverSettings
                PopulateImpedanceNameControl(cboSAImpedance, networkDataset, naSolverSettings.ImpedanceAttributeName);
                chkSAIgnoreInvalidLocations.Checked = naSolverSettings.IgnoreInvalidLocations;
                cboSARestrictUTurns.SelectedIndex   = System.Convert.ToInt32(naSolverSettings.RestrictUTurns);
                PopulateAttributeControl(chklstSAAccumulateAttributeNames, networkDataset, naSolverSettings.AccumulateAttributeNames, esriNetworkAttributeUsageType.esriNAUTCost);
                PopulateAttributeControl(chklstSARestrictionAttributeNames, networkDataset, naSolverSettings.RestrictionAttributeNames, esriNetworkAttributeUsageType.esriNAUTRestriction);
            }
            else if (vrpSolver != null) // VRP Solver
            {
                // Remove unnecessary tabs
                tabPropPages.TabPages.Remove(tabRoute);
                tabPropPages.TabPages.Remove(tabClosestFacility);
                tabPropPages.TabPages.Remove(tabODCostMatrix);
                tabPropPages.TabPages.Remove(tabServiceArea);
                tabPropPages.TabPages.Remove(tabLocationAllocation);

                cboVRPOutputShapeType.SelectedIndex = Convert.ToInt32(vrpSolver.OutputLines);
                cboVRPAllowUTurns.SelectedIndex     = Convert.ToInt32(naSolverSettings.RestrictUTurns);
                // VRP cannot have unknown units, so the index is offset by 1 from the solver field units
                cboVRPDistanceFieldUnits.SelectedIndex = Convert.ToInt32(vrpSolver.DistanceFieldUnits) - 1;
                cboVRPTransitTime.SelectedIndex        = Convert.ToInt32(vrpSolver.ExcessTransitTimePenaltyFactor);
                cboVRPTimeWindow.SelectedIndex         = Convert.ToInt32(vrpSolver.TimeWindowViolationPenaltyFactor);
                cboVRPTimeFieldUnits.SelectedIndex     = Convert.ToInt32(vrpSolver.TimeFieldUnits - 20);

                txtVRPCapacityCount.Text = vrpSolver.CapacityCount.ToString();
                txtVRPDefaultDate.Text   = vrpSolver.DefaultDate.ToShortDateString();

                chkVRPUseHierarchy.Checked = naSolverSettings.UseHierarchy;

                PopulateAttributeControl(chklstVRPRestrictionAttributeNames, networkDataset, naSolverSettings.RestrictionAttributeNames, esriNetworkAttributeUsageType.esriNAUTRestriction);

                //populate the time attribute combo box
                cboVRPTimeAttribute.Items.Clear();

                for (int i = 0; i < networkDataset.AttributeCount; i++)
                {
                    INetworkAttribute networkAttribute = networkDataset.get_Attribute(i);

                    if (networkAttribute.UsageType == esriNetworkAttributeUsageType.esriNAUTCost &&
                        networkAttribute.Units >= esriNetworkAttributeUnits.esriNAUSeconds)
                    {
                        cboVRPTimeAttribute.Items.Add(networkAttribute.Name);
                    }
                }

                if (cboVRPTimeAttribute.Items.Count > 0)
                {
                    cboVRPTimeAttribute.Text = naSolverSettings.ImpedanceAttributeName;
                }


                // for VRP, the AccumulateAttributeNames hold the length, and it can only hold one length.
                //  Loop through the network dataset attributes
                cboVRPDistanceAttribute.Items.Clear();
                cboVRPDistanceAttribute.SelectedIndex = cboVRPDistanceAttribute.Items.Add("");

                for (int i = 0; i < networkDataset.AttributeCount; i++)
                {
                    INetworkAttribute networkAttribute = networkDataset.get_Attribute(i);
                    if (networkAttribute.UsageType == esriNetworkAttributeUsageType.esriNAUTCost &&
                        networkAttribute.Units < esriNetworkAttributeUnits.esriNAUSeconds)
                    {
                        string attributeName = networkAttribute.Name;

                        int cboindex = cboVRPDistanceAttribute.Items.Add(networkAttribute.Name);

                        // If the attribute is in the strArray, it should be the selected one
                        for (int j = 0; j < naSolverSettings.AccumulateAttributeNames.Count; j++)
                        {
                            if (naSolverSettings.AccumulateAttributeNames.get_Element(j) == attributeName)
                            {
                                cboVRPDistanceAttribute.SelectedIndex = cboindex;
                            }
                        }
                    }
                }
            }
            else if (laSolver != null)  // Location-Allocation LAYER
            {
                // Remove unnecessary tabs
                tabPropPages.TabPages.Remove(tabRoute);
                tabPropPages.TabPages.Remove(tabClosestFacility);
                tabPropPages.TabPages.Remove(tabODCostMatrix);
                tabPropPages.TabPages.Remove(tabServiceArea);
                tabPropPages.TabPages.Remove(tabVRP);

                // INALocationAllocationSolver
                txtLACutOff.Text             = GetStringFromObject(laSolver.DefaultCutoff);
                txtLAFacilitiesToLocate.Text = laSolver.NumberFacilitiesToLocate.ToString();
                txtLAImpParameter.Text       = laSolver.TransformationParameter.ToString();
                txtLATargetMarketShare.Text  = laSolver.TargetMarketSharePercentage.ToString();

                cboLAImpTransformation.SelectedIndex = Convert.ToInt32(laSolver.ImpedanceTransformation);
                cboLAProblemType.SelectedIndex       = Convert.ToInt32(laSolver.ProblemType);
                cboLAOutputLines.SelectedIndex       = Convert.ToInt32(laSolver.OutputLines);
                cboLATravelDirection.SelectedIndex   = Convert.ToInt32(laSolver.TravelDirection);

                //// INASolverSettings
                PopulateImpedanceNameControl(cboLAImpedance, networkDataset, naSolverSettings.ImpedanceAttributeName);
                PopulateAttributeControl(chklstLAAccumulateAttributeNames, networkDataset, naSolverSettings.AccumulateAttributeNames, esriNetworkAttributeUsageType.esriNAUTCost);
                PopulateAttributeControl(chklstLARestrictionAttributeNames, networkDataset, naSolverSettings.RestrictionAttributeNames, esriNetworkAttributeUsageType.esriNAUTRestriction);
                chkLAUseHierarchy.Enabled           = (naSolverSettings.HierarchyAttributeName.Length > 0);
                chkLAUseHierarchy.Checked           = (chkCFUseHierarchy.Enabled && naSolverSettings.UseHierarchy);
                chkLAIgnoreInvalidLocations.Checked = naSolverSettings.IgnoreInvalidLocations;
            }
            else  // Unknown type of layer
            {
                // Remove unnecessary tabs
                tabPropPages.TabPages.Remove(tabRoute);
                tabPropPages.TabPages.Remove(tabClosestFacility);
                tabPropPages.TabPages.Remove(tabODCostMatrix);
                tabPropPages.TabPages.Remove(tabServiceArea);
                tabPropPages.TabPages.Remove(tabVRP);
                tabPropPages.TabPages.Remove(tabLocationAllocation);
            }
        }