Пример #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
        //! 通过点击获取需要分析的管线
        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);
        }
Пример #4
0
 private void chbisAnoPoint_CheckedChanged(object sender, EventArgs e)
 {
     panelPoint.Enabled = chbisAnoPoint.Checked;
     if (chbisAnoPoint.Checked)
     {
         IPipelineLayer pipelineLayer = cmbPipelineLayers.SelectedItem as IPipelineLayer;
         if (pipelineLayer?.Layers == null || pipelineLayer.Layers.Count <= 0)
         {
             return;
         }
         chbisAnoPoint.Checked = LoadPointLayerInfo(pipelineLayer);
     }
 }
Пример #5
0
        public List <string> GetCheckPipeline()
        {
            List <string> list = new List <string>();

            foreach (object checkedItem in this.checkedListBoxPipelineLayers.CheckedItems)
            {
                IPipelineLayer pipelineLayer = checkedItem as IPipelineLayer;
                if (pipelineLayer == null)
                {
                    continue;
                }
                list.Add(pipelineLayer.Code);
            }
            return(list);
        }
Пример #6
0
        public PipelineLayer(IPipelineLayer layer, bool keepClass)
        {
            _name      = layer.Name;
            _code      = layer.Code;
            _classCode = layer.ClassCode;
            _autoNames = layer.AutoNames;
            _layers    = new List <IBasicLayerInfo>();
            foreach (IBasicLayerInfo basicLayerInfo in layer.Layers)
            {
                IBasicLayerInfo newBasicLayerInfo = basicLayerInfo.Clone(keepClass);
                _layers.Add(newBasicLayerInfo);
            }

            if (keepClass)
            {
                _workspace = layer.Workspace;
            }
        }
Пример #7
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);
        }
Пример #8
0
        public static float GetPipeLineAlarmHrzDistByFeatureClassName2(IPipelineConfig config, string strFeaClassName1,
                                                                       string strFeaClassName2, IFeature pFeature1, IFeature pFeature2)
        {
            float           single;
            string          str;
            string          str1;
            IBasicLayerInfo pipeLayer1            = config.GetBasicLayerInfo(strFeaClassName1);
            IBasicLayerInfo pipeLayer2            = config.GetBasicLayerInfo(strFeaClassName2);
            IPipelineLayer  pipeline1             = config.GetPipelineLayer(pipeLayer1.FeatureClass);
            IPipelineLayer  pipeline2             = config.GetPipelineLayer(pipeLayer2.FeatureClass);
            object          pipeLineAlarmHrzDist2 = CommonUtils.GetPipeLineAlarmHrzDist2(config, pipeline1.ClassCode,
                                                                                         pipeline2.ClassCode, pFeature1, pFeature2, pipeLayer1, pipeLayer2);

            if (pipeLineAlarmHrzDist2 != null)
            {
                single = (!Convert.IsDBNull(pipeLineAlarmHrzDist2) ? Convert.ToSingle(pipeLineAlarmHrzDist2) : 0f);
            }
            else
            {
                single = 0f;
            }

            return(single);
        }
Пример #9
0
        public static float GetPipeLineAlarmVerDistByFeatureClassName(IPipelineConfig config, string className1,
                                                                      string className2, string strBuryKind1, string strBuryKind2)
        {
            float           single;
            string          str;
            string          str1;
            IBasicLayerInfo pipeLayer1           = config.GetBasicLayerInfo(className1);
            IBasicLayerInfo pipeLayer2           = config.GetBasicLayerInfo(className2);
            IPipelineLayer  pipeline1            = config.GetPipelineLayer(pipeLayer1.FeatureClass);
            IPipelineLayer  pipeline2            = config.GetPipelineLayer(pipeLayer2.FeatureClass);
            object          pipeLineAlarmVerDist = CommonUtils.GetPipeLineAlarmVerDist(config, pipeline1.ClassCode,
                                                                                       pipeline2.ClassCode, strBuryKind1, strBuryKind2);

            if (pipeLineAlarmVerDist != null)
            {
                single = (!Convert.IsDBNull(pipeLineAlarmVerDist) ? Convert.ToSingle(pipeLineAlarmVerDist) : 0f);
            }
            else
            {
                single = 0f;
            }

            return(single);
        }
