public GeometricNetworkControllerMembership(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     this._geometricNetworkName      = info.GetString("geometricNetworkName");
     this._enabledFieldName          = info.GetString("enabledFieldName");
     this._ancillaryRoleFieldName    = info.GetString("ancillaryRoleFieldName");
     this._networkClassAncillaryRole = (esriNetworkClassAncillaryRole)Enum.Parse(typeof(esriNetworkClassAncillaryRole), info.GetString("networkClassAncillaryRole"), true);
 }
 public GeometricNetworkControllerMembership(GeometricNetworkControllerMembership prototype) : base(prototype)
 {
     this._geometricNetworkName      = prototype.GeometricNetworkName;
     this._enabledFieldName          = prototype.EnabledFieldName;
     this._ancillaryRoleFieldName    = prototype.AncillaryRoleFieldName;
     this._networkClassAncillaryRole = prototype.NetworkClassAncillaryRole;
 }
        public GeometricNetworkControllerMembership(IXPathNavigable path) : base(path) {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // <GeometricNetworkName>Empty_Net</GeometricNetworkName> 
            XPathNavigator navigatorGeometricNetworkName = navigator.SelectSingleNode("GeometricNetworkName");
            if (navigatorGeometricNetworkName != null) {
                this._geometricNetworkName = navigatorGeometricNetworkName.Value;
            }

            // <EnabledFieldName>Enabled</EnabledFieldName> 
            XPathNavigator navigatorEnabledFieldName = navigator.SelectSingleNode("EnabledFieldName");
            if (navigatorEnabledFieldName != null) {
                this._enabledFieldName = navigatorEnabledFieldName.Value;
            }

            // <AncillaryRoleFieldName /> 
            XPathNavigator navigatorAncillaryRoleFieldName = navigator.SelectSingleNode("AncillaryRoleFieldName");
            if (navigatorAncillaryRoleFieldName != null) {
                this._ancillaryRoleFieldName = navigatorAncillaryRoleFieldName.Value;
            }

            // <NetworkClassAncillaryRole>esriNCARNone</NetworkClassAncillaryRole> 
            XPathNavigator navigatorNetworkClassAncillaryRole = navigator.SelectSingleNode("NetworkClassAncillaryRole");
            if (navigatorNetworkClassAncillaryRole != null) {
                this._networkClassAncillaryRole = (esriNetworkClassAncillaryRole)Enum.Parse(typeof(esriNetworkClassAncillaryRole), navigatorNetworkClassAncillaryRole.Value, true);
            }
        }
        public GeometricNetworkControllerMembership(IXPathNavigable path) : base(path)
        {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // <GeometricNetworkName>Empty_Net</GeometricNetworkName>
            XPathNavigator navigatorGeometricNetworkName = navigator.SelectSingleNode("GeometricNetworkName");

            if (navigatorGeometricNetworkName != null)
            {
                this._geometricNetworkName = navigatorGeometricNetworkName.Value;
            }

            // <EnabledFieldName>Enabled</EnabledFieldName>
            XPathNavigator navigatorEnabledFieldName = navigator.SelectSingleNode("EnabledFieldName");

            if (navigatorEnabledFieldName != null)
            {
                this._enabledFieldName = navigatorEnabledFieldName.Value;
            }

            // <AncillaryRoleFieldName />
            XPathNavigator navigatorAncillaryRoleFieldName = navigator.SelectSingleNode("AncillaryRoleFieldName");

            if (navigatorAncillaryRoleFieldName != null)
            {
                this._ancillaryRoleFieldName = navigatorAncillaryRoleFieldName.Value;
            }

            // <NetworkClassAncillaryRole>esriNCARNone</NetworkClassAncillaryRole>
            XPathNavigator navigatorNetworkClassAncillaryRole = navigator.SelectSingleNode("NetworkClassAncillaryRole");

            if (navigatorNetworkClassAncillaryRole != null)
            {
                this._networkClassAncillaryRole = (esriNetworkClassAncillaryRole)Enum.Parse(typeof(esriNetworkClassAncillaryRole), navigatorNetworkClassAncillaryRole.Value, true);
            }
        }
 public GeometricNetworkControllerMembership(GeometricNetworkControllerMembership prototype) : base(prototype) {
     this._geometricNetworkName = prototype.GeometricNetworkName;
     this._enabledFieldName = prototype.EnabledFieldName;
     this._ancillaryRoleFieldName = prototype.AncillaryRoleFieldName;
     this._networkClassAncillaryRole = prototype.NetworkClassAncillaryRole;
 }
 public GeometricNetworkControllerMembership(SerializationInfo info, StreamingContext context) : base(info, context) {
     this._geometricNetworkName = info.GetString("geometricNetworkName");
     this._enabledFieldName = info.GetString("enabledFieldName");
     this._ancillaryRoleFieldName = info.GetString("ancillaryRoleFieldName");
     this._networkClassAncillaryRole = (esriNetworkClassAncillaryRole)Enum.Parse(typeof(esriNetworkClassAncillaryRole), info.GetString("networkClassAncillaryRole"), true);
 }
