Exemple #1
0
        private void 查看地图中第一个图层的属性记录ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //判断地图视图中是否有处于显示状态中的地图
            if (this.mapCtrl.ActiveMap == null)
            {
                MessageBox.Show("请先在地图视图中显示一幅地图!!!");
                return;
            }

            //获取激活地图
            Map map = this.mapCtrl.ActiveMap;

            //判断地图中是否有图层
            if (map.LayerCount < 1)
            {
                MessageBox.Show("操作失败,地图中没有图层!!!");
                return;
            }

            //获取地图中第一个图层的属性表
            VectorLayer vecLayer = map.get_Layer(0) as VectorLayer;

            RecordSet rcdSet = null;
            QueryDef  qryDef = new QueryDef();

            IVectorCls vecCls = vecLayer.GetData() as IVectorCls;

            rcdSet = vecCls.Select(qryDef);

            this.attCtrl.SetXCls(vecCls, rcdSet);

            return;
        }
Exemple #2
0
        //打开图层,获取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);
        }
Exemple #3
0
        private void btnGeoUpdate_Click(object sender, EventArgs e)
        {
            GeoUpdateParameterSetDlg aupDlg = new GeoUpdateParameterSetDlg(this);

            if (aupDlg.ShowDialog() == DialogResult.OK)
            {
                mcGDBServer  GDBSvr            = null;
                mcGDataBase  GDB               = null;
                mcGDataBase  GDB_source        = null;
                mcQueryDef   QueryDef          = null;
                mcQueryDef   QueryDef_source   = null;
                mcGeoPolygon GeoPolygon        = null;
                mcGeoPolygon GeoPolygon_source = null;
                IGeometry    pgeo              = null;
                IGeometry    pgeo_source       = null;
                IVectorCls   VecCls            = null;
                IVectorCls   VecCls_source     = null;
                mcObjectID   ID         = null;
                mcObjectID   ID_Source  = null;
                IVectorCls   VecCls_Add = null;

                GDBSvr            = new mcGDBServer();
                QueryDef          = new mcQueryDef();
                QueryDef_source   = new mcQueryDef();
                GeoPolygon        = new mcGeoPolygon();
                GeoPolygon_source = new mcGeoPolygon();
                //变量初始化
                ID        = new mcObjectID();
                ID_Source = new mcObjectID();
                //连接数据源,打开数据库
                try
                {
                    GDBSvr.Connect("MapGislocal", "", "");
                    GDB           = GDBSvr.get_gdb(DB);
                    GDB_source    = GDBSvr.get_gdb(DB_source);
                    VecCls        = GDB.get_XClass(meXClsType.meXSFCls) as IVectorCls;
                    VecCls_source = GDB_source.get_XClass(meXClsType.meXSFCls) as IVectorCls;
                    VecCls.Open(KQ, 0);
                    VecCls_source.Open(KQ_source, 0);

                    ID.Int = 1;
                    VecCls.GetGeometry(ID, out pgeo);
                    GeoPolygon = (mcGeoPolygon)pgeo;
                    //空间查询模式。主要有四种 :相交、外包矩形相交、相等、相离,具体意思及区别见技术文档
                    QueryDef.set_Spatial(GeoPolygon, meSpaQueryMode.meModeIntersect);

                    ID_Source.Int = 1;
                    VecCls_source.GetGeometry(ID_Source, out pgeo_source);
                    GeoPolygon_source = (mcGeoPolygon)pgeo_source;
                    //空间查询模式。主要有四种 :相交、外包矩形相交、相等、相离,具体意思及区别见技术文档
                    QueryDef_source.set_Spatial(GeoPolygon_source, meSpaQueryMode.meModeIntersect);
                    string[] keys = new string[dict.Count];
                    dict.Keys.CopyTo(keys, 0);
                    foreach (string key in keys)
                    {
                        if ("".Equals(key))
                        {
                            mcQueryDef  QDef      = null;
                            mcRecordSet RecordSet = null;
                            QueryDef = new mcQueryDef();
                            IVectorCls VecCls_data = null;
                            //打开待分析数据
                            VecCls_data = GDB.get_XClass(meXClsType.meXSFCls) as IVectorCls;
                            VecCls_data.Open(dict[key], 0);
                            VecCls_Add = GDB_source.get_XClass(meXClsType.meXSFCls) as IVectorCls;
                            VecCls_Add.Create(dict[key], meGeomConstrainType.mefReg, 0, 0, null);
                            //设置属性查询条件
                            QueryDef.Filter = "";
                            VecCls_data.Select(QDef, out RecordSet);
                            int rtn = VecCls_Add.CopySet(RecordSet);
                            VecCls_Add.Close();
                            VecCls_data.Close();
                            break;
                        }
                        SpatialDataAutoUpdate(GDBSvr, GDB, GDB_source, QueryDef, QueryDef_source, dict[key], key, Field, Field_source);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    VecCls.Close();
                    VecCls_source.Close();
                    GDBSvr.DisConnect();
                    GDB.Close();
                    GDB_source.Close();
                }
            }
        }
Exemple #4
0
        private static void SpatialDataAutoUpdate(mcGDBServer GDBSvr, mcGDataBase GDB, mcGDataBase GDB_source,
                                                  mcQueryDef QueryDef, mcQueryDef QueryDef_source, string data, string data_source, string field, string field_source)
        {
            //变量定义


            mcRecordSet RecordSet          = null;
            mcRecordSet RecordSet_source   = null;
            IVectorCls  VecCls_data        = null;
            IVectorCls  VecCls_source_data = null;


            try
            {
                //打开待分析数据
                VecCls_data = GDB.get_XClass(meXClsType.meXSFCls) as IVectorCls;
                VecCls_data.Open(data, 0);

                VecCls_source_data = GDB_source.get_XClass(meXClsType.meXSFCls) as IVectorCls;
                VecCls_source_data.Open(data_source, 0);

                VecCls_data.Select(QueryDef, out RecordSet);

                VecCls_source_data.Select(QueryDef_source, out RecordSet_source);

                int SfcID = 0;
                SfcID = RecordSet.MoveFirst();
                while (!RecordSet.IsEOF())
                {
                    mcRecord  record  = null;
                    mcFields  Fields  = null;
                    IGeometry geo     = null;
                    IGeomInfo geoInfo = null;
                    object    val     = null;

                    mcObjectID mID = new mcObjectID();

                    RecordSet.Get(out geo, out record, out geoInfo);
                    record.GetFields(out Fields);
                    record.GetFldVal(field, out val);

                    int  SfcID_source = 0;
                    bool flag         = true;
                    SfcID_source = RecordSet_source.MoveFirst();
                    while (!RecordSet_source.IsEOF())
                    {
                        mcObjectID id_source      = new mcObjectID();
                        mcRecord   record_source  = null;
                        mcFields   Fields_source  = null;
                        IGeometry  geo_source     = null;
                        IGeomInfo  geoInfo_source = null;
                        object     val_source     = null;

                        RecordSet_source.Get(out geo_source, out record_source, out geoInfo_source);
                        RecordSet_source.GetID(out id_source);
                        record_source.GetFields(out Fields_source);
                        record_source.GetFldVal(field_source, out val_source);
                        //找到新旧数据中对应的矿体
                        if (val.ToString().Equals(val_source.ToString()))
                        {
                            flag = false;
                            VecCls_source_data.Del(id_source);
                            VecCls_source_data.Append(geo, record, geoInfo);
                            //更新原始数据结果集  要不会报空指针错误
                            VecCls_source_data.Select(QueryDef, out RecordSet_source);
                            break;
                        }
                        SfcID_source = RecordSet_source.MoveNext();
                    }
                    //判断是否是新增矿体 新增矿体直接添加
                    if (flag)
                    {
                        VecCls_source_data.Append(geo, record, geoInfo);
                        //更新原始数据结果集  要不会报空指针错误
                        VecCls_source_data.Select(QueryDef, out RecordSet_source);
                    }

                    SfcID = RecordSet.MoveNext();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("更新出错啦!");
            }
            finally
            {
                //关闭类、数据库、断开数据源
                VecCls_data.Close();
                VecCls_source_data.Close();
            }
        }
Exemple #5
0
        //获取新数据内标注圆的集合
        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;
        }