Esempio n. 1
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);
        }
Esempio n. 2
0
        public void PickThroughValve(IPoint _pMousePoint)
        {
            IPointToEID pointToEIDClass = new PointToEID();

            pointToEIDClass.GeometricNetwork = (this._nearestEdgeInfo.GeometricNetwork);
            pointToEIDClass.SourceMap        = (m_iApp.FocusMap);
            pointToEIDClass.SnapTolerance    = (m_iApp.ActiveView.Extent.Width / 200.0);
            int    junctionEID = 0;
            IPoint location    = null;

            pointToEIDClass.GetNearestJunction(_pMousePoint, out junctionEID, out location);
            if (location != null)
            {
                INetElements netElements = (INetElements)this._nearestEdgeInfo.GeometricNetwork.Network;
                int          userClassID;
                int          userID;
                int          userSubID;
                netElements.QueryIDs(junctionEID, esriElementType.esriETJunction, out userClassID, out userID,
                                     out userSubID);
                IFeature feature = this._networkInfo.LayerPoint.FeatureClass.GetFeature(userID);
                this.listOutBarriers.Items.Add(feature.OID.ToString());
            }
        }
Esempio n. 3
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("所选择的管线多于一条,或者不是管线!");
            }
        }