コード例 #7
0
        public IGeometricNetwork CreateGeometricNetwork(IFeatureDataset ifeatureDataset_1)
        {
            int i;
            IGeometricNetwork geometricNetworkByName;

            try
            {
                INetworkCollection  ifeatureDataset1      = ifeatureDataset_1 as INetworkCollection;
                INetworkLoader      networkLoader         = this.NetworkLoader;
                INetworkLoader2     preserveEnabledValues = networkLoader as INetworkLoader2;
                INetworkLoaderProps networkLoaderProp     = networkLoader as INetworkLoaderProps;
                networkLoader.FeatureDatasetName = ifeatureDataset_1.FullName as IFeatureDatasetName as IDatasetName;
                networkLoader.NetworkName        = this.Name;
                UID uIDClass                = new UIDClass();
                UID gUIDSIMPLEEDGECLSID     = new UIDClass();
                UID gUIDSIMPLEJUNCTIONCLSID = new UIDClass();
                uIDClass.Value                = this.GUID_COMPLEXEDGE_CLSID;
                gUIDSIMPLEEDGECLSID.Value     = this.GUID_SIMPLEEDGE_CLSID;
                gUIDSIMPLEJUNCTIONCLSID.Value = this.GUID_SIMPLEJUNCTION_CLSID;
                if (!this.IsSnap)
                {
                    networkLoader.SnapTolerance = preserveEnabledValues.MinSnapTolerance;
                }
                else
                {
                    networkLoader.SnapTolerance = this.SnapTolerance;
                }
                for (i = 0; i < this.Weights.Count; i++)
                {
                    BulidGeometryNetworkHelper.Weight item = this.Weights[i] as BulidGeometryNetworkHelper.Weight;
                    networkLoader.AddWeight(item.networkWeightName, item.weightType, item.bitGateSize);
                }
                bool flag  = true;
                bool flag1 = false;
                for (i = 0; i < this.FeatureClassWraps.Count; i++)
                {
                    BulidGeometryNetworkHelper.FeatureClassWrap featureClassWrap =
                        this.FeatureClassWraps[i] as BulidGeometryNetworkHelper.FeatureClassWrap;
                    if (featureClassWrap.IsUse)
                    {
                        flag = true;
                        IDataset featureClass = featureClassWrap.FeatureClass as IDataset;
                        esriNetworkLoaderFeatureClassCheck _esriNetworkLoaderFeatureClassCheck =
                            preserveEnabledValues.CanUseFeatureClass(featureClass.Name);
                        esriNetworkLoaderFeatureClassCheck _esriNetworkLoaderFeatureClassCheck1 =
                            _esriNetworkLoaderFeatureClassCheck;
                        if (_esriNetworkLoaderFeatureClassCheck1 ==
                            esriNetworkLoaderFeatureClassCheck.esriNLFCCUnknownError)
                        {
                            MessageBox.Show(string.Concat(featureClass.Name, " 未知错误"));
                            flag = false;
                        }
                        else
                        {
                            switch (_esriNetworkLoaderFeatureClassCheck1)
                            {
                            case esriNetworkLoaderFeatureClassCheck.esriNLFCCInTerrain:
                            {
                                MessageBox.Show(string.Concat(featureClass.Name, "已用在三角网中"));
                                flag = false;
                                break;
                            }

                            case esriNetworkLoaderFeatureClassCheck.esriNLFCCIsCompressedReadOnly:
                            {
                                MessageBox.Show(string.Concat(featureClass.Name, "是压缩只读要素类"));
                                flag = false;
                                break;
                            }

                            case esriNetworkLoaderFeatureClassCheck.esriNLFCCInTopology:
                            {
                                MessageBox.Show(string.Concat(featureClass.Name, "已用在拓扑中"));
                                flag = false;
                                break;
                            }

                            case esriNetworkLoaderFeatureClassCheck.esriNLFCCRegisteredAsVersioned:
                            {
                                MessageBox.Show(string.Concat(featureClass.Name, "已注册版本"));
                                flag = false;
                                break;
                            }

                            case esriNetworkLoaderFeatureClassCheck.esriNLFCCInvalidShapeType:
                            {
                                MessageBox.Show(string.Concat(featureClass.Name, "不是点或线几何要素"));
                                flag = false;
                                break;
                            }

                            case esriNetworkLoaderFeatureClassCheck.esriNLFCCInvalidFeatureType:
                            {
                                MessageBox.Show(string.Concat(featureClass.Name, "是无效要素类型"));
                                flag = false;
                                break;
                            }

                            case esriNetworkLoaderFeatureClassCheck.esriNLFCCInAnotherNetwork:
                            {
                                MessageBox.Show(string.Concat(featureClass.Name, "已在其它网络中使用"));
                                flag = false;
                                break;
                            }

                            case esriNetworkLoaderFeatureClassCheck.esriNLFCCCannotOpen:
                            {
                                MessageBox.Show(string.Concat("无法打开", featureClass.Name));
                                flag = false;
                                break;
                            }
                            }
                        }
                        if (flag &&
                            _esriNetworkLoaderFeatureClassCheck == esriNetworkLoaderFeatureClassCheck.esriNLFCCValid)
                        {
                            preserveEnabledValues.PreserveEnabledValues = this.PreserveEnabledValues;
                            esriNetworkLoaderFieldCheck _esriNetworkLoaderFieldCheck =
                                preserveEnabledValues.CheckEnabledDisabledField(featureClass.Name,
                                                                                networkLoaderProp.DefaultEnabledField);
                            if (_esriNetworkLoaderFieldCheck == esriNetworkLoaderFieldCheck.esriNLFCUnknownError)
                            {
                                MessageBox.Show(string.Concat(featureClass.Name, ": (ENABLED 字段)- 产生未知错误."));
                                flag = false;
                            }
                            else
                            {
                                switch (_esriNetworkLoaderFieldCheck)
                                {
                                case esriNetworkLoaderFieldCheck.esriNLFCInvalidDomain:
                                {
                                    MessageBox.Show(string.Concat(featureClass.Name, ": ENABLED字段有无效域值."));
                                    flag = false;
                                    break;
                                }

                                case esriNetworkLoaderFieldCheck.esriNLFCInvalidType:
                                {
                                    MessageBox.Show(string.Concat(featureClass.Name, ": ENABLED字段有无效类型"));
                                    flag = false;
                                    break;
                                }

                                case esriNetworkLoaderFieldCheck.esriNLFCNotFound:
                                {
                                    try
                                    {
                                        networkLoader.PutEnabledDisabledFieldName(featureClass.Name,
                                                                                  networkLoaderProp.DefaultEnabledField);
                                        break;
                                    }
                                    catch (Exception exception)
                                    {
                                        Logger.Current.Error("", exception, "");
                                        break;
                                    }
                                    break;
                                }
                                }
                            }
                            if (flag)
                            {
                                esriNetworkClassAncillaryRole _esriNetworkClassAncillaryRole =
                                    esriNetworkClassAncillaryRole.esriNCARNone;
                                if (featureClassWrap.GeometryType == esriGeometryType.esriGeometryPoint &&
                                    featureClassWrap.IsUse)
                                {
                                    _esriNetworkClassAncillaryRole = esriNetworkClassAncillaryRole.esriNCARSourceSink;
                                }
                                esriFeatureType featureType = featureClassWrap.FeatureType;
                                if (featureType == esriFeatureType.esriFTSimpleJunction)
                                {
                                    switch (_esriNetworkClassAncillaryRole)
                                    {
                                    case esriNetworkClassAncillaryRole.esriNCARNone:
                                    {
                                        break;
                                    }

                                    case esriNetworkClassAncillaryRole.esriNCARSourceSink:
                                    {
                                        _esriNetworkLoaderFieldCheck =
                                            preserveEnabledValues.CheckAncillaryRoleField(featureClass.Name,
                                                                                          networkLoaderProp.DefaultAncillaryRoleField);
                                        if (_esriNetworkLoaderFieldCheck ==
                                            esriNetworkLoaderFieldCheck.esriNLFCUnknownError)
                                        {
                                            MessageBox.Show(string.Concat(featureClass.Name,
                                                                          ": (ROLE Field)- An unknown error was encountered."));
                                            geometricNetworkByName = null;
                                            return(geometricNetworkByName);
                                        }
                                        else
                                        {
                                            switch (_esriNetworkLoaderFieldCheck)
                                            {
                                            case esriNetworkLoaderFieldCheck.esriNLFCInvalidDomain:
                                            {
                                                MessageBox.Show(string.Concat(featureClass.Name,
                                                                              ": ROLE字段有无效域值."));
                                                geometricNetworkByName = null;
                                                return(geometricNetworkByName);
                                            }

                                            case esriNetworkLoaderFieldCheck.esriNLFCInvalidType:
                                            {
                                                MessageBox.Show(string.Concat(featureClass.Name,
                                                                              ": ROLE字段有无效类型."));
                                                geometricNetworkByName = null;
                                                return(geometricNetworkByName);
                                            }

                                            case esriNetworkLoaderFieldCheck.esriNLFCNotFound:
                                            {
                                                try
                                                {
                                                    networkLoader.PutAncillaryRole(featureClass.Name,
                                                                                   esriNetworkClassAncillaryRole.esriNCARSourceSink,
                                                                                   networkLoaderProp.DefaultAncillaryRoleField);
                                                    break;
                                                }
                                                catch
                                                {
                                                    break;
                                                }
                                                break;
                                            }

                                            default:
                                            {
                                                break;
                                            }
                                            }
                                        }
                                        break;
                                    }

                                    default:
                                    {
                                        goto case esriNetworkClassAncillaryRole.esriNCARNone;
                                    }
                                    }
                                }
                                try
                                {
                                    switch (featureType)
                                    {
                                    case esriFeatureType.esriFTSimpleJunction:
                                    {
                                        networkLoader.AddFeatureClass(featureClass.Name,
                                                                      esriFeatureType.esriFTSimpleJunction, gUIDSIMPLEJUNCTIONCLSID,
                                                                      (this.IsSnap ? featureClassWrap.canChangeGeometry : false));
                                        goto case esriFeatureType.esriFTComplexJunction;
                                    }

                                    case esriFeatureType.esriFTSimpleEdge:
                                    {
                                        networkLoader.AddFeatureClass(featureClass.Name,
                                                                      esriFeatureType.esriFTSimpleEdge, gUIDSIMPLEEDGECLSID,
                                                                      (this.IsSnap ? featureClassWrap.canChangeGeometry : false));
                                        goto case esriFeatureType.esriFTComplexJunction;
                                    }

                                    case esriFeatureType.esriFTComplexJunction:
                                    {
                                        flag1 = true;
                                        break;
                                    }

                                    case esriFeatureType.esriFTComplexEdge:
                                    {
                                        networkLoader.AddFeatureClass(featureClass.Name,
                                                                      esriFeatureType.esriFTComplexEdge, uIDClass,
                                                                      (this.IsSnap ? featureClassWrap.canChangeGeometry : false));
                                        goto case esriFeatureType.esriFTComplexJunction;
                                    }

                                    default:
                                    {
                                        goto case esriFeatureType.esriFTComplexJunction;
                                    }
                                    }
                                }
                                catch (COMException cOMException1)
                                {
                                    COMException cOMException = cOMException1;
                                    if (cOMException.ErrorCode != -2147220462)
                                    {
                                        MessageBox.Show(cOMException.Message);
                                    }
                                    else
                                    {
                                        MessageBox.Show(string.Concat("要素类[", featureClass.Name, "]无法添加到几何网络中!"));
                                    }
                                }
                                catch (Exception exception1)
                                {
                                    MessageBox.Show(exception1.Message);
                                }
                            }
                        }
                    }
                }
                if (flag1)
                {
                    for (i = 0; i < this.WeightAssociations.Count; i++)
                    {
                        BulidGeometryNetworkHelper.WeightAssociation weightAssociation =
                            this.WeightAssociations[i] as BulidGeometryNetworkHelper.WeightAssociation;
                        preserveEnabledValues.AddWeightAssociation(weightAssociation.networkWeightName,
                                                                   weightAssociation.featureClassName, weightAssociation.fieldName);
                    }
                    preserveEnabledValues.ConfigurationKeyword  = this.ConfigurationKeyword;
                    preserveEnabledValues.PreserveEnabledValues = this.PreserveEnabledValues;
                    networkLoader.LoadNetwork();
                    geometricNetworkByName = ifeatureDataset1.GeometricNetworkByName[this.Name];
                }
                else
                {
                    geometricNetworkByName = null;
                }
            }
            catch (Exception exception2)
            {
                MessageBox.Show(exception2.Message);
                geometricNetworkByName = null;
                return(geometricNetworkByName);
            }
            return(geometricNetworkByName);
        }