//打开图层,获取IVecls public static IVectorCls GetVectorCls(string layername, AxWorkSpace.AxMxWorkSpace WorkSpace) { IXGroupLayer layer = null; layer = WorkSpace.MapCollection.get_Item(0).get_Layer2(layername) as IXGroupLayer; IVectorCls vcls = layer.get_Layer(1).XClass as IVectorCls; return(vcls); }
//打开图层,获取RecordSet public static mcRecordSet GetLayerRecordSet(string layername, AxWorkSpace.AxMxWorkSpace WorkSpace) { IXGroupLayer layer = null; mcRecordSet RecordSet = null; layer = WorkSpace.MapCollection.get_Item(0).get_Layer2(layername) as IXGroupLayer; IVectorCls vcls = layer.get_Layer(1).XClass as IVectorCls; vcls.Select(null, out RecordSet); return(RecordSet); }
private void btnOpenNewPrj_Click(object sender, EventArgs e) { this.axMxWorkSpace2.Open("C:\\Users\\Kylin\\Desktop\\测试矿区数据\\新数据\\Testsource.Map", WorkSpace.EnumOpenMode.OpenNormal); this.axMapXView2.Restore(); newWorkSpace = axMxWorkSpace2; }
private void btnOpenSorcePrj_Click(object sender, EventArgs e) { this.axMxWorkSpace1.Open("C:\\Users\\Kylin\\Desktop\\测试矿区数据\\原始矿区数据\\Testsource.Map", WorkSpace.EnumOpenMode.OpenNormal); this.axMapXView1.Restore(); sourceWorkSpace = axMxWorkSpace1; }
//获取新数据内标注圆的集合 public static void GetAnnoCircleGeoList(string frame_layername, out List <IGeometry> Anno_CircleGeoList, out List <IGeomInfo> Anno_CircleGeoInfoList, AxWorkSpace.AxMxWorkSpace WorkSpace) { List <IGeometry> _Anno_CircleGeoList = new List <IGeometry>(); List <IGeomInfo> _Anno_CircleGeoInfoList = new List <IGeomInfo>(); // 1、找到最大的图框 mcRecordSet AllFeatures_RecordSet = GetLayerRecordSet(frame_layername, WorkSpace); List <double> mpLengths = new List <double>(); int sfID = 0; sfID = AllFeatures_RecordSet.MoveFirst(); while (!AllFeatures_RecordSet.IsEOF()) { mcRecord record = null; AllFeatures_RecordSet.GetAtt(out record); object per = null; record.GetFldVal("mpLength", out per); mpLengths.Add((double)per); sfID = AllFeatures_RecordSet.MoveNext(); } mpLengths.Sort(); mcQueryDef lengthDef = new mcQueryDef(); lengthDef.Filter = "mpLength=" + mpLengths[mpLengths.Count - 1]; mcRecordSet frameRecordSet = null; AllFeatures_RecordSet.Select(lengthDef, out frameRecordSet); frameRecordSet.MoveFirst(); IGeometry geoFrame = null; frameRecordSet.GetGeometry(out geoFrame); // 2、找到图例圆 IXGroupLayer m_Layer = null; m_Layer = WorkSpace.MapCollection.get_Item(0).get_Layer2("T01_0060.WT") as IXGroupLayer; IVectorCls vcls = m_Layer.get_Layer(2).XClass as IVectorCls; mcQueryDef queryDef = new mcQueryDef(); //图框的外包矩形 mcRect FrameRect = null; geoFrame.CalRect(out FrameRect); //计算、保留图例圆的中心点坐标 mcDot CircleDot = new mcDot(); mcGeoPolygon queryPolygon = GetRectPolygon(FrameRect); queryDef.set_Spatial(queryPolygon, meSpaQueryMode.meModeContain); mcRecordSet containCircle = null; vcls.Select(queryDef, out containCircle);//图框内的圆 containCircle.MoveFirst(); while (!containCircle.IsEOF()) { mcObjectID id = null; containCircle.GetID(out id); IGeomInfo geoInfo = null; containCircle.GetInfo(out geoInfo); IPntInfo pntInfo = geoInfo as IPntInfo; if (pntInfo.height > 20 && pntInfo.width > 20) { IGeometry geoCircle = null; IGeomInfo geoCircleInfo = null; containCircle.GetGeometry(out geoCircle); _Anno_CircleGeoList.Add(geoCircle); containCircle.GetInfo(out geoCircleInfo); _Anno_CircleGeoInfoList.Add(geoCircleInfo); } containCircle.MoveNext(); } Anno_CircleGeoList = _Anno_CircleGeoList; Anno_CircleGeoInfoList = _Anno_CircleGeoInfoList; }