/// <summary> /// Method converts ESRI network attribute usage type into application /// network attributes usage type. /// </summary> /// <param name="naType">ESRI network attribute usage type.</param> /// <returns>Converted network attribute usage type.</returns> private static NetworkAttributeUsageType _ConvertUsageType( esriNetworkAttributeUsageType naType) { NetworkAttributeUsageType type; switch (naType) { case esriNetworkAttributeUsageType.esriNAUTCost: type = NetworkAttributeUsageType.Cost; break; case esriNetworkAttributeUsageType.esriNAUTDescriptor: type = NetworkAttributeUsageType.Descriptor; break; case esriNetworkAttributeUsageType.esriNAUTHierarchy: type = NetworkAttributeUsageType.Hierarchy; break; case esriNetworkAttributeUsageType.esriNAUTRestriction: type = NetworkAttributeUsageType.Restriction; break; default: throw new RouteException(Properties.Messages.Error_UnsupportedAttrUsageType); } return(type); }
public NetworkAttribute(SerializationInfo info, StreamingContext context) : base(info, context) { this._id = info.GetInt32("id"); this._name = info.GetString("name"); this._units = (esriNetworkAttributeUnits)Enum.Parse(typeof(esriNetworkAttributeUnits), info.GetString("units"), true); this._dataType = (esriNetworkAttributeDataType)Enum.Parse(typeof(esriNetworkAttributeDataType), info.GetString("dataType"), true); this._usageType = (esriNetworkAttributeUsageType)Enum.Parse(typeof(esriNetworkAttributeUsageType), info.GetString("usageType"), true); this._userData = (List <Property>)info.GetValue("userData", typeof(List <Property>)); this._useByDefault = info.GetBoolean("useByDefault"); this._attributeParameters = (List <NetworkAttributeParameter>)info.GetValue("attributeParameters", typeof(List <NetworkAttributeParameter>)); }
public NetworkAttribute(NetworkAttribute prototype) : base(prototype) { this._id = prototype.Id; this._name = prototype.Name; this._units = prototype.Units; this._dataType = prototype.DataType; this._usageType = prototype.UsageType; this._userData = new List <Property>(); foreach (Property property in prototype.UserDataCollection) { Property propertyClone = (Property)property.Clone(); this._userData.Add(propertyClone); } this._useByDefault = prototype.UseByDefault; this._attributeParameters = new List <NetworkAttributeParameter>(); foreach (NetworkAttributeParameter networkAttributeParameter in prototype.AttributeParameterCollection) { NetworkAttributeParameter networkAttributeParameterClone = (NetworkAttributeParameter)networkAttributeParameter.Clone(); this._attributeParameters.Add(networkAttributeParameterClone); } }
public static List <int> FindAttributeIndexes(IArray netAttributes, esriNetworkAttributeUsageType usage, esriNetworkAttributeDataType dataType, bool searchTimeUnits, bool ignoreDataType) { INetworkAttribute2 netAttribute = null; esriNetworkAttributeUnits units = esriNetworkAttributeUnits.esriNAUUnknown; bool isSearchUnits = false; bool isUnknownUnits = false; bool isTimeUnits = false; List <int> netAttributeIndexes = new List <int>(); int count = netAttributes.Count; for (int i = 0; i < count; ++i) { netAttribute = netAttributes.get_Element(i) as INetworkAttribute2; if (netAttribute == null) { continue; } if (netAttribute.UsageType == usage && (ignoreDataType || netAttribute.DataType == dataType)) { units = netAttribute.Units; isSearchUnits = false; if (usage != esriNetworkAttributeUsageType.esriNAUTCost) { isSearchUnits = true; } else { isUnknownUnits = false; if (units == esriNetworkAttributeUnits.esriNAUUnknown) { isUnknownUnits = true; } isTimeUnits = false; if (!isUnknownUnits) { if (units == esriNetworkAttributeUnits.esriNAUMinutes || units == esriNetworkAttributeUnits.esriNAUSeconds || units == esriNetworkAttributeUnits.esriNAUHours || units == esriNetworkAttributeUnits.esriNAUDays) { isTimeUnits = true; } if (searchTimeUnits) { isSearchUnits = isTimeUnits; } else { isSearchUnits = !isTimeUnits; } } } if (isSearchUnits) { netAttributeIndexes.Add(i); } } } return(netAttributeIndexes); }
// // CONSTRUCTOR // public NetworkAttribute(IXPathNavigable path) : base(path) { // Get Navigator XPathNavigator navigator = path.CreateNavigator(); // <ID> XPathNavigator navigatorID = navigator.SelectSingleNode("ID"); if (navigatorID != null) { this._id = navigatorID.ValueAsInt; } // <Name> XPathNavigator navigatorName = navigator.SelectSingleNode("Name"); if (navigatorName != null) { this._name = navigatorName.Value; } // <Units> XPathNavigator navigatorUnits = navigator.SelectSingleNode("Units"); if (navigatorUnits != null) { this._units = GeodatabaseUtility.GetNetworkAttributeUnits(navigatorUnits.Value); } // <DataType> XPathNavigator navigatorDataType = navigator.SelectSingleNode("DataType"); if (navigatorDataType != null) { this._dataType = (esriNetworkAttributeDataType)Enum.Parse(typeof(esriNetworkAttributeDataType), navigatorDataType.Value, true); } // <UsageType> XPathNavigator navigatorUsageType = navigator.SelectSingleNode("UsageType"); if (navigatorUsageType != null) { this._usageType = (esriNetworkAttributeUsageType)Enum.Parse(typeof(esriNetworkAttributeUsageType), navigatorUsageType.Value, true); } // <UserData><PropertyArray><PropertySetProperty> this._userData = new List <Property>(); XPathNodeIterator interatorProperty = navigator.Select("UserData/PropertyArray/PropertySetProperty"); while (interatorProperty.MoveNext()) { // Get <PropertySetProperty> XPathNavigator navigatorProperty = interatorProperty.Current; // Add PropertySetProperty Property property = new Property(navigatorProperty); this._userData.Add(property); } // <UseByDefault> XPathNavigator navigatorUseByDefault = navigator.SelectSingleNode("UseByDefault"); if (navigatorUseByDefault != null) { this._useByDefault = navigatorUseByDefault.ValueAsBoolean; } // <AttributedParameters><AttributedParameter> this._attributeParameters = new List <NetworkAttributeParameter>(); XPathNodeIterator interatorAttributedParameter = navigator.Select("AttributedParameters/AttributedParameter"); while (interatorAttributedParameter.MoveNext()) { // Get <AttributedParameter> XPathNavigator navigatorAttributedParameter = interatorAttributedParameter.Current; // Add AttributedParameter NetworkAttributeParameter networkAttributeParameter = new NetworkAttributeParameter(navigatorAttributedParameter); this._attributeParameters.Add(networkAttributeParameter); } }
/// <summary> /// Method converts ESRI network attribute usage type into application /// network attributes usage type. /// </summary> /// <param name="naType">ESRI network attribute usage type.</param> /// <returns>Converted network attribute usage type.</returns> private static NetworkAttributeUsageType _ConvertUsageType( esriNetworkAttributeUsageType naType) { NetworkAttributeUsageType type; switch (naType) { case esriNetworkAttributeUsageType.esriNAUTCost: type = NetworkAttributeUsageType.Cost; break; case esriNetworkAttributeUsageType.esriNAUTDescriptor: type = NetworkAttributeUsageType.Descriptor; break; case esriNetworkAttributeUsageType.esriNAUTHierarchy: type = NetworkAttributeUsageType.Hierarchy; break; case esriNetworkAttributeUsageType.esriNAUTRestriction: type = NetworkAttributeUsageType.Restriction; break; default: throw new RouteException(Properties.Messages.Error_UnsupportedAttrUsageType); } return type; }
// // CONSTRUCTOR // public NetworkAttribute(IXPathNavigable path) : base(path) { // Get Navigator XPathNavigator navigator = path.CreateNavigator(); // <ID> XPathNavigator navigatorID = navigator.SelectSingleNode("ID"); if (navigatorID != null) { this._id = navigatorID.ValueAsInt; } // <Name> XPathNavigator navigatorName = navigator.SelectSingleNode("Name"); if (navigatorName != null) { this._name = navigatorName.Value; } // <Units> XPathNavigator navigatorUnits = navigator.SelectSingleNode("Units"); if (navigatorUnits != null) { this._units = GeodatabaseUtility.GetNetworkAttributeUnits(navigatorUnits.Value); } // <DataType> XPathNavigator navigatorDataType = navigator.SelectSingleNode("DataType"); if (navigatorDataType != null) { this._dataType = (esriNetworkAttributeDataType)Enum.Parse(typeof(esriNetworkAttributeDataType), navigatorDataType.Value, true); } // <UsageType> XPathNavigator navigatorUsageType = navigator.SelectSingleNode("UsageType"); if (navigatorUsageType != null) { this._usageType = (esriNetworkAttributeUsageType)Enum.Parse(typeof(esriNetworkAttributeUsageType), navigatorUsageType.Value, true); } // <UserData><PropertyArray><PropertySetProperty> this._userData = new List<Property>(); XPathNodeIterator interatorProperty = navigator.Select("UserData/PropertyArray/PropertySetProperty"); while (interatorProperty.MoveNext()) { // Get <PropertySetProperty> XPathNavigator navigatorProperty = interatorProperty.Current; // Add PropertySetProperty Property property = new Property(navigatorProperty); this._userData.Add(property); } // <UseByDefault> XPathNavigator navigatorUseByDefault = navigator.SelectSingleNode("UseByDefault"); if (navigatorUseByDefault != null) { this._useByDefault = navigatorUseByDefault.ValueAsBoolean; } // <AttributedParameters><AttributedParameter> this._attributeParameters = new List<NetworkAttributeParameter>(); XPathNodeIterator interatorAttributedParameter = navigator.Select("AttributedParameters/AttributedParameter"); while (interatorAttributedParameter.MoveNext()) { // Get <AttributedParameter> XPathNavigator navigatorAttributedParameter = interatorAttributedParameter.Current; // Add AttributedParameter NetworkAttributeParameter networkAttributeParameter = new NetworkAttributeParameter(navigatorAttributedParameter); this._attributeParameters.Add(networkAttributeParameter); } }
public NetworkAttribute(NetworkAttribute prototype) : base(prototype) { this._id = prototype.Id; this._name = prototype.Name; this._units = prototype.Units; this._dataType = prototype.DataType; this._usageType = prototype.UsageType; this._userData = new List<Property>(); foreach (Property property in prototype.UserDataCollection) { Property propertyClone = (Property)property.Clone(); this._userData.Add(propertyClone); } this._useByDefault = prototype.UseByDefault; this._attributeParameters = new List<NetworkAttributeParameter>(); foreach (NetworkAttributeParameter networkAttributeParameter in prototype.AttributeParameterCollection) { NetworkAttributeParameter networkAttributeParameterClone = (NetworkAttributeParameter)networkAttributeParameter.Clone(); this._attributeParameters.Add(networkAttributeParameterClone); } }
public NetworkAttribute(SerializationInfo info, StreamingContext context) : base(info, context) { this._id = info.GetInt32("id"); this._name = info.GetString("name"); this._units = (esriNetworkAttributeUnits)Enum.Parse(typeof(esriNetworkAttributeUnits), info.GetString("units"), true); this._dataType = (esriNetworkAttributeDataType)Enum.Parse(typeof(esriNetworkAttributeDataType), info.GetString("dataType"), true); this._usageType = (esriNetworkAttributeUsageType)Enum.Parse(typeof(esriNetworkAttributeUsageType), info.GetString("usageType"), true); this._userData = (List<Property>)info.GetValue("userData", typeof(List<Property>)); this._useByDefault = info.GetBoolean("useByDefault"); this._attributeParameters = (List<NetworkAttributeParameter>)info.GetValue("attributeParameters", typeof(List<NetworkAttributeParameter>)); }
public static List<int> FindAttributeIndexes(IArray netAttributes, esriNetworkAttributeUsageType usage, esriNetworkAttributeDataType dataType, bool searchTimeUnits, bool ignoreDataType) { INetworkAttribute2 netAttribute = null; esriNetworkAttributeUnits units = esriNetworkAttributeUnits.esriNAUUnknown; bool isSearchUnits = false; bool isUnknownUnits = false; bool isTimeUnits = false; List<int> netAttributeIndexes = new List<int>(); int count = netAttributes.Count; for (int i = 0; i < count; ++i) { netAttribute = netAttributes.get_Element(i) as INetworkAttribute2; if (netAttribute == null) continue; if (netAttribute.UsageType == usage && (ignoreDataType || netAttribute.DataType == dataType)) { units = netAttribute.Units; isSearchUnits = false; if (usage != esriNetworkAttributeUsageType.esriNAUTCost) isSearchUnits = true; else { isUnknownUnits = false; if (units == esriNetworkAttributeUnits.esriNAUUnknown) isUnknownUnits = true; isTimeUnits = false; if (!isUnknownUnits) { if (units == esriNetworkAttributeUnits.esriNAUMinutes || units == esriNetworkAttributeUnits.esriNAUSeconds || units == esriNetworkAttributeUnits.esriNAUHours || units == esriNetworkAttributeUnits.esriNAUDays) { isTimeUnits = true; } if (searchTimeUnits) isSearchUnits = isTimeUnits; else isSearchUnits = !isTimeUnits; } } if (isSearchUnits) netAttributeIndexes.Add(i); } } return netAttributeIndexes; }
/// <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); } } }