void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender) { IPickResult pr = PickResult; if (EventSender == gviMouseSelectMode.gviMouseSelectClick) { if (PickResult != null) { if (pr.Type == gviObjectType.gviObjectFeatureLayer) { IFeatureLayerPickResult flpr = pr as IFeatureLayerPickResult; int fid = flpr.FeatureId; IFeatureLayer fl = flpr.FeatureLayer; foreach (IFeatureClass fc in fcMap_POI.Keys) { if (fc.Guid.Equals(fl.FeatureClassId)) { IRowBuffer row = fc.GetRow(fid); int pos = row.FieldIndex("Geometry"); IPoint point = row.GetValue(pos) as IPoint; try { INetworkLocation location = new NetworkLocation(); location.Position = point; routeSolver.AddLocation(location); } catch (COMException ex) { MessageBox.Show("所选点距离网络太远,请调整LocationSearchTolerance大小"); return; } pos = row.FieldIndex("Name"); if (row.GetValue(pos) == null) { pos = 0; } if (txtLocationNames.Text == "") { txtLocationNames.Text = row.GetValue(pos).ToString(); } else { txtLocationNames.Text = txtLocationNames.Text + Environment.NewLine + row.GetValue(pos).ToString(); } this.axRenderControl1.FeatureManager.HighlightFeature(fc, fid, System.Drawing.Color.Yellow); } } } } } }
private byte[] GetLogicTreeContent(IFeatureDataSet dataset) { byte[] strContent = null; try { IQueryDef qd = dataset.DataSource.CreateQueryDef(); qd.AddSubField("content"); qd.Tables = new String[] { "cm_logictree", "cm_group" }; qd.WhereClause = String.Format("cm_group.groupuid = cm_logictree.groupid " + " and cm_group.DataSet = '{0}'", dataset.Name); IFdeCursor cursor = qd.Execute(false); IRowBuffer row = null; if ((row = cursor.NextRow()) != null) { //content int nPose = row.FieldIndex("content"); if (nPose != -1) { IBinaryBuffer bb = row.GetValue(nPose) as IBinaryBuffer; strContent = (byte[])bb.AsByteArray(); } } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); return(null); } return(strContent); }
private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e) { int featureId = int.Parse((sender as DataGridView).CurrentRow.Cells[0].Value.ToString()); IFeatureClass curFeatureClass = null; foreach (IFeatureClass fc in fcMap.Keys) { curFeatureClass = fc; IRowBuffer fdeRow = curFeatureClass.GetRow(featureId); if (fdeRow != null) { int nPos = fdeRow.FieldIndex("Geometry"); if (nPos != -1 && !fdeRow.IsNull(nPos)) { IPOI mp = fdeRow.GetValue(nPos) as IPOI; // 从库中读取值 IPoint pos = new GeometryFactory().CreatePoint(gviVertexAttribute.gviVertexAttributeZ); pos.Position = mp.Position; pos.SpatialCRS = mp.SpatialCRS; IEulerAngle angle = new EulerAngle(); angle.Heading = 0; angle.Tilt = -60; angle.Roll = 0; this.axRenderControl1.Camera.LookAt2(pos, 3000, angle); this.axRenderControl1.FeatureManager.UnhighlightAll(); this.axRenderControl1.FeatureManager.HighlightFeature(curFeatureClass, int.Parse(fdeRow.GetValue(0).ToString()), System.Drawing.Color.Yellow); mp.ImageName = (strMediaPath + @"\png\lan.png"); IRenderPOI rpoi = this.axRenderControl1.ObjectManager.CreateRenderPOI(mp); rpoi.Highlight(System.Drawing.Color.Red); this.axRenderControl1.ObjectManager.DelayDelete(rpoi.Guid, 60000); } } } }
private void SetGeometry(IGeometry geo) { if (geo == null) { return; } if (this.beforeRowBufferMap != null) { foreach (DF3DFeatureClass featureClassInfo in this.beforeRowBufferMap.Keys) { string facName = featureClassInfo.GetFacilityClassName(); IRowBufferCollection rowBufferCollection = this.beforeRowBufferMap[featureClassInfo] as IRowBufferCollection; object arg_51_0 = SelectCollection.Instance().FeatureClassInfoMap[featureClassInfo]; for (int i = 0; i < rowBufferCollection.Count; i++) { IRowBuffer rowBuffer = rowBufferCollection.Get(i); if (rowBuffer != null) { #region 管线设施 if (facName == "PipeLine" || facName == "PipeBuild" || facName == "PipeBuild1") { int num3 = rowBuffer.FieldIndex("Shape"); if (num3 != -1) { rowBuffer.SetValue(num3, geo); } int num4 = rowBuffer.FieldIndex("FootPrint"); if (num4 != -1) { rowBuffer.SetValue(num4, geo.Clone2(gviVertexAttribute.gviVertexAttributeNone)); } } #endregion else { int num2 = rowBuffer.FieldIndex(featureClassInfo.GetFeatureLayer().GeometryFieldName); if (num2 != -1) { rowBuffer.SetValue(num2, geo); } } } } } } }
void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender) { IPickResult pr = PickResult; if (pr == null) { return; } if (EventSender == gviMouseSelectMode.gviMouseSelectClick) { if (pr.Type == gviObjectType.gviObjectFeatureLayer) { // 高亮Polygon this.axRenderControl1.FeatureManager.UnhighlightAll(); IFeatureLayerPickResult flpr = pr as IFeatureLayerPickResult; fid = flpr.FeatureId; IFeatureLayer fl = flpr.FeatureLayer; foreach (IFeatureClass fc in fcMap.Keys) { if (fc.Guid.Equals(fl.FeatureClassId)) { IRowBuffer fdeRow = fc.GetRow(fid); IFieldInfoCollection col = fdeRow.Fields; for (int i = 0; i < col.Count; ++i) { IFieldInfo info = col.Get(i); if (info.GeometryDef != null && info.GeometryDef.GeometryColumnType == gviGeometryColumnType.gviGeometryColumnPolyline) { int nPos = fdeRow.FieldIndex(info.Name); polyline = fdeRow.GetValue(nPos) as IPolyline; this.axRenderControl1.FeatureManager.HighlightFeature(fc, fid, System.Drawing.Color.Yellow); //获取路宽 nPos = fdeRow.FieldIndex("WIDTH"); //width = (double)fdeRow.GetValue(nPos); width = 10; } } } // end " if (fc.Guid.Equals(fl.FeatureClassId))" } // end "foreach (IFeatureClass fc in fcMap.Keys)" } } }
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; } } }
public static void AddAndVisualizePipeData(IConnectionInfo ci, string geoColumnName, TreeList parentTree, Dictionary <string, string> pipeCatelog, Dictionary <string, IRowBuffer> pipeInfos, bool bNeedFly = false, bool bTempData = true) { try { if (ci == null || parentTree == null || pipeCatelog == null || pipeCatelog.Count == 0 || pipeInfos == null || pipeInfos.Count == 0) { return; } //获取要素类对照表:string:guid Dictionary <string, IFeatureClass> fcs = DataUtils.GetFeatureClass(ci); if (fcs == null || fcs.Count == 0) { return; } //获取要素类与设施类的关联:string:code,string:guid Dictionary <string, string> relation = DataUtils.GetRelation(ci, "DataSet_BIZ", "OC_FacilityClass"); if (relation == null || relation.Count == 0) { return; } foreach (KeyValuePair <string, string> kv in pipeCatelog) { string code = kv.Key.ToString(); string pcode = kv.Value.ToString(); if (!relation.ContainsKey(code) && pcode == "-1") { Dictionary <string, string> childRelation = FindChildRelationByPCode(code, pipeCatelog); if (childRelation == null || childRelation.Count == 0) { continue; } IRowBuffer row = pipeInfos[code]; string name = row.GetValue(row.FieldIndex("Name")).ToString(); Group g = new Group() { Name = name, CustomValue = row, Temp = bTempData }; g.OwnNode = parentTree.AppendNode(new object[] { g.Name }, (TreeListNode)null); g.Visible = true; VisualizePipeData(fcs, relation, geoColumnName, g, pipeCatelog, childRelation, pipeInfos, bNeedFly, bTempData); g.CollapseAll(); } } } catch (Exception ex) { } }
private IModelPoint GetModel(IFeatureClass fc, string geoFieldName, int oid) { IModelPoint result = null; IRowBuffer row = fc.GetRow(oid); int num = row.FieldIndex(geoFieldName); if (num != -1) { result = (row.GetValue(num) as IModelPoint); } return(result); }
private void GetResultSet(IFeatureClass fc, IQueryFilter filter, DataTable dt) { if (fc != null) { IFdeCursor cursor = null; try { if (filter != null) { filter.PostfixClause = "order by oid asc"; } // 查找所有记录 cursor = fc.Search(filter, true); if (cursor != null) { dt.BeginLoadData(); IRowBuffer fdeRow = null; DataRow dr = null; while ((fdeRow = cursor.NextRow()) != null) { dr = dt.NewRow(); for (int i = 0; i < dt.Columns.Count; ++i) { string strColName = dt.Columns[i].ColumnName; int nPos = fdeRow.FieldIndex(strColName); if (nPos == -1 || fdeRow.IsNull(nPos)) { continue; } object v = fdeRow.GetValue(nPos); // 从库中读取值 dr[i] = v; } dt.Rows.Add(dr); } dt.EndLoadData(); } // 通过解析逻辑树获取GroupId对应的GroupName GroupId2LayerName(dt, fc.FeatureDataSet); } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } finally { if (cursor != null) { //Marshal.ReleaseComObject(cursor); cursor = null; } } } }
void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender) { this.axRenderControl1.FeatureManager.UnhighlightAll(); // 置空 _buffer = null; _featureLayer = null; 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(); QueryFilter 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; } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } finally { } this.axRenderControl1.FeatureManager.HighlightFeature(_featureClass, fid, System.Drawing.Color.Yellow); EditGeometry(); } break; } } }
private void InitData() { try { this.cbxFacilityStyle.SelectedIndex = -1; this.listStyles.SelectedIndex = -1; DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer; if (dffc == null) { return; } int count = SelectCollection.Instance().GetCount(false); if (count == 1) { HashMap hm = SelectCollection.Instance().GetSelectGeometrys(); if (hm != null && hm.Count == 1) { IRowBufferCollection rowBufferCollection = hm[dffc] as IRowBufferCollection; if (rowBufferCollection.Count == 1) { IRowBuffer rowBuffer = rowBufferCollection.Get(0); int index = rowBuffer.FieldIndex("StyleId"); if (index != -1 && !rowBuffer.IsNull(index)) { string styleId = rowBuffer.GetValue(index).ToString(); for (int i = 0; i < this.cbxFacilityStyle.Properties.Items.Count; i++) { FacStyleClass fsc = this.cbxFacilityStyle.Properties.Items[i] as FacStyleClass; if (fsc.ObjectId == styleId) { this.cbxFacilityStyle.SelectedIndex = i; this.listStyles.SelectedIndex = i; break; } } } } } } } catch (Exception ex) { } }
private void InitData() { try { foreach (DataRow dr in this._dt.Rows) { dr["FV"] = null; } DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer; if (dffc == null) { return; } int count = SelectCollection.Instance().GetCount(false); if (count == 1) { HashMap hm = SelectCollection.Instance().GetSelectGeometrys(); if (hm != null && hm.Count == 1) { IRowBufferCollection rowBufferCollection = hm[dffc] as IRowBufferCollection; if (rowBufferCollection.Count == 1) { IRowBuffer rowBuffer = rowBufferCollection.Get(0); foreach (DataRow dr in this._dt.Rows) { IFieldInfo fi = dr["F"] as IFieldInfo; if (fi == null) { continue; } int index = rowBuffer.FieldIndex(fi.Name); if (index != -1) { dr["FV"] = rowBuffer.GetValue(index); } } } } } this.gridView1.RefreshData(); } catch (Exception ex) { } }
void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender) { if (PickResult != null) { if (PickResult.Type == gviObjectType.gviObjectFeatureLayer) { IFeatureLayerPickResult flpr = PickResult as IFeatureLayerPickResult; int fid = flpr.FeatureId; IFeatureLayer fl = flpr.FeatureLayer; foreach (IFeatureClass fc in fcMap.Keys) { if (fc.Guid.Equals(fl.FeatureClassId)) { IRowBuffer fdeRow = fc.GetRow(fid); int nPos = fdeRow.FieldIndex("Geometry"); switch (source) { case SOURCE.SELECT1: this.axRenderControl1.FeatureManager.HighlightFeature(fc, fid, System.Drawing.Color.Yellow); geo1.AddGeometry(fdeRow.GetValue(nPos) as IPolygon); drawLabel(IntersectPoint, "要素一", System.Drawing.Color.Yellow); break; case SOURCE.SELECT2: this.axRenderControl1.FeatureManager.HighlightFeature(fc, fid, System.Drawing.Color.Red); geo2.AddGeometry(fdeRow.GetValue(nPos) as IPolygon); drawLabel(IntersectPoint, "要素二", System.Drawing.Color.Yellow); break; } SelectObject obj = new SelectObject(); obj.FC = fc; obj.ID = fid; objToHide.Add(obj); } } // end foreach } } if (source == SOURCE.SELECT1 || source == SOURCE.SELECT2) { this.axRenderControl1.RcMouseClickSelect -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect); this.axRenderControl1.InteractMode = gviInteractMode.gviInteractNormal; } }
/// <summary> /// 鼠标点击 拾取分析点 /// </summary> /// <param name="PickResult"></param> /// <param name="IntersectPoint"></param> /// <param name="Mask"></param> /// <param name="EventSender"></param> void g_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender) { if (IntersectPoint == null) { return; } if (EventSender.Equals(gviMouseSelectMode.gviMouseSelectClick)) { mouseClicks++; if (mouseClicks % 2 == 1) { this.label7.Text = "请鼠标点击选择目标点"; this.startX.Text = IntersectPoint.X.ToString(); this.startY.Text = IntersectPoint.Y.ToString(); this.startZ.Text = (IntersectPoint.Z + double.Parse(numZOffset.Value.ToString())).ToString(); axRenderControl1.MouseSelectMode = gviMouseSelectMode.gviMouseSelectClick | gviMouseSelectMode.gviMouseSelectMove; } else { this.label7.Text = "选择结束"; this.btnStartAnalyse.Enabled = true; axRenderControl1.InteractMode = gviInteractMode.gviInteractNormal; axRenderControl1.MouseSelectObjectMask = gviMouseSelectObjectMask.gviSelectNone; axRenderControl1.MouseSelectMode = gviMouseSelectMode.gviMouseSelectClick; axRenderControl1.RcMouseClickSelect -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(g_RcMouseClickSelect); geoRegion = axRenderControl1.HighlightHelper.GetRegion(); //开始空间查询 try { this.label7.Text = "开始空间查询"; ISpatialFilter sfilter = new SpatialFilter(); sfilter.Geometry = geoRegion; sfilter.SpatialRel = gviSpatialRel.gviSpatialRelIntersects; sfilter.GeometryField = "footprint"; cursor = buildingFC.Search(sfilter, false); row = null; while ((row = cursor.NextRow()) != null) { int nfidpos = row.FieldIndex("Geometry"); if (nfidpos > -1) { geoInFC = row.GetValue(nfidpos) as IGeometry; } if (geoInFC != null) { //AddOcluder axRenderControl1.VisualAnalysis.AddOccluder(buildingFL, geoInFC); //highlight occluder int fidpos = row.FieldIndex("oid"); if (fidpos > -1) { axRenderControl1.FeatureManager.HighlightFeature(buildingFC, int.Parse(row.GetValue(fidpos).ToString()), System.Drawing.Color.Red); } } } } catch (System.Exception ex) { } finally { if (cursor != null) { //Marshal.ReleaseComObject(cursor); cursor = null; } } this.label7.Text = "正在视域分析中..."; //StartAnalyse axRenderControl1.VisualAnalysis.StartViewshedAnalyse(fde_point1, fde_point2, double.Parse(this.numHorizontalAngle.Value.ToString())); axRenderControl1.HighlightHelper.VisibleMask = 0; this.label7.Text = "分析结束"; } } else if (EventSender.Equals(gviMouseSelectMode.gviMouseSelectMove)) { this.endX.Text = IntersectPoint.X.ToString(); this.endY.Text = IntersectPoint.Y.ToString(); this.endZ.Text = IntersectPoint.Z.ToString(); fde_point1 = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPoint, gviVertexAttribute.gviVertexAttributeZ) as IPoint; fde_point1.SetCoords(double.Parse(this.startX.Text), double.Parse(this.startY.Text), double.Parse(this.startZ.Text), 0, 0); fde_point2 = geoFactory.CreateGeometry(gviGeometryType.gviGeometryPoint, gviVertexAttribute.gviVertexAttributeZ) as IPoint; fde_point2.SetCoords(double.Parse(this.endX.Text), double.Parse(this.endY.Text), double.Parse(this.endZ.Text), 0, 0); axRenderControl1.HighlightHelper.SetSectorRegion(fde_point1, fde_point2, double.Parse(this.numHorizontalAngle.Value.ToString())); } }
private bool UpdateFacStyleClass(FacStyleClass style) { IFdeCursor cursor = null; IRowBuffer row = null; try { IFeatureDataSet fds = this._ds.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(false); } IObjectClass oc = fds.OpenObjectClass("OC_FacilityStyle"); if (oc == null) { return(false); } IQueryFilter filter = new QueryFilter() { WhereClause = string.Format("ObjectId = '{0}'", style.ObjectId) }; cursor = oc.Update(filter); row = cursor.NextRow(); if (row != null) { row.SetValue(row.FieldIndex("Name"), style.Name); row.SetValue(row.FieldIndex("FacClassCode"), style.FacClassCode); row.SetValue(row.FieldIndex("ObjectId"), style.ObjectId); row.SetValue(row.FieldIndex("StyleType"), style.Type.ToString()); row.SetValue(row.FieldIndex("StyleInfo"), style.ObjectToJson()); if (style.Thumbnail != null) { try { IBinaryBuffer bb = new BinaryBufferClass(); MemoryStream stream = new MemoryStream(); style.Thumbnail.Save(stream, ImageFormat.Png); bb.FromByteArray(stream.ToArray()); row.SetValue(row.FieldIndex("Thumbnail"), bb); } catch (Exception exception) { } } cursor.UpdateRow(row); return(true); } else { return(false); } } catch (Exception ex) { return(false); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
public static void VisualizePipeData(Dictionary <string, IFeatureClass> fcs, Dictionary <string, string> relation, string geoColumnName, IGroupLayer groupLayer, Dictionary <string, string> pipeCatelog, Dictionary <string, string> childPipeCatelog, Dictionary <string, IRowBuffer> infos, bool bNeedFly = false, bool bTempData = true) { try { foreach (KeyValuePair <string, string> kv in childPipeCatelog) { string code = kv.Key.ToString(); string pcode = kv.Value.ToString(); if (!relation.ContainsKey(code) && pcode != "-1") { Dictionary <string, string> cchildPipeCatelog = FindChildRelationByPCode(code, pipeCatelog); if (cchildPipeCatelog == null || cchildPipeCatelog.Count == 0) { continue; } IRowBuffer row = infos[code]; string name = row.GetValue(row.FieldIndex("Name")).ToString(); Group g = new Group() { Name = name, CustomValue = row, Temp = bTempData }; g.Visible = true; groupLayer.Add(g); VisualizePipeData(fcs, relation, geoColumnName, g, pipeCatelog, cchildPipeCatelog, infos, bNeedFly, bTempData); } else if (relation.ContainsKey(code) && fcs.ContainsKey(relation[code])) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } AxRenderControl d3 = app.Current3DMapControl; IRowBuffer row = infos[code]; string name = row.GetValue(row.FieldIndex("Name")).ToString(); IFeatureClass fc = fcs[relation[code]]; TreeNodeFeatureClass tnFeatureClass = new TreeNodeFeatureClass() { Name = name, CustomValue = fc, //Tag = row, Temp = bTempData }; groupLayer.Add(tnFeatureClass); IFieldInfoCollection fieldinfos = fc.GetFields(); if (fieldinfos == null) { continue; } int index = fieldinfos.IndexOf(geoColumnName); if (index == -1) { } else { IFieldInfo fieldinfo = fieldinfos.Get(index); if (null == fieldinfo) { continue; } IGeometryDef geometryDef = fieldinfo.GeometryDef; IFeatureLayer fl = null; if (null != geometryDef) { fl = d3.ObjectManager.CreateFeatureLayer(fc, fieldinfo.Name, null, null, d3.ProjectTree.RootID); tnFeatureClass.SetVisualFeatureLayer(fl); tnFeatureClass.Visible = true; switch (geometryDef.GeometryColumnType) { case gviGeometryColumnType.gviGeometryColumnModelPoint: tnFeatureClass.ImageIndex = 3; break; case gviGeometryColumnType.gviGeometryColumnPOI: case gviGeometryColumnType.gviGeometryColumnPoint: tnFeatureClass.ImageIndex = 4; break; case gviGeometryColumnType.gviGeometryColumnPolyline: tnFeatureClass.ImageIndex = 5; break; case gviGeometryColumnType.gviGeometryColumnPolygon: tnFeatureClass.ImageIndex = 6; break; } } if (fl != null && !bTempData) { DF3DFeatureClass dfFC = new DF3DFeatureClass(fcs[relation[code]]); if (dfFC == null) { continue; } DF3DFeatureClassManager.Instance.Add(dfFC); } if (fl != null && bNeedFly) { IEulerAngle angle = new EulerAngle(); angle.Set(0, -20, 0); d3.Camera.SetCamera(fl.Envelope.Center, angle, gviSetCameraFlags.gviSetCameraNoFlags); bNeedFly = false; } } } } } catch (Exception ex) { } }
private List <CMFieldConfig> GetFieldsConfig(string code) { IFdeCursor cursor = null; IRowBuffer row = null; try { IFeatureDataSet fds = this._dsTemplate.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IObjectClass oc = fds.OpenObjectClass("OC_FieldConfig"); if (oc == null) { return(null); } IQueryFilter filter = new QueryFilterClass { WhereClause = string.Format("FacClassCode = '{0}'", code), PostfixClause = "order by OrderBy asc" }; cursor = oc.Search(filter, true); List <CMFieldConfig> list = new List <CMFieldConfig>(); while ((row = cursor.NextRow()) != null) { CMFieldConfig fc = new CMFieldConfig(); if (row.FieldIndex("oid") >= 0) { object obj = row.GetValue(row.FieldIndex("oid")); if (obj != null) { fc.Id = int.Parse(obj.ToString()); } } if (row.FieldIndex("FacClassCode") >= 0) { object obj = row.GetValue(row.FieldIndex("FacClassCode")); if (obj != null) { fc.FacClassCode = obj.ToString(); } } if (row.FieldIndex("Name") >= 0) { object obj = row.GetValue(row.FieldIndex("Name")); if (obj != null) { fc.Name = obj.ToString(); } } if (row.FieldIndex("Alias") >= 0) { object obj = row.GetValue(row.FieldIndex("Alias")); if (obj != null) { fc.Alias = obj.ToString(); } } if (row.FieldIndex("FieldType") >= 0) { object obj = row.GetValue(row.FieldIndex("FieldType")); if (obj != null) { gviFieldType ts = 0; if (Enum.TryParse <gviFieldType>(obj.ToString(), out ts)) { fc.FieldType = ts; } else { fc.FieldType = gviFieldType.gviFieldUnknown; } } } if (row.FieldIndex("Length") >= 0) { object obj = row.GetValue(row.FieldIndex("Length")); if (obj != null) { fc.Length = Convert.ToInt32(obj.ToString()); } } if (row.FieldIndex("Nullable") >= 0) { object obj = row.GetValue(row.FieldIndex("Nullable")); if (obj != null) { fc.Nullable = obj.ToString() == "0" ? false : true; } } list.Add(fc); } return(list); } catch (Exception exception) { return(null); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
public override void Run(object sender, System.EventArgs e) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } try { Map3DCommandManager.Push(this); RenderControlEditServices.Instance().StopGeometryEdit(true); app.Current3DMapControl.PauseRendering(false); System.Collections.Generic.IList <System.Collections.Generic.KeyValuePair <int, string> > list = new System.Collections.Generic.List <System.Collections.Generic.KeyValuePair <int, string> >(); HashMap featureClassInfoMap = SelectCollection.Instance().FeatureClassInfoMap; DF3DFeatureClass featureClassInfo = null; System.Collections.Generic.IList <int> list2 = new System.Collections.Generic.List <int>(); System.Collections.IEnumerator enumerator = featureClassInfoMap.Keys.GetEnumerator(); try { if (enumerator.MoveNext()) { DF3DFeatureClass featureClassInfo2 = (DF3DFeatureClass)enumerator.Current; featureClassInfo = featureClassInfo2; ResultSetInfo resultSetInfo = featureClassInfoMap[featureClassInfo2] as ResultSetInfo; foreach (DataRow dataRow in resultSetInfo.ResultSetTable.Rows) { int num = int.Parse(dataRow[featureClassInfo.GetFeatureClass().FidFieldName].ToString()); string value = num.ToString(); System.Collections.Generic.KeyValuePair <int, string> item = new System.Collections.Generic.KeyValuePair <int, string>(num, value); list.Add(item); list2.Add(num); } } } finally { System.IDisposable disposable = enumerator as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } if (featureClassInfo != null) { using (MergeDlg mergeDlg = new MergeDlg(list)) { if (mergeDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (System.Windows.Forms.DialogResult.No != XtraMessageBox.Show("模型合并不支持撤销操作,是否继续?", "提示", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Exclamation)) { int fid = mergeDlg.Fid; using (new WaitDialogForm("", "正在进行模型合并,请稍后...")) { IFeatureClass featureClass = featureClassInfo.GetFeatureClass(); string geometryFieldName = featureClassInfo.GetFeatureLayer().GeometryFieldName; IModelPoint model = this.GetModel(featureClass, geometryFieldName, fid); IResourceManager resourceManager = CommonUtils.Instance().GetCurrentFeatureDataset() as IResourceManager; if (resourceManager != null) { if (!this.MergeModels(featureClass, geometryFieldName, list2.ToArray <int>(), resourceManager, ref model)) { XtraMessageBox.Show("模型合并失败!"); } else { if (list2.Remove(fid)) { featureClass.Delete(new QueryFilterClass { IdsFilter = list2.ToArray <int>() }); CommonUtils.Instance().Delete(featureClassInfo, list2.ToArray <int>()); app.Current3DMapControl.FeatureManager.DeleteFeatures(featureClass, list2.ToArray <int>()); } app.Current3DMapControl.RefreshModel(CommonUtils.Instance().GetCurrentFeatureDataset(), model.ModelName); IFdeCursor fdeCursor = featureClass.Update(new QueryFilterClass { IdsFilter = new int[] { fid } }); IRowBuffer rowBuffer = fdeCursor.NextRow(); if (rowBuffer != null) { int num2 = rowBuffer.FieldIndex(geometryFieldName); if (num2 != -1) { rowBuffer.SetValue(num2, model); } fdeCursor.UpdateRow(rowBuffer); System.Runtime.InteropServices.Marshal.ReleaseComObject(fdeCursor); app.Current3DMapControl.FeatureManager.EditFeature(featureClass, rowBuffer); } //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); } } } } } } } } catch (System.Runtime.InteropServices.COMException ex) { XtraMessageBox.Show(ex.Message); } catch (System.UnauthorizedAccessException var_23_389) { XtraMessageBox.Show("拒绝访问"); } catch (System.Exception ex2) { XtraMessageBox.Show(ex2.Message); } finally { app.Current3DMapControl.ResumeRendering(); } }
public static List <FacStyleClass> GetFacStyleByFacClassCode(string fcCode) { IFdeCursor cursor = null; IRowBuffer row = null; try { IFeatureDataSet fds = DF3DPipeCreateApp.App.TemplateLib.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IObjectClass oc = fds.OpenObjectClass("OC_FacilityStyle"); if (oc == null) { return(null); } IQueryFilter filter = new QueryFilterClass { WhereClause = string.Format("FacClassCode = '{0}'", fcCode) }; cursor = oc.Search(filter, true); List <FacStyleClass> list = new List <FacStyleClass>(); while ((row = cursor.NextRow()) != null) { StyleType type; FacStyleClass fs = null; if (row.FieldIndex("StyleType") >= 0 && Enum.TryParse <StyleType>(row.GetValue(row.FieldIndex("StyleType")).ToString(), out type)) { Dictionary <string, string> dictionary = null; if (row.FieldIndex("StyleInfo") >= 0) { object obj = row.GetValue(row.FieldIndex("StyleInfo")); if (obj != null) { IBinaryBuffer buffer2 = row.GetValue(row.FieldIndex("StyleInfo")) as IBinaryBuffer; if (buffer2 != null) { dictionary = JsonTool.JsonToObject <Dictionary <string, string> >(Encoding.UTF8.GetString(buffer2.AsByteArray())); } } } switch (type) { case StyleType.PipeNodeStyle: fs = new PipeNodeStyleClass(dictionary); break; case StyleType.PipeLineStyle: fs = new PipeLineStyleClass(dictionary); break; case StyleType.PipeBuildStyle: fs = new PipeBuildStyleClass(dictionary); break; } } if (fs == null) { continue; } if (row.FieldIndex("oid") >= 0) { object obj = row.GetValue(row.FieldIndex("oid")); if (obj != null) { fs.Id = int.Parse(obj.ToString()); } } if (row.FieldIndex("ObjectId") >= 0) { object obj = row.GetValue(row.FieldIndex("ObjectId")); if (obj != null) { fs.ObjectId = obj.ToString(); } } if (row.FieldIndex("FacClassCode") >= 0) { object obj = row.GetValue(row.FieldIndex("FacClassCode")); if (obj != null) { fs.FacClassCode = obj.ToString(); } } if (row.FieldIndex("Name") >= 0) { object obj = row.GetValue(row.FieldIndex("Name")); if (obj != null) { fs.Name = obj.ToString(); } } int index = row.FieldIndex("Thumbnail"); if (index != -1 && !row.IsNull(index)) { IBinaryBuffer b = row.GetValue(index) as IBinaryBuffer; if (row != null) { MemoryStream stream = new MemoryStream(b.AsByteArray()); fs.Thumbnail = Image.FromStream(stream); } } list.Add(fs); } return(list); } catch (Exception exception) { return(null); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
public static TopoClass GetTopoClassByObjectId(string objectId) { if (dictTopo.ContainsKey(objectId) && dictTopo[objectId] != null) { return(dictTopo[objectId]); } if (DF3DPipeCreateApp.App.TemplateLib == null) { return(null); } IFdeCursor o = null; IRowBuffer row = null; IQueryFilter filter = null; try { IFeatureDataSet fds = DF3DPipeCreateApp.App.TemplateLib.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IObjectClass oc = fds.OpenObjectClass("OC_TopoManage"); if (oc == null) { return(null); } filter = new QueryFilterClass { WhereClause = string.Format("ObjectId = '{0}'", objectId) }; o = oc.Search(filter, true); row = o.NextRow(); if (row != null) { TopoClass tc = new TopoClass(); if (row.FieldIndex("oid") >= 0) { object obj = row.GetValue(row.FieldIndex("oid")); if (obj != null) { tc.Id = int.Parse(obj.ToString()); } } if (row.FieldIndex("ObjectId") >= 0) { object obj = row.GetValue(row.FieldIndex("ObjectId")); if (obj != null) { tc.ObjectId = obj.ToString(); } } if (row.FieldIndex("TopoLayerName") >= 0) { object obj = row.GetValue(row.FieldIndex("TopoLayerName")); if (obj != null) { tc.Name = obj.ToString(); } } if (row.FieldIndex("Tolerance") >= 0) { object obj = row.GetValue(row.FieldIndex("Tolerance")); if (obj != null) { tc.Tolerance = double.Parse(obj.ToString()); } } if (row.FieldIndex("ToleranceZ") >= 0) { object obj = row.GetValue(row.FieldIndex("ToleranceZ")); if (obj != null) { tc.ToleranceZ = double.Parse(obj.ToString()); } } if (row.FieldIndex("IgnoreZ") >= 0) { object obj = row.GetValue(row.FieldIndex("IgnoreZ")); if (obj != null) { tc.IgnoreZ = obj.ToString() == "1" ? true : false; } } if (row.FieldIndex("TopoTableName") >= 0) { object obj = row.GetValue(row.FieldIndex("TopoTableName")); if (obj != null) { tc.TopoTable = obj.ToString(); } } if (row.FieldIndex("Comment") >= 0) { object obj = row.GetValue(row.FieldIndex("Comment")); if (obj != null) { tc.Comment = obj.ToString(); } } dictTopo[tc.ObjectId] = tc; return(tc); } return(null); } catch (Exception ex) { return(null); } finally { if (o != null) { Marshal.ReleaseComObject(o); o = null; } if (row != null) { Marshal.ReleaseComObject(row); row = null; } } }
private void GetResultSet(IFeatureClass fc, IQueryFilter filter, DataTable dt) { if (fc != null) { IFdeCursor cursor = null; try { if (filter != null) { filter.PostfixClause = "order by oid asc"; } // 查找所有记录 cursor = fc.Search(filter, true); if (cursor != null) { dt.BeginLoadData(); IRowBuffer fdeRow = null; DataRow dr = null; while ((fdeRow = cursor.NextRow()) != null) { dr = dt.NewRow(); for (int i = 0; i < dt.Columns.Count; ++i) { string strColName = dt.Columns[i].ColumnName; int nPos = fdeRow.FieldIndex(strColName); if (nPos == -1 || fdeRow.IsNull(nPos)) { continue; } object v = fdeRow.GetValue(nPos); // 从库中读取值 dr[i] = v; if (i == 0) { // 创建管子 int geoPos = fdeRow.FieldIndex("Geometry"); IGeometry geo = (IGeometry)fdeRow.GetValue(geoPos); if (geo.GeometryType == gviGeometryType.gviGeometryPolyline) { IPolyline pl = (IPolyline)fdeRow.GetValue(geoPos); IRenderPipeLine rpl = this.axRenderControl1.ObjectManager.CreateRenderPipeLine(pl, rootId); rpl.Radius = 10; rpl.Color = System.Drawing.Color.Red; ArrayList rpls = new ArrayList(); rpls.Add(rpl); pipeMap.Add(v, rpls); } else if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolyline) { IMultiPolyline multiPolyline = geo as IMultiPolyline; ArrayList rpls = new ArrayList(); for (int g = 0; g < multiPolyline.GeometryCount; g++) { IPolyline plIndex = multiPolyline.GetGeometry(g) as IPolyline; IRenderPipeLine rpl = this.axRenderControl1.ObjectManager.CreateRenderPipeLine(plIndex, rootId); rpl.Radius = 10; rpl.Color = System.Drawing.Color.Red; rpls.Add(rpl); } pipeMap.Add(v, rpls); } } } dt.Rows.Add(dr); } dt.EndLoadData(); } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } finally { if (cursor != null) { cursor.Dispose(); cursor = null; } } } }
public static Dictionary <string, IRowBuffer> GetPipeInfos(IConnectionInfo ci, string datasetName, string ocName) { Dictionary <string, IRowBuffer> infos = new Dictionary <string, IRowBuffer>(); IFdeCursor o = null; IQueryFilter filter = null; IRowBuffer r = null; try { IDataSourceFactory dsFactory = new DataSourceFactory(); if (!dsFactory.HasDataSource(ci)) { return(null); } IDataSource ds = dsFactory.OpenDataSource(ci); if (ds == null) { return(null); } string[] setnames = (string[])ds.GetFeatureDatasetNames(); if (setnames.Length == 0) { return(null); } for (int i = 0; i < setnames.Length; i++) { if (setnames[i] != datasetName) { continue; } IFeatureDataSet fds = ds.OpenFeatureDataset(setnames[i]); IObjectClass oc = fds.OpenObjectClass(ocName); if (oc == null) { return(null); } filter = new QueryFilterClass { WhereClause = "" }; o = oc.Search(filter, false); while ((r = o.NextRow()) != null) { string code = r.GetValue(r.FieldIndex("Code")).ToString(); infos[code] = r; } } } catch (Exception ex) { return(null); } finally { if (filter != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(filter); filter = null; } if (o != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(o); o = null; } if (r != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(r); r = null; } } return(infos); }
private bool CreateFacClassReg(FacClass fc) { if (fc == null || fc.FacilityType == null) { return(false); } IFdeCursor cursor = null; IRowBuffer row = null; try { IFeatureDataSet fds = this._dsPipe.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(false); } IFeatureDataSet fdsActuality = this._dsPipe.OpenFeatureDataset("DataSet_GEO_Actuality"); if (fdsActuality == null) { return(false); } IObjectClass oc = fds.OpenObjectClass("OC_FacilityClass"); if (oc == null) { return(false); } row = oc.CreateRowBuffer(); cursor = oc.Insert(); if (row != null) { row.SetValue(row.FieldIndex("FacClassCode"), fc.Code); row.SetValue(row.FieldIndex("Name"), fc.Name); row.SetValue(row.FieldIndex("FacilityType"), fc.FacilityType.Name); row.SetValue(row.FieldIndex("LocationType"), fc.LocationType.ToString()); row.SetValue(row.FieldIndex("TurnerStyle"), fc.TurnerStyle.ToString()); row.SetValue(row.FieldIndex("Comment"), fc.Comment); string fcName = string.Format("FC_{0}_{1}", (int)DataLifeCyle.Actuality, fc.Code); List <CMFieldConfig> fieldConfig = GetFieldsConfig(fc.Code); IFieldInfoCollection fielInfoCol = CreateFieldInfoCollection(fieldConfig, fc.FacilityType.Name); IFeatureClass featureClass = fdsActuality.CreateFeatureClass(fcName, fielInfoCol); if (featureClass == null) { return(false); } featureClass.AliasName = fc.Name; featureClass.LockType = gviLockType.gviLockExclusiveSchema; IGridIndexInfo indexInfo = new GridIndexInfoClass { L1 = 500.0, L2 = 2000.0, L3 = 10000.0, GeoColumnName = "Geometry" }; featureClass.AddSpatialIndex(indexInfo); indexInfo.GeoColumnName = "Shape"; featureClass.AddSpatialIndex(indexInfo); indexInfo.GeoColumnName = "FootPrint"; featureClass.AddSpatialIndex(indexInfo); IRenderIndexInfo info2 = new RenderIndexInfoClass { L1 = 500.0, GeoColumnName = "Geometry" }; featureClass.AddRenderIndex(info2); info2.GeoColumnName = "Shape"; featureClass.AddRenderIndex(info2); info2.GeoColumnName = "FootPrint"; featureClass.AddRenderIndex(info2); featureClass.LockType = gviLockType.gviLockSharedSchema; row.SetValue(row.FieldIndex("FeatureClassId"), featureClass.Guid.ToString()); row.SetValue(row.FieldIndex("DataSetName"), "DataSet_GEO_Actuality"); row.SetValue(row.FieldIndex("FcName"), featureClass.Name); row.SetValue(row.FieldIndex("DataType"), DataLifeCyle.Actuality.ToString()); cursor.InsertRow(row); return(true); } else { return(false); } } catch (Exception ex) { WaitForm.SetCaption("创建管线库中的设施要素类【" + fc.Name + "】失败!"); return(false); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender) { try { if (PickResult != null) { if (PickResult.Type == gviObjectType.gviObjectFeatureLayer) { IFeatureLayerPickResult flpr = PickResult as IFeatureLayerPickResult; int fid = flpr.FeatureId; this.axRenderControl1.FeatureManager.HighlightFeature(_featureClass, fid, System.Drawing.Color.Yellow); ////////////////////////////////////////////////////////////////////////// // // GeometryConvert的代码添加在这里 // ////////////////////////////////////////////////////////////////////////// fidList.Clear(); fidList.Add(fid); IRowBuffer rowGC = _featureClass.GetRow(fidList[0]); int nPose = rowGC.FieldIndex("Geometry"); if (nPose == -1) { MessageBox.Show("不存在Geometry列"); return; } // 获取polygon IPolyline polylineGC = null; if (rowGC != null) { nPose = rowGC.FieldIndex("Geometry"); IGeometry geo = rowGC.GetValue(nPose) as IGeometry; if (geo.GeometryType == gviGeometryType.gviGeometryPolyline) { polylineGC = geo as IPolyline; } } if (polylineGC != null) { this.Text = "拾取成功"; } else { this.Text = "拾取失败"; } param = new PropertySet(); if (this.tabControl1.SelectedIndex == 0) { // 1.调接口构造模型 double innerRadius = double.Parse(this.numInnerRadius.Value.ToString()); param.SetProperty("InnerRadius", innerRadius); double outerRadius = double.Parse(this.numOuterRadius.Value.ToString()); param.SetProperty("OuterRadius", outerRadius); double deflection = double.Parse(this.numDeflection.Value.ToString()); param.SetProperty("Deflection", deflection); Color difColor = Color.FromArgb(Convert.ToInt32(DifColorBox.Text, 16)); param.SetProperty("DiffuseColor", difColor); Color speColor = Color.FromArgb(Convert.ToInt32(SpeColorBox.Text, 16)); param.SetProperty("SpecularColor", speColor); IModelPoint mp = null; IModel model = null; if (!paraModel.PolylineToPipeLine(polylineGC, param, out mp, out model)) { MessageBox.Show("拉管线出错!"); return; } //2、将模型及贴图写入osg文件 string modelName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".osg");//输出osg文件路径 model.WriteFile(modelName, null); //3、测试显示模型 mp.ModelName = modelName; IRenderModelPoint rmp = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mp, null, rootId); rmp.MouseSelectMask = gviViewportMask.gviViewNone; rmp.MaxVisibleDistance = 100000; this.axRenderControl1.Camera.LookAtEnvelope(mp.Envelope);//飞入 mpList.Add(rmp); } } } } catch (System.Exception ex) { if (ex.GetType().Name.Equals("UnauthorizedAccessException")) { MessageBox.Show("需要标准runtime授权"); } else { MessageBox.Show(ex.Message); } } }
private void RotatingModel(double AxisX, double AxisY, double AxisZ, double Angle) { DF3DApplication app = DF3DApplication.Application; if (app == null || app.Current3DMapControl == null) { return; } this.bFinished = false; this.modifyRowbufferMap = SelectCollection.Instance().Clone(this.beginRowbufferMap); if (this.modifyRowbufferMap != null) { foreach (DF3DFeatureClass featureClassInfo in this.modifyRowbufferMap.Keys) { IFeatureClass featureClass = featureClassInfo.GetFeatureClass(); string facName = featureClassInfo.GetFacilityClassName(); IRowBufferCollection rowBufferCollection = this.modifyRowbufferMap[featureClassInfo] as IRowBufferCollection; for (int i = 0; i < rowBufferCollection.Count; i++) { IRowBuffer rowBuffer = rowBufferCollection.Get(i); if (rowBuffer != null) { int num = rowBuffer.FieldIndex(featureClassInfo.GetFeatureLayer().GeometryFieldName); if (num != -1) { IGeometry geometry = rowBuffer.GetValue(num) as IGeometry; if (geometry != null) { ITransform transform = geometry as ITransform; if (geometry.HasZ()) { transform.Rotate3D(AxisX, AxisY, AxisZ, this.centerX, this.centerY, this.centerZ, Angle); } else { if (!geometry.HasZ() && AxisZ > 0.0) { transform.Rotate2D(this.centerX, this.centerY, Angle); } } rowBuffer.SetValue(num, transform); } } #region 管线设施 if (facName == "PipeLine" || facName == "PipeNode" || facName == "PipeBuild" || facName == "PipeBuild1") { int num3 = rowBuffer.FieldIndex("Shape"); if (num3 != -1) { IGeometry geometry = rowBuffer.GetValue(num3) as IGeometry; if (geometry != null) { ITransform transform = geometry as ITransform; if (geometry != null && transform != null) { if (geometry.HasZ()) { transform.Rotate3D(AxisX, AxisY, AxisZ, this.centerX, this.centerY, this.centerZ, Angle); } else { transform.Rotate2D(this.centerX, this.centerY, Angle); } rowBuffer.SetValue(num3, transform); } } } int num4 = rowBuffer.FieldIndex("FootPrint"); if (num4 != -1) { IGeometry geometry = rowBuffer.GetValue(num4) as IGeometry; if (geometry != null) { ITransform transform = geometry as ITransform; if (geometry != null && transform != null) { if (geometry.HasZ()) { transform.Rotate3D(AxisX, AxisY, AxisZ, this.centerX, this.centerY, this.centerZ, Angle); } else { transform.Rotate2D(this.centerX, this.centerY, Angle); } rowBuffer.SetValue(num4, transform); } } } } #endregion } } app.Current3DMapControl.FeatureManager.EditFeatures(featureClass, rowBufferCollection); //System.Runtime.InteropServices.Marshal.ReleaseComObject(featureClass); } } }
private List <TopoClass> GetAllTopoClasses() { IFdeCursor cursor = null; IRowBuffer row = null; try { IFeatureDataSet fds = this._dsTemplate.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IObjectClass oc = fds.OpenObjectClass("OC_TopoManage"); if (oc == null) { return(null); } IQueryFilter filter = new QueryFilterClass { WhereClause = "1=1" }; cursor = oc.Search(filter, true); List <TopoClass> list = new List <TopoClass>(); while ((row = cursor.NextRow()) != null) { TopoClass tc = new TopoClass(); if (row.FieldIndex("oid") >= 0) { object obj = row.GetValue(row.FieldIndex("oid")); if (obj != null) { tc.Id = int.Parse(obj.ToString()); } } if (row.FieldIndex("ObjectId") >= 0) { object obj = row.GetValue(row.FieldIndex("ObjectId")); if (obj != null) { tc.ObjectId = obj.ToString(); } } if (row.FieldIndex("TopoLayerName") >= 0) { object obj = row.GetValue(row.FieldIndex("TopoLayerName")); if (obj != null) { tc.Name = obj.ToString(); } } if (row.FieldIndex("Tolerance") >= 0) { object obj = row.GetValue(row.FieldIndex("Tolerance")); if (obj != null) { tc.Tolerance = double.Parse(obj.ToString()); } } if (row.FieldIndex("ToleranceZ") >= 0) { object obj = row.GetValue(row.FieldIndex("ToleranceZ")); if (obj != null) { tc.ToleranceZ = double.Parse(obj.ToString()); } } if (row.FieldIndex("IgnoreZ") >= 0) { object obj = row.GetValue(row.FieldIndex("IgnoreZ")); if (obj != null) { tc.IgnoreZ = obj.ToString() == "1" ? true : false; } } if (row.FieldIndex("TopoTableName") >= 0) { object obj = row.GetValue(row.FieldIndex("TopoTableName")); if (obj != null) { tc.TopoTable = obj.ToString(); } } if (row.FieldIndex("Comment") >= 0) { object obj = row.GetValue(row.FieldIndex("Comment")); if (obj != null) { tc.Comment = obj.ToString(); } } list.Add(tc); } return(list); } catch (Exception exception) { return(null); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
private TextureClass GetTextureClass(string objectId) { IFdeCursor cursor = null; IRowBuffer row = null; try { IDataSource ds = DF3DPipeCreateApp.App.TemplateLib; if (ds == null) { return(null); } IFeatureDataSet fds = ds.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IObjectClass oc = fds.OpenObjectClass("OC_TextureInfo"); if (oc == null) { return(null); } IQueryFilter filter = new QueryFilterClass { WhereClause = "ObjectId = '" + objectId + "'" }; cursor = oc.Search(filter, true); if ((row = cursor.NextRow()) != null) { int id = -1; string name = "", objectid = "", groupid = "", code = "", comment = ""; Image thumbnail = null; int index = row.FieldIndex("oid"); if (index != -1 && !row.IsNull(index)) { id = Convert.ToInt32(row.GetValue(index).ToString()); } index = row.FieldIndex("Name"); if (index != -1 && !row.IsNull(index)) { name = row.GetValue(index).ToString(); } index = row.FieldIndex("ObjectId"); if (index != -1 && !row.IsNull(index)) { objectid = row.GetValue(index).ToString(); } index = row.FieldIndex("GroupId"); if (index != -1 && !row.IsNull(index)) { groupid = row.GetValue(index).ToString(); } index = row.FieldIndex("Code"); if (index != -1 && !row.IsNull(index)) { code = row.GetValue(index).ToString(); } index = row.FieldIndex("Comment"); if (index != -1 && !row.IsNull(index)) { comment = row.GetValue(index).ToString(); } index = row.FieldIndex("Thumbnail"); if (index != -1 && !row.IsNull(index)) { IBinaryBuffer b = row.GetValue(index) as IBinaryBuffer; if (row != null) { MemoryStream stream = new MemoryStream(b.AsByteArray()); thumbnail = Image.FromStream(stream); } } if (id != -1 && thumbnail != null) { TextureClass cc = new TextureClass(); cc.Id = id; cc.Name = name; cc.Group = groupid; cc.ObjectId = objectid; cc.Code = code; cc.Comment = comment; cc.Thumbnail = thumbnail; return(cc); } } return(null); } catch (Exception exception) { return(null); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender) { try { this.axRenderControl1.FeatureManager.UnhighlightAll(); if (PickResult != null) { if (PickResult.Type == gviObjectType.gviObjectFeatureLayer) { IFeatureLayerPickResult flpr = PickResult as IFeatureLayerPickResult; int fid = flpr.FeatureId; this.axRenderControl1.FeatureManager.HighlightFeature(_featureClass, fid, System.Drawing.Color.Yellow); ////////////////////////////////////////////////////////////////////////// // // GeometryConvert的代码添加在这里 // ////////////////////////////////////////////////////////////////////////// fidList.Clear(); fidList.Add(fid); IRowBuffer rowGC = _featureClass.GetRow(fidList[0]); int nPose = rowGC.FieldIndex("Geometry"); if (nPose == -1) { MessageBox.Show("不存在Geometry列"); return; } // 获取ModelPoint IModelPoint modelPointGC = null; if (rowGC != null) { nPose = rowGC.FieldIndex("Geometry"); IGeometry geo = rowGC.GetValue(nPose) as IGeometry; if (geo.GeometryType == gviGeometryType.gviGeometryModelPoint) { modelPointGC = geo as IModelPoint; } } this.Text = "拾取成功"; // 获取Model string modelName = modelPointGC.ModelName; IModel modelGC = (_featureClass.FeatureDataSet as IResourceManager).GetModel(modelName); // 1、获取MultiTriMesh IGeometryConvertor gc = new GeometryConvertor(); IMultiTriMesh multiTM = gc.ModelPointToTriMesh(modelGC, modelPointGC, false); this.Text = "ModelToTriMesh完成"; if (this.cbCreateRenderTriMesh.Checked) { // 创建RenderTriMesh在三维上显示 for (int i = 0; i < multiTM.GeometryCount; i++) { ITriMesh tm = multiTM.GetGeometry(i) as ITriMesh; IRenderTriMesh rtm = this.axRenderControl1.ObjectManager.CreateRenderTriMesh(tm, null, rootId); //随机颜色填充TriMesh Random randObj = new Random(i); int aColor = randObj.Next(0, 255); int gColor = randObj.Next(0, 255); int rColor = randObj.Next(0, 255); ISurfaceSymbol ss = new SurfaceSymbol(); ss.Color = System.Drawing.Color.FromArgb(rColor, gColor, aColor); rtm.Symbol = ss; rTMeshList.Add(rtm); } } if (this.cbCreateRenderPolygon.Checked) { // 2、获取投影MultiPolygon IMultiPolygon multiPolygon = gc.ProjectTriMeshToPolygon(multiTM, 1.0); this.Text = "MultiTriMeshToFootprint完成。面积:" + multiPolygon.GetArea(); // 创建RenderPolygon在三维上显示 for (int i = 0; i < multiPolygon.GeometryCount; i++) { IPolygon polygon = multiPolygon.GetGeometry(i) as IPolygon; IRenderPolygon rpolygon = this.axRenderControl1.ObjectManager.CreateRenderPolygon(polygon, null, rootId); rPolygonList.Add(rpolygon); } } if (this.cbCreateRenderPolygon2.Checked) { // 3、获取切割MultiPolygon double heightSpec = 0.0, heightIntersect = 0.0; Double.TryParse(IntersectPoint.Z.ToString(), out heightIntersect); fidList.Clear(); fidList.Add(fid); IEnvelope box = _featureClass.GetFeaturesEnvelope(fidList.ToArray(), "Geometry"); heightSpec = System.Math.Abs(heightIntersect - box.MinZ); // 注意:CutTriMeshToPolygon方法的第三个参数为空间分辨率,应该选择合适值。 // 值过大会导致结果不精确,值过小会导致转换时间过长。使用时应设置大小合适的值来平衡精度和效率问题。 IMultiPolygon multiPolygon2 = gc.CutTriMeshToPolygon(multiTM, heightSpec, 0.5); this.Text = "MultiTriMeshToFootprint2完成。面积:" + multiPolygon2.GetArea(); // 创建RenderPolygon在三维上显示 for (int i = 0; i < multiPolygon2.GeometryCount; i++) { IPolygon polygon2 = multiPolygon2.GetGeometry(i) as IPolygon; IRenderPolygon rpolygon2 = this.axRenderControl1.ObjectManager.CreateRenderPolygon(polygon2, null, rootId); rPolygonList2.Add(rpolygon2); } } if (this.cbCreateRenderMulPoint.Checked) { // 4、获取MultiPoint IMultiPoint multiPoint = gc.MultiTriMeshToMultiPoint(multiTM, 3.0); this.Text = "MultiTriMeshToMultiPoint完成。MultiPoint个数为:" + multiPoint.GeometryCount; //创建RenderPoint在三维上显示 IRenderMultiPoint rpoint = this.axRenderControl1.ObjectManager.CreateRenderMultiPoint(multiPoint, null, rootId); rPointList.Add(rpoint); } } } } catch (System.Exception ex) { if (ex.GetType().Name.Equals("UnauthorizedAccessException")) { MessageBox.Show("需要标准runtime授权"); } else { MessageBox.Show(ex.Message); } } }
public static List <FacClassReg> GetFacClassRegsByFacilityType(string str) { IFdeCursor cursor = null; IRowBuffer row = null; try { IFeatureDataSet fds = DF3DPipeCreateApp.App.PipeLib.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IObjectClass oc = fds.OpenObjectClass("OC_FacilityClass"); if (oc == null) { return(null); } IQueryFilter filter = new QueryFilter(); filter.WhereClause = "FacilityType='" + str + "'"; cursor = oc.Search(filter, false); List <FacClassReg> list = new List <FacClassReg>(); while ((row = cursor.NextRow()) != null) { FacClassReg fc = new FacClassReg(); if (row.FieldIndex("oid") >= 0) { object obj = row.GetValue(row.FieldIndex("oid")); if (obj != null) { fc.Id = int.Parse(obj.ToString()); } } if (row.FieldIndex("Name") >= 0) { object obj = row.GetValue(row.FieldIndex("Name")); if (obj != null) { fc.Name = obj.ToString(); } } if (row.FieldIndex("FacClassCode") >= 0) { object obj = row.GetValue(row.FieldIndex("FacClassCode")); if (obj != null) { fc.FacClassCode = obj.ToString(); } } if (row.FieldIndex("DataSetName") >= 0) { object obj = row.GetValue(row.FieldIndex("DataSetName")); if (obj != null) { fc.DataSetName = obj.ToString(); } } if (row.FieldIndex("FeatureClassId") >= 0) { object obj = row.GetValue(row.FieldIndex("FeatureClassId")); if (obj != null) { fc.FeatureClassId = obj.ToString(); } } if (row.FieldIndex("FcName") >= 0) { object obj = row.GetValue(row.FieldIndex("FcName")); if (obj != null) { fc.FcName = obj.ToString(); } } if (row.FieldIndex("DataType") >= 0) { object obj = row.GetValue(row.FieldIndex("DataType")); if (obj != null) { DataLifeCyle ts = 0; if (Enum.TryParse <DataLifeCyle>(obj.ToString(), out ts)) { fc.DataType = ts; } else { fc.DataType = 0; } } } if (row.FieldIndex("Comment") >= 0) { object obj = row.GetValue(row.FieldIndex("Comment")); if (obj != null) { fc.Comment = obj.ToString(); } } if (row.FieldIndex("TurnerStyle") >= 0) { object obj = row.GetValue(row.FieldIndex("TurnerStyle")); if (obj != null) { TurnerStyle ts = 0; if (Enum.TryParse <TurnerStyle>(obj.ToString(), out ts)) { fc.TurnerStyle = ts; } else { fc.TurnerStyle = 0; } } } if (row.FieldIndex("FacilityType") >= 0) { object obj = row.GetValue(row.FieldIndex("FacilityType")); if (obj != null) { fc.FacilityType = FacilityClassManager.Instance.GetFacilityClassByName(obj.ToString()); } } if (row.FieldIndex("LocationType") >= 0) { object obj = row.GetValue(row.FieldIndex("LocationType")); if (obj != null) { LocationType lt = 0; if (Enum.TryParse <LocationType>(obj.ToString(), out lt)) { fc.LocationType = lt; } else { fc.LocationType = 0; } } } list.Add(fc); } return(list); } catch (Exception ex) { return(null); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
private List <FacClass> GetAllFacClasses() { IFdeCursor cursor = null; IRowBuffer row = null; try { IFeatureDataSet fds = this._dsTemplate.OpenFeatureDataset("DataSet_BIZ"); if (fds == null) { return(null); } IObjectClass oc = fds.OpenObjectClass("OC_Catalog"); if (oc == null) { return(null); } IQueryFilter filter = new QueryFilterClass { WhereClause = string.Format("FacilityType <> '{0}'", "UnKnown"), PostfixClause = "order by OrderBy asc" }; cursor = oc.Search(filter, true); List <FacClass> list = new List <FacClass>(); while ((row = cursor.NextRow()) != null) { FacClass fc = new FacClass(); if (row.FieldIndex("oid") >= 0) { object obj = row.GetValue(row.FieldIndex("oid")); if (obj != null) { fc.Id = int.Parse(obj.ToString()); } } if (row.FieldIndex("Code") >= 0) { object obj = row.GetValue(row.FieldIndex("Code")); if (obj != null) { fc.Code = obj.ToString(); } } if (row.FieldIndex("PCode") >= 0) { object obj = row.GetValue(row.FieldIndex("PCode")); if (obj != null) { fc.PCode = obj.ToString(); } } if (row.FieldIndex("Comment") >= 0) { object obj = row.GetValue(row.FieldIndex("Comment")); if (obj != null) { fc.Comment = obj.ToString(); } } if (row.FieldIndex("FacilityType") >= 0) { object obj = row.GetValue(row.FieldIndex("FacilityType")); if (obj != null) { fc.FacilityType = FacilityClassManager.Instance.GetFacilityClassByName(obj.ToString()); } } if (row.FieldIndex("LocationType") >= 0) { object obj = row.GetValue(row.FieldIndex("LocationType")); if (obj != null) { fc.LocationType = (LocationType)Enum.Parse(typeof(LocationType), obj.ToString()); } } if (row.FieldIndex("TurnerStyle") >= 0) { object obj = row.GetValue(row.FieldIndex("TurnerStyle")); if (obj != null) { fc.TurnerStyle = (TurnerStyle)Enum.Parse(typeof(TurnerStyle), obj.ToString()); } } if (row.FieldIndex("Name") >= 0) { object obj = row.GetValue(row.FieldIndex("Name")); if (obj != null) { fc.Name = obj.ToString(); } } if (row.FieldIndex("TopoLayerId") >= 0) { object obj = row.GetValue(row.FieldIndex("TopoLayerId")); if (obj != null) { fc.TopoLayerId = obj.ToString(); } } list.Add(fc); } return(list); } catch (Exception exception) { return(null); } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }