Пример #1
0
 private void cmbPipelineLayers_SelectedIndexChanged(object sender, EventArgs e)
 {
     _pointLayerInfo    = null;
     _lineLayerInfo     = null;
     txtPointLayer.Text = null;
     txtLineLayer.Text  = null;
     _pipelineLayer     = cmbPipelineLayers.SelectedItem as IPipelineLayer;
     if (_pipelineLayer == null)
     {
         return;
     }
     _pointLayerInfo = _pipelineLayer.GetLayers(enumPipelineDataType.Point).FirstOrDefault();
     _lineLayerInfo  = _pipelineLayer.GetLayers(enumPipelineDataType.Line).FirstOrDefault();
     if (_pointLayerInfo?.FeatureClass != null)
     {
         txtPointLayer.Text = _pointLayerInfo.AliasName;
         ComboBoxHelper.AddItemsFromFields(_pointLayerInfo.FeatureClass.Fields, cmbKeyField);
         ComboBoxHelper.AddItemsFromFields(_pointLayerInfo.FeatureClass.Fields, cmbCodeField, true, _pointLayerInfo.GetFieldName(PipeConfigWordHelper.PointWords.GDBH));
     }
     if (_lineLayerInfo?.FeatureClass != null)
     {
         txtLineLayer.Text = _lineLayerInfo.AliasName;
         ComboBoxHelper.AddItemsFromFields(_lineLayerInfo.FeatureClass.Fields, cmbStartKeyField);
         ComboBoxHelper.AddItemsFromFields(_lineLayerInfo.FeatureClass.Fields, cmbEndKeyField);
         ComboBoxHelper.AddItemsFromFields(_lineLayerInfo.FeatureClass.Fields, cmbStartCodeField, true, _lineLayerInfo.GetFieldName(PipeConfigWordHelper.LineWords.QDBH));
         ComboBoxHelper.AddItemsFromFields(_lineLayerInfo.FeatureClass.Fields, cmbEndCodeField, true, _lineLayerInfo.GetFieldName(PipeConfigWordHelper.LineWords.ZDBH));
     }
 }
Пример #2
0
        private bool LoadLineLayerInfo(IPipelineLayer pipelineLayer)
        {
            _lineAnnLayerInfo = pipelineLayer.GetLayers(enumPipelineDataType.AnnoLine).FirstOrDefault();
            if (_lineAnnLayerInfo?.FeatureClass == null)
            {
                MessageBox.Show(@"没有配置线注记图层!");
                return(false);
            }
            txtLineAno.Text = _lineAnnLayerInfo.Name;

            _lineLayerInfo = pipelineLayer.GetLayers(enumPipelineDataType.Line).FirstOrDefault();
            if (_lineLayerInfo?.FeatureClass == null)
            {
                MessageBox.Show(@"没有配置线图层!");
                return(false);
            }
            tabPage2.Text = _lineLayerInfo.Name;

            ComboBoxHelper.AddItemsFromFields(_lineLayerInfo.FeatureClass.Fields, cmbLineFields);

            _lineFeatureLayer = CommonHelper.GetLayerByFeatureClassName(_context.FocusMap,
                                                                        _lineLayerInfo.EsriClassName);
            if (_lineFeatureLayer == null)
            {
                MessageBox.Show(@"当前地图中无可用图层!");
                return(false);
            }
            return(true);
        }
Пример #3
0
        private void InitBrokePoint()
        {
            int userClassID;
            int userID;
            int userSubID;
            IFeatureClassContainer featureDataset =
                (IFeatureClassContainer)this._nearestEdgeInfo.GeometricNetwork.FeatureDataset;
            IFeatureClass pointClass = null;
            IFeatureClass lineClass  = null;
            int           num3       = 0;


            pointClass = _pipeLayer.GetLayers(enumPipelineDataType.Point)[0].FeatureClass;
            lineClass  = _pipeLayer.GetLayers(enumPipelineDataType.Line)[0].FeatureClass;
            this._networkInfo.LayerLine =
                MapHelper.FindFeatureLayerByFCName(m_iApp.FocusMap as IBasicMap, ((IDataset)lineClass).Name, false) as
                IFeatureLayer;
            this._networkInfo.LayerPoint =
                MapHelper.FindFeatureLayerByFCName(m_iApp.FocusMap as IBasicMap, ((IDataset)pointClass).Name, false) as
                IFeatureLayer;
            INetElements network = (INetElements)this._nearestEdgeInfo.GeometricNetwork.Network;

            network.QueryIDs(this._nearestEdgeInfo.EdgeID, esriElementType.esriETEdge, out userClassID, out userID,
                             out userSubID);
            this._networkInfo.LineFeature = lineClass.GetFeature(userID);
            Label label = this.lblPickPipeInfo;

            string[] name = new string[]
            { this._networkInfo.LayerLine.Name, ",", lineClass.OIDFieldName, "=", userID.ToString() };
            label.Text = string.Concat(name);
            string.Format("\r\n爆管点位置({0:f2},{1:f2},{2:f2})", this._nearestEdgeInfo.Location.X,
                          this._nearestEdgeInfo.Location.Y, this._nearestEdgeInfo.Location.Z);

            //初始化下拉菜单

            cmbDomainValues.Items.Clear();
            IBasicLayerInfo pLayerInfo = _pipeLayer.GetLayers(enumPipelineDataType.Point)[0];
            IYTField        pField     = pLayerInfo.GetField(PipeConfigWordHelper.PointWords.FSW);

            this.label1.Text = pField.Name;
            if (!string.IsNullOrEmpty(pField.DomainValues))
            {
                string[] domianValues = pField.DomainValues.Split('/');
                foreach (var onePair in domianValues)
                {
                    cmbDomainValues.Items.Add(onePair);
                }
            }
            if (this.listFieldValues.Items.Count == 0)
            {
                this.listFieldValues.Items.Add("阀门");
                this.listFieldValues.Items.Add("阀门井");
            }
        }
Пример #4
0
        //! 通过点击获取需要分析的管线
        public bool PickBrokePipe(IPoint _pMousePoint)
        {
            this.InitClick();
            this.ipoint_0 = _pMousePoint;
            bool      flag      = false;
            double    num       = 2147483647.0;
            ArrayList arrayList = new ArrayList();

            GetMapVisibleILayers(m_iApp.FocusMap, null, arrayList);
            for (int i = 0; i < arrayList.Count; i++)
            {
                IFeatureLayer featureLayer = arrayList[i] as IFeatureLayer;
                if (featureLayer != null && featureLayer.FeatureClass != null && featureLayer.Visible &&
                    m_Config.IsPipelineLayer(featureLayer.FeatureClass.AliasName, enumPipelineDataType.Line))
                {
                    IPipelineLayer pipeLayer = m_Config.GetPipelineLayer(featureLayer.FeatureClass.AliasName,
                                                                         enumPipelineDataType.Line);
                    IFeatureDataset        featureDataset        = featureLayer.FeatureClass.FeatureDataset;
                    IFeatureClassContainer featureClassContainer = featureDataset as IFeatureClassContainer;
                    List <IBasicLayerInfo> basicInfos            = pipeLayer.GetLayers(enumPipelineDataType.Junction);

                    IFeatureClass featureClass = basicInfos.Count > 0 ? basicInfos[0].FeatureClass : null;
                    if (featureClass != null && featureClass is INetworkClass)
                    {
                        IGeometricNetwork geometricNetwork = ((INetworkClass)featureClass).GeometricNetwork;
                        IPointToEID       pointToEIDClass  = new PointToEID();
                        pointToEIDClass.SourceMap        = (m_iApp.FocusMap);
                        pointToEIDClass.GeometricNetwork = (geometricNetwork);
                        pointToEIDClass.SnapTolerance    = (m_iApp.ActiveView.Extent.Width / 200.0);
                        int    edgeID   = 0;
                        IPoint location = null;
                        double percent  = 0;
                        pointToEIDClass.GetNearestEdge(this.ipoint_0, out edgeID, out location, out percent);
                        if (location != null && num > percent)
                        {
                            num        = percent;
                            _pipeLayer = pipeLayer;
                            this._nearestEdgeInfo.GeometricNetwork = geometricNetwork;
                            this._nearestEdgeInfo.Percent          = percent;
                            this._nearestEdgeInfo.EdgeID           = edgeID;
                            this._nearestEdgeInfo.Location         = location;
                            flag = true;
                            break;
                        }
                    }
                }
            }
            arrayList.Clear();
            if (flag)
            {
                this.DrawBrokeEdge();
            }
            return(flag);
        }
Пример #5
0
        private void cmbPipelineLayers_SelectedIndexChanged(object sender, EventArgs e)
        {
            IPipelineLayer pipelineLayer = cmbPipelineLayers.SelectedItem as IPipelineLayer;

            if (pipelineLayer?.Layers == null || pipelineLayer.Layers.Count <= 0)
            {
                return;
            }
            _pointLayerInfo = pipelineLayer.GetLayers(enumPipelineDataType.Point).FirstOrDefault();
            if (_pointLayerInfo?.FeatureClass != null)
            {
                _pointFeatureLayer = CommonHelper.GetLayerByFeatureClassName(_context.FocusMap,
                                                                             _pointLayerInfo.EsriClassName);
                IDataset dataset = _pointFeatureLayer?.FeatureClass as IDataset;
                if (dataset != null)
                {
                    this.txtSavePath.Text = dataset.Workspace.PathName;
                }
            }

            chbisAnoPoint_CheckedChanged(null, null);
            chbisAnoLine_CheckedChanged(null, null);
        }
