麻辣GIS微信平台

更多 GIS 干货

微信关注不错过

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 开发手册

相关阅读

麻辣GIS-Sailor

作者:

GIS爱好者,学GIS,更爱玩GIS。

声明

1.本文所分享的所有需要用户下载使用的内容(包括但不限于软件、数据、图片)来自于网络或者麻辣GIS粉丝自行分享,版权归该下载资源的合法拥有者所有,如有侵权请第一时间联系本站删除。

2.下载内容仅限个人学习使用,请切勿用作商用等其他用途,否则后果自负。

手机阅读
公众号关注
知识星球
手机阅读
麻辣GIS微信公众号关注
最新GIS干货
关注麻辣GIS知识星球
私享圈子

留言板(小编看到第一时间回复)