Esempio n. 1
0
        /// <summary>
        /// Check whether the attribute unit is time or distance unit.
        /// </summary>
        /// <param name="units">Input network attribute units</param>
        /// <returns>Unit type</returns>
        private string GetAttributeUnitType(esriNetworkAttributeUnits units)
        {
            string unitType = "";

            switch (units)
            {
            case esriNetworkAttributeUnits.esriNAUDays:
            case esriNetworkAttributeUnits.esriNAUHours:
            case esriNetworkAttributeUnits.esriNAUMinutes:
            case esriNetworkAttributeUnits.esriNAUSeconds:
                unitType = "Time";
                break;

            case esriNetworkAttributeUnits.esriNAUYards:
            case esriNetworkAttributeUnits.esriNAUMillimeters:
            case esriNetworkAttributeUnits.esriNAUMiles:
            case esriNetworkAttributeUnits.esriNAUMeters:
            case esriNetworkAttributeUnits.esriNAUKilometers:
            case esriNetworkAttributeUnits.esriNAUInches:
            case esriNetworkAttributeUnits.esriNAUFeet:
            case esriNetworkAttributeUnits.esriNAUDecimeters:
            case esriNetworkAttributeUnits.esriNAUNauticalMiles:
            case esriNetworkAttributeUnits.esriNAUCentimeters:
                unitType = "Distance";
                break;

            default:
                listOutput.Items.Add("Failed to find Network Attribute Units.");
                break;
            }

            return(unitType);
        }
Esempio n. 2
0
 public NetworkDirections(NetworkDirections prototype) : base(prototype)
 {
     this._defaultOutputLengthUnits = prototype.DefaultOutputLengthUnits;
     this._lengthAttributeName      = prototype.LengthAttributeName;
     this._timeAttributeName        = prototype.TimeAttributeName;
     this._roadClassAttributeName   = prototype.RoadClassAttributeName;
     this._signpostFeatureClassName = prototype.SignpostFeatureClassName;
     this._signpostStreetsTableName = prototype.SignpostStreetsTableName;
 }
