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

本文目录
  • 正文

本文演示使用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);

运行结果

ArcGIS Engine 10 开发手册全集

ArcGIS Engine 10 开发手册全集: ArcGIS Engine 10 开发手册

如果本文对你有所帮助,欢迎对我们团队进行打赏捐助,让我们在传播3S的路上可以走得更远。
赞赏支持
微信捐助麻辣GIS 支付宝捐助麻辣GIS

麻辣GIS-Sailor
作者:
GIS爱好者,学GIS,更爱玩GIS。

如您有疑问,可在文末留言,或到QQ群中提问。

本站QQ群(一):291616564 麻辣GIS

本站QQ群(二):166408035 麻辣GIS(二)

本站QQ群(三):627853279 麻辣GIS(三)

微信公众号:malagis,扫描右边二维码直接关注。

发表评论