GlobeControl画的类似Google Earth中的网格线
GlobeControl画的类似Google Earth中的网格线
IGraphicsContainer3D pGCon3D = GC1.GlobeDisplay.Scene.BasicGraphicsLayer as IGraphicsContainer3D;
IRgbColor pColor = new RgbColorClass();
pColor.Green = 255;
ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();
pSimpleLineSymbol.Color = pColor;
pSimpleLineSymbol.Width = 3;
ILineElement pLineElement = new LineElementClass();
pLineElement.Symbol = pSimpleLineSymbol;
for (int N = 1; N <= 7; N++)
{
for (int j = 0; j <= 360; j += 10)
{
for (int i = 0; i <= 360; i += 10)
{
switch (N)
{
case 1:
{
IPoint pt1 = new PointClass();
pt1.PutCoords(i, j);
pt1.Z = 100000;
IPoint pt2 = new PointClass();
pt2.PutCoords(i, j);
pt2.Z = 100000;
ILine pLine = new LineClass();
pLine.PutCoords(pt1, pt2);
object pBefore = Type.Missing;
object pAfter = Type.Missing;
m_polyline.AddSegment((ISegment)pLine, ref pBefore, ref pAfter);
}
break;
case 2:
{
if (j == 0)
{
IPoint pt1 = new PointClass();
pt1.PutCoords(0, i);
pt1.Z = 100000;
IPoint pt2 = new PointClass();
pt2.PutCoords(0, i);
pt2.Z = 100000;
ILine pLine = new LineClass();
pLine.PutCoords(pt1, pt2);
object pBefore = Type.Missing;
object pAfter = Type.Missing;
TropicOfCancer.AddSegment((ISegment)pLine, ref pBefore, ref pAfter); //本初子午线
}
else
{
IPoint pt1 = new PointClass();
pt1.PutCoords(j, i);
pt1.Z = 100000;
IPoint pt2 = new PointClass();
pt2.PutCoords(j, i);
pt2.Z = 100000;
ILine pLine = new LineClass();
pLine.PutCoords(pt1, pt2);
object pBefore = Type.Missing;
object pAfter = Type.Missing;
m_polyline.AddSegment((ISegment)pLine, ref pBefore, ref pAfter); //经线
}
}
break;
case 3:
{
IPoint pt1 = new PointClass();
pt1.PutCoords(i, -23.5);
pt1.Z = 100000;
IPoint pt2 = new PointClass();
pt2.PutCoords(i, -23.5);
pt2.Z = 100000;
ILine pLine = new LineClass();
pLine.PutCoords(pt1, pt2);
object pBefore = Type.Missing;
object pAfter = Type.Missing;
TropicOfCancer.AddSegment((ISegment)pLine, ref pBefore, ref pAfter); //南回归线
}
break;
case 4:
{
IPoint pt1 = new PointClass();
pt1.PutCoords(i, 23.5);
pt1.Z = 100000;
IPoint pt2 = new PointClass();
pt2.PutCoords(i, 23.5);
pt2.Z = 100000;
ILine pLine = new LineClass();
pLine.PutCoords(pt1, pt2);
object pBefore = Type.Missing;
object pAfter = Type.Missing;
TropicOfCancer.AddSegment((ISegment)pLine, ref pBefore, ref pAfter); //北回归线
}
break;
case 5:
{
IPoint pt1 = new PointClass();
pt1.PutCoords(i, 65.56666666666666);
pt1.Z = 100000;
IPoint pt2 = new PointClass();
pt2.PutCoords(i, 65.56666666666666);
pt2.Z = 100000;
ILine pLine = new LineClass();
pLine.PutCoords(pt1, pt2);
object pBefore = Type.Missing;
object pAfter = Type.Missing;
TropicOfCancer.AddSegment((ISegment)pLine, ref pBefore, ref pAfter); //北极圈
}
break;
case 6:
{
IPoint pt1 = new PointClass();
pt1.PutCoords(i, -65.56666666666666);
pt1.Z = 100000;
IPoint pt2 = new PointClass();
pt2.PutCoords(i, -65.56666666666666);
pt2.Z = 100000;
ILine pLine = new LineClass();
pLine.PutCoords(pt1, pt2);
object pBefore = Type.Missing;
object pAfter = Type.Missing;
TropicOfCancer.AddSegment((ISegment)pLine, ref pBefore, ref pAfter); //南极圈
}
break;
case 7:
{
IPoint pt1 = new PointClass();
pt1.PutCoords(i, 0);
pt1.Z = 100000;
IPoint pt2 = new PointClass();
pt2.PutCoords(i, 0);
pt2.Z = 100000;
ILine pLine = new LineClass();
pLine.PutCoords(pt1, pt2);
object pBefore = Type.Missing;
object pAfter = Type.Missing;
TropicOfCancer.AddSegment((ISegment)pLine, ref pBefore, ref pAfter); //赤道
}
break;
}
}
}
}
IGeometry geometry = (IGeometry)m_polyline;
IElement pElement = new LineElementClass();
pElement.Geometry = geometry;
IGeometry pTropicOfCancerGeometry = (IGeometry)TropicOfCancer;
IElement pTropicOfCancerElement = (IElement)pLineElement;
pTropicOfCancerElement.Geometry = pTropicOfCancerGeometry;
pGCon3D.DeleteAllElements();
pGCon3D.AddElement(pElement);
pGCon3D.AddElement(pTropicOfCancerElement);
GC1.GlobeDisplay.RefreshViewers();
本程序还未进行优化先发出来给大家参考,转帖请署名地址
posted on 2009-05-22 16:26 kisstome88 阅读(1001) 评论(0) 收藏 举报
浙公网安备 33010602011771号