Пример #10
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);
            }
        }
Пример #11
0
        private void btnAnalysis_Click(object obj, EventArgs eventArgs)
        {
            if (cmbDepthType.SelectedIndex < 0)
            {
                MessageService.Current.Warn("请先选择埋深数据类型再进行分析!");
                return;
            }
            this.gridView1.Columns.Clear();
            //this.gridControl1.DataRowCount=0;//.Rows.Clear();
            IQueryFilter queryFilter = null;
            bool         isM         = cmbDepthType.SelectedIndex > 0 ? true : false;

            if (chkRegionAnalysis.Checked)
            {
                ISpatialFilter spatialFilter = new SpatialFilterClass();
                spatialFilter.Geometry   = _context.ActiveView.Extent;
                spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                queryFilter = spatialFilter as IQueryFilter;
            }
            _table = null;
            foreach (CheckListFeatureLayerItem pclass in this.checkedListBox1.CheckedItems)
            {
                IFeatureLayer ifeatureLayer = pclass.m_pFeatureLayer;
                this.progressBar1.Visible = true;
                this.progressBar1.Maximum = ifeatureLayer.FeatureClass.FeatureCount(queryFilter);
                this.progressBar1.Step    = 1;
                this.progressBar1.Value   = 0;
                this.Text = "覆土分析 - 正在处理:" + ifeatureLayer.Name + "...";
                IPipelineLayer  pipelineLayer = _config.GetPipelineLayer(ifeatureLayer.FeatureClass);
                IBasicLayerInfo pipeLine      = _config.GetBasicLayerInfo(ifeatureLayer.FeatureClass) as IBasicLayerInfo;


                string lineConfig_Kind = pipelineLayer.Code;

                string sDepthMethod = "";
                string sDepPosition = "";
                int    num          =
                    ifeatureLayer.FeatureClass.Fields.FindField(
                        pipeLine.GetFieldName(PipeConfigWordHelper.LineWords.MSFS));
                //基本上没有使用,因为所在位置没有数据
                int num2 =
                    ifeatureLayer.FeatureClass.Fields.FindField(
                        pipeLine.GetFieldName(PipeConfigWordHelper.LineWords.SZWZ));
                IFeatureCursor featureCursor = ifeatureLayer.Search(queryFilter, false);
                int            qdmsIdx       = featureCursor.FindField(pipeLine.GetFieldName(PipeConfigWordHelper.LineWords.QDMS));
                int            zdmsIdx       = featureCursor.FindField(pipeLine.GetFieldName(PipeConfigWordHelper.LineWords.ZDMS));

                BuildTable(featureCursor);
                IFeature feature = featureCursor.NextFeature();
                while (feature != null)
                {
                    this.progressBar1.Value = this.progressBar1.Value + 1;
                    if (feature.Shape == null || feature.Shape.GeometryType != esriGeometryType.esriGeometryPolyline)
                    {
                        feature = featureCursor.NextFeature();
                    }
                    else
                    {
                        if (num != -1)
                        {
                            sDepthMethod = feature.get_Value(num).ToString();
                        }
                        if (num2 != -1)
                        {
                            sDepPosition = feature.get_Value(num2).ToString();
                        }
                        double ruleMS = this.m_RuleMs.GetRuleMS(lineConfig_Kind, sDepthMethod, sDepPosition);
                        if (isM)
                        {
                            IPoint point  = ((IPointCollection)feature.Shape).get_Point(0);
                            IPoint point2 = ((IPointCollection)feature.Shape).get_Point(1);
                            if (point.M < ruleMS || point2.M < ruleMS)
                            {
                                this.FillFeatureValue(pipeLine, lineConfig_Kind, feature, ruleMS, point.M, point2.M);
                            }
                        }
                        else
                        {
                            double qdms = qdmsIdx >= 0 ? Convert.ToDouble(feature.Value[qdmsIdx]) : 0;
                            double zdms = qdmsIdx >= 0 ? Convert.ToDouble(feature.Value[zdmsIdx]) : 0;
                            if (qdms < ruleMS || zdms < ruleMS)
                            {
                                this.FillFeatureValue(pipeLine, lineConfig_Kind, feature, ruleMS, qdms, zdms);
                            }
                        }
                        feature = featureCursor.NextFeature();
                    }
                }
                Marshal.ReleaseComObject(featureCursor);
                this.progressBar1.Visible    = false;
                this.gridControl1.DataSource = _table;
            }
            this.Text = "覆土分析--记录数:" + _table.Rows.Count.ToString();
        }
