yushff

code the world。

导航

计算是否通视,如果不通视,返回遮挡点

Posted on 2013-08-15 14:44  yushff  阅读(645)  评论(3编辑  收藏  举报

计算是否通视,如果不通视,返回遮挡点

//计算是否通视,如果不通视,返回遮挡点
        /// <summary>
        /// 给定点点坐标和文字内容,添加文字
        /// </summary>
        /// <param name="tmpFromPnt">通视的起点</param>
        /// <param name="tmpToPnt">通视的终点</param>
        /// <param name="tmpIntersectPnt">第一个遮挡点</param>
        public bool Visibility(CoordTransform.Pnt3D tmpFromPnt, CoordTransform.Pnt3D tmpToPnt, ref CoordTransform.Pnt3D tmpIntersectPnt)
        {
            IRasterLayer pRasterLayer = pTmpMainWin.pCurrentMap.Map.get_Layer(DemLyrIndex) as IRasterLayer;
            IRasterSurface pRasterSurface = new RasterSurfaceClass();
            pRasterSurface.PutRaster(pRasterLayer.Raster, 0);
            ISurface pSurface = pRasterSurface as ISurface;
            //IGeoDatabaseBridge2 pBridge = new GeoDatabaseBridge2Class();

            IPoint pPoint = new PointClass();
            IPolyline pVPolyline = null;
            IPolyline pInPolyline = null;
            object pRef = 0.13;
            bool pBool = true;

            bool ReturnValue = true;

            IGeoDataset geoDt = pRasterLayer.Raster as IGeoDataset;
            ISpatialReference spatialreference = geoDt.SpatialReference;

            IPoint pPoint1 = new PointClass();
            IPoint pPoint2 = new PointClass();

            ////获取Dem的高程
            pPoint1.Project(spatialreference);
            pPoint2.Project(spatialreference);
            pPoint.Project(spatialreference);

            pPoint1.X = tmpFromPnt.X;
            pPoint1.Y = tmpFromPnt.Y;
            pPoint1.Z = tmpFromPnt.Z;

            pPoint2.X = tmpToPnt.X;
            pPoint2.Y = tmpToPnt.Y;
            pPoint2.Z = tmpToPnt.Z;

            IGeoDatabaseBridge2 pbridge2 = (IGeoDatabaseBridge2)new GeoDatabaseHelperClass();
            pbridge2.GetLineOfSight(pSurface, pPoint1, pPoint2, out pPoint, out pVPolyline, out pInPolyline, out pBool, false, false, ref pRef);

            if (pBool == false)
            {
                tmpIntersectPnt = new CoordTransform.Pnt3D();
                tmpIntersectPnt.X = pPoint.X;
                tmpIntersectPnt.Y = pPoint.Y;
                tmpIntersectPnt.Z = pPoint.Z;

                ReturnValue = false;
            }
            else
            {
                tmpIntersectPnt = new CoordTransform.Pnt3D();
                tmpIntersectPnt.X = pPoint2.X;
                tmpIntersectPnt.Y = pPoint2.Y;
                tmpIntersectPnt.Z = pPoint2.Z;

                ReturnValue = true;
            }
            return ReturnValue;
        }