示例#1
0
        //获取标注圆的圆心坐标
        public static mcDots GetCircleCoor(mcRecordSet recordset)
        {
            mcDots circleDots = new mcDots();
            int    SfcID      = 0;

            SfcID = recordset.MoveFirst();
            //找到图例中的注记圆
            while (!recordset.IsEOF())
            {
                IGeometry GeoResult = null;
                recordset.GetGeometry(out GeoResult);
                mcRect rect = null;
                GeoResult.CalRect(out rect);
                double width  = Math.Round(rect.xmax - rect.xmin, 2);
                double heigth = Math.Round(rect.ymax - rect.ymin, 2);
                //判断是否是注记圆
                if (width == heigth)
                {
                    //计算保留图例圆的中心点坐标
                    mcDot CircleDot = new mcDot();
                    CircleDot.x = (rect.xmax + rect.xmin) / 2;
                    CircleDot.y = (rect.ymin + rect.ymax) / 2;
                    circleDots.Add(CircleDot);
                }
                SfcID = recordset.MoveNext();
            }
            return(circleDots);
        }
示例#2
0
        //获取外包矩形的多边形
        public static mcGeoPolygon GetRectPolygon(mcRect rect)
        {
            mcGeoPolygon GeoPolygon = new mcGeoPolygon();
            mcLongList   LongList   = new mcLongList();
            mcDots       regDots    = new mcDots();
            mcDot        dot1       = new mcDot();
            mcDot        dot2       = new mcDot();
            mcDot        dot3       = new mcDot();
            mcDot        dot4       = new mcDot();

            dot1.x = rect.xmin;
            dot1.y = rect.ymin;
            dot2.x = rect.xmin;
            dot2.y = rect.ymax;
            dot3.x = rect.xmax;
            dot3.y = rect.ymax;
            dot4.x = rect.xmax;
            dot4.y = rect.ymin;
            regDots.Add(dot1);
            regDots.Add(dot2);
            regDots.Add(dot3);
            regDots.Add(dot4);
            LongList.Append(4);
            GeoPolygon.SetDots(regDots, LongList);
            return(GeoPolygon);
        }
示例#3
0
        //计算两点之间的距离
        public static double CalDistanceOfCircle(mcDot dot1, mcDot dot2)
        {
            double dis = 0;

            dis = Math.Sqrt(Math.Pow(dot2.y - dot1.y, 2) + Math.Pow(dot2.x - dot1.x, 2));
            return(dis);
        }
示例#4
0
        //延长线函数
        public static void ExpandLine(mcRecordSet LineSet, IVectorCls vcls)
        {
            IGeometry l_geoLine = null;

            LineSet.GetGeometry(out l_geoLine);
            IGeoVarLine l_Line = null;

            l_Line = l_geoLine as IGeoVarLine;
            mcDots l_dots = null;

            l_Line.Get2Dots(out l_dots);
            mcDot dot_1 = l_dots.get_item(0);
            mcDot dot_2 = l_dots.get_item(l_dots.count - 1);

            //垂直(因为数据不标准,所以设置为< 1)
            if (Math.Abs(dot_1.x - dot_2.x) < 1)
            {
                mcDot NewDot1 = new mcDot();
                mcDot NewDot2 = new mcDot();
                NewDot1.x = dot_1.x;
                NewDot1.y = dot_1.y + l_Line.CalLength(null) / 10;
                NewDot2.x = dot_2.x;
                NewDot2.y = dot_2.y - l_Line.CalLength(null) / 10;

                mcGeoVarLine NewLine = new mcGeoVarLine();

                NewLine.Append2D(NewDot1);
                NewLine.Append2D(NewDot2);
                vcls.Append(NewLine, null, null);

                mcObjectID delID = null;
                LineSet.GetID(out delID);
                vcls.Del(delID);
            }
            else
            {
                //计算直线的斜率
                double slope   = Math.Abs(dot_2.y - dot_1.y) / Math.Abs(dot_2.x - dot_1.x);
                mcDot  NewDot1 = new mcDot();
                mcDot  NewDot2 = new mcDot();

                NewDot1.x = dot_1.x - l_Line.CalLength(null) / 10;
                NewDot1.y = slope * (NewDot1.x - dot_1.x) + dot_1.y;

                NewDot2.x = dot_2.x + l_Line.CalLength(null) / 10;
                NewDot2.y = slope * (NewDot2.x - dot_2.x) + dot_2.y;

                mcGeoVarLine NewLine = new mcGeoVarLine();

                NewLine.Append2D(NewDot1);
                NewLine.Append2D(NewDot2);
                vcls.Append(NewLine, null, null);
                mcObjectID delID = null;
                LineSet.GetID(out delID);
                vcls.Del(delID);
            }
        }