Пример #12
0
        public void Analyse_Vertical(IFeatureCursor pFeaCursor)
        {
            double double0 = this.double_0 * 0.0005;
            ITopologicalOperator ipolyline1 = (ITopologicalOperator)this.baselineSimpleLine;
            IFeature             feature    = pFeaCursor.NextFeature();

            if (feature == null)
            {
                return;
            }
            int num  = -1;
            int num1 = -1;
            int num2 = -1;

            IBasicLayerInfo lineConfig     = m_config.GetBasicLayerInfo(feature.Class.AliasName) as IBasicLayerInfo;
            IPipelineLayer  pipelineLayer  = m_config.GetPipelineLayer(feature.Class as IFeatureClass);
            IPipelineLayer  pipelineLayer0 = m_config.GetPipelineLayer(baselineFC);

            if (feature != null)
            {
                num  = feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GJ));
                num1 = feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.DMCC));
                num2 = feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GDXZ));
            }
            if (num2 >= 0)
            {
                if ((num >= 0 ? true : num1 >= 0))
                {
                    int lineConfigHeightFlag = (int)lineConfig.HeightType;
                    // this.m_app.PipeConfig.getLineConfig_HeightFlag(CommonUtils.GetSmpClassName(feature.Class.AliasName));
                    while (feature != null)
                    {
                        IPolyline shape    = feature.Shape as IPolyline;
                        IPolyline polyline = this.SimplifyPolyline(shape);
                        double    num3     = 0;
                        this.GetPipeGJ(feature, num, num1, out num3);
                        if (num3 < 10)
                        {
                            num3 = 10;
                        }
                        num3 = num3 * 0.0005;
                        IGeometry geometry = ipolyline1.Intersect(polyline, (esriGeometryDimension)1);
                        if (geometry != null)
                        {
                            IPoint point = null;
                            if (geometry is IPoint)
                            {
                                point = (IPoint)geometry;
                            }
                            else if (geometry is IMultipoint)
                            {
                                IPointCollection pointCollection = (IPointCollection)geometry;
                                if (pointCollection.PointCount > 0)
                                {
                                    point = pointCollection.get_Point(0);
                                }
                            }
                            if (point != null)
                            {
                                int    num4 = this.method_3(this.baselineSimpleLine, point);
                                double num5 = this.CalculateZAlongLine(this.baselineShape, point, num4);
                                if (this.heightType == 0)
                                {
                                    num5 = num5 - double0;
                                }
                                else if (2 == this.heightType)
                                {
                                    num5 = num5 + double0;
                                }
                                int    num6 = this.method_3(polyline, point);
                                double num7 = this.CalculateZAlongLine(shape, point, num6);
                                if (lineConfigHeightFlag == 0)
                                {
                                    num7 = num7 - num3;
                                }
                                else if (2 == lineConfigHeightFlag)
                                {
                                    num7 = num7 + num3;
                                }
                                double num8 = Math.Abs(num5 - num7);
                                if (num8 >= 0.001)
                                {
                                    string            str   = feature.get_Value(num2).ToString();
                                    CHitAnalyse.CItem cItem = new CHitAnalyse.CItem()
                                    {
                                        _OID          = feature.OID,
                                        _sKind        = str,
                                        _dVerDistance = num8,
                                        _dVerBase     = 0,
                                        _pClass       = (IFeatureClass)feature.Class
                                    };
                                    string str1 = this.GetPipeMSFS(feature);
                                    string str2 = this.GetPipeMSFS(this.baseFeature);
                                    cItem._dVerBase =
                                        (double)
                                        CommonUtils.GetPipeLineAlarmVerDistByFeatureClassName(m_config,
                                                                                              pipelineLayer0.ClassCode, pipelineLayer.ClassCode, str2, str1);
                                    this.list_0.Add(cItem);
                                }
                                else
                                {
                                    feature = pFeaCursor.NextFeature();
                                    continue;
                                }
                            }
                        }
                        feature = pFeaCursor.NextFeature();
                    }
                }
            }
        }
