ArcEngine 개발: Ielement.Geometry 값이 예상 범위 내에 있지 않음 + 요소 그리기 코드
6349 단어 ArcEngine
pEle.Geometry = pLn;
pLn은 ILINe 대상입니다. 당연히 IGeometry 대상이라고 생각하고 값을 부여할 수 있습니다. 그 결과 이상 값이 예상 범위 내에 있지 않다는 것이 밝혀졌습니다.
해결 방법은 ILINe을 IPolyline 객체로 변환하는 것으로, Geometry의 기본 작업과 관련됩니다.그림% 1개의 캡션을 편집했습니다.
#region RgbColor
/// <summary>
/// RgbColor
/// </summary>
/// <param name="r"></param>
/// <param name="g"></param>
/// <param name="b"></param>
/// <param name="alpa"> , .0 </param>
/// <returns></returns>
public static IRgbColor getRgbColor(int r, int g, int b, byte alpa = 255)
{
IRgbColor pColor = new RgbColorClass();
pColor.Red = r;
pColor.Green = g;
pColor.Blue = b;
pColor.Transparency = alpa;
return pColor;
}
#endregion
#region
/// <summary>
///
/// </summary>
/// <returns></returns>
public static IRgbColor getRandColor()
{
Random rd = new Random();
IRgbColor myColor = new RgbColorClass();
myColor.Red = rd.Next(0, 255);
myColor.Blue = rd.Next(0, 255);
myColor.Green = rd.Next(0, 255);
return myColor;
}
#endregion
#region
/// <summary>
///
/// </summary>
/// <param name="pLine"></param>
/// <param name="pMapCtrl"></param>
/// <param name="pLineSymbol"> </param>
/// <param name="refresh"> </param>
public static void DrawLine(ILine pLine, IMapControl2 pMapCtrl, ISimpleLineSymbol pLineSymbol
, bool refresh)
{
ILineElement pLineEle = new LineElementClass();
pLineEle.Symbol = pLineSymbol;
IGeometryCollection pPolyline = new PolylineClass();
ISegmentCollection pPath = new PathClass();
object m1 = Type.Missing;
object m2 = Type.Missing;
pPath.AddSegment(pLine as ISegment, ref m1, ref m2);
pPolyline.AddGeometry(pPath as IGeometry, ref m1, ref m2);
IElement pEle = pLineEle as IElement;
pEle.Geometry = pPolyline as IGeometry;
IGraphicsContainer pGC = pMapCtrl.Map as IGraphicsContainer;
pGC.AddElement(pEle, 0);
if (refresh)
{
IActiveView pAv = pMapCtrl.ActiveView;
pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
}
#endregion
#region
/// <summary>
///
/// </summary>
/// <param name="pnt"></param>
/// <param name="value"></param>
/// <param name="ptxtSym"></param>
/// <param name="pMapCtrl"></param>
/// <param name="refresh"></param>
public static void DrawTextEle(IPoint pnt, string strvalue, ITextSymbol ptxtSym,
IMapControl2 pMapCtrl, bool refresh)
{
ITextElement pTextEle = new TextElementClass();
pTextEle.Text = strvalue;
pTextEle.Symbol = ptxtSym;
IElement pEle = pTextEle as IElement;
pEle.Geometry = pnt;
IGraphicsContainer pGc = pMapCtrl.Map as IGraphicsContainer;
pGc.AddElement(pEle, 0);
if (refresh)
{
IActiveView pAv = pMapCtrl.ActiveView;
pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
}
#endregion
#region polyline
/// <summary>
///
/// </summary>
/// <param name="pPolyline"></param>
/// <param name="pLineSym"></param>
/// <param name="pMapCtrl"></param>
/// <param name="refresh"></param>
public static void DrawPolyline(IPolyline pPolyline, ISimpleLineSymbol pLineSym, IMapControl2 pMapCtrl,
bool refresh)
{
ILineElement pLineEle = new LineElementClass();
IElement pEle = pLineEle as IElement;
pLineEle.Symbol = pLineSym;
pEle.Geometry = pPolyline;
IGraphicsContainer pGc = pMapCtrl.Map as IGraphicsContainer;
pGc.AddElement(pEle, 0);
if (refresh)
{
IActiveView pAv = pMapCtrl.ActiveView;
pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
}
#endregion
#region
/// <summary>
///
/// </summary>
/// <param name="pnt"></param>
/// <param name="pMapCtrl"></param>
/// <param name="pColor"> </param>
/// <param name="refresh"> </param>
public static void DrawPoint(IPoint pnt, IMapControl2 pMapCtrl, IRgbColor pColor, bool refresh)
{
ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass();
pMarkerSymbol.Color = pColor;
pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
pMarkerSymbol.Size = 3;
IElement pEle;
IMarkerElement pMe = new MarkerElementClass();
pMe.Symbol = pMarkerSymbol;
pEle = pMe as IElement;
pEle.Geometry = pnt;
IActiveView pav = pMapCtrl.ActiveView;
IGraphicsContainer pGc = pMapCtrl.Map as IGraphicsContainer;
pGc.AddElement(pEle, 0);
if (refresh)
pav.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
#endregion
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
ArcEngine 개발: Ielement.Geometry 값이 예상 범위 내에 있지 않음 + 요소 그리기 코드IElement pEle = pLineEle as IElement; pEle.Geometry = pLn; pLn은 ILINe 대상입니다. 당연히 IGeometry 대상이라고 생각하고 값을 부여할 수 있습니다. 그 결...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.