/// <summary> /// Set general solver settings (Impedance, Restrictions, Accumulates, etc.) /// </summary> private void SetINASolverSettings(INASolverSettings2 solverSettings) { //1.设置Impedance solverSettings.ImpedanceAttributeName = ExtractImpedanceName(cboImpedance.Text); //2.设置限制属性 IStringArray restrictionAttributes = solverSettings.RestrictionAttributeNames; restrictionAttributes.RemoveAll(); for (int i = 0; i < chklstRestrictions.CheckedItems.Count; i++) { restrictionAttributes.Add(chklstRestrictions.Items[chklstRestrictions.CheckedIndices[i]].ToString()); } solverSettings.RestrictionAttributeNames = restrictionAttributes; //3.设置累计属性 IStringArray accumulateAttributes = solverSettings.AccumulateAttributeNames; accumulateAttributes.RemoveAll(); for (int i = 0; i < chklstAccumulateAttributes.CheckedItems.Count; i++) { accumulateAttributes.Add(chklstAccumulateAttributes.Items[chklstAccumulateAttributes.CheckedIndices[i]].ToString()); } solverSettings.AccumulateAttributeNames = accumulateAttributes; //4.设置允许拐点策略 solverSettings.RestrictUTurns = (esriNetworkForwardStarBacktrack)cboUturnPolicy.SelectedIndex; //5.设置忽略无效位置 solverSettings.IgnoreInvalidLocations = chkIgnoreInvalidLocations.Checked; //6.设置使用高级属性 solverSettings.UseHierarchy = chkUseHierarchy.Checked; }
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); }
/* * This method queries the device layer and returns a set of features */ private IPropertySetArray QueryDevices(string whereClause, IStringArray outFields) { IPropertySetArray results = new PropertySetArray(); int deviceLayerId = soeUtil.GetLayerIdByName(mapService, DEVICE_LAYER_NAME); IFeatureClass deviceFC = (IFeatureClass)mapServerDataAccess.GetDataSource(mapService.DefaultMapName, deviceLayerId); IQueryFilter filter = new QueryFilterClass(); filter.WhereClause = whereClause; IFeatureCursor resultsFeatureCursor = deviceFC.Search(filter, false); IArray fieldIndex = new ArrayClass(); for (int i = 0; i < outFields.Count; i++) { fieldIndex.Add(deviceFC.FindField(outFields.Element[i])); } IFeature resultFeature = null; while ((resultFeature = resultsFeatureCursor.NextFeature()) != null) { IPropertySet values = new PropertySet(); for (int i = 0; i < outFields.Count; i++) { values.SetProperty(outFields.Element[i], resultFeature.Value[(int)fieldIndex.Element[i]]); } results.Add(values); } Marshal.ReleaseComObject(resultsFeatureCursor); return(results); }
/// <summary> /// Set solver settings /// </summary> public void SetSolverSettings() { // Set OD solver specific settings INASolver solver = m_NAContext.Solver; INAODCostMatrixSolver odSolver = solver as INAODCostMatrixSolver; if (textCutoff.Text.Length > 0 && IsNumeric(textCutoff.Text.Trim())) { odSolver.DefaultCutoff = textCutoff.Text; } else { odSolver.DefaultCutoff = null; } if (textTargetFacility.Text.Length > 0 && IsNumeric(textTargetFacility.Text.Trim())) { odSolver.DefaultTargetDestinationCount = textTargetFacility.Text; } else { odSolver.DefaultTargetDestinationCount = null; } odSolver.OutputLines = esriNAOutputLineType.esriNAOutputLineStraight; // Set generic solver settings // Set the impedance attribute INASolverSettings solverSettings = solver as INASolverSettings; solverSettings.ImpedanceAttributeName = comboCostAttribute.Text; // Set the OneWay restriction if necessary IStringArray restrictions = solverSettings.RestrictionAttributeNames; restrictions.RemoveAll(); if (checkUseRestriction.Checked) { restrictions.Add("oneway"); } solverSettings.RestrictionAttributeNames = restrictions; // Restrict UTurns solverSettings.RestrictUTurns = esriNetworkForwardStarBacktrack.esriNFSBNoBacktrack; solverSettings.IgnoreInvalidLocations = true; // Set the hierarchy attribute solverSettings.UseHierarchy = checkUseHierarchy.Checked; if (solverSettings.UseHierarchy) { solverSettings.HierarchyAttributeName = "HierarchyMultiNet"; } // Do not forget to update the context after you set your impedance solver.UpdateContext(m_NAContext, GetDENetworkDataset(m_NAContext.NetworkDataset), new GPMessagesClass()); }
UID myUID; // UID for the DMCII Raster Type. #endregion #region IRasterTypeFactory Members public DMCIIRasterTypeFactory() { string rasterTypeName = "DMCII Raster Type"; myRasterTypeNames = new StrArrayClass(); myRasterTypeNames.Add(rasterTypeName); myUID = new UIDClass(); myUID.Value = "{5DEF8E3C-51E9-49af-A3BE-EF8C68A4BBBE}"; }
/// <summary> /// Creates an <see cref="IEnumerable{T}" /> from an <see cref="IStringArray" /> /// </summary> /// <param name="source">An <see cref="IStringArray" /> to create an <see cref="IEnumerable{T}" /> from.</param> /// <returns>An <see cref="IEnumerable{T}" /> that contains the datasets from the input source.</returns> public static IEnumerable <string> AsEnumerable(this IStringArray source) { if (source != null) { for (int i = 0; i < source.Count; i++) { yield return(source.Element[i]); } } }
UID myUID; // UID for the Thumbnail Raster type. #endregion #region IRasterTypeFactory Members public ThumbnailFactory() { // The Raster Type name should follow the pattern // 'Thumbnail ' follwed by the name of the built-in // Raster Type to attach the Thumbnail Builder to. myRasterTypeNames = new StrArrayClass(); myRasterTypeNames.Add("Thumbnail Raster Dataset"); myRasterTypeNames.Add("Thumbnail QuickBird"); myUID = new UIDClass(); myUID.Value = "{C6629CC4-B301-451a-9481-4D7751E9701C}"; }
private void Initialize() { int ImpedanceIndex = 0; //Get Attributes cboImpedance.Items.Clear(); chklstAccumulateAttributes.Items.Clear(); chklstRestrictions.Items.Clear(); cboUturnPolicy.SelectedIndex = -1; //声明网络分析参数设置并赋予数值 INASolverSettings2 pNaSolverSetting = pMainFrm.m_NAContext.Solver as INASolverSettings2; //获得网络分析累积属性名 IStringArray accumulateAttributeNames = pNaSolverSetting.AccumulateAttributeNames; //获得网络分析限制属性名 IStringArray restrictionAttributeNames = pNaSolverSetting.RestrictionAttributeNames; //获得网络分析属性 INetworkAttribute pNetworkAttribute; for (int i = 0; i < pMainFrm.m_pNetDataset.AttributeCount; i++) { pNetworkAttribute = pMainFrm.m_pNetDataset.get_Attribute(i); string networkAttributeName = pNetworkAttribute.Name; //如果网络分析属性等于消耗 if (pNetworkAttribute.UsageType == esriNetworkAttributeUsageType.esriNAUTCost) { chklstAccumulateAttributes.Items.Add(networkAttributeName, IsStringInStringArray(networkAttributeName, accumulateAttributeNames)); int index = cboImpedance.Items.Add(pNetworkAttribute.Name + " (" + pNetworkAttribute.Units.ToString().Substring(7) + ")"); if (networkAttributeName == pNaSolverSetting.ImpedanceAttributeName) { ImpedanceIndex = index; } } //如果网络分析属性等于限制 if (pNetworkAttribute.UsageType == esriNetworkAttributeUsageType.esriNAUTRestriction) { chklstRestrictions.Items.Add(pNetworkAttribute.Name, IsStringInStringArray(networkAttributeName, restrictionAttributeNames)); } } if (cboImpedance.Items.Count > 0) { cboImpedance.SelectedIndex = ImpedanceIndex; } //是否使用高级 chkUseHierarchy.Checked = pNaSolverSetting.UseHierarchy; //是否使用高级 chkUseHierarchy.Enabled = pNaSolverSetting.HierarchyAttributeName.Length > 0; //是否忽略无效的位置 chkIgnoreInvalidLocations.Checked = pNaSolverSetting.IgnoreInvalidLocations; //是否允许拐点 cboUturnPolicy.SelectedIndex = System.Convert.ToInt32(pNaSolverSetting.RestrictUTurns); }
private void FrmNecCdfAttributeSelection_Load(object sender, EventArgs e) { IStringArray atArray = rsUtil.getNetCdfVariables(netCdf); for (int i = 0; i < atArray.Count; i++) { string s = atArray.get_Element(i); cmbVariable.Items.Add(s); cmbX.Items.Add(s); cmbY.Items.Add(s); cmbBands.Items.Add(s); } }
private bool IsStringInStringArray(string inputString, IStringArray stringArray) { int numInArray = stringArray.Count; for (int i = 0; i < numInArray; i++) { if (inputString.Equals(stringArray.get_Element(i))) { return(true); } } return(false); }
public void SetSolverSettings() { INASolver solver = this.m_pNAContext.Solver; INAClosestFacilitySolver solver2 = solver as INAClosestFacilitySolver; if ((this.txtCutOff.Text.Length > 0) && this.IsNumeric(this.txtCutOff.Text.Trim())) { solver2.DefaultCutoff = this.txtCutOff.Text; } else { solver2.DefaultCutoff = null; } if ((this.txtTargetFacility.Text.Length > 0) && this.IsNumeric(this.txtTargetFacility.Text)) { solver2.DefaultTargetFacilityCount = int.Parse(this.txtTargetFacility.Text); } else { solver2.DefaultTargetFacilityCount = 1; } solver2.OutputLines = esriNAOutputLineType.esriNAOutputLineTrueShapeWithMeasure; solver2.TravelDirection = esriNATravelDirection.esriNATravelDirectionToFacility; INASolverSettings settings = solver as INASolverSettings; settings.ImpedanceAttributeName = this.cboCostAttribute.Text; IStringArray restrictionAttributeNames = settings.RestrictionAttributeNames; restrictionAttributeNames.RemoveAll(); if (this.chkUseRestriction.Checked) { restrictionAttributeNames.Add("oneway"); } settings.RestrictionAttributeNames = restrictionAttributeNames; settings.RestrictUTurns = esriNetworkForwardStarBacktrack.esriNFSBNoBacktrack; settings.IgnoreInvalidLocations = true; settings.UseHierarchy = this.chkUseHierarchy.Checked; if (settings.UseHierarchy) { settings.HierarchyAttributeName = "hierarchy"; settings.HierarchyLevelCount = 3; settings.set_MaxValueForHierarchy(1, 1); settings.set_NumTransitionToHierarchy(1, 9); settings.set_MaxValueForHierarchy(2, 2); settings.set_NumTransitionToHierarchy(2, 9); } solver.UpdateContext(this.m_pNAContext, this.GetDENetworkDataset(this.m_pNAContext.NetworkDataset), new GPMessagesClass()); }
/// <summary> /// Deserialize the argument object from the stream provided /// </summary> /// <param name="data">Xml stream to deserialize the argument object from</param> public void Deserialize(IXMLSerializeData data) { int nameIndex = data.Find("Names"); int valIndex = data.Find("Values"); if (nameIndex != -1 && valIndex != -1) { IStringArray myNames = (IStringArray)data.GetVariant(nameIndex); IVariantArray myValues = (IVariantArray)data.GetVariant(valIndex); for (int i = 0; i < myNames.Count; ++i) { myProperties.SetProperty(myNames.get_Element(i), myValues.get_Element(i)); } } }
/// <summary> /// Update settings that apply to all solvers /// </summary> private void ConfigureGenericSolverSettings() { INASolverSettings naSolverSettings = m_NAContext.Solver as INASolverSettings; naSolverSettings.ImpedanceAttributeName = cbCostAttribute.Text; // set the oneway restriction, if necessary IStringArray restrictions = naSolverSettings.RestrictionAttributeNames; restrictions.RemoveAll(); if (ckbUseRestriction.Checked) { restrictions.Add("Oneway"); } naSolverSettings.RestrictionAttributeNames = restrictions; //naSolverSettings.RestrictUTurns = esriNetworkForwardStarBacktrack.esriNFSBNoBacktrack; }
/// <summary> /// 设置解决器 暂时没有使用到 /// 有问题待修正 /// </summary> /// <param name="pNAContext"></param> private static void SetSolverSettings(INAContext pNAContext) { if (pNAContext.Solver.CanAccumulateAttributes) { INASolver naSolver = pNAContext.Solver; INARouteSolver naRouteSolver = naSolver as INARouteSolver; naRouteSolver.FindBestSequence = true; naRouteSolver.PreserveFirstStop = true; naRouteSolver.PreserveLastStop = false; naRouteSolver.UseTimeWindows = false; naRouteSolver.OutputLines = esriNAOutputLineType.esriNAOutputLineTrueShapeWithMeasure; INASolverSettings2 naSolverSettings = naSolver as INASolverSettings2; IStringArray restrictions = naSolverSettings.RestrictionAttributeNames; restrictions.Add("Oneway"); naSolverSettings.RestrictionAttributeNames = restrictions; //基于上述设置更新Solver naSolver.UpdateContext(pNAContext, GetDENetworkDataset(pNAContext.NetworkDataset), new GPMessagesClass()); } }
/// <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); }
private static void OutputODCostsToCsvFiles( string layerFilePath, IReadOnlyList <double[, ]> costMatrixByCostAttributesList, IStringArray costAttributeNames, List <string> originNames, List <string> destinationNames) { var baseOutputFileName = Path.GetFileNameWithoutExtension(layerFilePath); var outputFolderPath = Directory.GetParent(layerFilePath).FullName; // For the impedance attribute (1st cost attribute), output costs as a flat table CSV text file. // For all cost attributes (impedance and accumulated), output costs as matrix CSV text file. // var attributeCount = costMatrixByCostAttributesList.Count; for (var a = 0; a < attributeCount; ++a) { var costs = costMatrixByCostAttributesList[a]; var attributeName = costAttributeNames.Element[a]; var isImpedance = (a == 0); var attributeDescription = $"{(isImpedance ? "OptimizedOn" : "AccumulationOf")}_{attributeName}"; const string outputFileNameFormat = "{0}_ODCost{1}_{2}.csv"; string outputFileName; string outputFilePath; if (isImpedance) { outputFileName = string.Format(outputFileNameFormat, baseOutputFileName, "FlatTable", attributeDescription); outputFilePath = Path.Combine(outputFolderPath, outputFileName); OutputCsvFlatTable(outputFilePath, costAttributeNames, originNames, destinationNames, costMatrixByCostAttributesList); } outputFileName = string.Format(outputFileNameFormat, baseOutputFileName, "Matrix", attributeDescription); outputFilePath = Path.Combine(outputFolderPath, outputFileName); OutputCsvMatrix(outputFilePath, originNames, destinationNames, costs); } }
public static INALayer CreateClosestFacilityLayer(string layerName, INetworkDataset networkDataset, INAClosestFacilitySolver naClosesFacilitySolver) { INASolverSettings settings = naClosesFacilitySolver as INASolverSettings; INASolver solver = naClosesFacilitySolver as INASolver; IDatasetComponent component = networkDataset as IDatasetComponent; IDENetworkDataset dataElement = component.DataElement as IDENetworkDataset; INAContext context = solver.CreateContext(dataElement, layerName); (context as INAContextEdit).Bind(networkDataset, new GPMessagesClass()); INALayer layer = solver.CreateLayer(context); (layer as ILayer).Name = layerName; naClosesFacilitySolver.CreateTraversalResult = true; naClosesFacilitySolver.TravelDirection = esriNATravelDirection.esriNATravelDirectionFromFacility; naClosesFacilitySolver.OutputLines = esriNAOutputLineType.esriNAOutputLineTrueShapeWithMeasure; IStringArray restrictionAttributeNames = settings.RestrictionAttributeNames; restrictionAttributeNames.Add("Oneway"); settings.RestrictionAttributeNames = restrictionAttributeNames; solver.UpdateContext(context, dataElement, new GPMessagesClass()); return(layer); }
/// <summary> /// Set solver settings /// </summary> public void SetSolverSettings() { // Set VRP solver specific settings INASolver solver = m_NAContext.Solver; INAVRPSolver vrpSolver = solver as INAVRPSolver; // Both orders and routes have capacity count of 2 in the input shape files. User can modify the input data and update this value accordingly. vrpSolver.CapacityCount = 2; // Read the time and distance unit from comboBox vrpSolver.DistanceFieldUnits = (esriNetworkAttributeUnits)m_unitDistList[comboDistUnits.Items[comboDistUnits.SelectedIndex].ToString()]; vrpSolver.TimeFieldUnits = (esriNetworkAttributeUnits)m_unitTimeList[comboTimeUnits.Items[comboTimeUnits.SelectedIndex].ToString()]; // The value of time window violation penalty factor can be adjusted in terms of the user's preference. string importance = comboTWImportance.Items[comboTWImportance.SelectedIndex].ToString(); if (importance == "Low") { vrpSolver.TimeWindowViolationPenaltyFactor = 0; } else if (importance == "Medium") { vrpSolver.TimeWindowViolationPenaltyFactor = 1; } else if (importance == "High") { vrpSolver.TimeWindowViolationPenaltyFactor = 10; } // Set output line type vrpSolver.OutputLines = esriNAOutputLineType.esriNAOutputLineStraight; // Set generic solver settings // Set the impedance attribute INASolverSettings solverSettings = solver as INASolverSettings; solverSettings.ImpedanceAttributeName = comboTimeAttribute.Text; // Set the accumulated attribute IStringArray accumulatedAttributes = solverSettings.AccumulateAttributeNames; accumulatedAttributes.RemoveAll(); accumulatedAttributes.Insert(0, comboDistanceAttribute.Text); solverSettings.AccumulateAttributeNames = accumulatedAttributes; // Set the oneway restriction if necessary IStringArray restrictions = solverSettings.RestrictionAttributeNames; restrictions.RemoveAll(); if (checkUseRestriction.Checked) { restrictions.Add("oneway"); } solverSettings.RestrictionAttributeNames = restrictions; // Restrict UTurns solverSettings.RestrictUTurns = esriNetworkForwardStarBacktrack.esriNFSBNoBacktrack; // Set the hierarchy attribute solverSettings.UseHierarchy = checkUseHierarchy.Checked; if (solverSettings.UseHierarchy) { solverSettings.HierarchyAttributeName = "HierarchyMultiNet"; } // Do not forget to update the context after you set your impedance solver.UpdateContext(m_NAContext, GetDENetworkDataset(m_NAContext.NetworkDataset), new GPMessagesClass()); }
/// <summary> /// Get all the properties associated with the dataset. /// </summary> /// <param name="dataset">Dataset to get the property from.</param> /// <param name="allKeys">String Array passed in by reference to fill with all keys.</param> /// <param name="allProperties">Object array passed in by reference to fill with all properties.</param> static void GetAllProperties(IDataset dataset, ref IStringArray allKeys, ref IVariantArray allProperties) { IRasterKeyProperties rasterKeyProps = (IRasterKeyProperties)dataset; rasterKeyProps.GetAllProperties(out allKeys, out allProperties); }
/// <summary> /// Get all the properties associated with a particular band of the dataset. /// </summary> /// <param name="dataset">Dataset to get the property from.</param> /// <param name="bandIndex">band for which to get all properties.</param> /// <param name="bandKeys">String Array passed in by reference to fill with all keys.</param> /// <param name="bandProperties">Object array passed in by reference to fill with all properties.</param> static void GetAllBandProperties(IDataset dataset, int bandIndex, ref IStringArray bandKeys, ref IVariantArray bandProperties) { IRasterKeyProperties rasterKeyProps = (IRasterKeyProperties)dataset; rasterKeyProps.GetAllBandProperties(bandIndex, out bandKeys, out bandProperties); }
private void btnOK_Click(object sender, EventArgs e) { INASolver naSolver = pMainFrm.m_NAContext.Solver; //开始进行设置 INAClosestFacilitySolver cfSolver = naSolver as INAClosestFacilitySolver; if (numericUpDownCutoff.Value == 0) { cfSolver.DefaultCutoff = null; } else { cfSolver.DefaultCutoff = numericUpDownCutoff.Value; } if (numericUpDownFCount.Value == 0) { cfSolver.DefaultTargetFacilityCount = 1; } else { cfSolver.DefaultTargetFacilityCount = int.Parse(numericUpDownFCount.Value.ToString()); } //设置输出线的形状 switch (cboOutShapeType.Text) { case "无": cfSolver.OutputLines = esriNAOutputLineType.esriNAOutputLineNone; break; case "直线": cfSolver.OutputLines = esriNAOutputLineType.esriNAOutputLineStraight; break; case "True Shape": cfSolver.OutputLines = esriNAOutputLineType.esriNAOutputLineTrueShape; break; case "True Shape(无测量)": cfSolver.OutputLines = esriNAOutputLineType.esriNAOutputLineTrueShapeWithMeasure; break; } //设置查找方向 if (rbnItoF.Checked == true) { cfSolver.TravelDirection = esriNATravelDirection.esriNATravelDirectionToFacility; } else { cfSolver.TravelDirection = esriNATravelDirection.esriNATravelDirectionFromFacility; } //设置SOLVER的参数 //设置Impedance的属性 INASolverSettings naSolverSetting = naSolver as INASolverSettings; naSolverSetting.ImpedanceAttributeName = cboImpedance.Text; //设置OneWay限制 IStringArray restriction = naSolverSetting.RestrictionAttributeNames; restriction.RemoveAll(); int i = 0; for (i = 0; i <= listView1.SelectedItems.Count - 1; i++) { restriction.Add(listView1.SelectedItems.ToString()); } naSolverSetting.RestrictionAttributeNames = restriction; //设置拐点 switch (cboAllowedTurn.Text) { case "无": naSolverSetting.RestrictUTurns = esriNetworkForwardStarBacktrack.esriNFSBNoBacktrack; break; case "任何端点": naSolverSetting.RestrictUTurns = esriNetworkForwardStarBacktrack.esriNFSBAllowBacktrack; break; case "仅在末端": naSolverSetting.RestrictUTurns = esriNetworkForwardStarBacktrack.esriNFSBAtDeadEndsOnly; break; } naSolverSetting.IgnoreInvalidLocations = chkIgnoreInvalidValue.Checked; naSolver.UpdateContext(pMainFrm.m_NAContext, Utility.GetDENetworkDataset(pMainFrm.m_pNetDataset), new GPMessagesClass()); ToolBarButton toolbarbutton1 = pMainFrm.returnToolbarButton(); toolbarbutton1.Enabled = true; this.Dispose(); }
/// <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); } } }
private bool IsStringInStringArray(string inputString, IStringArray stringArray) { int numInArray = stringArray.Count; for (int i = 0; i < numInArray; i++) { if (inputString.Equals(stringArray.get_Element(i))) return true; } return false; }
private static List <double[, ]> GetCostMatrixByCostAttributesList( INAContext context, out IStringArray costAttributeNames, out List <string> originNames, out List <string> destinationNames) { var odSolver = context.Solver as INAODCostMatrixSolver2; if (odSolver == null) { throw new InvalidOdLayerException("Unable to get INAODCostMatrixSolver2 from layer file context solver. Is your layer an OD layer?"); } var odCostMatrix = context.Result as INAODCostMatrix; // If an matrix already exists in this layer, use it. If not, solve and generate a matrix. if (odCostMatrix == null || !context.Result.HasValidResult || odSolver.MatrixResultType == esriNAODCostMatrixType.esriNAODCostMatrixNone || odSolver.PopulateODLines) { odCostMatrix = Solve(context, odSolver); } ////////////////////////////////////////////////////////////////// // // Set up mapping of OIDs to internal matrix indexes // // The reason for doing this is that the internal matrix is stored in such a way that // origins/destinations that map to the same location on the network are stored at the // same index in the matrix. This is an optimization to avoid storing redundant entries // in the matrix. // var originMapping = GetInternalIndexToOidMapping(context, odCostMatrix, isOrigin: true); var destinationMapping = GetInternalIndexToOidMapping(context, odCostMatrix, isOrigin: false); // There are values stored for the impedance, as well as every accumulated attribute. costAttributeNames = odCostMatrix.CostAttributeNames; var attributeCount = costAttributeNames.Count; if (attributeCount == 0) { throw new InvalidOdLayerException("At least one attribute is required."); } originNames = new List <string>(); foreach (var internalOrigins in originMapping) { originNames.AddRange(internalOrigins.Value); } destinationNames = new List <string>(); foreach (var internalDestinations in destinationMapping) { destinationNames.AddRange(internalDestinations.Value); } var originCount = originNames.Count; var destinationCount = destinationNames.Count; if ((originCount == 0) || (destinationCount == 0)) { throw new InvalidOdLayerException("At least one origin and destination are required."); } ////////////////////////////////////////////////////////////////// // // Iterate the internal matrix to create matrix of cost values by attribute origin and destination // var matrixUniqueOriginLocationCount = odCostMatrix.OriginCount; var matrixUniqueDestinationLocationCount = odCostMatrix.DestinationCount; // The index could start at a value less than zero, to represent non-located locations. // Therefore, find the lowest index value before doing the iterations. var startIndexMatrixUniqueOriginLocation = GetStartingIndex(originMapping); var startIndexMatrixUniqueDestinationLocation = GetStartingIndex(destinationMapping); var costMatrixByCostAttributesList = new List <double[, ]>(); for (var attributeIndex = 0; attributeIndex < attributeCount; ++attributeIndex) { var costs = new double[originCount, destinationCount]; costMatrixByCostAttributesList.Add(costs); var defaultValue = odCostMatrix.DefaultValue[attributeIndex]; // The outer loop iterates over all of the origins in the internal matrix. // Start at -1 to handle the non-located origins. for (int indexMatrixUniqueOriginLocation = startIndexMatrixUniqueOriginLocation, originIndex = 0; indexMatrixUniqueOriginLocation < matrixUniqueOriginLocationCount; ++indexMatrixUniqueOriginLocation) { var duplicateOriginCount = originMapping[indexMatrixUniqueOriginLocation].Count; for (var duplicateOriginIndex = 0; duplicateOriginIndex < duplicateOriginCount; ++duplicateOriginIndex, ++originIndex) { for (int indexMatrixUniqueDestinationLocation = startIndexMatrixUniqueDestinationLocation, destinationIndex = 0; indexMatrixUniqueDestinationLocation < matrixUniqueDestinationLocationCount; ++indexMatrixUniqueDestinationLocation) { var duplicateDestinationCount = destinationMapping[indexMatrixUniqueDestinationLocation].Count; for (var duplicateDestinationIndex = 0; duplicateDestinationIndex < duplicateDestinationCount; ++duplicateDestinationIndex, ++destinationIndex) { // If either the origin or destination is non-located, use the default value. var value = defaultValue; if ((indexMatrixUniqueOriginLocation >= 0) && (indexMatrixUniqueDestinationLocation >= 0)) { value = odCostMatrix.Value[indexMatrixUniqueOriginLocation, indexMatrixUniqueDestinationLocation, attributeIndex]; } costs[originIndex, destinationIndex] = value; } } } } } return(costMatrixByCostAttributesList); }
/** * Returns a list of customers serviced by the specified transformer */ private byte[] GetCustomersOperHandler(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties) { responseProperties = null; if (unDataset == null) { throw new RestErrorException("No Utility Network found"); } JSONObject result = new JSONObject(); try { string xfrAssetID = ""; operationInput.TryGetString("transformerAssetId", out xfrAssetID); if (string.IsNullOrEmpty(xfrAssetID)) { long?assetNumber = null; operationInput.TryGetAsLong("transformerAssetId", out assetNumber); if (assetNumber == null) { throw new ArgumentNullException("transformerAssetId"); } else { xfrAssetID = assetNumber.ToString(); } } // Get the transformer feature global ID from the asset ID string xfrWhereClause = "ASSETGROUP=" + MV_XFR_ASSETGROUP.ToString() + " AND ASSETID=" + xfrAssetID; IStringArray xfrOutFields = new StrArrayClass(); xfrOutFields.Add("GLOBALID"); xfrOutFields.Add("ASSETTYPE"); xfrOutFields.Add("SHAPE"); IPropertySetArray xfrQryResults = QueryDevices(xfrWhereClause, xfrOutFields); if (xfrQryResults == null || xfrQryResults.Count == 0) { throw new RestErrorException("No medium voltage transformer found for asset id: " + xfrAssetID); } string xfrGlobalID = (string)xfrQryResults.Element[0].GetProperty("GLOBALID"); short xfrAssetType = (short)xfrQryResults.Element[0].GetProperty("ASSETTYPE"); // Execute a downstream trace to find all customer low voltage service points IStringArray lvsGlobalIDs = FindLVServicePoints(xfrGlobalID); // Prepare response JSON JSONObject xfrInfo = new JSONObject(); xfrInfo.AddString("ASSETID", xfrAssetID); xfrInfo.AddString("GLOBALID", xfrGlobalID); xfrInfo.AddLong("ASSETGROUP", MV_XFR_ASSETGROUP); xfrInfo.AddLong("ASSETTYPE", xfrAssetType); IJSONObject xfrPointJson = new JSONObject(); IGeometry xfrPoint = (IGeometry)xfrQryResults.Element[0].GetProperty("SHAPE"); IJSONConverterGeometry geoSerializer = new JSONConverterGeometryClass(); geoSerializer.QueryJSONGeometry(xfrPoint, false, xfrPointJson); xfrInfo.AddJSONObject("geometry", xfrPointJson); result.AddJSONObject("transformer", xfrInfo); IJSONArray servicePoints = new JSONArrayClass(); // Get additional service point info if any returned from trace if (lvsGlobalIDs != null && lvsGlobalIDs.Count > 0) { // Query devices to get more details about service points string lvsGlobalIDList = ""; for (int i = 0; i < lvsGlobalIDs.Count; i++) { lvsGlobalIDList += (i == 0) ? "" : ","; lvsGlobalIDList += "'" + lvsGlobalIDs.Element[i] + "'"; } string lvsWhereClause = "GLOBALID IN (" + lvsGlobalIDList + ")"; IStringArray lvsOutFields = new StrArrayClass(); lvsOutFields.Add("GLOBALID"); lvsOutFields.Add("ASSETTYPE"); lvsOutFields.Add("ASSETGROUP"); lvsOutFields.Add("ASSETID"); lvsOutFields.Add("SHAPE"); IPropertySetArray lvsQryResults = QueryDevices(lvsWhereClause, lvsOutFields); // Get customer details if (lvsQryResults != null && lvsQryResults.Count > 0) { for (int i = 0; i < lvsQryResults.Count; i++) { IPropertySet lvs = lvsQryResults.Element[i]; JSONObject servicePoint = new JSONObject(); servicePoint.AddString("GLOBALID", (string)lvs.GetProperty("GLOBALID")); servicePoint.AddString("ASSETID", (string)lvs.GetProperty("ASSETID")); servicePoint.AddLong("ASSETGROUP", (int)lvs.GetProperty("ASSETGROUP")); servicePoint.AddLong("ASSETTYPE", (short)lvs.GetProperty("ASSETTYPE")); IGeometry lvsPoint = (IGeometry)lvs.GetProperty("SHAPE"); IJSONObject lvsPointJson = new JSONObject(); geoSerializer.QueryJSONGeometry(lvsPoint, false, lvsPointJson); servicePoint.AddJSONObject("geometry", lvsPointJson); JSONObject customerInfo = GetCustomerInfoJSON(); servicePoint.AddJSONObject("customerInfo", customerInfo); servicePoints.AddJSONObject(servicePoint); } } } result.AddJSONArray("servicePoints", servicePoints); } catch (Exception e) { logger.LogMessage(ServerLogger.msgType.debug, soe_name + " getCustomers", 500, "Exception " + e.GetType().Name + " " + e.Message + " " + e.StackTrace); JSONObject error = soeUtil.CreateErrorJSON(500, "Unable to complete operation", e.HResult, e.Message); return(Encoding.UTF8.GetBytes(error.ToJSONString(null))); } return(Encoding.UTF8.GetBytes(result.ToJSONString(null))); }
private static void OutputCsvFlatTable(string outputFilePath, IStringArray costAttributeNames, IReadOnlyList <string> originNames, IReadOnlyList <string> destinationNames, IReadOnlyList <double[, ]> costMatrixByCostAttributesList) { if (costAttributeNames == null) { throw new ArgumentNullException(nameof(costAttributeNames), "Missing cost attribute names"); } if (originNames == null) { throw new ArgumentNullException(nameof(originNames), "Missing origin names"); } if (destinationNames == null) { throw new ArgumentNullException(nameof(destinationNames), "Missing destination names"); } if (costMatrixByCostAttributesList == null) { throw new ArgumentNullException(nameof(costMatrixByCostAttributesList)); } var sbHeader = new StringBuilder(); const char cSeparator = ','; sbHeader.Append("Origin,Destination"); var costAttributeCount = costAttributeNames.Count; if (costAttributeCount == 0) { throw new InvalidOdLayerException("There are no cost attributes"); } var originCount = originNames.Count; if (originCount == 0) { throw new InvalidOdLayerException("There are no origins"); } var destinationCount = destinationNames.Count; if (destinationCount == 0) { throw new InvalidOdLayerException("There are no destinations"); } for (var costAttributeIndex = 0; costAttributeIndex < costAttributeCount; ++costAttributeIndex) { sbHeader.Append(cSeparator); var attributeName = NormalizeCsvName(costAttributeNames.Element[costAttributeIndex]); sbHeader.Append(attributeName); } var header = sbHeader.ToString(); sbHeader.Clear(); using (var writer = new StreamWriter(outputFilePath, false, Encoding.Unicode)) { writer.WriteLine(header); var sbCostsLine = new StringBuilder(); for (var originIndex = 0; originIndex < originCount; ++originIndex) { var originName = originNames[originIndex]; for (var destinationIndex = 0; destinationIndex < destinationCount; ++destinationIndex) { sbCostsLine.Append(originName); var destinationName = destinationNames[destinationIndex]; sbCostsLine.Append(cSeparator); sbCostsLine.Append(destinationName); for (var costAttributeIndex = 0; costAttributeIndex < costAttributeCount; ++costAttributeIndex) { var cost = costMatrixByCostAttributesList[costAttributeIndex][originIndex, destinationIndex]; sbCostsLine.Append(cSeparator); sbCostsLine.Append(cost); } writer.WriteLine(sbCostsLine.ToString()); sbCostsLine.Clear(); } } } }
public IFunctionRasterDataset setValueRangeToNodata(object inRaster,IStringArray sArray) { string tempAr = funcDir + "\\" + FuncCnt + ".afr"; IFunctionRasterDataset frDset = new FunctionRasterDatasetClass(); IFunctionRasterDatasetName frDsetName = new FunctionRasterDatasetNameClass(); frDsetName.FullName = tempAr; frDset.FullName = (IName)frDsetName; IRasterFunction rsFunc = new MaskFunctionClass(); IMaskFunctionArguments args = new MaskFunctionArgumentsClass(); //IMaskFunctionArguments2 args = new MaskFunctionArgumentsClass(); args.Raster = returnRaster(inRaster); args.NoDataValues = sArray; //args.NoDataInterpretation = esriNoDataInterpretation.esriNoDataMatchAll; frDset.Init(rsFunc, args); return frDset; //IRaster rs = returnRaster(inRaster); //IRasterProps rsProps = (IRasterProps)rs; //IRasterBandCollection rsBc = (IRasterBandCollection)rs; //int bCnt = rsBc.Count; //System.Array noDataArr = (System.Array)rsProps.NoDataValue; //IRasterBandCollection rsBcOut = new RasterClass(); //for (int i = 0; i < bCnt; i++) //{ // IRaster brs = getBand(rs, i); // double noData = System.Convert.ToDouble(noDataArr.GetValue(i)); // IRemapFilter rFilt = new RemapFilterClass(); // foreach (double[] d in minMaxList) // { // rFilt.AddClass(d[0], d[1], noData); // } // rsBcOut.AppendBands((IRasterBandCollection)calcRemapFunction(brs, rFilt)); //} //return (IRaster)rsBcOut; }
/// <summary> /// Updates the NALayer based on the current controls. /// This will update the solver settings for the solver referenced by the NALayer. /// </summary> private void UpdateNALayer(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; // Set Layer properties layer.Name = txtLayerName.Text; naLocator.MaxSnapTolerance = Convert.ToDouble(txtMaxSearchTolerance.Text); naLocator.SnapToleranceUnits = (esriUnits)cboMaxSearchToleranceUnits.SelectedIndex; // Set Solver properties if (routeSolver != null) // ROUTE LAYER { // INARouteSolver routeSolver.FindBestSequence = chkRouteFindBestSequence.Checked; routeSolver.PreserveFirstStop = chkRoutePreserveFirstStop.Checked; routeSolver.PreserveLastStop = chkRoutePreserveLastStop.Checked; routeSolver.UseTimeWindows = chkRouteUseTimeWindows.Checked; routeSolver.UseStartTime = chkRouteUseStartTime.Checked; routeSolver.StartTime = System.Convert.ToDateTime(txtRouteStartTime.Text); routeSolver.OutputLines = (esriNAOutputLineType)cboRouteOutputLines.SelectedIndex; // INASolverSettings naSolverSettings.ImpedanceAttributeName = cboRouteImpedance.Text; naSolverSettings.UseHierarchy = chkRouteUseHierarchy.Checked; naSolverSettings.IgnoreInvalidLocations = chkRouteIgnoreInvalidLocations.Checked; naSolverSettings.RestrictUTurns = (esriNetworkForwardStarBacktrack)cboRouteRestrictUTurns.SelectedIndex; naSolverSettings.AccumulateAttributeNames = GetCheckedAttributeNamesFromControl(chklstRouteAccumulateAttributeNames); naSolverSettings.RestrictionAttributeNames = GetCheckedAttributeNamesFromControl(chklstRouteRestrictionAttributeNames); } else if (cfSolver != null) // CLOSEST FACILITY LAYER { if (txtCFDefaultCutoff.Text.Length == 0) { cfSolver.DefaultCutoff = null; } else { cfSolver.DefaultCutoff = Convert.ToDouble(txtCFDefaultCutoff.Text); } if (txtCFDefaultTargetFacilityCount.Text.Length == 0) { cfSolver.DefaultTargetFacilityCount = 1; } else { cfSolver.DefaultTargetFacilityCount = Convert.ToInt32(txtCFDefaultTargetFacilityCount.Text); } cfSolver.TravelDirection = (esriNATravelDirection)cboCFTravelDirection.SelectedIndex; cfSolver.OutputLines = (esriNAOutputLineType)cboCFOutputLines.SelectedIndex; // INASolverSettings naSolverSettings.ImpedanceAttributeName = cboCFImpedance.Text; naSolverSettings.UseHierarchy = chkCFUseHierarchy.Checked; naSolverSettings.IgnoreInvalidLocations = chkCFIgnoreInvalidLocations.Checked; naSolverSettings.RestrictUTurns = (esriNetworkForwardStarBacktrack)cboCFRestrictUTurns.SelectedIndex; naSolverSettings.AccumulateAttributeNames = GetCheckedAttributeNamesFromControl(chklstCFAccumulateAttributeNames); naSolverSettings.RestrictionAttributeNames = GetCheckedAttributeNamesFromControl(chklstCFRestrictionAttributeNames); } else if (odSolver != null) // OD COST MATRIX LAYER { if (txtODDefaultCutoff.Text.Length == 0) { odSolver.DefaultCutoff = null; } else { odSolver.DefaultCutoff = Convert.ToDouble(txtODDefaultCutoff.Text); } if (txtODDefaultTargetDestinationCount.Text.Length == 0) { odSolver.DefaultTargetDestinationCount = null; } else { odSolver.DefaultTargetDestinationCount = Convert.ToInt32(txtODDefaultTargetDestinationCount.Text); } odSolver.OutputLines = (esriNAOutputLineType)cboODOutputLines.SelectedIndex; // INASolverSettings naSolverSettings.ImpedanceAttributeName = cboODImpedance.Text; naSolverSettings.UseHierarchy = chkODUseHierarchy.Checked; naSolverSettings.IgnoreInvalidLocations = chkODIgnoreInvalidLocations.Checked; naSolverSettings.RestrictUTurns = (esriNetworkForwardStarBacktrack)cboODRestrictUTurns.SelectedIndex; naSolverSettings.AccumulateAttributeNames = GetCheckedAttributeNamesFromControl(chklstODAccumulateAttributeNames); naSolverSettings.RestrictionAttributeNames = GetCheckedAttributeNamesFromControl(chklstODRestrictionAttributeNames); } else if (saSolver != null) // SERVICE AREA SOLVER { IDoubleArray defaultBreaks = saSolver.DefaultBreaks; defaultBreaks.RemoveAll(); string breaks = txtSADefaultBreaks.Text.Trim(); breaks.Replace(" ", " "); string[] values = breaks.Split(' '); for (int iBreak = values.GetLowerBound(0); iBreak <= values.GetUpperBound(0); iBreak++) { defaultBreaks.Add(System.Convert.ToDouble(values.GetValue(iBreak))); } saSolver.DefaultBreaks = defaultBreaks; saSolver.TravelDirection = (esriNATravelDirection)cboSATravelDirection.SelectedIndex; saSolver.OutputPolygons = (esriNAOutputPolygonType)cboSAOutputPolygons.SelectedIndex; saSolver.OverlapPolygons = chkSAOverlapPolygons.Checked; saSolver.SplitPolygonsAtBreaks = chkSASplitPolygonsAtBreaks.Checked; saSolver.MergeSimilarPolygonRanges = chkSAMergeSimilarPolygonRanges.Checked; saSolver.TrimOuterPolygon = chkSATrimOuterPolygon.Checked; saSolver.TrimPolygonDistance = Convert.ToDouble(this.txtSATrimPolygonDistance.Text); saSolver.TrimPolygonDistanceUnits = (esriUnits)cboSATrimPolygonDistanceUnits.SelectedIndex; if (cboSAOutputLines.SelectedIndex == 0) { saSolver.OutputLines = (esriNAOutputLineType)cboSAOutputLines.SelectedIndex; } else // Does not support Straight lines, so not in combobox, up by one to account for this { saSolver.OutputLines = (esriNAOutputLineType)(cboSAOutputLines.SelectedIndex + 1); } saSolver.OverlapLines = chkSAOverlapLines.Checked; saSolver.SplitLinesAtBreaks = chkSASplitLinesAtBreaks.Checked; saSolver.IncludeSourceInformationOnLines = this.chkSAIncludeSourceInformationOnLines.Checked; // INASolverSettings naSolverSettings.ImpedanceAttributeName = cboSAImpedance.Text; naSolverSettings.IgnoreInvalidLocations = chkSAIgnoreInvalidLocations.Checked; naSolverSettings.RestrictUTurns = (esriNetworkForwardStarBacktrack)cboSARestrictUTurns.SelectedIndex; naSolverSettings.AccumulateAttributeNames = GetCheckedAttributeNamesFromControl(chklstSAAccumulateAttributeNames); naSolverSettings.RestrictionAttributeNames = GetCheckedAttributeNamesFromControl(chklstSARestrictionAttributeNames); } else if (vrpSolver != null) { naSolverSettings.ImpedanceAttributeName = cboVRPTimeAttribute.Text; naSolverSettings.AccumulateAttributeNames.RemoveAll(); IStringArray strArray = naSolverSettings.AccumulateAttributeNames; strArray.RemoveAll(); strArray.Add(cboVRPDistanceAttribute.Text); naSolverSettings.AccumulateAttributeNames = strArray; vrpSolver.CapacityCount = Convert.ToInt32(txtVRPCapacityCount.Text); vrpSolver.DefaultDate = Convert.ToDateTime(txtVRPDefaultDate.Text); vrpSolver.TimeFieldUnits = ((esriNetworkAttributeUnits)cboVRPTimeFieldUnits.SelectedIndex) + 20; // there cannot be unknown units for a VRP, so the index is offset by 1 vrpSolver.DistanceFieldUnits = (esriNetworkAttributeUnits)cboVRPDistanceFieldUnits.SelectedIndex + 1; naSolverSettings.RestrictUTurns = (esriNetworkForwardStarBacktrack)cboVRPAllowUTurns.SelectedIndex; vrpSolver.OutputLines = (esriNAOutputLineType)cboVRPOutputShapeType.SelectedIndex; vrpSolver.TimeWindowViolationPenaltyFactor = cboVRPTimeWindow.SelectedIndex; vrpSolver.ExcessTransitTimePenaltyFactor = cboVRPTransitTime.SelectedIndex; naSolverSettings.UseHierarchy = chkVRPUseHierarchy.Checked; naSolverSettings.RestrictionAttributeNames = GetCheckedAttributeNamesFromControl(chklstVRPRestrictionAttributeNames); } else if (laSolver != null) // Location-Allocation LAYER { if (txtLACutOff.Text.Length == 0) { laSolver.DefaultCutoff = null; } else if (Convert.ToDouble(txtLACutOff.Text) == 0.0) { laSolver.DefaultCutoff = null; } else { laSolver.DefaultCutoff = Convert.ToDouble(txtLACutOff.Text); } if (txtLAFacilitiesToLocate.Text.Length == 0) { laSolver.NumberFacilitiesToLocate = 1; } else { laSolver.NumberFacilitiesToLocate = Convert.ToInt32(txtLAFacilitiesToLocate.Text); } laSolver.ProblemType = (esriNALocationAllocationProblemType)cboLAProblemType.SelectedIndex; laSolver.ImpedanceTransformation = (esriNAImpedanceTransformationType)cboLAImpTransformation.SelectedIndex; laSolver.TransformationParameter = Convert.ToDouble(txtLAImpParameter.Text); laSolver.TargetMarketSharePercentage = Convert.ToDouble(txtLATargetMarketShare.Text); laSolver.TravelDirection = (esriNATravelDirection)cboLATravelDirection.SelectedIndex; laSolver.OutputLines = (esriNAOutputLineType)cboLAOutputLines.SelectedIndex; //// INASolverSettings naSolverSettings.ImpedanceAttributeName = cboLAImpedance.Text; naSolverSettings.UseHierarchy = chkLAUseHierarchy.Checked; naSolverSettings.AccumulateAttributeNames = GetCheckedAttributeNamesFromControl(chklstLAAccumulateAttributeNames); naSolverSettings.RestrictionAttributeNames = GetCheckedAttributeNamesFromControl(chklstLARestrictionAttributeNames); naSolverSettings.IgnoreInvalidLocations = chkLAIgnoreInvalidLocations.Checked; } }