Пример #13
0
        public List <IPipelineLayer> ReadLayersFromDatabase()
        {
            List <IPipelineLayer> layers = new List <IPipelineLayer>();
            ITable     pCodeTable        = _workspace.OpenTable("YT_PIPE_CODE");
            ITableSort tableSort         = new TableSortClass();

            tableSort.Table  = pCodeTable;
            tableSort.Fields = "Priority";
            tableSort.Sort(null);

            ICursor pCursor  = tableSort.Rows;
            IRow    pRow     = pCursor.NextRow();
            int     codeIdx  = pCursor.FindField("PipeCode");
            int     classIdx = pCursor.FindField("ClassCode");
            int     nameIdx  = pCursor.FindField("PipeName");
            int     autoIdx  = pCursor.FindField("AutoNames");
            int     priIdx   = pCursor.FindField("Priority");

            while (pRow != null)
            {
                IPipelineLayer oneLayer = new PipelineLayer()
                {
                    Code      = pRow.Value[codeIdx].ToString(),
                    Name      = pRow.Value[nameIdx].ToString(),
                    AutoNames = pRow.Value[autoIdx].ToString(),
                    Layers    = new List <IBasicLayerInfo>(),
                    ClassCode = pRow.Value[classIdx].ToString()
                };
                layers.Add(oneLayer);
                pRow = pCursor.NextRow();
            }
            Marshal.ReleaseComObject(pCursor);
            Marshal.ReleaseComObject(tableSort);
            Marshal.ReleaseComObject(pCodeTable);

            List <IYTDomain> domains = new List <IYTDomain>();

            pCodeTable = _workspace.OpenTable("YT_PIPE_DOMAIN");
            pCursor    = pCodeTable.Search(null, false);
            pRow       = pCursor.NextRow();
            nameIdx    = pCursor.FindField("DomainName");
            autoIdx    = pCursor.FindField("DomainValues");

            while (pRow != null)
            {
                string    domainName   = pRow.Value[nameIdx].ToString();
                string    domainValues = pRow.Value[autoIdx].ToString();
                IYTDomain onedomain    = new YTDomain(domainName, domainValues);
                domains.Add(onedomain);
                pRow = pCursor.NextRow();
            }
            Marshal.ReleaseComObject(pCursor);
            Marshal.ReleaseComObject(pCodeTable);

            List <IPipelineTemplate> templates = new List <IPipelineTemplate>();

            //! 先读取模板
            pCodeTable       = _workspace.OpenTable("YT_PIPE_FIELD");
            tableSort        = new TableSortClass();
            tableSort.Table  = pCodeTable;
            tableSort.Fields = "TemplateName";

            tableSort.Sort(null);
            pCursor = tableSort.Rows;
            string oldTemplate = "";

            int[] fieldIndexes = new int[10];
            pRow            = pCursor.NextRow();
            fieldIndexes[0] = pRow.Fields.FindField("TemplateName");
            fieldIndexes[1] = pRow.Fields.FindField("TypeName");
            fieldIndexes[2] = pRow.Fields.FindField("FieldName");
            fieldIndexes[3] = pRow.Fields.FindField("FieldAliasName");
            fieldIndexes[4] = pRow.Fields.FindField("FieldType");
            fieldIndexes[5] = pRow.Fields.FindField("FieldLength");
            fieldIndexes[6] = pRow.Fields.FindField("FieldPrecision");
            fieldIndexes[7] = pRow.Fields.FindField("AllowNull");
            fieldIndexes[8] = pRow.Fields.FindField("AutoValues");
            fieldIndexes[9] = pRow.Fields.FindField("IsKey");
            //  fieldIndexes[10] = pRow.Fields.FindField("Domains");


            IPipelineTemplate oneTemplate = null;

            while (pRow != null)
            {
                string templateName = pRow.Value[fieldIndexes[0]].ToString();
                if (!templateName.Equals(oldTemplate))
                {
                    if (oneTemplate != null)
                    {
                        templates.Add(oneTemplate);
                    }
                    oneTemplate = new PipelineTemplate()
                    {
                        Name = templateName, Fields = new List <IYTField>()
                    };
                    oldTemplate = templateName;
                }
                IYTField field = new YTField()
                {
                    TypeName  = pRow.Value[fieldIndexes[1]].ToString(),
                    Name      = pRow.Value[fieldIndexes[2]].ToString(),
                    AliasName = pRow.Value[fieldIndexes[3]].ToString(),
                    Length    = Convert.ToInt32(pRow.Value[fieldIndexes[5]].ToString()),
                    Precision = Convert.ToInt32(pRow.Value[fieldIndexes[6]].ToString()),
                    AllowNull = Convert.ToInt32(pRow.Value[fieldIndexes[7]].ToString()) == -1 ? true : false,
                    AutoNames = pRow.Value[fieldIndexes[8]].ToString(),
                    FieldType = FieldHelper.ConvertFromString(pRow.Value[fieldIndexes[4]].ToString())
                };
                oneTemplate.Fields.Add(field);
                pRow = pCursor.NextRow();
            }
            if (oneTemplate != null)
            {
                templates.Add(oneTemplate);
            }
            Marshal.ReleaseComObject(pCursor);
            Marshal.ReleaseComObject(tableSort);
            Marshal.ReleaseComObject(pCodeTable);

            List <IBasicLayerInfo> basicInfos = new List <IBasicLayerInfo>();

            pCodeTable       = _workspace.OpenTable("YT_PIPE_LAYER");
            tableSort        = new TableSortClass();
            tableSort.Table  = pCodeTable;
            tableSort.Fields = "Priority,LayerName";
            tableSort.Sort(null);
            pCursor      = tableSort.Rows;
            pRow         = pCursor.NextRow();
            fieldIndexes = new int[8];

            fieldIndexes[0] = pRow.Fields.FindField("PipeCode");
            fieldIndexes[1] = pRow.Fields.FindField("BasicName");
            fieldIndexes[2] = pRow.Fields.FindField("LayerName");
            fieldIndexes[3] = pRow.Fields.FindField("AutoNames");
            fieldIndexes[4] = pRow.Fields.FindField("Priority");
            fieldIndexes[5] = pRow.Fields.FindField("DataType");
            fieldIndexes[6] = pRow.Fields.FindField("Template");
            fieldIndexes[7] = pRow.Fields.FindField("Domains");
            while (pRow != null)
            {
                string         pipeCode = pRow.Value[fieldIndexes[0]].ToString();
                IPipelineLayer oneLayer = layers.Find(c => c.Code == pipeCode);
                if (oneLayer == null)
                {
                    pRow = pCursor.NextRow();
                    continue;
                }
                enumPipelineDataType dataType =
                    Yutai.Pipeline.Config.Helpers.EnumHelper.ConvertDataTypeFromString(
                        pRow.Value[fieldIndexes[5]].ToString().Trim());
                IBasicLayerInfo basicLayer = new BasicLayerInfo()
                {
                    Name         = pRow.Value[fieldIndexes[1]].ToString(),
                    AliasName    = pRow.Value[fieldIndexes[2]].ToString(),
                    AutoNames    = pRow.Value[fieldIndexes[3]].ToString(),
                    DataType     = dataType,
                    TemplateName = pRow.Value[fieldIndexes[6]].ToString(),
                    Fields       = new List <IYTField>()
                };
                if (pRow.Value[fieldIndexes[6]] != null)
                {
                    IPipelineTemplate template = templates.Find(c => c.Name == basicLayer.TemplateName);
                    if (template != null)
                    {
                        foreach (IYTField field in template.Fields)
                        {
                            basicLayer.Fields.Add(new YTField(field));
                        }
                    }
                }

                string domainStr = pRow.Value[fieldIndexes[7]] == DBNull.Value
                    ? string.Empty
                    : pRow.Value[fieldIndexes[7]].ToString();
                if (!string.IsNullOrEmpty(domainStr))
                {
                    //获得Domainzhi值
                    string[] domainPairs = domainStr.Split('/');
                    for (int j = 0; j < domainPairs.Length; j++)
                    {
                        string[]  domainPair = domainPairs[j].Split(':');
                        string    fieldName  = domainPair[0];
                        string    domainName = domainPair[1];
                        IYTDomain findDomain = domains.FirstOrDefault(c => c.DomainName == domainName);
                        if (findDomain != null)
                        {
                            IYTField pField = basicLayer.Fields.FirstOrDefault(c => c.TypeName == fieldName);
                            if (pField != null)
                            {
                                pField.Domain = new YTDomain(findDomain.DomainName, findDomain.DomainValues);
                            }
                        }
                    }
                }

                oneLayer.Layers.Add(basicLayer);
                pRow = pCursor.NextRow();
            }
            Marshal.ReleaseComObject(pCursor);
            Marshal.ReleaseComObject(tableSort);
            Marshal.ReleaseComObject(pCodeTable);
            return(layers);
        }