Esempio n. 3
0
 public NetworkDirections(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     this._defaultOutputLengthUnits = (esriNetworkAttributeUnits)Enum.Parse(typeof(esriNetworkAttributeUnits), info.GetString("defaultOutputLengthUnits"), true);
     this._lengthAttributeName      = info.GetString("lengthAttributeName");
     this._timeAttributeName        = info.GetString("timeAttributeName");
     this._roadClassAttributeName   = info.GetString("roadClassAttributeName");
     this._signpostFeatureClassName = info.GetString("signpostFeatureClassName");
     this._signpostStreetsTableName = info.GetString("signpostStreetsTableName");
 }
 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>));
 }
        //private static string ExportGeometricNetworkXml(IGeometricNetworkName geometricNetworkName) {
        //    // Get Workspace
        //    IName name = (IName)geometricNetworkName;
        //    //IGeometricNetwork geometricNetwork = (IGeometricNetwork)name.Open();

        //    // Create Temporary File
        //    string path = System.IO.Path.GetTempPath();
        //    string file = string.Format("{0}.{1}", Guid.NewGuid().ToString("N").ToUpper(), "xml");
        //    string outfile = System.IO.Path.Combine(path, file);

        //    //
        //    IEnumName enumName = new NamesEnumeratorClass();
        //    IEnumNameEdit enumNameEdit = (IEnumNameEdit)enumName;
        //    enumNameEdit.Add(name);

        //    IScratchWorkspaceFactory scratchWorkspaceFactory = new ScratchWorkspaceFactoryClass();
        //    IWorkspace workspaceScratch = scratchWorkspaceFactory.CreateNewScratchWorkspace();
        //    IDataset datasetScratch = (IDataset)workspaceScratch;
        //    IName nameScratch = datasetScratch.FullName;

        //    IEnumNameMapping enumNameMapping = null;

        //    IGeoDBDataTransfer geoDBDataTransfer = new GeoDBDataTransferClass();
        //    bool boolHaveConflicts = geoDBDataTransfer.GenerateNameMapping(enumName, nameScratch, out enumNameMapping);
        //    if (boolHaveConflicts) {
        //        MessageBox.Show(
        //                "Problems encountered generating 'name mapping' for geomeric network.",
        //                Resources.TEXT_APPLICATION,
        //                MessageBoxButtons.OK,
        //                MessageBoxIcon.Error,
        //                MessageBoxDefaultButton.Button1,
        //                MessageBoxOptions.DefaultDesktopOnly);
        //        return null;
        //    }

        //    //
        //    IGdbXmlExport gdbXmlExport = new GdbExporterClass();
        //    try {
        //        gdbXmlExport.ExportDatasetsSchema(enumNameMapping, outfile, false, true);
        //    }
        //    catch (COMException ex) {
        //        // Handle Exception
        //        ExceptionDialog.HandleException(ex);
        //    }

        //    // Clear Geodatabase Exporter
        //    gdbXmlExport = null;

        //    // Return pathname to Xml File
        //    return outfile;
        //}
        public static string GetDescription(esriNetworkAttributeUnits units)
        {
            switch (units)
            {
            case esriNetworkAttributeUnits.esriNAUCentimeters:
                return("Centimeters");

            case esriNetworkAttributeUnits.esriNAUDays:
                return("Days");

            case esriNetworkAttributeUnits.esriNAUDecimalDegrees:
                return("DecimalDegrees");

            case esriNetworkAttributeUnits.esriNAUDecimeters:
                return("Decimeters");

            case esriNetworkAttributeUnits.esriNAUFeet:
                return("Feet");

            case esriNetworkAttributeUnits.esriNAUHours:
                return("Hours");

            case esriNetworkAttributeUnits.esriNAUInches:
                return("Inches");

            case esriNetworkAttributeUnits.esriNAUKilometers:
                return("Kilometers");

            case esriNetworkAttributeUnits.esriNAUMeters:
                return("Meters");

            case esriNetworkAttributeUnits.esriNAUMiles:
                return("Miles");

            case esriNetworkAttributeUnits.esriNAUMillimeters:
                return("Millimeters");

            case esriNetworkAttributeUnits.esriNAUMinutes:
                return("Minutes");

            case esriNetworkAttributeUnits.esriNAUNauticalMiles:
                return("NauticalMiles");

            case esriNetworkAttributeUnits.esriNAUSeconds:
                return("Seconds");

            case esriNetworkAttributeUnits.esriNAUYards:
                return("Yards");

            case esriNetworkAttributeUnits.esriNAUUnknown:
            default:
                return("Unknown");
            }
        }
