Azure Lei Zhang的博客

weibo: LeiZhang的微博/QQ: 185165016/QQ群:319036205/邮箱:leizhang1984@outlook.com/TeL:139-161-22926

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

   /// <summary>
        /// 判断2个几何图形是否相交
        /// </summary>
        /// <param name="oneGeometry"></param>
        /// <param name="otherGeometry"></param>
        /// <returns></returns>
        public bool Intersect(IGeometry oneGeometry, IGeometry otherGeometry)
        {
            try
            {
                ISpatialReferenceFactory3 pSRF = new SpatialReferenceEnvironmentClass();
                ISpatialReference pSR = pSRF.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_Beijing1954);
                pSR.SetDomain(-400, -400, 400, 400);

 

                oneGeometry.SpatialReference = pSR;
                otherGeometry.SpatialReference = pSR;

                ITopologicalOperator iTopoOperator = (ITopologicalOperator)oneGeometry;

               
                IGeometry outGeometry = iTopoOperator.Intersect(otherGeometry, esriGeometryDimension.esriGeometryNoDimension);
                if (!outGeometry.IsEmpty)
                {
                    return true;
                }
                else
                {
                    return false;
                }          
            }
            catch (Exception ex)
            {
                return false;
            }
        }

posted on 2010-08-19 10:10  Lei Zhang的博客  阅读(2006)  评论(0编辑  收藏  举报