Пример #14
0
        //! 依据数据库内配置识别当前地图图层
        public void OrganizeMap(IMap pMap)
        {
            _layers.Clear();
            if (_dbLayers == null || _dbLayers.Count == 0)
            {
                _dbLayers = ReadLayersFromDatabase();
            }

            //先读取Map里面的图层,并按照Workspace进行组织,有点类似启动编辑时候的整理
            IArray arrayClass = ConfigHelper.OrganizeMapWorkspaceAndLayer(pMap);

            //图层已经按照Workspace组织,在一个Workspace里面,不允许有同名称的管线图层存在,而且在配置里面,不是依据图层,而是依据要素类,因为在实际中有可能一个要素类被渲染成好几个图层
            for (int i = 0; i < arrayClass.Count; i++)
            {
                PipeWorkspaceInfo workspaceInfo = arrayClass.Element[i] as PipeWorkspaceInfo;

                for (int j = 0; j < workspaceInfo.ClassArray.Count; j++)
                {
                    IFeatureClass pClass    = workspaceInfo.ClassArray.Element[j] as IFeatureClass;
                    string        className = ((IDataset)pClass).Name;
                    string        shortName = ConfigHelper.GetClassShortName(className);
                    bool          findExist = false;
                    foreach (IPipelineLayer existLayer in _layers)
                    {
                        // if(existLayer.Workspace.ConnectionProperties != workspaceInfo.Workspace.ConnectionProperties)
                        if (existLayer.Workspace.PathName != workspaceInfo.Workspace.PathName)
                        {
                            continue;
                        }
                        bool back = existLayer.OrganizeFeatureClass(pClass);
                        if (back)
                        {
                            findExist = true;
                            break;
                        }
                        IPipelineLayer newLayer = existLayer.NewOrganizeFeatureClass(pClass);

                        if (newLayer != null)
                        {
                            newLayer.Workspace = workspaceInfo.Workspace;
                            _layers.Add(newLayer);
                            findExist = true;
                            break;
                        }
                    }
                    if (findExist)
                    {
                        continue;
                    }
                    foreach (IPipelineLayer dbLayer in _dbLayers)
                    {
                        IPipelineLayer newLayer = dbLayer.NewOrganizeFeatureClass(pClass);

                        if (newLayer != null)
                        {
                            IPipelineLayer pSaveLayer = newLayer.Clone(true);
                            newLayer.Workspace = workspaceInfo.Workspace;
                            _layers.Add(newLayer);
                            break;
                        }
                    }
                }
            }
            for (int i = _layers.Count - 1; i >= 0; i--)
            {
                IPipelineLayer oneLayer = _layers[i];
                for (int j = oneLayer.Layers.Count - 1; j >= 0; j--)
                {
                    IBasicLayerInfo layerInfo = oneLayer.Layers[j];
                    if (layerInfo.FeatureClass == null)
                    {
                        oneLayer.Layers.Remove(layerInfo);
                    }
                }
                if (oneLayer.Layers == null || oneLayer.Layers.Count == 0)
                {
                    _layers.Remove(oneLayer);
                }
            }
        }