Пример #6
0
        private void StartAnalysis(IFeature feature)
        {
            if (feature.FeatureType != esriFeatureType.esriFTSimpleJunction)
            {
                MessageService.Current.Warn("请选择管线点");
                return;
            }
            if (!_pipelineConfig.IsPipelineLayer(feature.Class.AliasName, enumPipelineDataType.Point))
            {
                MessageService.Current.Warn("请选择管线点");
                return;
            }
            double snapDist = CommonUtils.ConvertPixelsToMapUnits(_context.ActiveView,
                                                                  _context.Config.SnapTolerance);
            IBasicLayerInfo lineConfig =
                _plugin.PipeConfig.GetBasicLayerInfo(feature.Class as IFeatureClass) as IBasicLayerInfo;

            if (this._startPoint == null && _startEid == 0)
            {
                //开始记录起始点
                IPipelineLayer oldLayer = _pipelineConfig.GetPipelineLayer(feature.Class.AliasName,
                                                                           enumPipelineDataType.Point);
                if (oldLayer == null)
                {
                    MessageService.Current.Warn("你选择的图层不是合法的管线图层!");
                    return;
                }
                List <IBasicLayerInfo> basicInfos = oldLayer.GetLayers(enumPipelineDataType.Junction);

                IFeatureClass featureClass = basicInfos.Count > 0 ? basicInfos[0].FeatureClass : null;
                if (featureClass == null)
                {
                    MessageService.Current.Warn("管线图层没有构建网络图层!");
                    return;
                }
                INetworkClass networkClass = featureClass as INetworkClass;
                _geometricNetwork = networkClass.GeometricNetwork;
                IPointToEID pnToEid = new PointToEIDClass();
                pnToEid.GeometricNetwork = _geometricNetwork;
                pnToEid.SnapTolerance    = snapDist;
                pnToEid.SourceMap        = _context.FocusMap;
                pnToEid.GetNearestJunction(feature.Shape as IPoint, out _startEid, out _startPoint);
                return;
            }
            IPipelineLayer newLayer = _pipelineConfig.GetPipelineLayer(feature.Class.AliasName,
                                                                       enumPipelineDataType.Point);

            if (newLayer == null)
            {
                MessageService.Current.Warn("你选择的图层不是合法的管线图层!");
                return;
            }
            List <IBasicLayerInfo> basicInfos1 = newLayer.GetLayers(enumPipelineDataType.Junction);

            IFeatureClass featureClass2 = basicInfos1.Count > 0 ? basicInfos1[0].FeatureClass : null;

            if (featureClass2 == null)
            {
                MessageService.Current.Warn("第二个管线图层没有构建网络图层!");
                return;
            }
            INetworkClass networkClass2 = featureClass2 as INetworkClass;

            if (networkClass2.GeometricNetwork != _geometricNetwork)
            {
                if (MessageService.Current.Ask("两个点位属于不同的网络图层,使用第二个网络图层作为分析图层吗?") == false)
                {
                    return;
                }
                _geometricNetwork = networkClass2.GeometricNetwork;
                IPointToEID pnToEid = new PointToEIDClass();
                pnToEid.GeometricNetwork = _geometricNetwork;
                pnToEid.SnapTolerance    = snapDist;
                pnToEid.SourceMap        = _context.FocusMap;
                pnToEid.GetNearestJunction(feature.Shape as IPoint, out _startEid, out _startPoint);
                return;
            }

            try
            {
                IPointToEID pntEid = new PointToEIDClass();
                pntEid.GeometricNetwork = _geometricNetwork;
                pntEid.SourceMap        = _context.FocusMap;
                pntEid.SnapTolerance    = snapDist;

                pntEid.GetNearestJunction(feature.Shape as IPoint, out _endEid, out _endPoint);
                if (_endEid < 1)
                {
                    MessageService.Current.Warn("未能找到第二个分析点!");
                    return;
                }
                if (_startEid == _endEid)
                {
                    MessageService.Current.Warn("起点终点为同一个点!");
                    return;
                }

                INetElements  netElements  = _geometricNetwork.Network as INetElements;
                INetworkClass networkClass = feature.Class as INetworkClass;

                IJunctionFlag[] array   = new JunctionFlag[2];
                INetFlag        netFlag = new JunctionFlag() as INetFlag;

                int userClassID;
                int userID;
                int userSubID;
                netElements.QueryIDs(_endEid, esriElementType.esriETJunction, out userClassID, out userID, out userSubID);
                netFlag.UserClassID = (userClassID);
                netFlag.UserID      = (userID);
                netFlag.UserSubID   = (userSubID);
                IJunctionFlag value = netFlag as IJunctionFlag;
                array.SetValue(value, 0);
                INetFlag netFlag2 = new JunctionFlag() as INetFlag;
                netElements.QueryIDs(_startEid, esriElementType.esriETJunction, out userClassID,
                                     out userID, out userSubID);
                netFlag2.UserClassID = (userClassID);
                netFlag2.UserID      = (userID);
                netFlag2.UserSubID   = (userSubID);
                value = (netFlag2 as IJunctionFlag);
                array.SetValue(value, 1);
                ITraceFlowSolverGEN traceFlowSolverGEN = new TraceFlowSolver() as ITraceFlowSolverGEN;
                INetSolver          netSolver          = traceFlowSolverGEN as INetSolver;
                netSolver.SourceNetwork = _geometricNetwork.Network;
                traceFlowSolverGEN.PutJunctionOrigins(ref array);
                object[]    array2 = new object[1];
                IEnumNetEID enumNetEID;
                IEnumNetEID enumNetEID2;
                traceFlowSolverGEN.FindPath((esriFlowMethod)2, (esriShortestPathObjFn)1, out enumNetEID,
                                            out enumNetEID2, 1, ref array2);
                if (this.ipolyline_0 == null)
                {
                    this.ipolyline_0 = new Polyline() as IPolyline;
                }
                IGeometryCollection geometryCollection = this.ipolyline_0 as IGeometryCollection;
                geometryCollection.RemoveGeometries(0, geometryCollection.GeometryCount);
                if (enumNetEID2.Count <= 0)
                {
                    this.ifeature_0 = null;
                    MessageBox.Show("两点之间不存在路径可以连通!");
                }
                else
                {
                    ShowShortObjectForm showShortObjectForm = new ShowShortObjectForm(_context);
                    showShortObjectForm.pApp = _context;
                    ISpatialReference spatialReference = _context.FocusMap.SpatialReference;
                    IEIDHelper        eIDHelperClass   = new EIDHelper();
                    eIDHelperClass.GeometricNetwork       = (networkClass.GeometricNetwork);
                    eIDHelperClass.OutputSpatialReference = (spatialReference);
                    eIDHelperClass.ReturnGeometries       = (true);
                    eIDHelperClass.ReturnFeatures         = (true);
                    IEnumEIDInfo enumEIDInfo = eIDHelperClass.CreateEnumEIDInfo(enumNetEID2);
                    int          count       = enumEIDInfo.Count;
                    enumEIDInfo.Reset();
                    for (int i = 0; i < count; i++)
                    {
                        IEIDInfo  iEIDInfo = enumEIDInfo.Next();
                        IGeometry geometry = iEIDInfo.Geometry;
                        if (i == 0)
                        {
                            showShortObjectForm.AddPipeName(this.string_0);
                        }
                        showShortObjectForm.AddFeature(iEIDInfo.Feature);
                        geometryCollection.AddGeometryCollection(geometry as IGeometryCollection);
                    }
                    showShortObjectForm.AddShortPath(this.ipolyline_0);
                    showShortObjectForm.AddLenght(this.ipolyline_0.Length);
                    this.ifeature_2 = feature;
                    EsriUtils.ZoomToGeometry(this.ipolyline_0, _context.MapControl.Map, 1.3);
                    FlashUtility.FlashGeometry(this.ipolyline_0, _context.MapControl);
                    this.ifeature_0   = null;
                    _startEid         = 0;
                    _startPoint       = null;
                    _geometricNetwork = null;
                    showShortObjectForm.Show();
                }
            }
            catch (Exception ex)
            {
                this.ifeature_0 = null;
                MessageBox.Show(ex.Message);
            }
        }
