我是靠谱客的博主 坚强乌龟,最近开发中收集的这篇文章主要介绍arcgis两点之间连线_Engine中如何截取线上指定两点间的线段?,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

//调用

IPolyline newLine = GetSubCurve(polyline, p1, p2);

ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = axMapControl1.ActiveView.ScreenDisplay;

screenDisplay.StartDrawing(screenDisplay.hDC, System.Convert.ToInt16(ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache));

IRgbColor rgbColor = new RgbColorClass();

rgbColor.Red = 255;

ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit Cast

ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();

simpleLineSymbol.Color = color;

ESRI.ArcGIS.Display.ISymbol symbol = (ESRI.ArcGIS.Display.ISymbol)simpleLineSymbol; // Explicit Cast

screenDisplay.SetSymbol(symbol);

screenDisplay.DrawPolyline(newLine);

screenDisplay.FinishDrawing();

private IPolyline GetSubCurve(IPolyline inpolyLine, IPoint pnt1, IPoint pnt2)

{

double d1 = GetDistAlong(inpolyLine, pnt1);

double d2 = GetDistAlong(inpolyLine, pnt2);

var c = inpolyLine as ICurve;

ICurve outCurve;

c.GetSubcurve(d1, d2, false, out outCurve);

if (c == null || c.IsEmpty)

throw new Exception(fail);

var outPolyline = outCurve as IPolyline;

if (outPolyline == null)

{

outPolyline = new PolylineClass() as IPolyline;

var sc = outPolyline as ISegmentCollection;

sc.AddSegment((ISegment)outCurve);

((IGeometry)sc).SpatialReference = outCurve.SpatialReference;

}

return outPolyline;

}

private double GetDistAlong(IPolyline polyLine, IPoint pnt)

{

var outPnt = new PointClass() as IPoint;

double distAlong = double.NaN;

double distFrom = double.NaN;

bool bRight = false;

polyLine.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, pnt, false, outPnt,

ref distAlong, ref distFrom, ref bRight);

return distAlong;

}

最后

以上就是坚强乌龟为你收集整理的arcgis两点之间连线_Engine中如何截取线上指定两点间的线段?的全部内容,希望文章能够帮你解决arcgis两点之间连线_Engine中如何截取线上指定两点间的线段?所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(56)

评论列表共有 0 条评论

立即
投稿
返回
顶部