예제 #1
0
 private void comboBoxEdit_SelectedIndexChanged(object sender, EventArgs e)
 {
     BulidGeometryNetworkHelper.Weight selectedItem =
         this.comboBoxEdit.SelectedItem as BulidGeometryNetworkHelper.Weight;
     this.listView1.Items.Clear();
     if (selectedItem != null)
     {
         int num = 0;
         for (int i = 0; i < BulidGeometryNetworkHelper.BulidGNHelper.FeatureClassWraps.Count; i++)
         {
             BulidGeometryNetworkHelper.FeatureClassWrap wrap =
                 BulidGeometryNetworkHelper.BulidGNHelper.FeatureClassWraps[i] as
                 BulidGeometryNetworkHelper.FeatureClassWrap;
             if (wrap.IsUse)
             {
                 num++;
             }
         }
         int      num3  = this.comboBoxEdit.SelectedIndex * num;
         string[] items = new string[2];
         for (int j = num3; j < (num3 + num); j++)
         {
             BulidGeometryNetworkHelper.WeightAssociation association =
                 this.ilist_0[j] as BulidGeometryNetworkHelper.WeightAssociation;
             items[0] = association.featureClassName;
             items[1] = association.fieldName;
             ListViewItem item = new ListViewItem(items)
             {
                 Tag = association
             };
             this.listView1.Items.Add(item);
         }
     }
 }
예제 #2
0
 public void Init()
 {
     for (int i = 0; i < BulidGeometryNetworkHelper.BulidGNHelper.Weights.Count; i++)
     {
         BulidGeometryNetworkHelper.Weight item =
             BulidGeometryNetworkHelper.BulidGNHelper.Weights[i] as BulidGeometryNetworkHelper.Weight;
         this.comboBoxEdit.Properties.Items.Add(item);
         for (int j = 0; j < BulidGeometryNetworkHelper.BulidGNHelper.FeatureClassWraps.Count; j++)
         {
             BulidGeometryNetworkHelper.FeatureClassWrap wrap =
                 BulidGeometryNetworkHelper.BulidGNHelper.FeatureClassWraps[j] as
                 BulidGeometryNetworkHelper.FeatureClassWrap;
             if (wrap.IsUse)
             {
                 BulidGeometryNetworkHelper.WeightAssociation association = new BulidGeometryNetworkHelper.
                                                                            WeightAssociation
                 {
                     networkWeightName = item.networkWeightName,
                     featureClassName  = (wrap.FeatureClass as IDataset).Name,
                     fieldName         = "<无>"
                 };
                 this.ilist_0.Add(association);
             }
         }
     }
     if (this.comboBoxEdit.Properties.Items.Count > 0)
     {
         this.comboBoxEdit.SelectedIndex = 0;
     }
     BulidGeometryNetworkHelper.BulidGNHelper.WeightAssociations.Clear();
 }
예제 #3
0
 public void Apply()
 {
     for (int i = 0; i < this.ilist_0.Count; i++)
     {
         BulidGeometryNetworkHelper.WeightAssociation association =
             this.ilist_0[i] as BulidGeometryNetworkHelper.WeightAssociation;
         if (association.fieldName != "<无>")
         {
             BulidGeometryNetworkHelper.BulidGNHelper.WeightAssociations.Clear();
             BulidGeometryNetworkHelper.BulidGNHelper.WeightAssociations.Add(association);
         }
     }
 }
예제 #4
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);
        }