Exemplo n.º 1
0
        /// <summary>
        /// 框选要素,需要考虑框的宽度为0的情况
        /// </summary>
        /// <param name="rect">选择框</param>
        /// <returns>选到的要素</returns>
        public List <DataRow> SelectByBox(RectangleD rect)
        {
            List <DataRow> mSelectedRows = new List <DataRow>();

            if (this._GeoType == typeof(MultiPolygon))
            {
                MultiPolygon sMul;
                foreach (DataRow mRow in this._DT.Rows)
                {
                    if (!Convert.IsDBNull(mRow[2]))
                    {
                        sMul = (MultiPolygon)mRow[2];
                        if (LayerTools.IsRectInterMultipolygon(sMul, rect))
                        {
                            mSelectedRows.Add(mRow);
                        }
                    }
                }
            }
            else if (this._GeoType == typeof(MultiPolyLine))
            {
                MultiPolyLine sMul;
                foreach (DataRow mRow in this._DT.Rows)
                {
                    if (!Convert.IsDBNull(mRow[2]))
                    {
                        sMul = (MultiPolyLine)mRow[2];
                        if (LayerTools.IsRectInterMultiPolyline(sMul, rect))
                        {
                            mSelectedRows.Add(mRow);
                        }
                    }
                }
            }
            else if (this._GeoType == typeof(PointD))
            {
                PointD sPoint;
                foreach (DataRow mRow in this._DT.Rows)
                {
                    if (!Convert.IsDBNull(mRow[2]))
                    {
                        sPoint = (PointD)mRow[2];
                        if (LayerTools.IsPointInRect(sPoint, rect))
                        {
                            mSelectedRows.Add(mRow);
                        }
                    }
                }
            }
            return(mSelectedRows);
        }
Exemplo n.º 2
0
        public static PointD GetClosePoint(PointD point, List <DataRow> rowList, double tolerance)
        {
            PointD sPoint = null;

            foreach (DataRow sRow in rowList)
            {
                if (!Convert.IsDBNull(sRow[2]))
                {
                    sPoint = LayerTools.GetClosePoint(point, (Geometry)sRow[2], tolerance);
                    if (sPoint != null)
                    {
                        return(sPoint);
                    }
                }
            }
            return(null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 点选要素
        /// </summary>
        /// <param name="point">点</param>
        /// <param name="tolerance">容限</param>
        /// <returns>此次点击选中的要素</returns>
        public List <DataRow> SelectByPoint(PointD point, double tolerance)
        {
            //List<DataRow> mSelectedRows = _Index.SelectByPoint(point, tolerance);
            List <DataRow> mSelectedRows = new List <DataRow>();

            if (this._GeoType == typeof(MultiPolygon))
            {
                MultiPolygon sMul;
                foreach (DataRow mRow in this._DT.Rows)
                {
                    if (!Convert.IsDBNull(mRow[2]))
                    {
                        sMul = (MultiPolygon)mRow[2];
                        if (LayerTools.IsPointInMultiPolygon(point, sMul))
                        {
                            mSelectedRows.Add(mRow);
                        }
                    }
                }
            }
            else if (this._GeoType == typeof(MultiPolyLine))
            {
                MultiPolyLine sMul;
                foreach (DataRow mRow in this._DT.Rows)
                {
                    if (!Convert.IsDBNull(mRow[2]))
                    {
                        sMul = (MultiPolyLine)mRow[2];
                        if (LayerTools.IsPointOnMulPolyline(point, sMul, tolerance))
                        {
                            mSelectedRows.Add(mRow);
                        }
                    }
                }
            }
            else if (this._GeoType == typeof(PointD))
            {
                PointD sPoint;
                foreach (DataRow mRow in this._DT.Rows)
                {
                    if (!Convert.IsDBNull(mRow[2]))
                    {
                        sPoint = (PointD)mRow[2];
                        if (LayerTools.IsPointOnPoint(point, sPoint, tolerance))
                        {
                            mSelectedRows.Add(mRow);
                        }
                    }
                }
            }


            //HashSet<DataRow> mSet = _Index.SelectByPoint(point);
            //if (this._GeoType == typeof(MultiPolygon))
            //{
            //    MultiPolygon sMultiPolygon;
            //    if (mSet != null)
            //    {
            //        foreach (DataRow row in mSet)
            //        {
            //            sMultiPolygon = row.Field<MultiPolygon>(2);
            //            if (sMultiPolygon != null)
            //            {
            //                if (LayerTools.IsPointInMultiPolygon(point, sMultiPolygon))
            //                {
            //                    mSelectedRows.Add(row);
            //                }
            //                //Console.WriteLine("search");
            //            }
            //        }
            //    }

            //}
            //_SelectedRecords = mSelectedRows;
            return(mSelectedRows);
        }