Пример #15
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("所选择的管线多于一条,或者不是管线!");
            }
        }
Пример #16
0
        public void Analyse_Horizontal(IFeatureCursor pFeaCursor)
        {
            double             double1    = this.double_1 * 0.0005;
            IProximityOperator ipolyline1 = (IProximityOperator)this.baselineSimpleLine;
            IFeature           feature    = pFeaCursor.NextFeature();

            if (feature == null)
            {
                return;
            }
            int num  = -1;
            int num1 = -1;
            int num2 = -1;


            IBasicLayerInfo lineConfig     = m_config.GetBasicLayerInfo(feature.Class.AliasName) as IBasicLayerInfo;
            IPipelineLayer  pipelineLayer  = m_config.GetPipelineLayer(feature.Class as IFeatureClass);
            IPipelineLayer  pipelineLayer0 = m_config.GetPipelineLayer(baselineFC);

            num  = feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GJ));
            num1 = feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.DMCC));
            num2 = feature.Fields.FindField(lineConfig.GetFieldName(PipeConfigWordHelper.LineWords.GDXZ));

            if (num2 >= 0)
            {
                if ((num >= 0 ? true : num1 >= 0))
                {
                    while (feature != null)
                    {
                        IPolyline polyline = this.SimplifyPolyline(feature.Shape as IPolyline);
                        double    num3     = 0;
                        double    num4     = this.GetPipeGJ(feature, num, num1, out num3);
                        if (num4 < 10)
                        {
                            num4 = 10;
                        }
                        num4 = num4 * 0.0005;
                        double num5 = ipolyline1.ReturnDistance(polyline);
                        num5 = num5 - double1 - num4;
                        if (num5 >= 0.001)
                        {
                            string            str   = feature.get_Value(num2).ToString();
                            CHitAnalyse.CItem cItem = new CHitAnalyse.CItem()
                            {
                                _OID          = feature.OID,
                                _sKind        = str,
                                _dHorDistance = num5,
                                _dHorBase     = 0,
                                _pClass       = (IFeatureClass)feature.Class
                            };
                            cItem._dHorBase =
                                (double)
                                CommonUtils.GetPipeLineAlarmHrzDistByFeatureClassName2(m_config,
                                                                                       baselineFC.AliasName, feature.Class.AliasName, this.baseFeature, feature);
                            this.list_0.Add(cItem);
                            feature = pFeaCursor.NextFeature();
                        }
                        else
                        {
                            feature = pFeaCursor.NextFeature();
                        }
                    }
                }
            }
        }
Пример #17
0
 public Pipeline3DItem(I3DBuilder builder, IPipelineLayer pipelineLayer)
 {
     _3DBuilder     = builder;
     _pipelineLayer = pipelineLayer;
 }