Esempio n. 6
0
        public NetworkDirections(IXPathNavigable path) : base(path)
        {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // DefaultOutputLengthUnits
            XPathNavigator navigatorDefaultOutputLengthUnits = navigator.SelectSingleNode("DefaultOutputLengthUnits");

            if (navigatorDefaultOutputLengthUnits != null)
            {
                this._defaultOutputLengthUnits = (esriNetworkAttributeUnits)Enum.Parse(typeof(esriNetworkAttributeUnits), navigatorDefaultOutputLengthUnits.Value, true);
            }

            // LengthAttributeName
            XPathNavigator navigatorLengthAttributeName = navigator.SelectSingleNode("LengthAttributeName");

            if (navigatorLengthAttributeName != null)
            {
                this._lengthAttributeName = navigatorLengthAttributeName.Value;
            }

            // TimeAttributeName
            XPathNavigator navigatorTimeAttributeName = navigator.SelectSingleNode("TimeAttributeName");

            if (navigatorTimeAttributeName != null)
            {
                this._timeAttributeName = navigatorTimeAttributeName.Value;
            }

            // RoadClassAttributeName
            XPathNavigator navigatorRoadClassAttributeName = navigator.SelectSingleNode("RoadClassAttributeName");

            if (navigatorRoadClassAttributeName != null)
            {
                this._roadClassAttributeName = navigatorRoadClassAttributeName.Value;
            }

            // SignpostFeatureClassName
            XPathNavigator navigatorSignpostFeatureClassName = navigator.SelectSingleNode("SignpostFeatureClassName");

            if (navigatorSignpostFeatureClassName != null)
            {
                this._signpostFeatureClassName = navigatorSignpostFeatureClassName.Value;
            }

            // SignpostStreetsTableName
            XPathNavigator navigatorSignpostStreetsTableName = navigator.SelectSingleNode("SignpostStreetsTableName");

            if (navigatorSignpostStreetsTableName != null)
            {
                this._signpostStreetsTableName = navigatorSignpostStreetsTableName.Value;
            }
        }
 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 NetworkDirections(IXPathNavigable path) : base(path) {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // DefaultOutputLengthUnits
            XPathNavigator navigatorDefaultOutputLengthUnits = navigator.SelectSingleNode("DefaultOutputLengthUnits");
            if (navigatorDefaultOutputLengthUnits != null) {
                this._defaultOutputLengthUnits = (esriNetworkAttributeUnits)Enum.Parse(typeof(esriNetworkAttributeUnits), navigatorDefaultOutputLengthUnits.Value, true);
            }

            // LengthAttributeName
            XPathNavigator navigatorLengthAttributeName = navigator.SelectSingleNode("LengthAttributeName");
            if (navigatorLengthAttributeName != null) {
                this._lengthAttributeName = navigatorLengthAttributeName.Value;
            }

            // TimeAttributeName
            XPathNavigator navigatorTimeAttributeName = navigator.SelectSingleNode("TimeAttributeName");
            if (navigatorTimeAttributeName != null) {
                this._timeAttributeName = navigatorTimeAttributeName.Value;
            }

            // RoadClassAttributeName
            XPathNavigator navigatorRoadClassAttributeName = navigator.SelectSingleNode("RoadClassAttributeName");
            if (navigatorRoadClassAttributeName != null) {
                this._roadClassAttributeName = navigatorRoadClassAttributeName.Value;
            }

            // SignpostFeatureClassName
            XPathNavigator navigatorSignpostFeatureClassName = navigator.SelectSingleNode("SignpostFeatureClassName");
            if (navigatorSignpostFeatureClassName != null) {
                this._signpostFeatureClassName = navigatorSignpostFeatureClassName.Value;
            }

            // SignpostStreetsTableName
            XPathNavigator navigatorSignpostStreetsTableName = navigator.SelectSingleNode("SignpostStreetsTableName");
            if (navigatorSignpostStreetsTableName != null) {
                this._signpostStreetsTableName = navigatorSignpostStreetsTableName.Value;
            }
        }
 public NetworkDirections(NetworkDirections prototype) : base(prototype) {
     this._defaultOutputLengthUnits = prototype.DefaultOutputLengthUnits;
     this._lengthAttributeName = prototype.LengthAttributeName;
     this._timeAttributeName = prototype.TimeAttributeName;
     this._roadClassAttributeName = prototype.RoadClassAttributeName;
     this._signpostFeatureClassName = prototype.SignpostFeatureClassName;
     this._signpostStreetsTableName = prototype.SignpostStreetsTableName;
 }
        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>
		/// Check whether the attribute unit is time or distance unit. 
		/// </summary>
		/// <param name="units">Input network attribute units</param>
		/// <returns>Unit type</returns>
		private string GetAttributeUnitType(esriNetworkAttributeUnits units)
		{
			string unitType = "";

			switch (units)
			{
				case esriNetworkAttributeUnits.esriNAUDays:
				case esriNetworkAttributeUnits.esriNAUHours:
				case esriNetworkAttributeUnits.esriNAUMinutes:
				case esriNetworkAttributeUnits.esriNAUSeconds:
					unitType = "Time";
					break;

				case esriNetworkAttributeUnits.esriNAUYards:
				case esriNetworkAttributeUnits.esriNAUMillimeters:
				case esriNetworkAttributeUnits.esriNAUMiles:
				case esriNetworkAttributeUnits.esriNAUMeters:
				case esriNetworkAttributeUnits.esriNAUKilometers:
				case esriNetworkAttributeUnits.esriNAUInches:
				case esriNetworkAttributeUnits.esriNAUFeet:
				case esriNetworkAttributeUnits.esriNAUDecimeters:
				case esriNetworkAttributeUnits.esriNAUNauticalMiles:
				case esriNetworkAttributeUnits.esriNAUCentimeters:
					unitType = "Distance";
					break;

				default:
					listOutput.Items.Add("Failed to find Network Attribute Units.");
					break;
			}

			return unitType;
		}
        private IEvaluatedNetworkAttribute CreateLengthNetworkAttribute(string attrName, esriNetworkAttributeUnits attrUnits,
                                                                        string fieldEvalExpression, INetworkSource edgeNetworkSource)
        {
            // Create an EvaluatedNetworkAttribute object and populate its settings.
            IEvaluatedNetworkAttribute evalNetAttr = new EvaluatedNetworkAttributeClass();
            INetworkAttribute2 netAttr2 = (INetworkAttribute2)evalNetAttr;
            netAttr2.Name = attrName;
            netAttr2.UsageType = esriNetworkAttributeUsageType.esriNAUTCost;
            netAttr2.DataType = esriNetworkAttributeDataType.esriNADTDouble;
            netAttr2.Units = attrUnits;
            netAttr2.UseByDefault = false;

            // Create evaluator objects and set them on the EvaluatedNetworkAttribute object.
            INetworkFieldEvaluator netFieldEval = new NetworkFieldEvaluatorClass();
            netFieldEval.SetExpression(fieldEvalExpression, "");
            evalNetAttr.set_Evaluator(edgeNetworkSource, esriNetworkEdgeDirection.esriNEDAlongDigitized, (INetworkEvaluator)netFieldEval);

            netFieldEval = new NetworkFieldEvaluatorClass();
            netFieldEval.SetExpression(fieldEvalExpression, "");
            evalNetAttr.set_Evaluator(edgeNetworkSource, esriNetworkEdgeDirection.esriNEDAgainstDigitized, (INetworkEvaluator)netFieldEval);

            INetworkConstantEvaluator netConstEval = new NetworkConstantEvaluatorClass();
            netConstEval.ConstantValue = false;
            evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETEdge, (INetworkEvaluator)netConstEval);

            netConstEval = new NetworkConstantEvaluatorClass();
            netConstEval.ConstantValue = false;
            evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETJunction, (INetworkEvaluator)netConstEval);

            netConstEval = new NetworkConstantEvaluatorClass();
            netConstEval.ConstantValue = false;
            evalNetAttr.set_DefaultEvaluator(esriNetworkElementType.esriNETTurn, (INetworkEvaluator)netConstEval);

            return evalNetAttr;
        }
        //
        // 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 NetworkDirections(SerializationInfo info, StreamingContext context) : base(info, context) {
     this._defaultOutputLengthUnits = (esriNetworkAttributeUnits)Enum.Parse(typeof(esriNetworkAttributeUnits), info.GetString("defaultOutputLengthUnits"), true);
     this._lengthAttributeName = info.GetString("lengthAttributeName");
     this._timeAttributeName = info.GetString("timeAttributeName");
     this._roadClassAttributeName = info.GetString("roadClassAttributeName");
     this._signpostFeatureClassName = info.GetString("signpostFeatureClassName");
     this._signpostStreetsTableName = info.GetString("signpostStreetsTableName");
 }
        /// <summary>
        /// Method converts ESRI network attribute units into application network attributes units.
        /// </summary>
        /// <param name="naUnits">ESRI Network attribute units to convert.</param>
        /// <returns>Converted network attribute units.</returns>
        private static NetworkAttributeUnits _ConvertUnits(esriNetworkAttributeUnits naUnits)
        {
            NetworkAttributeUnits unit;

            switch (naUnits)
            {
                case esriNetworkAttributeUnits.esriNAUCentimeters:
                    unit = NetworkAttributeUnits.Centimeters;
                    break;
                case esriNetworkAttributeUnits.esriNAUDays:
                    unit = NetworkAttributeUnits.Days;
                    break;
                case esriNetworkAttributeUnits.esriNAUDecimalDegrees:
                    unit = NetworkAttributeUnits.DecimalDegrees;
                    break;
                case esriNetworkAttributeUnits.esriNAUDecimeters:
                    unit = NetworkAttributeUnits.Decimeters;
                    break;
                case esriNetworkAttributeUnits.esriNAUFeet:
                    unit = NetworkAttributeUnits.Feet;
                    break;
                case esriNetworkAttributeUnits.esriNAUHours:
                    unit = NetworkAttributeUnits.Hours;
                    break;
                case esriNetworkAttributeUnits.esriNAUInches:
                    unit = NetworkAttributeUnits.Inches;
                    break;
                case esriNetworkAttributeUnits.esriNAUKilometers:
                    unit = NetworkAttributeUnits.Kilometers;
                    break;
                case esriNetworkAttributeUnits.esriNAUMeters:
                    unit = NetworkAttributeUnits.Meters;
                    break;
                case esriNetworkAttributeUnits.esriNAUMiles:
                    unit = NetworkAttributeUnits.Miles;
                    break;
                case esriNetworkAttributeUnits.esriNAUMillimeters:
                    unit = NetworkAttributeUnits.Millimeters;
                    break;
                case esriNetworkAttributeUnits.esriNAUMinutes:
                    unit = NetworkAttributeUnits.Minutes;
                    break;
                case esriNetworkAttributeUnits.esriNAUNauticalMiles:
                    unit = NetworkAttributeUnits.NauticalMiles;
                    break;
                case esriNetworkAttributeUnits.esriNAUPoints:
                    unit = NetworkAttributeUnits.Points;
                    break;
                case esriNetworkAttributeUnits.esriNAUSeconds:
                    unit = NetworkAttributeUnits.Seconds;
                    break;
                case esriNetworkAttributeUnits.esriNAUUnknown:
                    unit = NetworkAttributeUnits.Unknown;
                    break;
                case esriNetworkAttributeUnits.esriNAUYards:
                    unit = NetworkAttributeUnits.Yards;
                    break;
                default:
                    throw new RouteException(Properties.Messages.Error_UnsupportedAttrUnits);
            }

            return unit;
        }
        //private static string ExportGeometricNetworkXml(IGeometricNetworkName geometricNetworkName) {
        //    // Get Workspace
        //    IName name = (IName)geometricNetworkName;
        //    //IGeometricNetwork geometricNetwork = (IGeometricNetwork)name.Open();

        //    // Create Temporary File
        //    string path = System.IO.Path.GetTempPath();
        //    string file = string.Format("{0}.{1}", Guid.NewGuid().ToString("N").ToUpper(), "xml");
        //    string outfile = System.IO.Path.Combine(path, file);

        //    //
        //    IEnumName enumName = new NamesEnumeratorClass();
        //    IEnumNameEdit enumNameEdit = (IEnumNameEdit)enumName;
        //    enumNameEdit.Add(name);

        //    IScratchWorkspaceFactory scratchWorkspaceFactory = new ScratchWorkspaceFactoryClass();
        //    IWorkspace workspaceScratch = scratchWorkspaceFactory.CreateNewScratchWorkspace();
        //    IDataset datasetScratch = (IDataset)workspaceScratch;
        //    IName nameScratch = datasetScratch.FullName;

        //    IEnumNameMapping enumNameMapping = null;

        //    IGeoDBDataTransfer geoDBDataTransfer = new GeoDBDataTransferClass();
        //    bool boolHaveConflicts = geoDBDataTransfer.GenerateNameMapping(enumName, nameScratch, out enumNameMapping);
        //    if (boolHaveConflicts) {
        //        MessageBox.Show(
        //                "Problems encountered generating 'name mapping' for geomeric network.",
        //                Resources.TEXT_APPLICATION,
        //                MessageBoxButtons.OK,
        //                MessageBoxIcon.Error,
        //                MessageBoxDefaultButton.Button1,
        //                MessageBoxOptions.DefaultDesktopOnly);
        //        return null;
        //    }

        //    //
        //    IGdbXmlExport gdbXmlExport = new GdbExporterClass();
        //    try {
        //        gdbXmlExport.ExportDatasetsSchema(enumNameMapping, outfile, false, true);
        //    }
        //    catch (COMException ex) {
        //        // Handle Exception
        //        ExceptionDialog.HandleException(ex);
        //    }

        //    // Clear Geodatabase Exporter
        //    gdbXmlExport = null;

        //    // Return pathname to Xml File
        //    return outfile;
        //}
        public static string GetDescription(esriNetworkAttributeUnits units) {
            switch (units) {
                case esriNetworkAttributeUnits.esriNAUCentimeters:
                    return "Centimeters";
                case esriNetworkAttributeUnits.esriNAUDays:
                    return "Days";
                case esriNetworkAttributeUnits.esriNAUDecimalDegrees:
                    return "DecimalDegrees";
                case esriNetworkAttributeUnits.esriNAUDecimeters:
                    return "Decimeters";
                case esriNetworkAttributeUnits.esriNAUFeet:
                    return "Feet";
                case esriNetworkAttributeUnits.esriNAUHours:
                    return "Hours";
                case esriNetworkAttributeUnits.esriNAUInches:
                    return "Inches";
                case esriNetworkAttributeUnits.esriNAUKilometers:
                    return "Kilometers";
                case esriNetworkAttributeUnits.esriNAUMeters:
                    return "Meters";
                case esriNetworkAttributeUnits.esriNAUMiles:
                    return "Miles";
                case esriNetworkAttributeUnits.esriNAUMillimeters:
                    return "Millimeters";
                case esriNetworkAttributeUnits.esriNAUMinutes:
                    return "Minutes";
                case esriNetworkAttributeUnits.esriNAUNauticalMiles:
                    return "NauticalMiles";
                case esriNetworkAttributeUnits.esriNAUSeconds:
                    return "Seconds";
                case esriNetworkAttributeUnits.esriNAUYards:
                    return "Yards";
                case esriNetworkAttributeUnits.esriNAUUnknown:
                default:
                    return "Unknown";
            }
        }
        /// <summary>
        /// Method converts ESRI network attribute units into application network attributes units.
        /// </summary>
        /// <param name="naUnits">ESRI Network attribute units to convert.</param>
        /// <returns>Converted network attribute units.</returns>
        private static NetworkAttributeUnits _ConvertUnits(esriNetworkAttributeUnits naUnits)
        {
            NetworkAttributeUnits unit;

            switch (naUnits)
            {
            case esriNetworkAttributeUnits.esriNAUCentimeters:
                unit = NetworkAttributeUnits.Centimeters;
                break;

            case esriNetworkAttributeUnits.esriNAUDays:
                unit = NetworkAttributeUnits.Days;
                break;

            case esriNetworkAttributeUnits.esriNAUDecimalDegrees:
                unit = NetworkAttributeUnits.DecimalDegrees;
                break;

            case esriNetworkAttributeUnits.esriNAUDecimeters:
                unit = NetworkAttributeUnits.Decimeters;
                break;

            case esriNetworkAttributeUnits.esriNAUFeet:
                unit = NetworkAttributeUnits.Feet;
                break;

            case esriNetworkAttributeUnits.esriNAUHours:
                unit = NetworkAttributeUnits.Hours;
                break;

            case esriNetworkAttributeUnits.esriNAUInches:
                unit = NetworkAttributeUnits.Inches;
                break;

            case esriNetworkAttributeUnits.esriNAUKilometers:
                unit = NetworkAttributeUnits.Kilometers;
                break;

            case esriNetworkAttributeUnits.esriNAUMeters:
                unit = NetworkAttributeUnits.Meters;
                break;

            case esriNetworkAttributeUnits.esriNAUMiles:
                unit = NetworkAttributeUnits.Miles;
                break;

            case esriNetworkAttributeUnits.esriNAUMillimeters:
                unit = NetworkAttributeUnits.Millimeters;
                break;

            case esriNetworkAttributeUnits.esriNAUMinutes:
                unit = NetworkAttributeUnits.Minutes;
                break;

            case esriNetworkAttributeUnits.esriNAUNauticalMiles:
                unit = NetworkAttributeUnits.NauticalMiles;
                break;

            case esriNetworkAttributeUnits.esriNAUPoints:
                unit = NetworkAttributeUnits.Points;
                break;

            case esriNetworkAttributeUnits.esriNAUSeconds:
                unit = NetworkAttributeUnits.Seconds;
                break;

            case esriNetworkAttributeUnits.esriNAUUnknown:
                unit = NetworkAttributeUnits.Unknown;
                break;

            case esriNetworkAttributeUnits.esriNAUYards:
                unit = NetworkAttributeUnits.Yards;
                break;

            default:
                throw new RouteException(Properties.Messages.Error_UnsupportedAttrUnits);
            }

            return(unit);
        }