public override void OnClick(object sender, EventArgs args) { if (_plugin.CurrentLayer == null) { MessageBox.Show(@"未设置当前编辑图层!"); _context.ClearCurrentTool(); return; } IBasicLayerInfo pointLayerInfo = _plugin.CurrentLayer.Layers.FirstOrDefault(c => c.DataType == enumPipelineDataType.Point); if (pointLayerInfo != null) { _pointFeatureLayer = CommonHelper.GetLayerByName(_context.FocusMap, pointLayerInfo.AliasName, true) as IFeatureLayer; } IBasicLayerInfo lineLayerInfo = _plugin.CurrentLayer.Layers.FirstOrDefault(c => c.DataType == enumPipelineDataType.Line); if (lineLayerInfo != null) { _lineFeatureLayer = CommonHelper.GetLayerByName(_context.FocusMap, lineLayerInfo.AliasName, true) as IFeatureLayer; } if (_pointFeatureLayer == null || _lineFeatureLayer == null) { MessageBox.Show(@"点图层或线图层未设置!"); _context.ClearCurrentTool(); return; } _context.SetCurrentTool(this); _pointSnapper = new PointSnapper(); (_pointSnapper as PointSnapper).Map = _context.FocusMap; }
private void FillFeatureValue(IBasicLayerInfo pipeLine, string value, IFeature feature, double num, double num2, double num3) { Regex regex = new Regex("^[\\u4e00-\\u9fa5]+$"); DataRow pRow = _table.NewRow(); pRow["管线名称"] = pipeLine.Name; pRow["规范埋深"] = string.Format("{0:f2}", num); pRow["起点埋深"] = string.Format("{0:f2}", num2); pRow["终点埋深"] = string.Format("{0:f2}", num3); pRow["管线类别"] = value; pRow["对象"] = feature.Shape; for (int j = 0; j < feature.Fields.FieldCount; j++) { string name2 = feature.Fields.get_Field(j).Name; if (regex.IsMatch(name2)) { pRow[name2] = feature.get_Value(j); } } _table.Rows.Add(pRow); // this.gridView1.Columns["ObjShape"].Visible = false; }
public List <FeatureItem> Check() { List <FeatureItem> list = new List <FeatureItem>(); foreach (IPipelineLayer pipelineLayer in _dataCheck.PipelineLayers) { if (_worker != null && _worker.CancellationPending) { return(list); } if (_dataCheck.CheckPipelineList.Contains(pipelineLayer.Code)) { IBasicLayerInfo pointLayerInfo = pipelineLayer.Layers.FirstOrDefault(c => c.DataType == enumPipelineDataType.Point); IBasicLayerInfo lineLayerInfo = pipelineLayer.Layers.FirstOrDefault(c => c.DataType == enumPipelineDataType.Line); if (pointLayerInfo == null || lineLayerInfo == null || pointLayerInfo.FeatureClass == null || lineLayerInfo.FeatureClass == null) { continue; } list.AddRange(Check(pipelineLayer.Name, pointLayerInfo.FeatureClass, lineLayerInfo.FeatureClass, pointLayerInfo.GetFieldName(PipeConfigWordHelper.PointWords.GDBH), lineLayerInfo.GetFieldName(PipeConfigWordHelper.LineWords.QDBH), lineLayerInfo.GetFieldName(PipeConfigWordHelper.LineWords.ZDBH))); } } return(list); }
public List <FeatureItem> Check() { List <FeatureItem> list = new List <FeatureItem>(); foreach (IPipelineLayer pipelineLayer in _dataCheck.PipelineLayers) { if (_worker != null && _worker.CancellationPending) { return(list); } if (_dataCheck.CheckPipelineList.Contains(pipelineLayer.Code)) { IBasicLayerInfo pointBasicLayerInfo = pipelineLayer.Layers.FirstOrDefault(c => c.DataType == enumPipelineDataType.Point); if (pointBasicLayerInfo?.FeatureClass == null) { continue; } list.AddRange(CheckPoint(pipelineLayer.Name, pointBasicLayerInfo.FeatureClass)); IBasicLayerInfo lineBasicLayerInfo = pipelineLayer.Layers.FirstOrDefault(c => c.DataType == enumPipelineDataType.Line); if (lineBasicLayerInfo?.FeatureClass == null) { continue; } list.AddRange(CheckLine(pipelineLayer.Name, lineBasicLayerInfo.FeatureClass)); } } return(list); }
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); }
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)); } }
public List <FeatureItem> CheckPoint(string pipelineName, IFeatureClass featureClass) { List <FeatureItem> list = new List <FeatureItem>(); IFeatureCursor featureCursor = featureClass.Search(null, false); IFeature feature; while ((feature = featureCursor.NextFeature()) != null) { if (_worker != null && _worker.CancellationPending) { return(list); } IPoint point = feature.Shape as IPoint; if (point == null || point.IsEmpty) { list.Add(new FeatureItem(feature) { PipelineName = pipelineName, PipeLayerName = featureClass.AliasName, CheckItem = "最小间距检查", ErrDesc = "几何图形为空", }); continue; } foreach (IPipelineLayer checkPipelineLayer in _dataCheck.PipelineLayers) { if (_worker != null && _worker.CancellationPending) { return(list); } if (_dataCheck.CheckPipelineList.Contains(checkPipelineLayer.Code)) { IBasicLayerInfo pointBasicLayerInfo = checkPipelineLayer.Layers.FirstOrDefault(c => c.DataType == enumPipelineDataType.Point); if (pointBasicLayerInfo?.FeatureClass == null) { continue; } string msg = CheckPoint(checkPipelineLayer.Name, point, pointBasicLayerInfo.FeatureClass); if (string.IsNullOrWhiteSpace(msg)) { continue; } list.Add(new FeatureItem(feature) { PipelineName = pipelineName, PipeLayerName = featureClass.AliasName, CheckItem = "最小间距检查", ErrDesc = msg }); } } } Marshal.ReleaseComObject(featureCursor); return(list); }
private void FillFieldValuesToListBox(IFeatureLayer pFeaLay, ListBox lbVal) { IFeatureClass featureClass = pFeaLay.FeatureClass; IBasicLayerInfo layerInfo = pPipeCfg.GetBasicLayerInfo(featureClass); IQueryFilter queryFilter = new QueryFilter(); IFeatureCursor featureCursor = featureClass.Search(queryFilter, false); IFeature feature = featureCursor.NextFeature(); int num = featureClass.Fields.FindField(layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.QDMS)); int num2 = featureClass.Fields.FindField(layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.ZDMS)); if (num != -1 && num2 != -1) { double num3 = 2147483647.0; double num4 = -2147483648.0; this.minNum = 2147483647.0; this.maxNum = -2147483648.0; while (feature != null) { try { object obj = feature.Value[num].ToString(); object obj2 = feature.Value[num2].ToString(); if (Convert.IsDBNull(obj)) { continue; } if (Convert.IsDBNull(obj2)) { continue; } double num5 = Convert.ToDouble(obj); double num6 = Convert.ToDouble(obj2); num3 = ((num3 < num5) ? num3 : num5); num3 = ((num3 < num6) ? num3 : num6); num4 = ((num4 > num5) ? num4 : num5); num4 = ((num4 > num6) ? num4 : num6); feature = featureCursor.NextFeature(); } catch (Exception) { return; } if (num3 < this.minNum) { this.minNum = num3; } if (num4 > this.maxNum) { this.maxNum = num4; } } this.all(); } }
public override void OnClick(object sender, EventArgs args) { if (_plugin.CurrentLayer == null) { MessageBox.Show(@"未设置当前编辑图层!"); _context.ClearCurrentTool(); return; } IBasicLayerInfo pointLayerInfo = _plugin.CurrentLayer.Layers.FirstOrDefault(c => c.DataType == enumPipelineDataType.Point); if (pointLayerInfo != null) { _gdbhFieldName = pointLayerInfo.GetFieldName(PipeConfigWordHelper.PointWords.GDBH); _dmgcFieldName = pointLayerInfo.GetFieldName(PipeConfigWordHelper.PointWords.DMGC); _pointFeatureLayer = CommonHelper.GetLayerByName(_context.FocusMap, pointLayerInfo.AliasName, true) as IFeatureLayer; _idxGdbhField = _pointFeatureLayer.FeatureClass.FindField(_gdbhFieldName); _idxDmgcField = _pointFeatureLayer.FeatureClass.FindField(_dmgcFieldName); } IBasicLayerInfo lineLayerInfo = _plugin.CurrentLayer.Layers.FirstOrDefault(c => c.DataType == enumPipelineDataType.Line); if (lineLayerInfo != null) { _qdbhFieldName = lineLayerInfo.GetFieldName(PipeConfigWordHelper.LineWords.QDBH); _zdbhFieldName = lineLayerInfo.GetFieldName(PipeConfigWordHelper.LineWords.ZDBH); _qdmsFieldName = lineLayerInfo.GetFieldName(PipeConfigWordHelper.LineWords.QDMS); _zdmsFieldName = lineLayerInfo.GetFieldName(PipeConfigWordHelper.LineWords.ZDMS); _qdgcFieldName = lineLayerInfo.GetFieldName(PipeConfigWordHelper.LineWords.QDGC); _zdgcFieldName = lineLayerInfo.GetFieldName(PipeConfigWordHelper.LineWords.ZDGC); _lineFeatureLayer = CommonHelper.GetLayerByName(_context.FocusMap, lineLayerInfo.AliasName, true) as IFeatureLayer; _idxQdbhField = _lineFeatureLayer.FeatureClass.FindField(_qdbhFieldName); _idxZdbhField = _lineFeatureLayer.FeatureClass.FindField(_zdbhFieldName); _idxQdmsField = _lineFeatureLayer.FeatureClass.FindField(_qdmsFieldName); _idxZdmsField = _lineFeatureLayer.FeatureClass.FindField(_zdmsFieldName); _idxQdgcField = _lineFeatureLayer.FeatureClass.FindField(_qdgcFieldName); _idxZdgcField = _lineFeatureLayer.FeatureClass.FindField(_zdgcFieldName); } if (_pointFeatureLayer == null || _lineFeatureLayer == null) { MessageBox.Show(@"点图层或线图层未设置!"); _context.ClearCurrentTool(); return; } IEnumFeature featureSelection = _context.FocusMap.FeatureSelection as IEnumFeature; featureSelection.Reset(); _feature = featureSelection.Next(); if (_feature == null) { MessageBox.Show(@"未选择将打断的线要素!"); _context.ClearCurrentTool(); return; } _context.SetCurrentTool(this); }
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("阀门井"); } }
public IYTField GetSpecialField(string classAliasName, string typeWord) { IBasicLayerInfo layer = GetBasicLayerInfo(classAliasName); if (layer == null) { return(null); } IYTField field = layer.Fields.FirstOrDefault(c => c.TypeName == typeWord); return(field); }
private List <FeatureItem> Check(IBasicLayerInfo basicLayerInfo, string pipelineName) { List <FeatureItem> list = new List <FeatureItem>(); IDictionary <int, IYTField> fieldDictionary = new Dictionary <int, IYTField>(); foreach (IYTField ytField in basicLayerInfo.Fields) { if (ytField.AllowNull) { continue; } IFields fields = basicLayerInfo.FeatureClass.Fields; if (string.IsNullOrWhiteSpace(ytField.Name)) { continue; } int idx = fields.FindField(ytField.Name); if (idx < 0) { continue; } fieldDictionary.Add(idx, ytField); } IFeatureCursor featureCursor = basicLayerInfo.FeatureClass.Search(null, false); IFeature feature; while ((feature = featureCursor.NextFeature()) != null) { if (_worker != null && _worker.CancellationPending) { return(list); } foreach (KeyValuePair <int, IYTField> keyValuePair in fieldDictionary) { object curValue = feature.Value[keyValuePair.Key]; if (curValue == null || curValue is DBNull || string.IsNullOrWhiteSpace(curValue.ToString())) { list.Add(new FeatureItem(feature) { PipelineName = pipelineName, PipeLayerName = basicLayerInfo.FeatureClass.AliasName, CheckItem = "字段完整性检查", ErrDesc = "字段 " + keyValuePair.Value.Name + " 为空值", }); } } } return(list); }
private void ValidateField() { int selectedIndex = this.LayerBox.SelectedIndex; if (selectedIndex >= 0) { this.SelectLayer = null; if (this.MapControl != null) { this.SelectLayer = ((SimpleQueryByDiaUI.LayerboxItem) this.LayerBox.SelectedItem).m_pPipeLayer; if (this.SelectLayer != null) { IBasicLayerInfo layerInfo = pPipeCfg.GetBasicLayerInfo(this.SelectLayer.FeatureClass); this.myfields = this.SelectLayer.FeatureClass.Fields; this.strGJ = layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.GJ); ; this.strKG = layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.DMCC); ; if (this.myfields.FindField(this.strGJ) < 0) { this.radioButton1.Enabled = false; this.OperateBox.Enabled = false; this.ValueBox1.Enabled = false; this.ValueBox2.Enabled = false; this.radioButton1.Checked = false; } else { this.radioButton1.Enabled = true; this.OperateBox.Enabled = true; this.ValueBox1.Enabled = true; this.ValueBox2.Enabled = true; } if (this.myfields.FindField(this.strKG) < 0) { this.radioButton2.Enabled = false; this.radioButton2.Checked = false; this.OperateBox2.Enabled = false; this.ValueBox3.Enabled = false; } else { this.radioButton2.Enabled = true; this.OperateBox2.Enabled = true; this.ValueBox3.Enabled = true; } } } } }
private void FillFieldValuesToListBox(IFeatureLayer pFeaLay, ListBox lbVal) { IFeatureClass featureClass = pFeaLay.FeatureClass; IBasicLayerInfo layerInfo = pPipeCfg.GetBasicLayerInfo(featureClass); IQueryFilter queryFilter = new QueryFilter(); IFeatureCursor featureCursor = featureClass.Search(queryFilter, false); IFeature feature; _idxQdms = featureClass.Fields.FindField(layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.QDMS)); _idxZdms = featureClass.Fields.FindField(layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.ZDMS)); if (_idxQdms != -1 && _idxZdms != -1) { double num3 = 2147483647.0; double num4 = -2147483648.0; this.minNum = 2147483647.0; this.maxNum = -2147483648.0; while ((feature = featureCursor.NextFeature()) != null) { try { double num5 = ConvertToDouble(feature.Value[_idxQdms]); double num6 = ConvertToDouble(feature.Value[_idxZdms]); if (double.IsNaN(num5) || double.IsNaN(num6)) { continue; } num3 = ((num3 < num5) ? num3 : num5); num3 = ((num3 < num6) ? num3 : num6); num4 = ((num4 > num5) ? num4 : num5); num4 = ((num4 > num6) ? num4 : num6); } catch (Exception exception) { continue; } if (num3 < this.minNum) { this.minNum = num3; } if (num4 > this.maxNum) { this.maxNum = num4; } } this.all(); } }
private bool ValidateField() { int selectedIndex = this.LayerBox.SelectedIndex; bool result; if (selectedIndex < 0) { result = false; } else { this.SelectLayer = null; if (this.MapControl == null) { result = false; } else { this.SelectLayer = ((SimpleQueryByJdxzUI.LayerboxItem) this.LayerBox.SelectedItem).m_pPipeLayer; if (this.SelectLayer == null) { result = false; } else { this.myfields = this.SelectLayer.FeatureClass.Fields; IBasicLayerInfo layerInfo = pPipeCfg.GetBasicLayerInfo(this.SelectLayer.FeatureClass); this.strDX = layerInfo.GetFieldName(PipeConfigWordHelper.PointWords.TZW); // this.pPipeCfg.GetPointTableFieldName("点性"); if (this.myfields.FindField(this.strDX) < 0) { this.QueryBut.Enabled = false; result = false; } else { this.QueryBut.Enabled = true; result = true; } } } } return(result); }
private bool FindPipePointLayer() { int selectedIndex = this.LayerBox.SelectedIndex; bool result; if (selectedIndex < 0) { result = false; } else { this.ifeatureLayer_0 = null; if (this.MapControl == null) { result = false; } else { string strDstName = this.LayerBox.SelectedItem.ToString(); this.ifeatureLayer_0 = (IFeatureLayer)CommonUtils.GetLayerByName(this.m_iApp.FocusMap, strDstName); if (this.ifeatureLayer_0 == null) { result = false; } else { IBasicLayerInfo basicLayerInfo = pPipeCfg.GetBasicLayerInfo(ifeatureLayer_0.FeatureClass); if (basicLayerInfo.DataType != enumPipelineDataType.Point) { this.btnAnalyse.Enabled = false; result = false; } else { this.btnAnalyse.Enabled = true; _basicLayerInfo = basicLayerInfo; //string values=basicLayerInfo.GetField(PipeConfigWordHelper.PointWords.FSW).DomainValues; FillValues(); result = true; } } } } return(result); }
//!+ 自动识别图层并匹配配置,这个时候是这个图层组中有图层已经被识别 public bool OrganizeFeatureClass(IFeatureClass featureClass) { //! 因为图层是按照工作空间组织的,所以图层不可能被重复,也就是说一个工作控件里面的图层只可能识别一次 string ownerName = ConfigHelper.GetClassOwnerName(((IDataset)featureClass).FullName.NameString); string baseName = ConfigHelper.GetClassShortName(featureClass); string classAliasName = featureClass.AliasName; string autoStr = "/" + _autoNames + "/"; IBasicLayerInfo layerInfo = _layers.FirstOrDefault( c => c.Name == baseName || c.AliasName == baseName || c.FixAutoNames.ToUpper().Replace("_", "").Contains("/" + baseName.ToUpper().Replace("_", "") + "/")); if (layerInfo != null && layerInfo.FeatureClass == null) { layerInfo.FeatureClass = featureClass; return(true); } return(false); }
public void FillValue() { if (this.myfields != null) { IFeatureClass featureClass = this.SelectLayer.FeatureClass; IBasicLayerInfo layerInfo = pPipeCfg.GetBasicLayerInfo(featureClass); int num = this.myfields.FindField(layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.QDMS)); if (num > 0) { this.myfield = this.myfields.Field[num]; this.listBox1.Items.Clear(); List <string> values = new List <string>(); CommonHelper.GetUniqueValues((ITable)featureClass, layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.QDMS), values); this.listBox1.Items.AddRange(values.ToArray()); } } }
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; } }
public BasicLayerInfo(IBasicLayerInfo info, bool keepClass) { _name = info.Name; _autoNames = info.AutoNames; _aliasName = info.AliasName; _visible = info.Visible; _dataType = info.DataType; _heightType = info.HeightType; _validateKeys = info.ValidateKeys; _templateName = info.TemplateName; _fields = new List <IYTField>(); foreach (IYTField infoField in info.Fields) { _fields.Add(infoField.Clone(keepClass)); } if (keepClass) { _featureClass = info.FeatureClass; _esriClassName = info.EsriClassName; } }
public IPipelineLayer NewOrganizeFeatureClass(IFeatureClass featureClass) { string ownerName = ConfigHelper.GetClassOwnerName(((IDataset)featureClass).Name); string baseName = ConfigHelper.GetClassShortName(featureClass); string classAliasName = featureClass.AliasName; string autoStr = "/" + _autoNames + "/"; IBasicLayerInfo layerInfo = _layers.FirstOrDefault( c => c.Name.ToUpper() == baseName.ToUpper() || c.AliasName.ToUpper() == baseName.ToUpper() || autoStr.Contains("/" + baseName + "/") || c.AutoNames.ToUpper().Replace("_", "").Contains(baseName.ToUpper().Replace("_", ""))); if (layerInfo != null) { IPipelineLayer pipeLayer = new PipelineLayer(this, false); layerInfo = pipeLayer.Layers.FirstOrDefault( c => c.Name == baseName || c.AliasName == baseName || autoStr.Contains("/" + baseName + "/") || c.AutoNames.ToUpper().Replace("_", "").Contains(baseName.ToUpper().Replace("_", ""))); layerInfo.FeatureClass = featureClass; return(pipeLayer); } return(null); }
public void GetValues(ArrayList Values) { Values.Clear(); if (this._networkInfo.LayerPoint == null) { return; } IBasicLayerInfo pipePoint = m_Config.GetBasicLayerInfo(this._networkInfo.LayerPoint.FeatureClass.AliasName) as IBasicLayerInfo; //IPipePoint pipePoint = m_Config.GetSubLayer(this._networkInfo.LayerPoint, enumPipelineDataType.Point) as IPipePoint; //string text = CRegOperator.GetRegistryKey().GetValue("节点性质字段值", "").ToString(); string text = pipePoint.GetField(PipeConfigWordHelper.PointWords.FSW).DomainValues; for (int num = text.IndexOf("/"); num != -1; num = text.IndexOf("/")) { Values.Add(text.Substring(0, num)); text = text.Substring(num + 1, text.Length - num - 1); } }
private string GetPipeMSFS(IFeature feature) { string str; string str1; if (feature != null) { IBasicLayerInfo layerInfo = m_config.GetBasicLayerInfo(feature.Class as IFeatureClass); if (layerInfo == null) { return(""); } int num = feature.Fields.FindField(layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.MSFS)); str1 = (num == -1 ? "" : CommonUtils.ObjToString(feature.get_Value(num))); str = str1; } else { str = ""; } return(str); }
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); }
public override void OnClick(object sender, EventArgs args) { if (_plugin.CurrentLayer == null) { MessageBox.Show(@"未设置当前编辑图层!"); _context.ClearCurrentTool(); return; } IBasicLayerInfo pointLayerInfo = _plugin.CurrentLayer.Layers.FirstOrDefault(c => c.DataType == enumPipelineDataType.Point); if (pointLayerInfo != null) { _gdbhFieldName = pointLayerInfo.GetFieldName(PipeConfigWordHelper.PointWords.GDBH); _pointFeatureLayer = CommonHelper.GetLayerByName(_context.FocusMap, pointLayerInfo.AliasName, true) as IFeatureLayer; } IBasicLayerInfo lineLayerInfo = _plugin.CurrentLayer.Layers.FirstOrDefault(c => c.DataType == enumPipelineDataType.Line); if (lineLayerInfo != null) { _qdbhFieldName = lineLayerInfo.GetFieldName(PipeConfigWordHelper.LineWords.QDBH); _zdbhFieldName = lineLayerInfo.GetFieldName(PipeConfigWordHelper.LineWords.ZDBH); _lineFeatureLayer = CommonHelper.GetLayerByName(_context.FocusMap, lineLayerInfo.AliasName, true) as IFeatureLayer; } if (_pointFeatureLayer == null || _lineFeatureLayer == null) { MessageBox.Show(@"点图层或线图层未设置!"); _context.ClearCurrentTool(); return; } _context.SetCurrentTool(this); _pointSnapper = new PointSnapper(); (_pointSnapper as PointSnapper).Map = _context.FocusMap; _tolerance = _context.Config.EngineSnapEnvironment.SnapTolerance; }
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); }
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); }
private bool ValidateField() { int selectedIndex = this.LayerBox.SelectedIndex; bool result; if (selectedIndex < 0) { result = false; } else { this.SelectLayer = null; if (this.MapControl == null) { result = false; } else { this.SelectLayer = ((SimpleQueryByAddressUI1.LayerboxItem) this.LayerBox.SelectedItem).m_pPipeLayer; if (this.SelectLayer == null) { result = false; } else { this.myfields = this.SelectLayer.FeatureClass.Fields; IBasicLayerInfo layerInfo = pPipeCfg.GetBasicLayerInfo(this.SelectLayer.FeatureClass); if (this.radioButton1.Checked) { this.FieldBox.Text = layerInfo.GetFieldName(PipeConfigWordHelper.PointWords.SZDL); // this.pPipeCfg.GetPointTableFieldName("所在道路"); this.FindField = layerInfo.GetFieldName(PipeConfigWordHelper.PointWords.TZW); // this.pPipeCfg.GetPointTableFieldName("点性"); } else { this.FieldBox.Text = layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.SZDL); // this.pPipeCfg.GetLineTableFieldName("所在道路"); this.FindField = layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.GJ); // this.pPipeCfg.GetLineTableFieldName("管径"); this.FindField1 = layerInfo.GetFieldName(PipeConfigWordHelper.LineWords.DMCC); // this.pPipeCfg.GetLineTableFieldName("断面尺寸"); } if (this.myfields.FindField(this.FindField) < 0 && this.myfields.FindField(this.FindField1) < 0) { this.ValueBox.Enabled = false; this.AllBut.Enabled = false; this.NoneBut.Enabled = false; this.RevBut.Enabled = false; } else { this.ValueBox.Enabled = true; this.AllBut.Enabled = true; this.NoneBut.Enabled = true; this.RevBut.Enabled = true; } if (this.myfields.FindField(this.FieldBox.Text) < 0) { this.QueryBut.Enabled = false; result = false; } else { this.QueryBut.Enabled = true; result = true; } } } } return(result); }
public static object GetPipeLineAlarmHrzDist2(IPipelineConfig config, string strPipeLine1, string strPipeLine2, IFeature pFeature1, IFeature pFeature2, IBasicLayerInfo basicLayer1, IBasicLayerInfo basicLayer2) { object obj; double num; double num1; double num2; double num3; double num4; double num5; double num6; double num7; ITable table = CommonUtils.GetTable(config, "YT_PIPE_HORLIMITED"); if (table != null) { string[] strArrays = new string[] { "(CLASSCODE1 = '", strPipeLine1, "' AND CLASSCODE2 = '", strPipeLine2, "')" }; string str = string.Concat(strArrays); strArrays = new string[] { str, " OR (CLASSCODE1 = '", strPipeLine2, "' AND CLASSCODE2 = '", strPipeLine1, "')" }; string str1 = string.Concat(strArrays); IQueryFilter queryFilterClass = new QueryFilter(); queryFilterClass.WhereClause = (str1); ICursor cursor = table.Search(queryFilterClass, false); IRow row = cursor.NextRow(); int fieldIndex = CommonUtils.GetFieldIndex(table, "CONDITION1"); int fieldIndex1 = CommonUtils.GetFieldIndex(table, "CONDITION2"); int fieldIndex2 = CommonUtils.GetFieldIndex(table, "RANGE1"); int fieldIndex3 = CommonUtils.GetFieldIndex(table, "RANGE2"); int fieldIndex4 = CommonUtils.GetFieldIndex(table, "LIMITED"); string strCondition1 = ""; string strCondition2 = ""; string strRange1 = ""; string strRange2 = ""; double num8 = -1; double num9 = -1; double num10 = -1; double num11 = -1; while (row != null) { strCondition1 = CommonUtils.ObjToString(row.get_Value(fieldIndex)); strCondition2 = CommonUtils.ObjToString(row.get_Value(fieldIndex1)); strRange1 = CommonUtils.ObjToString(row.get_Value(fieldIndex2)); strRange2 = CommonUtils.ObjToString(row.get_Value(fieldIndex3)); double dblLimited = CommonUtils.ObjToDouble(row.get_Value(fieldIndex4)); if ((strCondition1 != "" ? false : strCondition2 == "")) { num8 = dblLimited; } string lineTableFieldName = basicLayer1.GetFieldName(PipeConfigWordHelper.LineWords.GJ); if ((pFeature1 == null ? false : strCondition1 == PipeConfigWordHelper.LineWords.GJ)) { int num13 = pFeature1.Fields.FindField(lineTableFieldName); if (num13 != -1) { string str6 = CommonUtils.ObjToString(pFeature1.get_Value(num13)); double num14 = -1; try { num14 = Convert.ToDouble(str6); } catch (Exception exception) { } CommonUtils.GetMaxAndMinValue(strRange1, out num, out num1); if ((num14 > num ? false : num14 >= num1)) { num9 = dblLimited; } } } string lineTableFieldName1 = basicLayer2.GetFieldName(PipeConfigWordHelper.LineWords.GJ); if (strCondition2 == PipeConfigWordHelper.LineWords.GJ) { int num15 = pFeature2.Fields.FindField(lineTableFieldName1); if (num15 != -1) { string str7 = CommonUtils.ObjToString(pFeature2.get_Value(num15)); double num16 = -1; try { num16 = Convert.ToDouble(str7); } catch (Exception exception1) { } CommonUtils.GetMaxAndMinValue(strRange2, out num2, out num3); if ((num16 > num2 ? false : num16 >= num3)) { num10 = dblLimited; } } } lineTableFieldName = basicLayer1.GetFieldName(PipeConfigWordHelper.LineWords.YL); if ((pFeature1 == null ? false : strCondition1 == PipeConfigWordHelper.LineWords.YL)) { int num17 = pFeature1.Fields.FindField(lineTableFieldName); if (num17 != -1) { string str8 = CommonUtils.ObjToString(pFeature1.get_Value(num17)); if (str8 == "低压") { str8 = "0.043"; } else if (str8 == "中压") { str8 = "0.2"; } else if (str8 == "高压") { str8 = "0.8"; } double num18 = -1; try { num18 = Convert.ToDouble(str8); } catch (Exception exception2) { } CommonUtils.GetMaxAndMinValue(strRange1, out num4, out num5); if ((num18 > num4 ? false : num18 >= num5)) { num9 = dblLimited; } } } lineTableFieldName = basicLayer2.GetFieldName(PipeConfigWordHelper.LineWords.YL); if (strCondition2 == PipeConfigWordHelper.LineWords.YL) { int num19 = pFeature2.Fields.FindField(lineTableFieldName); if (num19 != -1) { string str9 = CommonUtils.ObjToString(pFeature2.get_Value(num19)); if (str9 == "低压") { str9 = "0.043"; } else if (str9 == "中压") { str9 = "0.2"; } else if (str9 == "高压") { str9 = "0.8"; } double num20 = -1; try { num20 = Convert.ToDouble(str9); } catch (Exception exception3) { } CommonUtils.GetMaxAndMinValue(strRange2, out num6, out num7); if ((num20 > num6 ? false : num20 >= num7)) { num10 = dblLimited; } } } lineTableFieldName = basicLayer1.GetFieldName(PipeConfigWordHelper.LineWords.MSFS); ; if ((pFeature1 == null ? false : strCondition1 == PipeConfigWordHelper.LineWords.MSFS)) { int num21 = pFeature1.Fields.FindField(lineTableFieldName); if (num21 != -1 && CommonUtils.ObjToString(pFeature1.get_Value(num21)).Trim().ToUpper() == strRange1.ToUpper()) { num9 = dblLimited; } } lineTableFieldName = basicLayer2.GetFieldName(PipeConfigWordHelper.LineWords.MSFS); ; if (strCondition2 == PipeConfigWordHelper.LineWords.MSFS) { int num22 = pFeature2.Fields.FindField(lineTableFieldName); if (num22 != -1 && CommonUtils.ObjToString(pFeature2.get_Value(num22)).Trim().ToUpper() == strRange2.ToUpper()) { num9 = dblLimited; } } row = cursor.NextRow(); } Marshal.ReleaseComObject(cursor); double num23 = -1; if (num11 != -1) { num23 = num11; } if (num10 != -1) { num23 = (num23 == -1 ? num10 : Math.Min(num23, num10)); } if (num9 != -1) { num23 = (num23 == -1 ? num9 : Math.Min(num23, num9)); } if (num8 != -1) { num23 = (num23 == -1 ? num8 : Math.Min(num23, num8)); } obj = num23; } else { obj = null; } return(obj); }
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); } }