示例#5
0
 //判断点是否在矩形
 public static bool isDotInRect(mcDot dot, mcRect rect)
 {
     if (dot.x >= rect.xmin && dot.x <= rect.xmax && dot.y >= rect.ymin && dot.y <= rect.ymax)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#6
0
 //更新块段储量
 private void btnUpdateKDCL_Click(object sender, EventArgs e)
 {
     try
     {
         if (Conn.State == ConnectionState.Open)
         {
             foreach (KeyValuePair <mcDot, Dictionary <string, string> > sourceKVP in SourceAnnoDictionSet)
             {
                 mcDot  sourceDot = sourceKVP.Key;
                 double minDis    = double.MaxValue;
                 Dictionary <string, string> newCircleAnnoDic = null;//与原始数据圆最近的新数据的圆
                 foreach (KeyValuePair <mcDot, Dictionary <string, string> > newKVP in NewAnnoDictionSet)
                 {
                     mcDot newDot = newKVP.Key;
                     //数据截取,去除y值的38000000
                     string valueStr = newDot.x.ToString().Substring(2);
                     //处理过后,去掉带号的坐标
                     mcDot exceptPreDot = new mcDot();
                     exceptPreDot.x = double.Parse(valueStr);
                     exceptPreDot.y = newDot.y;
                     double distance = MapGIsK9Utils.CalDistanceOfCircle(sourceDot, exceptPreDot);
                     if (minDis > distance)
                     {
                         minDis           = distance;
                         newCircleAnnoDic = newKVP.Value;
                     }
                 }
                 //找到原始块段编号
                 Dictionary <string, string> sourceValueDic = sourceKVP.Value;
                 string KDBH    = "";
                 string newKDBH = "";
                 sourceValueDic.TryGetValue("1", out KDBH);
                 newCircleAnnoDic.TryGetValue("1", out newKDBH);
                 //从DataGridView中读取需要更新的字段
                 string sqlStr = "";
                 for (int i = 0; i < dgvFieldsUpdate.Rows.Count - 1; i++)
                 {
                     if (i < dgvFieldsUpdate.Rows.Count - 2)
                     {
                         string id    = dgvFieldsUpdate.Rows[i].Cells[1].Value.ToString().Split('、')[0];
                         string value = "";
                         newCircleAnnoDic.TryGetValue(id, out value);
                         sqlStr += dgvFieldsUpdate.Rows[i].Cells[0].Value.ToString() + " = '" + value + "',";
                     }
                     else
                     {
                         string id    = dgvFieldsUpdate.Rows[i].Cells[1].Value.ToString().Split('、')[0];
                         string value = "";
                         newCircleAnnoDic.TryGetValue(id, out value);
                         sqlStr += dgvFieldsUpdate.Rows[i].Cells[0].Value.ToString() + " = '" + value + "'";
                     }
                 }
                 //更新核查块段
                 string JGAB309SQL = "update " + this.cbxTableName.SelectedItem.ToString() + " set " + sqlStr + " where KDBH = '" + newKDBH +
                                     "' and  KCMC = '" + this.cbxKCName.SelectedItem.ToString() + "矿'";
                 OleDbCommand cmd = new OleDbCommand(JGAB309SQL, Conn);
                 cmd.ExecuteNonQuery();
                 cmd.Dispose();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#7
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;
        }