private void FrmNormalConditionQuery_Load(object sender, EventArgs e) { try { this.cmbLayer.Properties.Items.Clear(); this.lbcCondition.SelectedIndex = 0; oper = " = "; List <DF3DFeatureClass> list = DF3DFeatureClassManager.Instance.GetAllFeatureClass(); if (list != null) { foreach (DF3DFeatureClass dffc in list) { FacilityClass fac = dffc.GetFacilityClass(); if (fac != null && (fac.Name == "PipeLine" || fac.Name == "PipeNode" || fac.Name == "PipeBuild" || fac.Name == "PipeBuild1")) { break; } IBaseLayer treelayer = dffc.GetTreeLayer(); if (treelayer != null && treelayer.Visible == false) { continue; } this.cmbLayer.Properties.Items.Add(dffc); } } } catch (Exception ex) { } }
public void Init() { try { this.cmbLayer.Properties.Items.Clear(); List <DF3DFeatureClass> list = DF3DFeatureClassManager.Instance.GetAllFeatureClass(); if (list != null) { foreach (DF3DFeatureClass dffc in list) { FacilityClass fac = dffc.GetFacilityClass(); if (fac != null && (fac.Name == "PipeLine" || fac.Name == "PipeNode" || fac.Name == "PipeBuild" || fac.Name == "PipeBuild1")) { break; } IBaseLayer treelayer = dffc.GetTreeLayer(); if (treelayer != null && treelayer.Visible == false) { continue; } this.cmbLayer.Properties.Items.Add(dffc); } } } catch (Exception ex) { } }
private void AddHField(IFeatureClass fc) { FacilityClass fac = FacilityClassManager.Instance.GetFacilityClassByName("GCD"); DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName("Height"); if (fi == null) { return; } int index = fc.FindField(fi.Name); if (index == -1) { IField Field = new FieldClass(); IFieldEdit pFieldEdit = Field as IFieldEdit; pFieldEdit.Name_2 = "HEIGHT"; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble; fc.AddField(Field); } else { return; } }
private void CreateNewFC() { Dictionary <string, FacilityClass> dict = new Dictionary <string, FacilityClass>(); List <IBaseLayer> logicBaseTree1GetRootLayers = this.logicBaseTree1.GetRootLayers(); if (logicBaseTree1GetRootLayers != null) { foreach (IBaseLayer layer in logicBaseTree1GetRootLayers) { if (!(layer is TreeNodeFacilityClass)) { continue; } TreeNodeFacilityClass tn = layer as TreeNodeFacilityClass; FacilityClass fc = tn.CustomValue as FacilityClass; dict[fc.Name] = fc; } } FormCreateFacilityClass dlg = new FormCreateFacilityClass(dict); if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { FacilityClass fc = new FacilityClass(dlg.FCName, dlg.FCAlias); TreeNodeFacilityClass treenode = new TreeNodeFacilityClass() { Name = string.IsNullOrEmpty(fc.Alias) ? fc.Name : fc.Alias, CustomValue = fc }; treenode.OwnNode = this.logicBaseTree1.TreeList.AppendNode(new object[] { treenode.Name }, (TreeListNode)null); } }
private bool SaveData(string fileName) { try { XmlDocument document = new XmlDocument(); XmlDeclaration newChild = document.CreateXmlDeclaration("1.0", "utf-8", null); document.AppendChild(newChild); XmlNode node = document.CreateElement("FacilityClassManager"); document.AppendChild(node); List <IBaseLayer> logicBaseTree1GetRootLayers = this.logicBaseTree1.GetRootLayers(); if (logicBaseTree1GetRootLayers != null) { foreach (IBaseLayer layer in logicBaseTree1GetRootLayers) { if (!(layer is TreeNodeFacilityClass)) { continue; } TreeNodeFacilityClass tn = layer as TreeNodeFacilityClass; FacilityClass fc = tn.CustomValue as FacilityClass; if (fc == null) { continue; } XmlElement element = document.CreateElement("FacilityClass"); element.SetAttribute("name", fc.Name.Trim()); element.SetAttribute("alias", layer.Name.Trim()); element.SetAttribute("fc2D", (fc.Fc2D == null) ? "" : fc.Fc2D.Trim()); element.SetAttribute("fc3D", (fc.Fc3D == null) ? "" : fc.Fc3D.Trim()); XmlNode fcNode = node.AppendChild(element); if (fcNode == null) { continue; } foreach (FieldInfo fi in fc.FieldInfoCollection) { XmlElement ele = document.CreateElement("StdField"); ele.SetAttribute("name", fi.Name.Trim()); ele.SetAttribute("alias", fi.Alias.Trim()); ele.SetAttribute("datatype", fi.DataType.Trim()); ele.SetAttribute("systemname", fi.SystemName.Trim()); ele.SetAttribute("systemalias", fi.SystemAlias.Trim()); ele.SetAttribute("canquery", fi.CanQuery ? "true" : "false"); ele.SetAttribute("needcheck", fi.NeedCheck ? "true" : "false"); ele.SetAttribute("canstats", fi.CanStats ? "true" : "false"); fcNode.AppendChild(ele); } } } document.Save(fileName); return(true); } catch (Exception ex) { XtraMessageBox.Show("保存数据失败!", "提示"); return(false); } }
public void SetData(FacilityClass fc) { if (this._fc != null && this._bNeedSave) { if (XtraMessageBox.Show("是否需要保存当前设施类的字段信息?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK) { SaveFieldInfo(); } else { this._bNeedSave = false; } } this._dtGrid.Clear(); this._fc = fc; if (this._fc != null) { foreach (FieldInfo fi in this._fc.FieldInfoCollection) { DataRow dr = this._dtGrid.NewRow(); dr["Name"] = fi.Name; dr["Alias"] = fi.Alias; dr["DataType"] = fi.DataType; dr["SystemName"] = fi.SystemName; dr["SystemAlias"] = fi.SystemAlias; if (fi.CanQuery) { dr["CanQuery"] = "true"; } else { dr["CanQuery"] = "false"; } if (fi.NeedCheck) { dr["NeedCheck"] = "true"; } else { dr["NeedCheck"] = "false"; } if (fi.CanStats) { dr["CanStats"] = "true"; } else { dr["CanStats"] = "false"; } this._dtGrid.Rows.Add(dr); } } }
private void ReadFieldInfo() { List <DF2DFeatureClass> list = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeNode"); if (list == null) { return; } dfcc = list[0]; IFeatureClass fc = dfcc.GetFeatureClass(); if (fc == null) { return; } FacilityClass fcc = dfcc.GetFacilityClass(); List <DFDataConfig.Class.FieldInfo> m_list = fcc.FieldInfoCollection; foreach (DFDataConfig.Class.FieldInfo Field in m_list) { if (Field.NeedCheck) { FieldName = Field.Name + "," + Field.Alias; m_arrPntField.Add(FieldName); } else { continue; } } List <DF2DFeatureClass> nist = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeLine"); if (nist == null) { return; } dfcc = nist[0]; fcc = dfcc.GetFacilityClass(); List <DFDataConfig.Class.FieldInfo> n_list = fcc.FieldInfoCollection; foreach (DFDataConfig.Class.FieldInfo Field in n_list) { if (Field.NeedCheck) { FieldName = Field.Name + "," + Field.Alias; m_arrArcField.Add(FieldName); } else { continue; } } }
private void DoAnalysis() { IFeature pFeature; IGeometry pGeo; IGeometry pPipeLineGeo; IFeatureClass pFeatureClass; IFeatureCursor pFeaCur; ITopologicalOperator pTopo; string scName = ""; int i = 0; foreach (MajorClass mc in LogicDataStructureManage.Instance.GetAllMajorClass()) { string[] arrFc2DId = mc.Fc2D.Split(';');//将二级大类所对应的要素类ID转换为数组 if (arrFc2DId == null) { continue; } foreach (SubClass sc in mc.SubClasses) { if (!sc.Visible2D) { continue; } foreach (string fc2DId in arrFc2DId) //遍历二级子类所对应的要素类ID { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); //根据要素类ID得到DF2DFC if (dffc == null) { continue; } FacilityClass fcc = dffc.GetFacilityClass(); if (fcc.Name != "PipeLine") { continue; } IFeatureLayer fl = dffc.GetFeatureLayer(); ISpatialFilter pSpatialFilter = new SpatialFilterClass(); pSpatialFilter.Geometry = m_pGeoTrack; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; pSpatialFilter.WhereClause = "SMSCODE = '" + sc.Name + "'"; IFeatureClass fc = dffc.GetFeatureClass(); pFeaCur = fc.Search(pSpatialFilter, false); while ((pFeature = pFeaCur.NextFeature()) != null) { DrawPipeInfo(fl, pFeature, i); ++i; } } } } }
public Dictionary <string, string> GetAllPipeLines() { Dictionary <string, string> dict = new Dictionary <string, string>(); try { foreach (MajorClass mc in LogicDataStructureManage2D.Instance.GetAllMajorClass()) //对所有二级大类进行遍历 { string[] arrFc2DId = mc.Fc2D.Split(';'); //将二级大类所对应的要素类ID转换为数组 if (arrFc2DId == null) { continue; } List <IFeature> lines = new List <IFeature>(); bool bHave = false; foreach (SubClass sc in mc.SubClasses)//对当前二级大类的子类进行遍历 { if (!sc.Visible2D) { continue; } foreach (string fc2DId in arrFc2DId) //遍历二级子类所对应的要素类ID { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); //根据要素类ID得到DF2DFC if (dffc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); //得到设施类 IFeatureClass fc = dffc.GetFeatureClass(); //得到要素类 if (fc == null || facc == null || facc.Name != "PipeLine") { continue; } IQueryFilter filter = new QueryFilter(); //filter.WhereClause = UpOrDown.DecorateWhereClasuse(fc).Substring(0, UpOrDown.DecorateWhereClasuse(fc).Length - 4); int count = fc.FeatureCount(filter); bHave = true; dict[mc.Alias] = count.ToString(); break; } if (bHave) { break; } } } return(dict); } catch (System.Exception ex) { return(null); } }
private void ClassQuery(MajorClass mc, MajorClass mctemp, ISpatialFilter filter, IGeometry geo) { if (mc == null || filter == null || geo == null) { return; } string[] arrFc3DId = mc.Fc3D.Split(';'); if (arrFc3DId == null) { return; } foreach (SubClass sc in mc.SubClasses) { if (!sc.Visible3D) { continue; } bool bHave = false; foreach (string fc3DId in arrFc3DId) { DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fc3DId); if (dffc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null || facc == null) { continue; } filter.WhereClause = "GroupId = " + sc.GroupId; int count = fc.GetCount(filter); if (count == 0) { continue; } bHave = true; bHaveRes = true; if (bHave) { break; } } if (bHave) { SubClass sctemp = new SubClass(sc.Name, sc.GroupId, sc.Parent); sctemp.Visible3D = sc.Visible3D; mctemp.SubClasses.Add(sctemp); } } }
public FacilityClass GetFacilityClassByDFFeatureClassID(string id) { foreach (KeyValuePair <string, string> kv in dict) { if (kv.Key == id) { FacilityClass fc = FacilityClassManager.Instance.GetFacilityClassByName(kv.Value); return(fc); } } return(null); }
private IGeoDataset GetBeforeGeo(IFeatureClass fc, IGeometry geo) { try { WaitForm.SetCaption("正在生成栅格表面..."); IInterpolationOp3 pInterpolationOp = new RasterInterpolationOpClass(); IFields fields = fc.Fields; FacilityClass fac = FacilityClassManager.Instance.GetFacilityClassByName("GCD"); DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName("Altitude"); if (fi == null) { return(null); } int index = fields.FindField(fi.Name); if (index == -1) { return(null); } IField field = fields.get_Field(index); ISpatialFilter filter = new SpatialFilter(); filter.Geometry = geo; filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains; int count = fc.FeatureCount(filter); if (count == 0) { return(null); } IFeatureClassDescriptor pFcd = new FeatureClassDescriptorClass(); pFcd.Create(fc, filter, field.Name); //定义搜索半径 IRasterRadius pRadius = new RasterRadiusClass(); object Missing = Type.Missing; pRadius.SetVariable(12, ref Missing); //设置栅格图像的单位大小 object cellSizeProvider = 5; IRasterAnalysisEnvironment pEnv = pInterpolationOp as IRasterAnalysisEnvironment; pEnv.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, ref cellSizeProvider); IGeoDataset outGeoDataset = pInterpolationOp.IDW(pFcd as IGeoDataset, 2, pRadius, ref Missing); return(outGeoDataset); } catch (System.Exception ex) { return(null); WaitForm.Stop(); } }
public List <DF2DFeatureClass> GetFeatureClassByFacilityClass(FacilityClass fc) { List <DF2DFeatureClass> list = new List <DF2DFeatureClass>(); foreach (DF2DFeatureClass temp in DF2DFeatureClassManager.Instance.GetAllFeatureClass()) { if (temp.GetFacilityClass() == fc) { list.Add(temp); } } return(list); }
public static int GetIndex(IFeatureClass fc, string sysFieldName) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc.FeatureClassID.ToString()); FacilityClass fac = dffc.GetFacilityClass(); FieldInfo fi = fac.GetFieldInfoBySystemName(sysFieldName); if (fi == null) { return(-1); } int index = fc.Fields.FindField(fi.Name); return(index); }
private void FrmPipeLineLengthStats_Load(object sender, EventArgs e) { BuildTree(); FacilityClass fac = FacilityClassManager.Instance.GetFacilityClassByName("PipeLine"); if (fac != null) { foreach (DFDataConfig.Class.FieldInfo fi in fac.FieldInfoCollection) { if (fi.CanStats) { this.cbProperty.Properties.Items.Add(fi); } } this.cbProperty.SelectedIndex = 0; } }
private void btnSearch_Click(object sender, EventArgs e) { RestoreEnv(); this._dt.Rows.Clear(); string str = this.teRoadName.Text.Trim(); object obj = this.cmbFCs.SelectedItem; WaitForm.Start("正在搜索...", "请稍后"); try { if (obj == null) { List <DF3DFeatureClass> list = Dictionary3DTable.Instance.GetFeatureClassByFacilityClassName("Road"); if (list != null && list.Count != 0) { foreach (DF3DFeatureClass dffc in list) { IFeatureClass fc = dffc.GetFeatureClass(); FacilityClass fac = dffc.GetFacilityClass(); if (fc != null && fac != null) { SearchRes(fc, fac.GetFieldInfoNameBySystemName("Name"), str); } } } } else { if (obj is DF3DFeatureClass) { DF3DFeatureClass dffc = obj as DF3DFeatureClass; IFeatureClass fc = dffc.GetFeatureClass(); FacilityClass fac = dffc.GetFacilityClass(); if (fc != null && fac != null) { SearchRes(fc, fac.GetFieldInfoNameBySystemName("Name"), str); } } } } catch (Exception ex) { } WaitForm.Stop(); }
public override void Run(object sender, EventArgs e) { List <DF2DFeatureClass> list = Dictionary2DTable.Instance.GetFeatureClassByFacilityClassName("PipeNode"); if (list == null) { return; } foreach (DF2DFeatureClass dffc in list) { IFeatureClass fc = dffc.GetFeatureClass(); if (fc.AliasName == "给水_点") { FacilityClass fac = dffc.GetFacilityClass(); if (fac == null) { continue; } fi = fac.GetFieldInfoBySystemName("Additional"); break; } } mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView; if (mapView == null) { return; } bool bBind = mapView.Bind(this); if (!bBind) { return; } app = (DF2DApplication)this.Hook; if (app == null || app.Current2DMapControl == null) { return; } m_pMapControl = app.Current2DMapControl; m_FocusMap = m_pMapControl.ActiveView.FocusMap; m_pActiveView = (IActiveView)this.m_FocusMap; }
private IFeatureClass GetGCD() { //string path = Config.GetConfigValue("2DMdbPipe"); //IWorkspaceFactory pWsF = new AccessWorkspaceFactory(); //IFeatureWorkspace pFWs = pWsF.OpenFromFile(path, 0) as IFeatureWorkspace; //IFeatureClass pFc = pFWs.OpenFeatureClass("GCD"); //return pFc; FacilityClass fac = FacilityClassManager.Instance.GetFacilityClassByName("GCD"); string[] arrayFc2D = fac.Fc2D.Split(';'); foreach (string fcID in arrayFc2D) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fcID); if (dffc == null) { continue; } IFeatureClass fc = dffc.GetFeatureClass(); return(fc); } return(null); }
private IFeatureClass GetOnlyFcByFacilityClass(FacilityClass fac) { string[] arrayFc2D = fac.Fc2D.Split(';'); if (arrayFc2D == null) { return(null); } foreach (string fc2d in arrayFc2D) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2d); if (dffc == null) { continue; } IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { return(null); } return(fc); } return(null); }
private void btnSearch_Click(object sender, EventArgs e) { RestoreEnv(); this._dt.Rows.Clear(); string str = this.teName.Text.Trim(); object obj = this.cmbFCs.SelectedItem; WaitForm.Start("正在搜索...", "请稍后"); try { if (obj != null && obj is DF3DFeatureClass) { DF3DFeatureClass dffc = obj as DF3DFeatureClass; IFeatureClass fc = dffc.GetFeatureClass(); FacilityClass fac = dffc.GetFacilityClass(); if (fc != null && fac != null) { SearchRes(fc, fac.GetFieldInfoNameBySystemName("Name"), str); } } } catch (Exception ex) { } WaitForm.Stop(); }
private DataTable RegionAnalysis(IGeometry geo) { DataTable dtResult = new DataTable(); dtResult.Columns.AddRange(new DataColumn[] { new DataColumn("PIPELINETYPE"), new DataColumn("FIELDNAME"), new DataColumn("PVALUE"), new DataColumn("LENGTH", typeof(double)), new DataColumn("TOTALLENGTH", typeof(double)) });//初始化统计用数据表的列 dtstats = new DataTable(); dtstats.Columns.AddRange(new DataColumn[] { new DataColumn("PIPELINETYPE"), new DataColumn("FIELDNAME"), new DataColumn("LENGTH", typeof(double)) }); //初始化生成统计图表用数据表的列 foreach (MajorClass mc in LogicDataStructureManage2D.Instance.GetAllMajorClass()) //对所有二级大类进行遍历 { string[] arrFc2DId = mc.Fc2D.Split(';'); //将二级大类所对应的要素类ID转换为数组 if (arrFc2DId == null) { continue; } double majorclasslength = 0.0; int indexStart = dtResult.Rows.Count; //获得数据表当前的行数 double subclasslength = 0.0; foreach (SubClass sc in mc.SubClasses) //对当前二级大类的子类进行遍历 { if (!sc.Visible2D) { continue; } double subfieldlength = 0.0; bool bHave = false; foreach (string fc2DId in arrFc2DId) //遍历二级子类所对应的要素类ID { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); //根据要素类ID得到DF2DFC if (dffc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); //得到设施类 IFeatureClass fc = dffc.GetFeatureClass(); //得到要素类 if (fc == null || facc == null || facc.Name != "PipeLine") { continue; } DFDataConfig.Class.FieldInfo fiPipeLength = facc.GetFieldInfoBySystemName("PipeLength2D");//得到设施类的管线长度字段 if (fiPipeLength == null) { continue; } IFields pFields = fc.Fields; //得到要素类字段集 int indexPipeLength = pFields.FindField(fiPipeLength.Name); //根据管线长度字段名得到要素类管线长度字段的索引 if (indexPipeLength < 0) { continue; } IField pField = pFields.get_Field(indexPipeLength); //根据管线长度字段索引得到管线长度字段 ISpatialFilter filter = new SpatialFilter(); //初始化空间过滤类 filter.Geometry = geo; filter.SubFields = pField.Name; filter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " = '" + sc.Name + "'"; filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;//选择过滤的空间条件 if (fc == null || geo == null) { return(null); } IFeatureCursor pFeatureCursor = null; IFeature pFeature = null; try { pFeatureCursor = fc.Search(filter, false);//获得过滤结果的游标 while ((pFeature = pFeatureCursor.NextFeature()) != null) { object tempobj = pFeature.get_Value(indexPipeLength); //获得当前要素管线长度字段的值 double dtemp = 0.0; if (tempobj != null && double.TryParse(tempobj.ToString(), out dtemp)) //将管线长度转换为double { bHave = true; subfieldlength += dtemp;//累加到当前二级子类总长度 } } } catch { } finally { if (pFeatureCursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor); pFeatureCursor = null; } if (pFeature != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeature); pFeature = null; } } if (bHave) { DataRow dr = dtResult.NewRow();//将对应数据填写到统计用数据表的新行 dr["PIPELINETYPE"] = mc; dr["FIELDNAME"] = ""; dr["PVALUE"] = sc; subclasslength += subfieldlength; dr["LENGTH"] = subfieldlength.ToString("0.00"); dtResult.Rows.Add(dr); DataRow dr1 = dtstats.NewRow();//将对应数据填写到统计图表用数据表的新行 dr1["PIPELINETYPE"] = mc; dr1["FIELDNAME"] = sc; dr1["LENGTH"] = subfieldlength.ToString("0.00"); dtstats.Rows.Add(dr1); } } } int indexEnd = dtResult.Rows.Count; for (int i = indexStart; i < indexEnd; i++) { DataRow dr = dtResult.Rows[i]; dr["TOTALLENGTH"] = subclasslength.ToString("0.00"); } } return(dtResult); }
private void treeLayer_AfterCheckNode(object sender, DevExpress.XtraTreeList.NodeEventArgs e) { this.cbProperty.Properties.Items.Clear(); this.selectFeatureClass.Clear(); try { List <string> list = new List <string>(); List <TreeListNode> treeListNodes = this.treeLayer.GetAllCheckedNodes(); foreach (TreeListNode node in treeListNodes) { object obj = node.GetValue("NodeObject"); if (obj is DF2DFeatureClass) { DF2DFeatureClass dffc = obj as DF2DFeatureClass; IFeatureClass fc = dffc.GetFeatureClass(); selectFeatureClass.Add(dffc); FacilityClass fac = dffc.GetFacilityClass(); if (fc == null || dffc == null) { continue; } IFields fiCol = fc.Fields; if (aliaNameAndName.Count > 0) { for (int i = 0; i < fiCol.FieldCount; i++) { string str = fiCol.get_Field(i).AliasName; string str2 = fiCol.get_Field(i).Name; //aliaNameAndName.Add(str, str2); FieldInfo fi = fac.GetFieldInfoByName(str2); if (fi == null) { continue; } else if (fi.CanQuery) { list.Add(str); } } } else { for (int i = 0; i < fiCol.FieldCount; i++) { string str = fiCol.get_Field(i).AliasName; string str2 = fiCol.get_Field(i).Name; aliaNameAndName.Add(str, str2); FieldInfo fi = fac.GetFieldInfoByName(str2); if (fi == null) { continue; } else if (fi.CanQuery) { list.Add(str); } } } } } if (list.Count > 0) { foreach (string str2 in from v in list.Distinct <string>() orderby v select v) { if (!string.IsNullOrEmpty(str2)) { this.cbProperty.Properties.Items.Add(str2); } } } } catch (System.Exception ex) { } //try //{ // List<string> list = new List<string>(); // foreach (TreeListNode node in this.treeLayer.GetAllCheckedNodes()) // { // object obj = node.GetValue("NodeObject"); // if (obj is DF2DFeatureClass) // { // DF2DFeatureClass dffc = obj as DF2DFeatureClass; // IFeatureClass fc = dffc.GetFeatureClass(); // FacilityClass fac = dffc.GetFacilityClass(); // if (fc == null || fac == null) continue; // DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName(); // IFields fiCol = fc.Fields; // int index = fiCol.FindField(fi.Name); // if (index < 0) continue; // IField pField = fiCol.get_Field(index); // IQueryFilter filter = new QueryFilterClass(); // filter.SubFields = pField.Name; // IFeatureCursor ftCursor = fc.Search(filter, true); // IFeature pfeature = ftCursor.NextFeature(); // while (pfeature != null) // { // string temp = pfeature.get_Value(index).ToString(); // if (temp != null) list.Add(temp); // pfeature = ftCursor.NextFeature(); // } // } // } //} //catch (System.Exception ex) //{ //} }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { DF2DApplication app = DF2DApplication.Application; m_ActiveView = app.Current2DMapControl.ActiveView; IGraphicsContainer pGC = m_ActiveView.GraphicsContainer; if (this.m_ActiveView.FocusMap.FeatureSelection != null) { this.m_ActiveView.FocusMap.ClearSelection(); } bool ready = false; if (app == null || app.Current2DMapControl == null) { return; } IGeometry pGeo = null; int preCount = 0; int nextCount = 0; try { if (button == 1) { PointClass searchPoint = new PointClass(); searchPoint.PutCoords(mapX, mapY); pGeo = PublicFunction.DoBuffer(searchPoint, PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate)); if (pGeo == null) { return; } ready = true; if (ready) { bool haveone = false; foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups) { if (haveone) { break; } foreach (MajorClass mc in lg.MajorClasses) { if (haveone) { break; } string[] arrFc2DId = mc.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } IFeatureCursor pFeatureCursor = null; IFeature pFeature = null; //DFDataConfig.Class.FieldInfo fi; //int indexFusu = 0; ////string nodefcId = null; foreach (SubClass sc in mc.SubClasses) { if (haveone) { break; } if (!sc.Visible2D) { continue; } foreach (string fc2DId in arrFc2DId) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } IFeatureClass fc = dffc.GetFeatureClass(); FacilityClass facc = dffc.GetFacilityClass(); if (facc.Name != "PipeLine") { continue; } ISpatialFilter pSpatialFilter = new SpatialFilter(); pSpatialFilter.Geometry = pGeo; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; pFeatureCursor = fc.Search(pSpatialFilter, false); if (pFeatureCursor == null) { continue; } pFeature = pFeatureCursor.NextFeature(); if (pFeature == null) { continue; } IGeometry pGeometry = pFeature.Shape as IGeometry; if (pGeometry.GeometryType == esriGeometryType.esriGeometryPolyline) { IPolyline pLine = pGeometry as IPolyline; this._EdgeFCID = fc.FeatureClassID.ToString(); this._EdgeOID = pFeature.OID; color = GetRGBColor(0, 230, 240); IElement lineElement = LineElementRenderer(pLine, color); pGC.AddElement(lineElement, 0); } haveone = true; break; } foreach (string fc2DId in arrFc2DId) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } IFeatureClass fc = dffc.GetFeatureClass(); FacilityClass facc = dffc.GetFacilityClass(); IFeatureLayer fl = dffc.GetFeatureLayer(); if (fc == null || pGeo == null || fl == null) { continue; } if (!fl.Visible) { continue; } if (facc.Name != "PipeNode") { continue; } DFDataConfig.Class.FieldInfo fi = facc.GetFieldInfoBySystemName("Additional"); IFields fiCol = fc.Fields; int indexFusu = fiCol.FindField(fi.Name); WaitForm.Start("正在分析...", "请稍后"); TopoClass2D tc = FacilityInfoService2D.GetTopoClassByFeatureClassID(fc2DId); if (tc == null) { WaitForm.Stop(); return; } TopoNetwork net = tc.GetNetwork(); if (net == null) { WaitForm.Stop(); XtraMessageBox.Show("构建拓扑网络失败!", "提示"); return; } else { HashSet <string> valveIds = new HashSet <string>(); if (!string.IsNullOrEmpty(fc2DId) && ValveManager.Instance.Exists(fc2DId)) { valveIds = ValveManager.Instance.GetValveIds(fc2DId); } else { IFeature feature; string fusu; //IQueryFilter filter = new QueryFilter(); //filter.WhereClause = fi.Name + " LIKE '%阀%'"; IFeatureCursor cursor = fc.Search(null, false); int n = fc.FeatureCount(null); if (indexFusu == 0) { return; } while ((feature = cursor.NextFeature()) != null) { //valveIds.Add(fc2DId + "_" + feature.OID.ToString()); fusu = feature.get_Value(indexFusu).ToString(); if (fusu == "阀门" || fusu == "阀门井") { valveIds.Add(fc2DId + "_" + feature.OID.ToString()); } } ValveManager.Instance.Add(fc2DId, valveIds); } //string edgeID = this._EdgeFCID + "_" + this._EdgeOID.ToString(); if (EdgeManager.Instance.Exists(this._EdgeFCID, this._EdgeOID.ToString())) { edge = EdgeManager.Instance.GetEdgeByID(this._EdgeFCID, this._EdgeOID.ToString()); } preNode = edge.PreNode; nextNode = edge.NextNode; HashSet <string> recordPre = new HashSet <string>(); HashSet <string> recordNext = new HashSet <string>(); color = GetRGBColor(255, 0, 0); net.BGFX(preNode.ID, nextNode.ID, valveIds, ref recordPre, ref recordNext); if (recordPre.Count <= 0 && recordNext.Count <= 0) { continue; } preCount = recordPre.Count; nextCount = recordNext.Count; foreach (string s in recordPre) { int id; Node n = NodeManager.Instance.GetNodeByID(s); Int32.TryParse(n.FeatureId, out id); IFeature feature = fc.GetFeature(id); IPoint point = feature.Shape as IPoint; //color = GetRGBColor(255, 0, 0); IElement elementpPoint = PointElementRenderer(point, color); pGC.AddElement(elementpPoint, 0); IElement elementText = AddCallout(app.Current2DMapControl, point, "需关闭阀门", color); pGC.AddElement(elementText, 1); app.Current2DMapControl.CenterAt(point); } foreach (string s in recordNext) { int id; Node n = NodeManager.Instance.GetNodeByID(s); Int32.TryParse(n.FeatureId, out id); IFeature feature = fc.GetFeature(id); IPoint point = feature.Shape as IPoint; color = GetRGBColor(0, 0, 0); IElement elementpPoint = PointElementRenderer(point, color); pGC.AddElement(elementpPoint, 0); IElement elementText = AddCallout(app.Current2DMapControl, point, "需关闭阀门", color); pGC.AddElement(elementText, 1); app.Current2DMapControl.CenterAt(point); } app.Current2DMapControl.MapScale = 500; app.Current2DMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } if (haveone) { break; } } } } } } } } catch (System.Exception ex) { } finally { WaitForm.Stop(); XtraMessageBox.Show("上游需关闭阀门:" + preCount + "\n下游需关闭阀门:" + nextCount, "提示"); SuspendCommand(); } }
/*private DataTable DoCrossAnalysis(Dictionary<string, List<IFeature>> dict,int crossType) * { * if (dict.Count <= 0) return null; * //dicCross = new Dictionary<string,string>(); * hsCross = new HashSet<string>(); * DataTable dt = new DataTable(); * dt.Columns.Add(new DataColumn("图层")); * foreach (string s in dict.Keys) * { * dt.Columns.Add(new DataColumn(s)); * } * try * { * foreach (MajorClass mca in LogicDataStructureManage2D.Instance.GetAllMajorClass()) * { * if (!dict.ContainsKey(mca.Alias)) continue; * List<IFeature> linesA = dict[mca.Alias]; * DataRow dr = dt.NewRow(); * dr["图层"] = mca.Alias; * foreach (MajorClass mcb in LogicDataStructureManage2D.Instance.GetAllMajorClass()) * { * if (!dict.ContainsKey(mcb.Alias)) continue; * List<IFeature> linesB = dict[mcb.Alias]; * int count = 0; * * //if (linesB == linesA) continue; * * int n = 0; * foreach (IFeature la in linesA) * { * count++; * WaitForm.SetCaption("正在分析【" + mca.Alias + "】与【" + mcb.Alias + "】," + count + "/" + linesA.Count); * int dA = GetDiameter(la, this._diameter); * IPolyline lineA = la.Shape as IPolyline; * foreach (IFeature lb in linesB) * { * if (la == lb) continue; * int dB = GetDiameter(lb, this._diameter); * IPolyline lineB = lb.Shape as IPolyline; * //ITopologicalOperator topo = lineA as ITopologicalOperator; * ITopologicalOperator topo = lineA as ITopologicalOperator; * topo.Simplify(); * IGeometry geo = topo.Intersect(lineB, esriGeometryDimension.esriGeometry0Dimension); * if (geo.IsEmpty) continue; * IPointCollection pc = geo as IPointCollection; * IPoint point = pc.get_Point(0); * //if (point == lineA.FromPoint || point == lineA.ToPoint || point == lineB.FromPoint || point == lineB.ToPoint) * if(IsPointSame(point,lineA.FromPoint)||IsPointSame(point,lineA.ToPoint)||IsPointSame(point,lineB.FromPoint)||IsPointSame(point,lineB.ToPoint)) * continue; * double disA = double.MaxValue; * double zA = double.MaxValue; * GetDistanceAndZ(lineA, point, out disA, out zA); * double disB = double.MaxValue; * double zB = double.MaxValue; * GetDistanceAndZ(lineB, point, out disB, out zB); * double l = Double.MaxValue; * if (crossType == 0) * { * l = Convert.ToDouble((dA + dB) / 2000); * } * else * { * if (dictVertical.ContainsKey(mca.Name + "_" + mcb.Name)) * * * l = (((double)dA +(double) dB) / 2000) + dictVertical[mca.Name + "_" + mcb.Name]; * } * if (l == Double.MaxValue) continue; * if (System.Math.Abs(zA - zB) > l) continue; * else * { * string idA = mca.Name + "_" + la.OID; * string idB = mcb.Name + "_" + lb.OID; * hsCross.Add(idA + "," + idB); * n++; * //if (dicCross.ContainsValue(idA) && dicCross.ContainsKey(idB)) * //{ * // if (dicCross[idB] == idA) continue; * * //} * //else * //{ * // if (dicCross.ContainsKey(idA)) continue; * // dicCross[idA] = idB; * // n++; * * //} * //cross.Add(idA + "," + idB); * //n++; * } * } * } * dr[mcb.Alias] = n; * * } * dt.Rows.Add(dr); * } * return dt; * } * catch (System.Exception ex) * { * return null; * } * * } * * private bool IsPointSame(IPoint p1, IPoint p2) * { * if (p1.X == p2.X && p1.Y == p2.Y && p1.Z == p2.Z) return true; * else return false; * } * private void GetDistanceAndZ(IPolyline line, IPoint point, out double dis, out double z) * { * if (line == null || point == null) * { * dis = double.MaxValue; * z = double.MaxValue; * return; * } * else * { * dis = System.Math.Sqrt((point.X - line.FromPoint.X) * (point.X - line.FromPoint.X) + (point.Y - line.FromPoint.Y) * (point.Y - line.FromPoint.Y)); * z = dis * (line.ToPoint.Z - line.FromPoint.Z) / line.Length + line.FromPoint.Z; * } * * } * * private int GetDiameter(IFeature feature, string fieldName) * { * IFields fields = feature.Fields; * int index = fields.FindField(this._diameter); * string d = feature.get_Value(index).ToString(); * int h; * if (d.Contains("*")) * { * int n = d.IndexOf("*"); * string strd = d.Substring(n + 1); * System.Int32.TryParse(strd, out h); * } * else * { * System.Int32.TryParse(d, out h); * } * return h; * }*/ private void lbx_CrossPipe_DoubleClick(object sender, EventArgs e) { try { app.Current2DMapControl.ActiveView.FocusMap.ClearSelection(); string temp = this.lbx_CrossPipe.SelectedItem.ToString(); string lineA = temp.Substring(0, (temp.IndexOf(","))); string lineB = temp.Substring(temp.IndexOf(",") + 1); if (lineA == null || lineB == null) { return; } string mcNameA = lineA.Substring(0, lineA.IndexOf("_")); string fOidA = lineA.Substring(lineA.IndexOf("_") + 1); string mcNameB = lineB.Substring(0, lineB.IndexOf("_")); string fOidB = lineB.Substring(lineB.IndexOf("_") + 1); int OIDA; int OIDB; Int32.TryParse(fOidA, out OIDA); Int32.TryParse(fOidB, out OIDB); foreach (MajorClass mc in LogicDataStructureManage2D.Instance.GetAllMajorClass()) { if (mc.Name == mcNameA) { bool have = false; string[] arrFc2DId = mc.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } foreach (SubClass sc in mc.SubClasses) { if (!sc.Visible2D) { continue; } foreach (string fc2DId in arrFc2DId) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);//根据要素类ID得到DF2DFC if (dffc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); //得到设施类 IFeatureClass fc = dffc.GetFeatureClass(); //得到要素类 IFeatureLayer fl = dffc.GetFeatureLayer(); if (fc == null || facc == null || facc.Name != "PipeLine") { continue; } if (fl == null) { return; } IFeature feature1 = fc.GetFeature(OIDA); if (feature1 == null) { return; } app.Current2DMapControl.ActiveView.FocusMap.SelectFeature(fl, feature1); //app.Current2DMapControl.ActiveView.FocusMap.SelectFeature(fl, feature2); IPolyline polyline = feature1.Shape as IPolyline; IPoint point = polyline.ToPoint; app.Current2DMapControl.MapScale = 500; app.Current2DMapControl.CenterAt(point); have = true; } if (have) { break; } } } if (mc.Name == mcNameB) { bool have = false; string[] arrFc2DId = mc.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } foreach (SubClass sc in mc.SubClasses) { if (!sc.Visible2D) { continue; } foreach (string fc2DId in arrFc2DId) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);//根据要素类ID得到DF2DFC if (dffc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); //得到设施类 IFeatureClass fc = dffc.GetFeatureClass(); //得到要素类 IFeatureLayer fl = dffc.GetFeatureLayer(); if (fc == null || facc == null || facc.Name != "PipeLine") { continue; } if (fl == null) { return; } IFeature feature = fc.GetFeature(OIDB); app.Current2DMapControl.ActiveView.FocusMap.SelectFeature(fl, feature); IPolyline polyline = feature.Shape as IPolyline; IPoint point = polyline.FromPoint; app.Current2DMapControl.MapScale = 500; app.Current2DMapControl.CenterAt(point); have = true; } if (have) { break; } } } } } catch (System.Exception ex) { } }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { DF2DApplication app = DF2DApplication.Application; if (app == null || app.Current2DMapControl == null) { return; } IActiveView m_ActiveView = app.Current2DMapControl.ActiveView; IScreenDisplay m_Display = app.Current2DMapControl.ActiveView.ScreenDisplay; IGeometry pGeo = null; try { if (button == 1) { ISimpleLineSymbol pLineSym = new SimpleLineSymbol(); IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 255; pColor.Blue = 0; pLineSym.Color = pColor; pLineSym.Style = esriSimpleLineStyle.esriSLSSolid; pLineSym.Width = 2; IRubberBand pRubberBand; pRubberBand = new RubberLineClass(); IGeometry pLine = pRubberBand.TrackNew(m_Display, null); object symbol = pLineSym as object; app.Current2DMapControl.DrawShape(pLine, ref symbol); if ((pLine as IPolyline).Length > 500) { XtraMessageBox.Show("横断面线超过500米,分析效率很低,请重新绘制", "提示"); return; } WaitForm.Start("正在进行横断面分析...", "请稍后"); pGeo = pLine; if (pGeo == null) { return; } string road1 = ""; string road2 = ""; bool bAlert = false; double hmax = double.MinValue; double hmin = double.MaxValue; List <PPLine2D> pplines = new List <PPLine2D>(); IFeatureCursor pFeatureCursor = null; IFeature pFeature = null; foreach (MajorClass mc in LogicDataStructureManage2D.Instance.GetAllMajorClass()) { foreach (SubClass sc in mc.SubClasses) { if (!sc.Visible2D) { continue; } string[] arrFc2DId = mc.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } foreach (string fc2DId in arrFc2DId) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); if (facc.Name != "PipeLine") { continue; } //查找管径长宽字段,获得该要素类下字段索引值,若为圆管,则长宽相等 DFDataConfig.Class.FieldInfo fiDia = facc.GetFieldInfoBySystemName("Diameter"); DFDataConfig.Class.FieldInfo fiDia1 = facc.GetFieldInfoBySystemName("Diameter1"); DFDataConfig.Class.FieldInfo fiDia2 = facc.GetFieldInfoBySystemName("Diameter2"); int indexDia = fc.Fields.FindField(fiDia.Name); int indexDiaWith = fc.Fields.FindField(fiDia1.Name); int indexDiaHeight = fc.Fields.FindField(fiDia2.Name); if (indexDiaWith == -1 || indexDiaHeight == -1 || indexDia == -1) { continue; } //查找道路字段索引 DFDataConfig.Class.FieldInfo fiRoad = facc.GetFieldInfoBySystemName("Road"); int indexRoad = fc.Fields.FindField(fiRoad.Name); //查找管线高类别索引 DFDataConfig.Class.FieldInfo fiHLB = facc.GetFieldInfoBySystemName("HLB"); int indexHLB = fc.Fields.FindField(fiHLB.Name); //二级分类名索引 int indexClassify = fc.Fields.FindField(mc.ClassifyField); ISpatialFilter pSpatialFilter = new SpatialFilter(); pSpatialFilter.Geometry = pGeo; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; pSpatialFilter.WhereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " = '" + sc.Name + "'"; int count = fc.FeatureCount(pSpatialFilter); if (count == 0) { continue; } pFeatureCursor = fc.Search(pSpatialFilter, true); while ((pFeature = pFeatureCursor.NextFeature()) != null) { if (indexRoad != -1) { if (road2 == "") { road1 = pFeature.get_Value(indexRoad).ToString(); road2 = pFeature.get_Value(indexRoad).ToString(); } else { road1 = pFeature.get_Value(indexRoad).ToString(); if (road1 != road2) { if (!bAlert) { XtraMessageBox.Show("横断面线跨越多条道路,当前只绘制在【" + road2 + "】上的管线横断面图。", "提示"); bAlert = true; } continue; } } } //查找管线的起点终点地面高 double startSurfHeight = double.MaxValue; double endSurfHeight = double.MaxValue; DFDataConfig.Class.FieldInfo fiStartSurfHeight = facc.GetFieldInfoBySystemName("StartSurfH"); if (fiStartSurfHeight == null) { continue; } int indexStartSurfHeight = pFeature.Fields.FindField(fiStartSurfHeight.Name); if (indexStartSurfHeight == -1) { continue; } DFDataConfig.Class.FieldInfo fiEndSurfHeight = facc.GetFieldInfoBySystemName("EndSurfH"); if (fiEndSurfHeight == null) { continue; } int indexEndSurfHeight = pFeature.Fields.FindField(fiEndSurfHeight.Name); if (indexEndSurfHeight == -1) { continue; } //若管线属性地面高字段为null,则从DEM取值 if (pFeature.get_Value(indexStartSurfHeight).ToString() == "" || pFeature.get_Value(indexEndSurfHeight).ToString() == "") { startSurfHeight = ReadDemRaster.GetH((pFeature.Shape as IPolyline).FromPoint); endSurfHeight = ReadDemRaster.GetH((pFeature.Shape as IPolyline).ToPoint); } else { startSurfHeight = Convert.ToDouble(pFeature.get_Value(indexStartSurfHeight).ToString()); endSurfHeight = Convert.ToDouble(pFeature.get_Value(indexEndSurfHeight).ToString()); } //查找管线起点高程和终点高程 double startDepthHeight = double.MaxValue; double endDepthHeight = double.MaxValue; DFDataConfig.Class.FieldInfo fiStartDepthHeight = facc.GetFieldInfoBySystemName("StartHeight2D"); if (fiStartDepthHeight == null) { continue; } int indexStartDepthHeight = pFeature.Fields.FindField(fiStartDepthHeight.Name); if (indexStartDepthHeight == -1) { continue; } DFDataConfig.Class.FieldInfo fiEndDepthHeight = facc.GetFieldInfoBySystemName("EndHeight"); if (fiEndDepthHeight == null) { continue; } int indexEndDepthHeight = pFeature.Fields.FindField(fiEndDepthHeight.Name); if (indexEndDepthHeight == -1) { continue; } startDepthHeight = Convert.ToDouble(pFeature.get_Value(indexStartDepthHeight).ToString()); endDepthHeight = Convert.ToDouble(pFeature.get_Value(indexEndDepthHeight).ToString()); //计算管线和断面的交点 IGeometry ppGeo = pFeature.Shape; ITopologicalOperator pTopo = ppGeo as ITopologicalOperator; IGeometry geoIntersect = pTopo.Intersect(pGeo, esriGeometryDimension.esriGeometry0Dimension); if (geoIntersect == null) { continue; } PPLine2D ppline = new PPLine2D(); if (indexClassify == -1) { ppline.facType = mc.Name; } else { ppline.facType = pFeature.get_Value(indexClassify).ToString(); } //查找管线的管径,判断其是方管还是圆管 string diameter = pFeature.get_Value(indexDia).ToString(); string diameter1 = pFeature.get_Value(indexDiaWith).ToString(); string diameter2 = pFeature.get_Value(indexDiaHeight).ToString(); if (diameter.Trim() == "") { continue; } ppline.dia = diameter; int indexSplit = diameter.IndexOf('*'); if (indexSplit != -1) { ppline.isrect = true; int iDia1; bool bDia1 = int.TryParse(diameter.Substring(0, indexSplit), out iDia1); if (!bDia1) { continue; } int iDia2; bool bDia2 = int.TryParse(diameter.Substring(indexSplit + 1, diameter.Length - indexSplit - 1), out iDia2); if (!bDia2) { continue; } ppline.gj.Add(iDia1); ppline.gj.Add(iDia2); } else { ppline.isrect = false; int iDia; bool bDia = int.TryParse(diameter, out iDia); if (!bDia) { continue; } ppline.gj.Add(iDia); ppline.gj.Add(iDia); } //判断管线高方式 int hlb = 0; if (indexHLB != -1) { string strhlb = pFeature.get_Value(indexHLB).ToString(); if (strhlb.Contains("内")) { hlb = 1; } else if (strhlb.Contains("外")) { hlb = -1; } else { hlb = 0; } ppline.hlb = hlb; } #region 交点为一个 if (geoIntersect.GeometryType == esriGeometryType.esriGeometryPoint) { IPolyline polyline = pFeature.Shape as IPolyline; IPoint ptIntersect = geoIntersect as IPoint; ppline.interPoint = new PPPoint(ptIntersect.X, ptIntersect.Y); ppline.clh = GetInterPointHeight(ptIntersect, polyline, startDepthHeight, endDepthHeight); if (ppline.clh > hmax) { hmax = ppline.clh; } if (ppline.clh < hmin) { hmin = ppline.clh; } ppline.cgh = startSurfHeight + (endSurfHeight - startSurfHeight) * Math.Sqrt((polyline.FromPoint.X - ptIntersect.X) * (polyline.FromPoint.X - ptIntersect.X) + (polyline.FromPoint.Y - ptIntersect.Y) * (polyline.FromPoint.Y - ptIntersect.Y)) / polyline.Length; if (ppline.cgh > hmax) { hmax = ppline.cgh; } if (ppline.cgh < hmin) { hmin = ppline.cgh; } // 辅助画图 IPolyline l = pGeo as IPolyline; ppline.startPt = new PPPoint(l.FromPoint.X, l.FromPoint.Y); pplines.Add(ppline); } #endregion #region 交点为多个 else if (geoIntersect.GeometryType == esriGeometryType.esriGeometryMultipoint) { IPolyline polyline = pFeature.Shape as IPolyline; IPointCollection geoCol = geoIntersect as IPointCollection; for (int i = 0; i < geoCol.PointCount; i++) { IPoint ptIntersect = geoCol.get_Point(i); ppline.interPoint = new PPPoint(ptIntersect.X, ptIntersect.Y); ppline.clh = GetInterPointHeight(ptIntersect, polyline, startDepthHeight, endDepthHeight); if (ppline.clh > hmax) { hmax = ppline.clh; } if (ppline.clh < hmin) { hmin = ppline.clh; } ppline.cgh = startSurfHeight + (endSurfHeight - startSurfHeight) * Math.Sqrt((polyline.FromPoint.X - ptIntersect.X) * (polyline.FromPoint.X - ptIntersect.X) + (polyline.FromPoint.Y - ptIntersect.Y) * (polyline.FromPoint.Y - ptIntersect.Y)) / polyline.Length; if (ppline.cgh > hmax) { hmax = ppline.cgh; } if (ppline.cgh < hmin) { hmin = ppline.cgh; } // 辅助画图 IPolyline l = pGeo as IPolyline; ppline.startPt = new PPPoint(l.FromPoint.X, l.FromPoint.Y); pplines.Add(ppline); } } else { continue; } #endregion } } } } WaitForm.Stop(); if (pplines.Count < 2) { XtraMessageBox.Show("相交管线少于2个", "提示"); return; } pplines.Sort(new PPLineCompare2D()); double spacesum = 0.0; for (int i = 1; i < pplines.Count; i++) { PPLine2D line1 = pplines[i - 1]; PPLine2D line2 = pplines[i]; line2.space = Math.Sqrt((line1.interPoint.X - line2.interPoint.X) * (line1.interPoint.X - line2.interPoint.X) + (line1.interPoint.Y - line2.interPoint.Y) * (line1.interPoint.Y - line2.interPoint.Y)); spacesum += line2.space; } ; var str1 = (pplines[0].interPoint.X / 1000).ToString("0.00"); var str2 = (pplines[0].interPoint.Y / 1000).ToString("0.00"); string mapNum = str2 + "-" + str1; string mapName = SystemInfo.Instance.SystemFullName + "横断面图"; FrmSectionAnalysis dialog = new FrmSectionAnalysis("横断面分析结果", 0); dialog.SetInfo(mapName, mapNum, pplines, hmax, hmin, spacesum, road2); dialog.Show(); } } catch { WaitForm.Stop(); } }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { DF2DApplication app = DF2DApplication.Application; this._dict.Clear(); m_ActiveView = app.Current2DMapControl.ActiveView; if (this.m_ActiveView.FocusMap.FeatureSelection != null) { this.m_ActiveView.FocusMap.ClearSelection(); } bool ready = false; bool haveone = false; if (app == null || app.Current2DMapControl == null || app.Workbench == null) { return; } app.Workbench.SetMenuEnable(true); IGeometry pGeo = null; try { if (button == 1) { WaitForm.Start("正在查询...", "请稍后"); PointClass searchPoint = new PointClass(); searchPoint.PutCoords(mapX, mapY); pGeo = PublicFunction.DoBuffer(searchPoint, PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate)); if (pGeo == null) { return; } ready = true; if (ready == true) { //foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups) //{ IFeatureCursor pFeatureCursor = null; IFeature pFeature = null; ISpatialFilter pSpatialFilter = new SpatialFilter(); IFeatureClass fc; DF2DFeatureClass dffc; //foreach (MajorClass mc in lg.MajorClasses) foreach (MajorClass mc in FrmMajorClass.Instance.MajorClasses) { foreach (SubClass sc in mc.SubClasses) { if (!sc.Visible2D) { continue; } string[] arrFc2DId = mc.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } foreach (string fc2DId in arrFc2DId) { dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } fc = dffc.GetFeatureClass(); FacilityClass facc = dffc.GetFacilityClass(); if (facc.Name != "PipeLine") { continue; } if (fc == null || pGeo == null) { continue; } pSpatialFilter = new SpatialFilter(); pSpatialFilter.Geometry = pGeo; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; string whereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " = '" + sc.Name + "'"; pSpatialFilter.WhereClause = whereClause; pFeatureCursor = fc.Search(pSpatialFilter, false); if (pFeatureCursor == null) { continue; } pFeature = pFeatureCursor.NextFeature(); if (pFeature == null) { continue; } DataTable dt = new DataTable(); dt.TableName = facc.Name; DataColumn oidcol = new DataColumn(); oidcol.ColumnName = "oid"; oidcol.Caption = "ID"; dt.Columns.Add(oidcol); foreach (DFDataConfig.Class.FieldInfo fitemp in facc.FieldInfoCollection) { if (!fitemp.CanQuery) { continue; } DataColumn col = new DataColumn(); col.ColumnName = fitemp.Name; col.Caption = fitemp.Alias; dt.Columns.Add(col); } DataRow dtRow = dt.NewRow(); dtRow["oid"] = pFeature.get_Value(pFeature.Fields.FindField("OBJECTID")); foreach (DataColumn col in dt.Columns) { int index1 = pFeature.Fields.FindField(col.ColumnName); if (index1 < 0) { continue; } object obj1 = GetFieldValueByIndex(pFeature, index1); string str = ""; if (obj1 != null) { IField field = pFeature.Fields.get_Field(index1); switch (field.Type) { case esriFieldType.esriFieldTypeBlob: case esriFieldType.esriFieldTypeGeometry: case esriFieldType.esriFieldTypeRaster: continue; case esriFieldType.esriFieldTypeDouble: double d; if (double.TryParse(obj1.ToString(), out d)) { str = d.ToString("0.00"); } break; default: str = obj1.ToString(); break; } } dtRow[col.ColumnName] = str; } dt.Rows.Add(dtRow); if (dt.Rows.Count > 0) { this._dict[sc.Name] = dt; } haveone = true; break; } if (haveone) { break; } } if (haveone) { break; } } } #region 查询建筑物 if (!haveone) { FacilityClass facBuild = FacilityClassManager.Instance.GetFacilityClassByName("Building"); if (facBuild != null) { haveone = HaveOne(facBuild, pGeo); } if (!haveone) { FacilityClass facStruct = FacilityClassManager.Instance.GetFacilityClassByName("Structure"); if (facStruct != null) { haveone = HaveOne(facStruct, pGeo); } } } #endregion try { if (!haveone) { WaitForm.Stop(); XtraMessageBox.Show("未选中要素,请重新选择", "提示"); return; } this._uPanel = new UIDockPanel("查询结果", "查询结果", this.Location, this._width, this._height); this._dockPanel = FloatPanelManager.Instance.Add(ref this._uPanel, DockingStyle.Right); this._dockPanel.Visibility = DockVisibility.Visible; this._dockPanel.FloatSize = new System.Drawing.Size(this._width, this._height); this._dockPanel.Width = this._width; this._dockPanel.Height = this._height; if (this._ucPropInfo2D == null) { this._ucPropInfo2D = new UCPropertyInfo2D(); } this._ucPropInfo2D.Dock = System.Windows.Forms.DockStyle.Fill; this._uPanel.RegisterEvent(new PanelClose(this.Close)); this._dockPanel.Controls.Add(this._ucPropInfo2D); this._ucPropInfo2D.Init(); this._ucPropInfo2D.SetPropertyInfo(this._dict); WaitForm.Stop(); } catch { WaitForm.Stop(); } } //} } catch { WaitForm.Stop(); } finally { } }
private bool HaveOne(FacilityClass facc, IGeometry pGeo) { bool haveone = false; string[] fc2D = facc.Fc2D.Split(';'); if (fc2D.Length == 0) { return(false); } string facID = fc2D[0]; DF2DFeatureClass dffacc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(facID); //如果图层不显示,则不查询 TreeNodeComLayer treeLayer = dffacc.GetTreeLayer(); if (treeLayer == null || !treeLayer.Visible) { return(false); } IFeatureClass fc = dffacc.GetFeatureClass(); ISpatialFilter filter = new SpatialFilter(); filter = new SpatialFilter(); filter.Geometry = pGeo; filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; IFeatureCursor cursor = fc.Search(filter, false); IFeature feature = cursor.NextFeature(); if (feature != null) { haveone = true; DataTable dt = new DataTable(); dt.TableName = facc.Name; DataColumn oidcol = new DataColumn(); oidcol.ColumnName = "oid"; oidcol.Caption = "ID"; dt.Columns.Add(oidcol); foreach (DFDataConfig.Class.FieldInfo fitemp in facc.FieldInfoCollection) { if (!fitemp.CanQuery) { continue; } DataColumn col = new DataColumn(); col.ColumnName = fitemp.Name; col.Caption = fitemp.Alias; dt.Columns.Add(col); } DataRow dtRow = dt.NewRow(); dtRow["oid"] = feature.get_Value(feature.Fields.FindField("OBJECTID")); foreach (DataColumn col in dt.Columns) { int index1 = feature.Fields.FindField(col.ColumnName); if (index1 < 0) { continue; } object obj1 = GetFieldValueByIndex(feature, index1); string str = ""; if (obj1 != null) { IField field = feature.Fields.get_Field(index1); switch (field.Type) { case esriFieldType.esriFieldTypeBlob: case esriFieldType.esriFieldTypeGeometry: case esriFieldType.esriFieldTypeRaster: continue; case esriFieldType.esriFieldTypeDouble: double d; if (double.TryParse(obj1.ToString(), out d)) { str = d.ToString("0.00"); } break; default: str = obj1.ToString(); break; } } dtRow[col.ColumnName] = str; } dt.Rows.Add(dtRow); if (dt.Rows.Count > 0) { this._dict[facc.Alias] = dt; } } return(haveone); }
private void treelist_AfterCheckNode(object sender, NodeEventArgs e) { this.teValue.Text = ""; this.listBoxControlValues.Items.Clear(); if (string.IsNullOrEmpty(this._sysFieldName)) { return; } IFdeCursor cursor = null; IRowBuffer row = null; try { WaitForm.Start("正在加载列表...", "请稍后"); HashSet <string> list = new HashSet <string>(); bool bBreak = false; foreach (TreeListNode node in this.treelist.GetAllCheckedNodes()) { object obj = node.GetValue("NodeObject"); if (obj != null && obj is SubClass) { SubClass sc = obj as SubClass; if (sc.Parent == null) { continue; } string cacheType = sc.Parent.Name + "_" + sc.GroupId + "_3D_" + this._sysFieldName; object objCache = CacheHelper.GetCache(cacheType); if (objCache != null && objCache is HashSet <string> ) { HashSet <string> temphs = objCache as HashSet <string>; foreach (string tempstr in temphs) { list.Add(tempstr); } continue; } HashSet <string> listsc = new HashSet <string>(); string[] arrFc3DId = sc.Parent.Fc3D.Split(';'); if (arrFc3DId == null) { continue; } foreach (string fc3DId in arrFc3DId) { DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fc3DId); if (dffc == null) { continue; } FacilityClass facClass = dffc.GetFacilityClass(); IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null || facClass == null || facClass.Name != this._facType) { continue; } DFDataConfig.Class.FieldInfo fi = facClass.GetFieldInfoBySystemName(this._sysFieldName); if (fi == null) { continue; } IFieldInfoCollection fiCol = fc.GetFields(); int index = fiCol.IndexOf(fi.Name); if (index < 0) { continue; } Gvitech.CityMaker.FdeCore.FieldInfo gfi = (Gvitech.CityMaker.FdeCore.FieldInfo)fiCol.Get(index); IQueryFilter filter = new QueryFilter(); filter.SubFields = gfi.Name; filter.ResultBeginIndex = 0; filter.ResultLimit = 1; while (true) { string strTempClause = gfi.Name + " is not null and "; string fClause = strTempClause; foreach (string strtemp in listsc) { fClause += gfi.Name + " <> " + strtemp + " and "; } fClause = fClause.Substring(0, fClause.Length - 5); filter.WhereClause = "GroupId = " + sc.GroupId + " and " + fClause; cursor = fc.Search(filter, true); if ((row = cursor.NextRow()) != null) { if (row.IsNull(0)) { break; } object temp = row.GetValue(0); string strtemp = ""; switch (gfi.FieldType) { case gviFieldType.gviFieldFID: case gviFieldType.gviFieldFloat: case gviFieldType.gviFieldDouble: case gviFieldType.gviFieldInt16: case gviFieldType.gviFieldInt32: case gviFieldType.gviFieldInt64: strtemp = temp.ToString(); break; case gviFieldType.gviFieldDate: case gviFieldType.gviFieldString: case gviFieldType.gviFieldUUID: strtemp = "'" + temp.ToString() + "'"; break; case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldGeometry: case gviFieldType.gviFieldUnknown: default: continue; } if (temp != null) { list.Add(strtemp); listsc.Add(strtemp); if (list.Count > 10) { bBreak = true; break;// 列举10个 } } } else { break; } } if (bBreak) { break; } } CacheHelper.SetCache(cacheType, listsc); } if (bBreak) { break; } } foreach (string str2 in list) { //if (!(string.IsNullOrEmpty(str2))) //{ this.listBoxControlValues.Items.Add(str2); //} } } catch (Exception ex) { } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } WaitForm.Stop(); } }
private void DoQuery() { if (string.IsNullOrEmpty(this._sysFieldName)) { return; } string value = this.teValue.Text.Trim(); if (value.Length > 1) { int lastindex = value.LastIndexOf(';'); if (lastindex == (value.Length - 1)) { value = value.Substring(0, value.Length - 1); } } if (this.treelist.GetAllCheckedNodes() != null) { foreach (TreeListNode node in this.treelist.GetAllCheckedNodes()) { object obj = node.GetValue("NodeObject"); if (obj != null && obj is SubClass) { SubClass sc = obj as SubClass; if (sc.Parent == null) { continue; } string[] arrFc3DId = sc.Parent.Fc3D.Split(';'); if (arrFc3DId == null) { continue; } foreach (string fc3DId in arrFc3DId) { DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fc3DId); if (dffc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null || facc == null || facc.Name != this._facType) { continue; } DFDataConfig.Class.FieldInfo fi = facc.GetFieldInfoBySystemName(this._sysFieldName); if (fi == null) { continue; } int index = fc.GetFields().IndexOf(fi.Name); if (index == -1) { continue; } IFieldInfo fcfi = fc.GetFields().Get(index); switch (fcfi.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldGeometry: case gviFieldType.gviFieldUnknown: continue; } string[] arr1 = value.Split(';'); if (arr1 == null || arr1.Length == 0) { continue; } string temp1 = "("; foreach (string str1 in arr1) { temp1 += str1 + ","; } if (temp1 == "(") { temp1 = "()"; } else { temp1 = temp1.Substring(0, temp1.Length - 1) + ")"; } string strWhereClause = "GroupId = " + sc.GroupId + " and (" + fi.Name + " in " + temp1 + ")"; _dict.Add(sc, strWhereClause); } } } } }
public override void Run(object sender, EventArgs e) { int i = 0, k; string strDicValue; string strPntID; IFeatureClass Pntfc; IFeatureClass Arcfc; IFeatureCursor pFeaCursor; IQueryFilter pFilter = new QueryFilterClass(); IFeature pFea; string[] arrFc2DId; mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView; if (mapView == null) { return; } bool bBind = mapView.Bind(this); if (!bBind) { return; } app = (DF2DApplication)this.Hook; if (app == null || app.Current2DMapControl == null) { return; } m_pMapControl = app.Current2DMapControl; frmSelType frmType = new frmSelType(); if (frmType.ShowDialog() == DialogResult.OK) { try { List <DF2DFeatureClass> pPntlist = new List <DF2DFeatureClass>(); List <DF2DFeatureClass> pArclist = new List <DF2DFeatureClass>(); m_arrPipeType = frmType.PipeType; for (i = 0; i < m_arrPipeType.Count; i++) { MajorClass mc = m_arrPipeType[i] as MajorClass; arrFc2DId = mc.Fc2D.Split(';'); if (arrFc2DId == null) { continue; } foreach (string fc2DId in arrFc2DId) { DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId); if (dffc == null) { continue; } IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { continue; } if (dffc.GetFacilityClassName() == "PipeNode") { pPntlist.Add(dffc); continue; } if (dffc.GetFacilityClassName() == "PipeLine") { pArclist.Add(dffc); continue; } } } if ((pPntlist == null) || (pArclist == null)) { return; } Dictionary <IFeatureClass, DataTable> dict = new Dictionary <IFeatureClass, DataTable>(); WaitForm.Start("开始数据一致性检查..", "请稍候"); int count = 0; foreach (DF2DFeatureClass Pntdfcc in pPntlist) { DataTable dt = GetDataTableByStruture(); DF2DFeatureClass Arcdfcc = pArclist[count]; Pntfc = Pntdfcc.GetFeatureClass(); Arcfc = Arcdfcc.GetFeatureClass(); if (Pntfc == null && Arcfc == null) { return; } WaitForm.SetCaption("正在检查图层:" + " " + Pntfc.AliasName); FacilityClass fac = Pntdfcc.GetFacilityClass(); if (fac == null) { continue; } FacilityClass facc = Arcdfcc.GetFacilityClass(); if (facc == null) { continue; } //List<DFDataConfig.Class.FieldInfo> listField = fac.FieldInfoCollection; DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName("LinkType"); if (fi == null) { continue; } DFDataConfig.Class.FieldInfo fi1 = fac.GetFieldInfoBySystemName("Detectid"); if (fi1 == null) { continue; } DFDataConfig.Class.FieldInfo fi2 = facc.GetFieldInfoBySystemName("StartNo"); if (fi2 == null) { continue; } DFDataConfig.Class.FieldInfo fi3 = facc.GetFieldInfoBySystemName("EndNo"); if (fi3 == null) { continue; } DFDataConfig.Class.FieldInfo fi4 = fac.GetFieldInfoBySystemName("UState"); if (fi4 == null) { continue; } // DFDataConfig.Class.FieldInfo fi5 = facc.GetFieldInfoBySystemName("source"); // if (fi5 == null) continue; pFeaCursor = Pntfc.Search(null, true); while ((pFea = pFeaCursor.NextFeature()) != null) { bool b1 = false, b2 = false; strPntID = pFea.get_Value(Pntfc.FindField(fi1.Name)).ToString(); strDicValue = pFea.get_Value(Pntfc.FindField(fi.Name)).ToString(); if (strDicValue == "三通" || strDicValue == "三分支") { k = 3; } else if (strDicValue == "四通" || strDicValue == "四分支") { k = 4; } else if (strDicValue == "五通" || strDicValue == "五分支") { k = 5; } else if (strDicValue == "六通" || strDicValue == "六分支") { k = 6; } else if (strDicValue == "七通" || strDicValue == "七分支") { k = 7; } else if (strDicValue == "八通" || strDicValue == "八分支") { k = 8; } else { k = 2; } pFilter.WhereClause = fi2.Name + " = '" + strPntID + "' or " + fi3.Name + " = '" + strPntID + "'"; if (Arcfc.FeatureCount(pFilter) != k) { b1 = true; } if (Pntfc.FindField(fi4.Name) != -1 && Arcfc.FindField(fi4.Name) != -1) { pFilter.WhereClause = "(" + fi2.Name + " = '" + strPntID + "' or " + fi3.Name + " = '" + strPntID + "') and " + fi4.Name + " <> '" + strDicValue + "'"; if (Arcfc.FeatureCount(pFilter) > 0) { b2 = true; } } DataRow dr = dt.NewRow(); dr["ErrorFeatureID"] = pFea.OID; dr["FeatureofClass"] = Pntfc.AliasName; dr["FeatureofLayer"] = (Pntfc as IDataset).Name; dr["FeatureClass"] = Pntfc; if (b1 && b2) { dr["ErrorType"] = "多通多分支与管点连接管线数量不一致;管点与相连接管线的使用状态不一致"; } else if (b1 && !b2) { dr["ErrorType"] = "多通多分支与管点连接管线数量不一致"; } else if (!b1 && b2) { dr["ErrorType"] = "管点与相连接管线的使用状态不一致"; } dt.Rows.Add(dr); //Console.WriteLine(pFea.OID + " " + Pntfc.AliasName); } if (dt.Rows.Count > 0) { dict[Pntfc] = dt; } count++; } WaitForm.Stop(); FormCheckResult dlg = new FormCheckResult(dict, m_pMapControl); dlg.Text = this.CommandName; dlg.Show(); } catch (System.Exception ex) { } } }