public int GetFeatureCount(IFeatureDataSet fds, QueryFilter filter) { int num = 0; try { string[] namesByType = fds.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable); if (namesByType != null) { string[] array = namesByType; for (int i = 0; i < array.Length; i++) { string name = array[i]; IFeatureClass featureClass = fds.OpenFeatureClass(name); if (featureClass != null) { num += featureClass.GetCount(filter); System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); } } } } catch (System.Runtime.InteropServices.COMException ex) { } catch (System.Exception e) { LoggingService.Error(e.Message + "\r\n" + e.StackTrace); } return(num); }
private void query() { if (this.cmbLayer.SelectedItem == null) { return; } DF3DFeatureClass dffc = this.cmbLayer.SelectedItem as DF3DFeatureClass; IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { return; } ISpatialFilter filter = new SpatialFilter(); #region if (this.cmbField.SelectedItem == null) { filter.WhereClause = "1=1"; } else { if (this.cmbField.SelectedItem is DFDataConfig.Class.FieldInfo) { DFDataConfig.Class.FieldInfo fi = this.cmbField.SelectedItem as DFDataConfig.Class.FieldInfo; if (oper == " like ") { filter.WhereClause = fi.Name + " like '%" + this.teFieldValue.Text + "%'"; } else { if (fi.DataType.ToLower() == "decimal") { filter.WhereClause = fi.Name + oper + this.teFieldValue.Text; } else { filter.WhereClause = fi.Name + oper + "'" + this.teFieldValue.Text + "'"; } } } else { filter.WhereClause = "1!=1"; } } #endregion int count = fc.GetCount(filter); if (count == 0) { XtraMessageBox.Show("查询结果为空", "提示"); return; } this._dffc = dffc; this._filter = filter; this._total = count; this.DialogResult = System.Windows.Forms.DialogResult.OK; }
void axRenderControl1_RcMouseClickSelect_CreateFeature(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender) { _geoEditor.FinishEdit(); //用于当拾取到基准面时,或者没有正常右键结束连续调用Start时 this.axRenderControl1.FeatureManager.UnhighlightAll(); if (PickResult != null) { switch (PickResult.Type) { case gviObjectType.gviObjectFeatureLayer: { IFeatureLayerPickResult flpr = PickResult as IFeatureLayerPickResult; int fid = flpr.FeatureId; //加载多FeatureClass时要每次重新获取 _featureClass = (IFeatureClass)fcGUIDMap[flpr.FeatureLayer.FeatureClassId]; _featureLayer = flpr.FeatureLayer; IFdeCursor cursor = null; try { _buffer = _featureClass.CreateRowBuffer(); IQueryFilter filter = new QueryFilter(); //filter.AddSubField("oid"); //注意:StartEditFeatureGeometry里必须传入一个完整的rowbuffer,所以这里不能限定字段 filter.WhereClause = "oid =" + fid; cursor = _featureClass.Search(filter, false); IRowBuffer row = null; if ((row = cursor.NextRow()) != null) { _buffer = row as IRowBuffer; int pos = _buffer.FieldIndex("Geometry"); oldfdeGeometry = _buffer.GetValue(pos) as IGeometry; _buffer.SetValue(0, _featureClass.GetCount(null)); //修改fid为不同值,否则不是创建而是编辑 } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } finally { } this.axRenderControl1.FeatureManager.HighlightFeature(_featureClass, fid, System.Drawing.Color.Yellow); resultCode = _geoEditor.StartEditFeatureGeometry(_buffer, _featureLayer, gviGeoEditType.gviGeoEditCreator); if (!resultCode) { MessageBox.Show(this.axRenderControl1.GetLastError().ToString()); } } break; } } }
private void toolStripMenuItemViewData_Click(object sender, EventArgs e) { string fc_name = selectNode.Text; string set_name = selectNode.Parent.Text; myTreeNode node = (myTreeNode)selectNode.Parent.Parent; IConnectionInfo ci = node.con; IDataSource ds = null; IFeatureDataSet dataset = null; IFeatureClass fc = null; try { ds = dsFactory.OpenDataSource(ci); dataset = ds.OpenFeatureDataset(set_name); fc = dataset.OpenFeatureClass(fc_name); IQueryFilter filter = new QueryFilter(); int nCount = fc.GetCount(filter); if (nCount == 0) { return; } // 初始化表格 DataTable dt = CreateDataTable(fc); // 查找数据 GetResultSet(fc, filter, dt); // 显示表格 FCConnectionInfo info = new FCConnectionInfo(ci, set_name, fc_name); new AttributeFrm(dt, info, filter.WhereClause).Show(); } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } finally { if (ds != null) { //Marshal.ReleaseComObject(ds); ds = null; } if (dataset != null) { //Marshal.ReleaseComObject(dataset); dataset = null; } if (fc != null) { //Marshal.ReleaseComObject(fc); fc = 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 List <PipeLineFac> GetTopoPipeLine() { if (this._tc == null) { return(null); } if (DF3DPipeCreateApp.App.PipeLib == null) { return(null); } IQueryFilter filter = null; IFdeCursor o = null; IRowBuffer r = null; Dictionary <string, List <int> > dictionary = null; Dictionary <string, FacClassReg> dictReg = null; Dictionary <int, int> dictionary2 = null; List <PipeLineFac> list = null; try { IFeatureDataSet fds = DF3DPipeCreateApp.App.PipeLib.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IFeatureClass class2 = fds.OpenFeatureClass(this._tc.TopoTable); if (class2 == null) { return(null); } filter = new QueryFilterClass { WhereClause = string.Format("(P_FacClass = '{0}' and PNode = {1}) or (E_FacClass = '{0}' and ENode = {1})", this._facClassReg.FeatureClassId, base._oid), SubFields = "oid,A_FacClass,Edge,PNode,ENode" }; int count = class2.GetCount(filter); if (count == 0) { return(null); } dictionary = new Dictionary <string, List <int> >(); dictionary2 = new Dictionary <int, int>(); dictReg = new Dictionary <string, FacClassReg>(); o = class2.Search(filter, true); while ((r = o.NextRow()) != null) { if (!r.IsNull(1) && !r.IsNull(2)) { FacClassReg reg = GetFacClassReg(r.GetValue(1).ToString()); if (!dictionary.ContainsKey(reg.FacClassCode)) { dictionary.Add(reg.FacClassCode, new List <int>()); dictReg.Add(reg.FacClassCode, reg); } dictionary[reg.FacClassCode].Add(Fac.GetInt(r, 2)); if (Fac.GetInt(r, 3) == this._oid) { dictionary2.Add(Fac.GetInt(r, 2), 0); } else { dictionary2.Add(Fac.GetInt(r, 2), 1); } } } if (dictionary.Count == 0) { return(null); } list = new List <PipeLineFac>(); foreach (KeyValuePair <string, List <int> > pair in dictionary) { FacClassReg reg = dictReg[pair.Key]; if (reg.FacilityType.Name == "PipeLine") { IFeatureClass class3 = reg.GetFeatureClass(); o = class3.GetRows(pair.Value.ToArray(), false); while ((r = o.NextRow()) != null) { int index = r.FieldIndex("StyleId"); if (index == -1) { continue; } FacStyleClass style = GetFacStyleByID(r.GetValue(index).ToString()); if (style != null) { PipeLineFac line = new PipeLineFac(reg, style, r, this._tc); line.Tag = dictionary2[line.FeatureId]; list.Add(line); } } } } return(list); } catch (Exception ex) { return(null); } finally { if (o != null) { Marshal.ReleaseComObject(o); o = null; } if (r != null) { Marshal.ReleaseComObject(r); r = null; } } }
private void GetData() { string whereClause = _dict[_currentClass]; SubClass sc = _currentClass; if (sc.Parent == null) { return; } string[] arrFc3DId = sc.Parent.Fc3D.Split(';'); if (arrFc3DId == null) { return; } 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; } List <DFDataConfig.Class.FieldInfo> facFields = facc.FieldInfoCollection; if (facFields == null || facFields.Count == 0) { return; } ISpatialFilter filter = new SpatialFilter(); filter.SpatialRel = gviSpatialRel.gviSpatialRelIntersects; filter.Geometry = this._geo; filter.GeometryField = "FootPrint"; filter.WhereClause = whereClause; _count = fc.GetCount(filter); if (_num > _count || _count == 0) { return; } filter.ResultBeginIndex = _num - 1; filter.ResultLimit = 1; IFdeCursor cursor = null; IRowBuffer row = null; try { cursor = fc.Search(filter, false); if ((row = cursor.NextRow()) != null) { #region 定位 int geoindex = row.FieldIndex("Geometry"); if (geoindex == -1 || !(row.GetValue(geoindex) is IModelPoint)) { continue; } DF3DApplication app = DF3DApplication.Application; if (app != null && app.Current3DMapControl != null) { IModelPoint geo = row.GetValue(geoindex) as IModelPoint; IModelPointSymbol mps = new ModelPointSymbol(); mps.SetResourceDataSet(fc.FeatureDataSet); IRenderGeometry render = app.Current3DMapControl.ObjectManager.CreateRenderModelPoint(geo, mps, app.Current3DMapControl.ProjectTree.RootID); //app.Current3DMapControl.Camera.FlyToObject(render.Guid, gviActionCode.gviActionJump); render.Glow(5000); app.Current3DMapControl.ObjectManager.DelayDelete(render.Guid, 5000); ITableLabel tl = DrawTool.CreateTableLabel1(1); tl.TitleText = "属性查询"; tl.SetRecord(0, 0, dffc.ToString()); IPoint ptTL = null; int geoshapeindex = row.FieldIndex("Shape"); if (geoshapeindex != -1) { if (!row.IsNull(geoshapeindex)) { IGeometry geoShape = row.GetValue(geoshapeindex) as IGeometry; if (geoShape.GeometryType == gviGeometryType.gviGeometryMultiPolyline) { double x = 0; double y = 0; double z = 0; IMultiPolyline mPolyline = geoShape as IMultiPolyline; for (int m = 0; m < mPolyline.GeometryCount; m++) { IPolyline polyline = mPolyline.GetPolyline(m); IPoint pttemp = polyline.Midpoint; x += pttemp.X; y += pttemp.Y; z += pttemp.Z; } x = x / mPolyline.GeometryCount; y = y / mPolyline.GeometryCount; z = z / mPolyline.GeometryCount; ptTL = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); ptTL.X = x; ptTL.Y = y; ptTL.Z = z; } else if (geoShape.GeometryType == gviGeometryType.gviGeometryMultiPolygon) { double x = 0; double y = 0; double z = 0; IMultiPolygon mPolygon = geoShape as IMultiPolygon; for (int m = 0; m < mPolygon.GeometryCount; m++) { IPolygon polygon = mPolygon.GetPolygon(m); IPoint pttemp = polygon.Centroid; x += pttemp.X; y += pttemp.Y; z += pttemp.Z; } x = x / mPolygon.GeometryCount; y = y / mPolygon.GeometryCount; z = z / mPolygon.GeometryCount; ptTL = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); ptTL.X = x; ptTL.Y = y; ptTL.Z = z; } else if (geoShape.GeometryType == gviGeometryType.gviGeometryPolyline) { ptTL = (geoShape as IPolyline).Midpoint; } else if (geoShape.GeometryType == gviGeometryType.gviGeometryPoint) { ptTL = geoShape as IPoint; } else if (geoShape.GeometryType == gviGeometryType.gviGeometryPolygon) { ptTL = (geoShape as IPolygon).Centroid; } } } if (ptTL != null) { tl.Position = ptTL; } else { tl.Position = geo; } app.Current3DMapControl.Camera.FlyToObject(tl.Guid, gviActionCode.gviActionFlyTo); app.Current3DMapControl.ObjectManager.DelayDelete(tl.Guid, 5000); } #endregion foreach (DFDataConfig.Class.FieldInfo facField in facFields) { if (!facField.CanQuery) { continue; } int index = row.FieldIndex(facField.Name); if (index != -1 && !row.IsNull(index)) { object obj = row.GetValue(index); string str = ""; IFieldInfo fiFC = row.Fields.Get(index); switch (fiFC.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldUnknown: case gviFieldType.gviFieldGeometry: continue; case gviFieldType.gviFieldFloat: case gviFieldType.gviFieldDouble: double d; if (double.TryParse(obj.ToString(), out d)) { str = d.ToString("0.00"); } break; default: str = obj.ToString(); break; } DataRow dr = this._dtShow.NewRow(); dr["Property"] = facField.ToString(); dr["Value"] = str; this._dtShow.Rows.Add(dr); } } } } 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; } } } }
private void OnFinishedDraw() { if (this._drawTool != null) { if (this.radioGroup1.SelectedIndex == 0) { if (this._drawTool.GetSelectFeatureLayerPickResult() != null && this._drawTool.GetSelectPoint() != null) { IFeatureLayerPickResult pr = this._drawTool.GetSelectFeatureLayerPickResult(); string g = pr.FeatureLayer.FeatureClassId.ToString(); string facName = Dictionary3DTable.Instance.GetFacilityClassNameByDFFeatureClassID(g); if (facName != "PipeLine") { XtraMessageBox.Show("您选择的不是管线设施。", "提示"); return; } DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(g); if (dffc == null) { return; } int fid = pr.FeatureId; MajorClass mc = LogicDataStructureManage3D.Instance.GetMajorClassByDFFeatureClassID(g); if (mc == null) { return; } _num++; IPoint interPoint = this._drawTool.GetSelectPoint(); ISimplePointSymbol sps = new SimplePointSymbol(); sps.FillColor = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16); sps.Size = SystemInfo.Instance.SymbolSize; IRenderPoint rp = d3.ObjectManager.CreateRenderPoint(interPoint, sps, d3.ProjectTree.RootID); this._dict[_num] = rp.Guid; ILabel label = d3.ObjectManager.CreateLabel(d3.ProjectTree.RootID); IPoint pt = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pt.SetCoords(interPoint.X, interPoint.Y, interPoint.Z + 1, 0, 0); label.Position = pt; label.Text = _num.ToString(); TextSymbol ts = new TextSymbol(); TextAttribute ta = new TextAttribute(); ta.TextColor = Convert.ToUInt32(SystemInfo.Instance.TextColor, 16); ta.TextSize = SystemInfo.Instance.TextSize; ts.TextAttribute = ta; label.TextSymbol = ts; this._dictLabel[_num] = label.Guid; DataRow dr = this._dt.NewRow(); dr["Num"] = _num; dr["PipeType"] = mc; dr["Fid"] = fid; dr["FeatureClass"] = dffc.GetFeatureClass(); dr["InterPoint"] = interPoint; this._dt.Rows.Add(dr); } } if (this.radioGroup1.SelectedIndex == 1) { if (this._drawTool.GetGeo() != null) { WaitForm.Start("正在进行相交查询...", "请稍后"); IPolyline line = this._drawTool.GetGeo() as IPolyline; IPolyline l = line.Clone2(gviVertexAttribute.gviVertexAttributeNone) as IPolyline; List <DF3DFeatureClass> listdffc = DF3DFeatureClassManager.Instance.GetFeatureClassByFacilityClassName("PipeLine"); if (listdffc == null) { return; } foreach (DF3DFeatureClass dffc in listdffc) { IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { continue; } MajorClass mc = LogicDataStructureManage3D.Instance.GetMajorClassByDFFeatureClassID(fc.GuidString); if (mc == null) { continue; } if (this._dt.Rows.Count > 0) { if (this._dt.Rows[0]["PipeType"] != null && this._dt.Rows[0]["PipeType"] is MajorClass) { if (mc.Name != (this._dt.Rows[0]["PipeType"] as MajorClass).Name) { continue; } } } ISpatialFilter filter = new SpatialFilter(); filter.Geometry = l; filter.GeometryField = "FootPrint"; filter.SpatialRel = gviSpatialRel.gviSpatialRelIntersects; int counttemp = fc.GetCount(filter); if (counttemp == 0) { continue; } IFdeCursor cursor = null; IRowBuffer row = null; try { IFieldInfoCollection fields = fc.GetFields(); cursor = fc.Search(filter, true); while ((row = cursor.NextRow()) != null) { IPolyline geo = row.GetValue(fields.IndexOf("FootPrint")) as IPolyline; IPolyline geoShape = row.GetValue(fields.IndexOf("Shape")) as IPolyline; if (geo == null || geoShape == null || geo.GeometryType != gviGeometryType.gviGeometryPolyline || geoShape.GeometryType != gviGeometryType.gviGeometryPolyline) { continue; } if ((l as IRelationalOperator2D).Intersects2D(geo)) { IPoint intersectPointTemp = (l as ITopologicalOperator2D).Intersection2D(geo) as IPoint; double height = geoShape.StartPoint.Z + (geoShape.EndPoint.Z - geoShape.StartPoint.Z) * Math.Sqrt((geo.StartPoint.X - intersectPointTemp.X) * (geo.StartPoint.X - intersectPointTemp.X) + (geo.StartPoint.Y - intersectPointTemp.Y) * (geo.StartPoint.Y - intersectPointTemp.Y)) / geo.Length; IPoint intersectPoint = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); intersectPoint.Z = height; intersectPoint.X = intersectPointTemp.X; intersectPoint.Y = intersectPointTemp.Y; int fid = int.Parse(row.GetValue(0).ToString()); _num++; ISimplePointSymbol sps = new SimplePointSymbol(); sps.FillColor = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16); sps.Size = SystemInfo.Instance.SymbolSize; IRenderPoint rp = d3.ObjectManager.CreateRenderPoint(intersectPoint, sps, d3.ProjectTree.RootID); this._dict[_num] = rp.Guid; ILabel label = d3.ObjectManager.CreateLabel(d3.ProjectTree.RootID); IPoint pt = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pt.SetCoords(intersectPoint.X, intersectPoint.Y, intersectPoint.Z + 1, 0, 0); label.Position = pt; label.Text = _num.ToString(); TextSymbol ts = new TextSymbol(); TextAttribute ta = new TextAttribute(); ta.TextColor = Convert.ToUInt32(SystemInfo.Instance.TextColor, 16); ta.TextSize = SystemInfo.Instance.TextSize; ts.TextAttribute = ta; label.TextSymbol = ts; this._dictLabel[_num] = label.Guid; DataRow dr = this._dt.NewRow(); dr["Num"] = _num; dr["PipeType"] = mc; dr["Fid"] = fid; dr["FeatureClass"] = fc; dr["InterPoint"] = intersectPoint; this._dt.Rows.Add(dr); } } } 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 DataTable DoStats() { DataTable dtResult = new DataTable(); dtResult.TableName = "DataStats"; dtResult.Columns.AddRange(new DataColumn[] { new DataColumn("PIPENODETYPE"), new DataColumn("FIELDNAME"), new DataColumn("PVALUE"), new DataColumn("NUMBER", typeof(long)), new DataColumn("TOTALNUMBER", typeof(long)) }); string localDataPath = SystemInfo.Instance.LocalDataPath; string tmpPath = ""; tmpPath = Path.Combine(localDataPath, "Stats"); if (!Directory.Exists(tmpPath)) { Directory.CreateDirectory(tmpPath); } string filePath = tmpPath + "\\全库3D管点统计.xml"; bool bHaveXml = false; if (File.Exists(filePath)) { dtResult.ReadXml(filePath); if (dtResult != null && dtResult.Rows.Count != 0) { bHaveXml = true; return(dtResult); } else { bHaveXml = false; } } List <MajorClass> list = LogicDataStructureManage3D.Instance.GetAllMajorClass(); foreach (MajorClass mc in list) { string[] arrFc3DId = mc.Fc3D.Split(';'); if (arrFc3DId == null) { continue; } long majorclasscount = 0; int indexStart = dtResult.Rows.Count; foreach (SubClass sc in mc.SubClasses) { long sccount = 0; 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 || facc.Name != "PipeNode") { continue; } IQueryFilter filter = new QueryFilter(); filter.WhereClause = "GroupId = " + sc.GroupId; int count = fc.GetCount(filter); if (count == 0) { continue; } bHave = true; sccount += count; } if (bHave) { DataRow dr = dtResult.NewRow(); dr["PIPENODETYPE"] = mc; dr["FIELDNAME"] = ""; dr["PVALUE"] = sc; dr["NUMBER"] = sccount; majorclasscount += sccount; dtResult.Rows.Add(dr); } } int indexEnd = dtResult.Rows.Count; for (int i = indexStart; i < indexEnd; i++) { DataRow dr = dtResult.Rows[i]; dr["TOTALNUMBER"] = majorclasscount; } } if (!bHaveXml) { dtResult.WriteXml(filePath); } return(dtResult); }
private void OnFinishedDraw() { try { if (this._drawTool != null && this._drawTool.GetGeo() != null) { switch (this._drawTool.GeoType) { case DrawType.Point: break; case DrawType.Polyline: break; case DrawType.Circle: break; case DrawType.Rectangle: break; case DrawType.Polygon: break; default: return; } IGeometry geo = this._drawTool.GetGeo(); if (geo == null) { return; } IGeometry geoBuffer = (geo as ITopologicalOperator2D).Buffer2D(Convert.ToDouble(this.seBufferDis.Value.ToString()), gviBufferStyle.gviBufferCapround); if (geoBuffer == null) { return; } if (this._drawTool != null) { this._drawTool.OnStartDraw -= new OnStartDraw(this.OnStartDraw); this._drawTool.OnFinishedDraw -= new OnFinishedDraw(this.OnFinishedDraw); this._drawTool.Close(); this._drawTool.End(); } this._3DControl.HighlightHelper.VisibleMask = 1; this._3DControl.HighlightHelper.SetRegion(geoBuffer); if (geoBuffer.GeometryType == gviGeometryType.gviGeometryPolygon) { this._rPolygon = this._3DControl.ObjectManager.CreateRenderPolygon(geoBuffer as IPolygon, this._surfaceSymbol, this._3DControl.ProjectTree.RootID); if (this._3DControl.Terrain.IsRegistered && this._3DControl.Terrain.VisibleMask != gviViewportMask.gviViewNone) { (this._rPolygon as IRenderPolygon).HeightStyle = gviHeightStyle.gviHeightOnTerrain; } else { (this._rPolygon as IRenderPolygon).HeightStyle = gviHeightStyle.gviHeightAbsolute; } } else if (geoBuffer.GeometryType == gviGeometryType.gviGeometryMultiPolygon) { this._rPolygon = this._3DControl.ObjectManager.CreateRenderMultiPolygon(geoBuffer as IMultiPolygon, this._surfaceSymbol, this._3DControl.ProjectTree.RootID); if (this._3DControl.Terrain.IsRegistered && this._3DControl.Terrain.VisibleMask != gviViewportMask.gviViewNone) { (this._rPolygon as IRenderMultiPolygon).HeightStyle = gviHeightStyle.gviHeightOnTerrain; } else { (this._rPolygon as IRenderMultiPolygon).HeightStyle = gviHeightStyle.gviHeightAbsolute; } } else { return; } if (this.cmbLayer.SelectedItem == null) { return; } ISpatialFilter filter = new SpatialFilter(); filter.Geometry = geoBuffer; if (this.cmbSpatialRelation.Text == "包含") { filter.SpatialRel = gviSpatialRel.gviSpatialRelContains; } else { filter.SpatialRel = gviSpatialRel.gviSpatialRelIntersects; } DF3DFeatureClass dffc = this.cmbLayer.SelectedItem as DF3DFeatureClass; IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { return; } IFeatureLayer fl = dffc.GetFeatureLayer(); if (fl == null) { return; } filter.GeometryField = fl.GeometryFieldName; int count = fc.GetCount(filter); if (count == 0) { XtraMessageBox.Show("查询结果为空", "提示"); return; } WaitForm.Start("正在查询...", "请稍后"); this._uPanel = new UIDockPanel("查询结果", "查询结果", this.Location1, 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; this._uc = new UCPropertyInfo(); this._uc.Init(); this._uc.Dock = System.Windows.Forms.DockStyle.Fill; this._uPanel.RegisterEvent(new PanelClose(this.Close)); this._dockPanel.Controls.Add(this._uc); this._uc.SetInfo(dffc, filter, count); WaitForm.Stop(); } } catch (Exception ex) { } }
/// <summary> /// 在要素类里创建要素 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripButtonInsertFeature_Click(object sender, EventArgs e) { if (dsFactory == null) { dsFactory = new DataSourceFactory(); } IDataSource ds = null; IFeatureDataSet dataset = null; IFeatureClass fc = null; IFdeCursor cursor = null; try { ds = dsFactory.OpenDataSource(Info.ci); dataset = ds.OpenFeatureDataset(Info.datasetName); fc = dataset.OpenFeatureClass(Info.featureclassName); DataRow dr = AttriTable.NewRow();; RowBufferFactory rbf = new RowBufferFactory(); IRowBuffer rb = rbf.CreateRowBuffer(fc.GetFields()); // 构造待插入的数据:暂时用最后一行的数据进行插入 int lastOid = int.Parse(dataGridView1.Rows[AttriTable.Rows.Count - 1].Cells["oid"].Value.ToString()); IRowBuffer lastRow = fc.GetRow(lastOid); for (int i = 0; i < fc.GetFields().Count; ++i) { string strColName = fc.GetFields().Get(i).Name; int nPos = rb.FieldIndex(strColName); if (fc.GetFields().Get(i).Name != "oid") { rb.SetValue(nPos, lastRow.GetValue(nPos)); //插入字段值 } } // 构造界面显示数据 for (int j = 0; j < AttriTable.Columns.Count; ++j) { string strColName = AttriTable.Columns[j].ColumnName; int nPos = rb.FieldIndex(strColName); if (nPos != -1 && strColName != "oid") { if (lastRow.GetValue(nPos) != null) { dr[j] = lastRow.GetValue(nPos).ToString(); } } if ("GroupName" == strColName) { dr[j] = this.dataGridView1.Rows[AttriTable.Rows.Count - 1].Cells["GroupName"].Value.ToString(); } } // 往数据库中增加 cursor = fc.Insert(); cursor.InsertRow(rb); // 往界面DataTable上增加 dr["oid"] = cursor.LastInsertId; //获取插入后oid值在界面显示 AttriTable.Rows.Add(dr); this.dataGridView1.Refresh(); this.dataGridView1.Rows[AttriTable.Rows.Count - 1].Selected = true; this.dataGridView1.FirstDisplayedScrollingRowIndex = AttriTable.Rows.Count - 1; MessageBox.Show("增加记录成功"); // 更新表头文字 if (FilterWhereClause.Equals("")) { this.Text = "Attributes of " + Info.featureclassName + " [Total records: " + fc.GetCount(null).ToString() + "]"; } else { this.Text = "Attributes of " + Info.featureclassName + " [Total records: " + AttriTable.Rows.Count.ToString() + "]" + " Filter: " + FilterWhereClause; } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } finally { if (ds != null) { //Marshal.ReleaseComObject(ds); ds = null; } if (dataset != null) { //Marshal.ReleaseComObject(dataset); dataset = null; } if (fc != null) { //Marshal.ReleaseComObject(fc); fc = null; } if (cursor != null) { //Marshal.ReleaseComObject(cursor); cursor = null; } } }
private DataTable DoStats() { DataTable dtResult = new DataTable(); dtResult.TableName = "DataStats"; dtResult.Columns.AddRange(new DataColumn[] { new DataColumn("PIPELINETYPE"), new DataColumn("FIELDNAME"), new DataColumn("PVALUE"), new DataColumn("LENGTH", typeof(double)), new DataColumn("TOTALLENGTH", typeof(double)) }); string localDataPath = SystemInfo.Instance.LocalDataPath; string tmpPath = ""; tmpPath = Path.Combine(localDataPath, "Stats"); if (!Directory.Exists(tmpPath)) { Directory.CreateDirectory(tmpPath); } string filePath = tmpPath + "\\全库3D管线统计.xml"; bool bHaveXml = false; if (File.Exists(filePath)) { dtResult.ReadXml(filePath); if (dtResult != null && dtResult.Rows.Count != 0) { bHaveXml = true; return(dtResult); } else { bHaveXml = false; } } List <MajorClass> list = LogicDataStructureManage3D.Instance.GetAllMajorClass(); foreach (MajorClass mc in list) { string[] arrFc3DId = mc.Fc3D.Split(';'); if (arrFc3DId == null) { continue; } double majorclasslength = 0.0; int indexStart = dtResult.Rows.Count; foreach (SubClass sc in mc.SubClasses) { double subclasslength = 0.0; 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 || facc.Name != "PipeLine") { continue; } DFDataConfig.Class.FieldInfo fiPipeLength = facc.GetFieldInfoBySystemName("PipeLength"); if (fiPipeLength == null) { continue; } int indexPipeLength = fc.GetFields().IndexOf(fiPipeLength.Name); if (indexPipeLength == -1) { continue; } IQueryFilter filter = new QueryFilter(); filter.SubFields = fiPipeLength.Name; filter.WhereClause = "GroupId = " + sc.GroupId; int count = fc.GetCount(filter); if (count == 0) { continue; } int loop = (int)Math.Ceiling(count / 800.0); for (int k = 1; k <= loop; k++) { if (k == 1) { filter.ResultBeginIndex = 0; } else { filter.ResultBeginIndex = (k - 1) * 800; } filter.ResultLimit = 800; IFdeCursor cur = null; IRowBuffer rowBuf = null; try { cur = fc.Search(filter, true); while ((rowBuf = cur.NextRow()) != null) { if (!rowBuf.IsNull(0)) { object tempobj = rowBuf.GetValue(0); double dtemp = 0.0; if (tempobj != null && double.TryParse(tempobj.ToString(), out dtemp)) { subclasslength += dtemp; bHave = true; } } } } catch { } finally { if (cur != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cur); cur = null; } if (rowBuf != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(rowBuf); rowBuf = null; } } } } if (bHave) { DataRow dr = dtResult.NewRow(); dr["PIPELINETYPE"] = mc; dr["FIELDNAME"] = ""; dr["PVALUE"] = sc; dr["LENGTH"] = subclasslength.ToString("0.00"); majorclasslength += subclasslength; dtResult.Rows.Add(dr); } } int indexEnd = dtResult.Rows.Count; for (int i = indexStart; i < indexEnd; i++) { DataRow dr = dtResult.Rows[i]; dr["TOTALLENGTH"] = majorclasslength.ToString("0.00"); } } if (!bHaveXml) { dtResult.WriteXml(filePath); } return(dtResult); }
private Dictionary <string, string> GetQueryResult(DF3DFeatureClass dffc, int featureId) { if (dffc == null) { return(null); } IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { return(null); } IFdeCursor cursor = null; IRowBuffer row = null; try { IQueryFilter filter = new QueryFilter(); filter.WhereClause = fc.FidFieldName + "=" + featureId; if (fc.GetCount(filter) == 0) { return(null); } cursor = fc.Search(filter, false); if (cursor == null) { return(null); } row = cursor.NextRow(); if (row == null) { return(null); } FacilityClass facClass = dffc.GetFacilityClass(); IFieldInfoCollection fiCol = row.Fields; Dictionary <string, string> dict = new Dictionary <string, string>(); if (facClass == null) { for (int i = 0; i < fiCol.Count; i++) { IFieldInfo fi = row.Fields.Get(i); object obj = row.GetValue(i); if (obj == null) { continue; } string str = ""; switch (fi.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldUnknown: case gviFieldType.gviFieldGeometry: break; case gviFieldType.gviFieldFloat: case gviFieldType.gviFieldDouble: double d; if (double.TryParse(obj.ToString(), out d)) { str = d.ToString("0.00"); } break; default: str = obj.ToString(); break; } if (!string.IsNullOrEmpty(str.Trim())) { string temp = (string.IsNullOrEmpty(fi.Alias)) ? fi.Name : fi.Alias; dict[temp] = str; } } } else { foreach (DFDataConfig.Class.FieldInfo fi in facClass.FieldInfoCollection) { if (!fi.CanQuery) { continue; } int index = row.Fields.IndexOf(fi.Name); if (index == -1) { continue; } object obj = row.GetValue(index); if (obj == null) { continue; } IFieldInfo fiFC = row.Fields.Get(index); string str = ""; switch (fiFC.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldUnknown: case gviFieldType.gviFieldGeometry: break; case gviFieldType.gviFieldFloat: case gviFieldType.gviFieldDouble: double d; if (double.TryParse(obj.ToString(), out d)) { str = d.ToString("0.00"); } break; default: str = obj.ToString(); break; } if (!string.IsNullOrEmpty(str.Trim())) { string temp = (string.IsNullOrEmpty(fi.Alias)) ? fi.Name : fi.Alias; dict[temp] = str; } } } return(dict); } catch (Exception ex) { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } return(null); } }
private Dictionary <string, string> GetQueryResult(IFeatureClassInfo fcInfo, int featureId) { if (fcInfo == null || featureId < 0) { return(null); } IFdeCursor cursor = null; IRowBuffer row = null; try { IDataSourceFactory dsf = new DataSourceFactory(); if (!dsf.HasDataSourceByString(fcInfo.DataSourceConnectionString)) { return(null); } IDataSource ds = dsf.OpenDataSourceByString(fcInfo.DataSourceConnectionString); if (ds == null) { return(null); } IFeatureDataSet fds = ds.OpenFeatureDataset(fcInfo.DataSetName); if (fds == null) { return(null); } IFeatureClass fc = fds.OpenFeatureClass(fcInfo.FeatureClassName); if (fc == null) { return(null); } IQueryFilter filter = new QueryFilter(); filter.WhereClause = fc.FidFieldName + "=" + featureId; if (fc.GetCount(filter) == 0) { return(null); } cursor = fc.Search(filter, false); if (cursor == null) { return(null); } row = cursor.NextRow(); if (row == null) { return(null); } IFieldInfoCollection fiCol = row.Fields; Dictionary <string, string> dict = new Dictionary <string, string>(); for (int i = 0; i < fiCol.Count; i++) { IFieldInfo fi = row.Fields.Get(i); object obj = row.GetValue(fiCol.IndexOf(fi.Name)); if (obj == null) { continue; } string str = ""; switch (fi.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldUnknown: case gviFieldType.gviFieldGeometry: break; case gviFieldType.gviFieldFloat: case gviFieldType.gviFieldDouble: double d; if (double.TryParse(obj.ToString(), out d)) { str = d.ToString("0.00"); } break; default: str = obj.ToString(); break; } if (!string.IsNullOrEmpty(str.Trim())) { string temp = (string.IsNullOrEmpty(fi.Alias)) ? fi.Name : fi.Alias; dict[temp] = str; } } return(dict); } catch (Exception ex) { return(null); } }
private void toolStripMenuItemQuery_Click(object sender, EventArgs e) { string fc_name = selectNode.Text; string set_name = selectNode.Parent.Text; myTreeNode node = (myTreeNode)selectNode.Parent.Parent; IConnectionInfo ci = node.con; IDataSource ds = null; IFeatureDataSet dataset = null; IFeatureClass fc = null; try { ds = dsFactory.OpenDataSource(ci); dataset = ds.OpenFeatureDataset(set_name); fc = dataset.OpenFeatureClass(fc_name); QueryFilterDlg pQueryFilterDlg = new QueryFilterDlg(); for (int index = 0; index < fc.GetFields().Count; index++) { pQueryFilterDlg.FieldList_listBox.Items.Add(fc.GetFields().Get(index).Name); } if (DialogResult.OK == pQueryFilterDlg.ShowDialog()) { IQueryFilter filter = new QueryFilter(); filter.WhereClause = pQueryFilterDlg.QueryFilter_txt.Text; int nCount = fc.GetCount(filter); if (nCount == 0) { return; } // 初始化表格 DataTable dt = CreateDataTable(fc); // 查找数据 GetResultSet(fc, filter, dt); // 显示表格 new AttributeFrm(dt, fc.Name, filter.WhereClause).Show(); } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } finally { if (ds != null) { //Marshal.ReleaseComObject(ds); ds = null; } if (dataset != null) { //Marshal.ReleaseComObject(dataset); dataset = null; } if (fc != null) { //Marshal.ReleaseComObject(fc); fc = null; } } }
/// <summary> /// 在要素类里删除要素 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripButtonDeleteFeature_Click(object sender, EventArgs e) { if (dsFactory == null) { dsFactory = new DataSourceFactory(); } IDataSource ds = null; IFeatureDataSet dataset = null; IFeatureClass fc = null; try { if (dataGridView1.SelectedRows.Count > 0) { if (MessageBox.Show("该操作无法恢复,请确定是否删除所选择的要素?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { ds = dsFactory.OpenDataSource(Info.ci); dataset = ds.OpenFeatureDataset(Info.datasetName); fc = dataset.OpenFeatureClass(Info.featureclassName); int oid = int.Parse(dataGridView1.SelectedRows[0].Cells["oid"].Value.ToString()); // 从数据库中删除 IQueryFilter filter = new QueryFilter(); filter.WhereClause = "oid = " + oid; int nRet = fc.Delete(filter); MessageBox.Show("成功删除" + nRet + "条记录"); // 从界面DataTable中删除 int index = dataGridView1.SelectedRows[0].Index; AttriTable.Rows.RemoveAt(index); this.dataGridView1.Refresh(); if (index < dataGridView1.RowCount) { this.dataGridView1.Rows[index].Selected = true; this.dataGridView1.FirstDisplayedScrollingRowIndex = index; } else { this.dataGridView1.Rows[dataGridView1.RowCount - 1].Selected = true; this.dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.RowCount - 1; } // 更新表头文字 if (FilterWhereClause.Equals("")) { this.Text = "Attributes of " + Info.featureclassName + " [Total records: " + fc.GetCount(null).ToString() + "]"; } else { this.Text = "Attributes of " + Info.featureclassName + " [Total records: " + AttriTable.Rows.Count.ToString() + "]" + " Filter: " + FilterWhereClause; } } } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } finally { if (ds != null) { //Marshal.ReleaseComObject(ds); ds = null; } if (dataset != null) { //Marshal.ReleaseComObject(dataset); dataset = null; } if (fc != null) { //Marshal.ReleaseComObject(fc); fc = null; } } }
private DataTable RegionAnalysis() { IGeometry geo = this._drawTool.GetGeo(); if (geo == null) { return(null); } ISpatialFilter filter = new SpatialFilter(); filter.Geometry = geo; filter.SpatialRel = gviSpatialRel.gviSpatialRelEnvelope; filter.GeometryField = "Geometry"; DataTable dtResult = new DataTable(); dtResult.Columns.AddRange(new DataColumn[] { new DataColumn("PIPENODETYPE"), new DataColumn("PVALUE"), new DataColumn("NUMBER", typeof(long)), new DataColumn("TOTALNUMBER", typeof(long)) }); foreach (MajorClass mc in LogicDataStructureManage3D.Instance.GetAllMajorClass()) { string[] arrFc3DId = mc.Fc3D.Split(';'); if (arrFc3DId == null) { continue; } long majorclasscount = 0; int indexStart = dtResult.Rows.Count; foreach (SubClass sc in mc.SubClasses) { if (!sc.Visible3D) { continue; } long sccount = 0; 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 || facc.Name != "PipeNode") { continue; } int geometryIndex = fc.GetFields().IndexOf("Geometry"); if (geometryIndex == -1) { continue; } filter.WhereClause = "GroupId = " + sc.GroupId; filter.SubFields = "Geometry"; int count = fc.GetCount(filter); if (count == 0) { continue; } int loop = (int)Math.Ceiling(count / 800.0); for (int k = 1; k <= loop; k++) { if (k == 1) { filter.ResultBeginIndex = 0; } else { filter.ResultBeginIndex = (k - 1) * 800; } filter.ResultLimit = 800; IFdeCursor cursor = fc.Search(filter, true); IRowBuffer row = null; while ((row = cursor.NextRow()) != null) { IModelPoint modelPoint = row.GetValue(0) as IModelPoint; if ((geo as IRelationalOperator2D).Contains2D(modelPoint)) { sccount++; bHave = true; } } } } if (bHave) { DataRow dr = dtResult.NewRow(); dr["PIPENODETYPE"] = mc; dr["PVALUE"] = sc; dr["NUMBER"] = sccount; majorclasscount += sccount; dtResult.Rows.Add(dr); } } int indexEnd = dtResult.Rows.Count; for (int i = indexStart; i < indexEnd; i++) { DataRow dr = dtResult.Rows[i]; dr["TOTALNUMBER"] = majorclasscount; } } return(dtResult); }
public static HashSet <string> GetValveIdsByFCGuid(string fcGuid) { if (ValveManager.Instance.Exists(fcGuid)) { return(ValveManager.Instance.GetValveIds(fcGuid)); } if (DF3DPipeCreateApp.App.PipeLib == null) { return(null); } IFeatureClass fc = null; IQueryFilter filter = null; IFdeCursor cursor = null; IRowBuffer buffer = null; try { if (dictFC.ContainsKey(fcGuid) && dictFC[fcGuid] != null) { fc = dictFC[fcGuid]; } else { IFeatureDataSet fds = DF3DPipeCreateApp.App.PipeLib.OpenFeatureDataset("DataSet_GEO_Actuality"); if (fds == null) { return(null); } string[] fcNames = fds.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable); if (fcNames == null) { return(null); } foreach (string fcName in fcNames) { IFeatureClass fcTemp = fds.OpenFeatureClass(fcName); if (fcTemp.GuidString == fcGuid) { fc = fcTemp; break; } } if (fc == null) { return(null); } FacilityClass fac = FacilityClassManager.Instance.GetFacilityClassByName("PipeNode"); if (fac == null) { return(null); } DFDataConfig.Class.FieldInfo fi = fac.GetFieldInfoBySystemName("Additional"); if (fi == null) { return(null); } filter = new QueryFilterClass { SubFields = "oid," + fi.Name, WhereClause = fi.Name + " LIKE '%阀%'"//改 }; int count = fc.GetCount(filter); if (count == 0) { return(null); } cursor = fc.Search(filter, false); HashSet <string> hsRes = new HashSet <string>(); while ((buffer = cursor.NextRow()) != null) { hsRes.Add(fc.GuidString + "_" + buffer.GetValue(0).ToString()); } ValveManager.Instance.Add(fcGuid, hsRes); return(hsRes); } return(null); } catch (Exception ex) { return(null); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (buffer != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(buffer); buffer = null; } } }
private void OnFinishedDraw() { if (this._drawTool != null && this._drawTool.GeoType == DrawType.Polygon && this._drawTool.GetGeo() != null) { try { WaitForm.Start("正在空间查询...", "请稍后"); List <MajorClass> listMCs = LogicDataStructureManage3D.Instance.GetAllMajorClass(); if (listMCs != null) { ISpatialFilter filter = new SpatialFilterClass(); filter.Geometry = this._drawTool.GetGeo(); filter.GeometryField = "FootPrint"; filter.SpatialRel = gviSpatialRel.gviSpatialRelContains; Dictionary <MajorClass, List <IRowBuffer> > dict = new Dictionary <MajorClass, List <IRowBuffer> >(); foreach (MajorClass mc in listMCs) { IRowBuffer row = null; IFdeCursor cursor = null; try { string[] arrFc3DId = mc.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(); IFeatureLayer fl = dffc.GetFeatureLayer(); if (fl == null || fc == null || facc == null || facc.Name != "PipeLine") { continue; } if (fl.VisibleMask == gviViewportMask.gviViewNone) { continue; } int count = fc.GetCount(filter); if (count == 0) { break; } List <IRowBuffer> list = new List <IRowBuffer>(); cursor = fc.Search(filter, false); while ((row = cursor.NextRow()) != null) { list.Add(row); } dict[mc] = list; } } catch (Exception ex) { } finally { if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } } } WaitForm.Stop(); if (dict.Count == 0) { XtraMessageBox.Show("该区域内没有管线", "提示"); return; } FrmPipelineCross dlg = new FrmPipelineCross(dict); dlg.Show(); } } catch (Exception ex) { WaitForm.Stop(); } finally { } } }
public TopoNetwork GetNetwork() { if (TopoNetworkManager.Instance.Exists(this._objectId)) { return(TopoNetworkManager.Instance.GetTopoNetWorkByObjectId(this._objectId)); } if (DF3DPipeCreateApp.App.PipeLib == null) { return(null); } TopoNetwork network = null; IFeatureClass class2 = null; IQueryFilter filter = null; IFdeCursor cursor = null; IRowBuffer buffer = null; try { IFeatureDataSet fds = DF3DPipeCreateApp.App.PipeLib.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } class2 = fds.OpenFeatureClass(this._topotable); filter = new QueryFilterClass { SubFields = "A_FacClass,Edge,P_FacClass,PNode,E_FacClass,ENode,Geometry" }; Dictionary <string, Node> dictNode = new Dictionary <string, Node>(); // 点字典 int totalcount = class2.GetCount(null); int loop = (int)Math.Ceiling((decimal)(totalcount / 1000.0)); for (int i = 1; i <= loop; i++) { if (i == 1) { filter.ResultBeginIndex = 0; } else { filter.ResultBeginIndex = (i - 1) * 1000; } filter.ResultLimit = 1000; cursor = class2.Search(filter, true); while ((buffer = cursor.NextRow()) != null) { string edgeFC, edgeOid, snodeFC, snodeOid, enodeFC, enodeOid; if (!buffer.IsNull(0)) { edgeFC = buffer.GetValue(0).ToString(); } else { edgeFC = "0"; } if (!buffer.IsNull(1)) { edgeOid = buffer.GetValue(1).ToString(); } else { edgeOid = BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant(); } if (!buffer.IsNull(2)) { snodeFC = buffer.GetValue(2).ToString(); } else { snodeFC = "0"; } if (!buffer.IsNull(3)) { snodeOid = buffer.GetValue(3).ToString(); } else { snodeOid = BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant(); } if (!buffer.IsNull(4)) { enodeFC = buffer.GetValue(4).ToString(); } else { enodeFC = "0"; } if (!buffer.IsNull(5)) { enodeOid = buffer.GetValue(5).ToString(); } else { enodeOid = BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant(); } double edgeLength = double.MaxValue; if (!buffer.IsNull(6) && buffer.GetValue(6) is IPolyline) { IPolyline line = buffer.GetValue(6) as IPolyline; edgeLength = line.Length; } Node sn = null; Node en = null; string key = snodeFC + "_" + snodeOid; if (!dictNode.ContainsKey(key)) { if (NodeManager.Instance.GetNodeByID(key) == null) { sn = new Node(snodeFC, snodeOid); NodeManager.Instance.Add(sn); } else { sn = NodeManager.Instance.GetNodeByID(key); } dictNode.Add(key, sn); } else { sn = dictNode[key]; } key = enodeFC + "_" + enodeOid; if (!dictNode.ContainsKey(key)) { if (NodeManager.Instance.GetNodeByID(key) == null) { en = new Node(enodeFC, enodeOid); NodeManager.Instance.Add(en); } else { en = NodeManager.Instance.GetNodeByID(key); } dictNode.Add(key, en); } else { en = dictNode[key]; } if (sn == null || en == null) { continue; } Edge e = new Edge(edgeFC, edgeOid, sn, en, edgeLength); EdgeManager.Instance.Add(e); } } network = new TopoNetwork(this._objectId, dictNode); TopoNetworkManager.Instance.Add(this.ObjectId, network); return(network); } catch (Exception ex) { return(null); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (buffer != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(buffer); buffer = 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; } int geometryIndex = fc.GetFields().IndexOf("Geometry"); if (geometryIndex == -1) { continue; } filter.WhereClause = "GroupId = " + sc.GroupId; filter.SubFields = "Geometry"; int count = fc.GetCount(filter); if (count == 0) { continue; } int loop = (int)Math.Ceiling(count / 800.0); for (int k = 1; k <= loop; k++) { if (k == 1) { filter.ResultBeginIndex = 0; } else { filter.ResultBeginIndex = (k - 1) * 800; } filter.ResultLimit = 800; IFdeCursor cursor = fc.Search(filter, true); IRowBuffer row = null; while ((row = cursor.NextRow()) != null) { IModelPoint modelPoint = row.GetValue(0) as IModelPoint; if ((geo as IRelationalOperator2D).Contains2D(modelPoint)) { bHave = true; bHaveRes = true; break; } } if (bHave) { break; } } } if (bHave) { SubClass sctemp = new SubClass(sc.Name, sc.GroupId, sc.Parent); sctemp.Visible3D = sc.Visible3D; mctemp.SubClasses.Add(sctemp); } } }