draw a 3d line in globe control

356
3
10-17-2011 03:13 AM
sercanpehlivan
New Contributor
I am using ArcGIS 10 and I want to draw a realistic line on globe control by using c# and my code is below.But my problem is when i run my program it draws a straight line.But i want t� draw a geodesic line(a curved segment according to earth's geodic shape )

public void drawline(double lon1, double lat1, double alt1, double lon2, double lat2, double alt2)
        {
            const esriSimple3DLineStyle AxisStyle = esriSimple3DLineStyle.esriS3DLSTube;
            const double AxisWidth = 1;


            IPoint point = (IPoint)new ESRI.ArcGIS.Geometry.Point();
            ((IZAware)point).ZAware = true;
            point.PutCoords(lon1, lat1);
            point.Z = alt1;

            IPoint point2 = new ESRI.ArcGIS.Geometry.Point();
            ((IZAware)point2).ZAware = true;
            point2.PutCoords(lon2, lat2);
            point2.Z = alt2;

            IPoint zero = new ESRI.ArcGIS.Geometry.Point();
            ((IZAware)zero).ZAware = true;
            zero.PutCoords(0, 0);
            zero.Z = 0;

            IRgbColor color = new RgbColor();
            color.Red = 255;
            color.Green = 0;
            color.Blue = 0;

            IPointCollection axisPointCollection = new Polyline();
            // ((IGeometry)axisPointCollection).SpatialReference = //axGlobeControl1.GlobeDisplay.Scene.SpatialReference;
            axisPointCollection.AddPoint(point, ref _missing, ref _missing);
            axisPointCollection.AddPoint(point2, ref _missing, ref _missing);

            IZAware zAware = axisPointCollection as IZAware;
            zAware.ZAware = true;



            ISimpleLine3DSymbol simpleLine3DSymbol = new SimpleLine3DSymbol();
            simpleLine3DSymbol.Style = AxisStyle;
            simpleLine3DSymbol.ResolutionQuality = 1;

            ILineSymbol lineSymbol = simpleLine3DSymbol as ILineSymbol;
            lineSymbol.Color = color;

            lineSymbol.Width = AxisWidth * 20;

            ILine3DPlacement line3DPlacement = lineSymbol as ILine3DPlacement;
            //line3DPlacement.Units = Units;

            ILineElement lineElement = (ILineElement)new LineElement();
            lineElement.Symbol = lineSymbol;

            IElement element = lineElement as IElement;
            element.Geometry = axisPointCollection as IPolyline;



            ((IGraphicsContainer)m_globeGraphicsLayer).AddElement(element, 1);
        }


Is there a way to do so.

Thanks in advance.
0 Kudos
3 Replies
EricRice
Esri Regular Contributor
Greetings,

You need to have a look at the IConstructGeodetic Interface.

Eric
0 Kudos
sercanpehlivan
New Contributor
Thank you very much Eric.
It works.

But now, i have another problem.My problem is i have a geodetic closed polyline and i want to convert it to a polygon so that i can fill inside of that closed polyline. Or is there another way to fill inside the closed polyline without converting it to a polygon.

Thanks in advance.
0 Kudos
EricRice
Esri Regular Contributor
If you want a polygon, you can create a polygon using IConstructGeodetic.

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000m74000000

If continuing down the current path, you can't fill inside a closed polyline.  It must be polygon to have area.

Regards,
Eric
0 Kudos