『公告』 预祝您龙年大吉,万事如意, 过节期间, 大家如需数据服务,请拨打400 或直接添加客服微信,再祝大家龙年,心想事成。
关注我们 新浪 腾讯

ArcGIS Engine 10 开发手册(8-19)示例:通视分析代码

ArcGIS Engine 10 开发手册(8-19)示例:通视分析代码
本文演示使用ArcGIS Engine 实现通视分析功能演示代码示例。

     本文演示使用ArcGIS Engine 实现通视分析功能演示代码示例。


    示例代码

if (axMapControl1.Map.get_Layer (0) != null)

 

{

 

  IRasterLayer pRasterLayer = axMapControl1.Map.get_Layer (0) as IRasterLayer;

 

  IRasterSurface pRasterSurface = new RasterSurfaceClass ();

 

  pRasterSurface.PutRaster (pRasterLayer.Raster, 0);

 

  ISurface pSurface = pRasterSurface as ISurface;

 

  IPolyline pPolyline = axMapControl1.TrackLine () as IPolyline;

  IPoint pPoint = null;

 

  IPolyline pVPolyline = null;

 

  IPolyline pInPolyline = null;

  object pRef = 0.13;

 

  bool pBool = true;

 

  //获取Dem的高程

 

  double pZ1 = pSurface.GetElevation (pPolyline.FromPoint);

  double pZ2 = pSurface.GetElevation (pPolyline.ToPoint);

 

  IPoint pPoint1 = new PointClass ();

  pPoint1.Z = pZ1;

 

  pPoint1.X = pPolyline.FromPoint.X;

  pPoint1.Y = pPolyline.FromPoint.Y;

  IPoint pPoint2 = new PointClass ();

  pPoint2.Z = pZ2;

 

  pPoint2.X = pPolyline.ToPoint.X;

  pPoint2.Y = pPolyline.ToPoint.Y;

 

  pSurface.GetLineOfSight (pPoint1, pPoint2, out pPoint, out pVPolyline, out pInPolyline, out pBool, false, false, ref pRef);

 

  if (pVPolyline != null)

 

  {

 

    IElement pLineElementV = new LineElementClass ();

    pLineElementV.Geometry = pVPolyline;

 

    ILineSymbol pLinesymbolV = new SimpleLineSymbolClass ();

 

    pLinesymbolV.Width = 2;

 

    IRgbColor pColorV = new RgbColorClass ();

    pColorV.Green = 255;

 

    pLinesymbolV.Color = pColorV;

 

    ILineElement pLineV = pLineElementV as ILineElement;

    pLineV.Symbol = pLinesymbolV;

 

    axMapControl1.ActiveView.GraphicsContainer.AddElement (pLineElementV, 0);

 

  }

 

  if (pInPolyline != null)

 

  {

 

    IElement pLineElementIn = new LineElementClass ();

    pLineElementIn.Geometry = pInPolyline;

 

    ILineSymbol pLinesymbolIn = new SimpleLineSymbolClass ();

 

    pLinesymbolIn.Width = 2;

 

    IRgbColor pColorIn = new RgbColorClass ();

    pColorIn.Red = 255;

 

    pLinesymbolIn.Color = pColorIn;

 

    ILineElement pLineIn = pLineElementIn as ILineElement;

    pLineIn.Symbol = pLinesymbolIn;

 

    axMapControl1.ActiveView.GraphicsContainer.AddElement (pLineElementIn, 1);

 

  }

 

  axMapControl1.ActiveView.PartialRefresh (esriViewDrawPhase.esriViewGraphics, null, null);

     运行结果

 

 

      京ICP备08100627号-22 京公网安备 11010802030428号