Пример #7
0
        public void GetBaseLine(IPoint point)
        {
            string str;
            string str1;
            string str2;

            this.timer_0.Stop();
            this.dataGridView1.Rows.Clear();
            IMap     map     = this.m_app.FocusMap;
            IFeature feature = ((IEnumFeature)map.FeatureSelection).Next();

            if (feature == null ? true : feature.FeatureType != esriFeatureType.esriFTSimpleEdge)
            {
                this.m_commonDistAls.m_pBaseLine = null;
                this.btAnalyse.Enabled           = false;
                this.m_app.FocusMap.ClearSelection();
                this.m_app.ActiveView.Refresh();
                //this.tbPipeWidthOrHeight.Text = "";
                return;
            }
            IFeatureLayer pLayer =
                CommonUtils.GetLayerByFeatureClassName(m_app.FocusMap, ((IDataset)feature.Class).Name) as IFeatureLayer;
            IPipelineLayer  pipeLayer = m_config.GetPipelineLayer(feature.Class as IFeatureClass);
            IBasicLayerInfo pipeLine  = m_config.GetBasicLayerInfo(feature.Class as IFeatureClass);

            if (pipeLine == null)
            {
                this.m_commonDistAls.m_pBaseLine = null;
                this.btAnalyse.Enabled           = false;
                this.m_app.FocusMap.ClearSelection();
                this.m_app.ActiveView.Refresh();
                return;
            }
            List <IBasicLayerInfo> basicInfos      = pipeLayer.GetLayers(enumPipelineDataType.Junction);
            IFeatureClass          junFeatureClass = basicInfos.Count > 0 ? basicInfos[0].FeatureClass : null;
            //需要重新获取边信息
            IGeometricNetwork      geometricNetwork = ((INetworkClass)junFeatureClass).GeometricNetwork;
            IFeatureClassContainer featureDataset   = geometricNetwork.FeatureDataset as IFeatureClassContainer;
            IPointToEID            pointToEIDClass  = new PointToEID();

            pointToEIDClass.SourceMap        = (m_app.FocusMap);
            pointToEIDClass.GeometricNetwork = (geometricNetwork);
            pointToEIDClass.SnapTolerance    = (m_app.ActiveView.Extent.Width / 200.0);
            int    edgeID   = 0;
            IPoint location = null;
            double percent  = 0;

            pointToEIDClass.GetNearestEdge(point, out edgeID, out location, out percent);
            if (edgeID == 0)
            {
                return;
            }

            int          userClassID;
            int          userID;
            int          userSubID;
            INetElements network = geometricNetwork.Network as INetElements;

            network.QueryIDs(edgeID, esriElementType.esriETEdge, out userClassID, out userID, out userSubID);
            IFeatureClass lineClass   = featureDataset.ClassByID[userClassID] as IFeatureClass;
            IFeature      lineFeature = lineClass.GetFeature(userID);
            IGeometry     shape       = lineFeature.Shape;

            if (shape.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                this.ipolyline_0 = CommonUtils.GetPolylineDeepCopy((IPolyline)shape);
                this.m_commonDistAls.m_pFeature     = feature;
                this.m_commonDistAls.m_pBaseLine    = this.ipolyline_0;
                this.m_commonDistAls.m_strLayerName = feature.Class.AliasName;
                //int num = feature.Fields.FindField("埋设方式");
                int num = lineFeature.Fields.FindField(pipeLine.GetFieldName(PipeConfigWordHelper.LineWords.MSFS));
                str = (num == -1 ? "" : this.GetDBObjectValue(lineFeature.get_Value(num)));
                this.m_commonDistAls.m_strBuryKind = str;
                int num1 = lineFeature.Fields.FindField(pipeLine.GetFieldName(PipeConfigWordHelper.LineWords.GJ));
                str1 = (num1 == -1 ? "" : this.GetDBObjectValue(lineFeature.get_Value(num1)));
                num1 = feature.Fields.FindField(pipeLine.GetFieldName(PipeConfigWordHelper.LineWords.DMCC));
                str2 = (num1 == -1 ? "" : lineFeature.get_Value(num1).ToString());
                string str3 = "";
                if (str1 != "")
                {
                    str3 = str1;
                }
                if (str2 != "")
                {
                    str3 = str2;
                }
                this.m_commonDistAls.m_dDiameter = this.m_commonDistAls.GetDiameterFromString(str3.Trim());
                IEdgeFeature edgeFeature = (IEdgeFeature)lineFeature;
                this.m_commonDistAls.m_nBaseLineFromID = edgeFeature.FromJunctionEID;
                this.m_commonDistAls.m_nBaseLineToID   = edgeFeature.ToJunctionEID;
                this.btAnalyse.Enabled             = this.m_commonDistAls.m_pBaseLine != null;
                this.chitAnalyse_0.PipeLayer_Class = lineFeature.Class as IFeatureClass;
                this.chitAnalyse_0.BaseLine_OID    = lineFeature.OID;
                _baseLayerInfo = pipeLine;
            }
            else
            {
                MessageBox.Show("所选择的管线多于一条,或者不是管线!");
            }
        }