ArcGlobe常用代码

1.     按照适当的顺序绘制ArcGlobe图层

              public void GetSetGlobeDrawingOrder(ESRI.ArcGIS.GlobeCore.IGlobe globe)

        {

            ESRI.ArcGIS.GlobeCore.IGlobeDisplay globeDisplay = globe.GlobeDisplay;

            ESRI.ArcGIS.GlobeCore.IGlobeDrawingOrder globeDrawingOrder = (ESRI.ArcGIS.GlobeCore.IGlobeDrawingOrder)globe;

 

                     ESRI.ArcGIS.Carto.IEnumLayer enumLayer = globeDrawingOrder.OrderedLayers;

 

                     ESRI.ArcGIS.Carto.IEnumLayer baseLayers = globe.get_GlobeLayers(null, true, true, true);

                     ESRI.ArcGIS.Carto.IEnumLayer floatingLayers = globe.get_GlobeLayers(null, false, false, true);

 

 

                     ESRI.ArcGIS.GlobeCore.IGlobeLayerProperties globeLayerProperties;

                     ESRI.ArcGIS.GlobeCore.IGlobeDisplayLayers globeDisplayLayers = (ESRI.ArcGIS.GlobeCore.IGlobeDisplayLayers)globeDisplay;

 

                     System.Collections.ArrayList DrapedLayers = new System.Collections.ArrayList();

                     System.Collections.ArrayList ElevationLayers = new System.Collections.ArrayList();

 

                     ESRI.ArcGIS.Carto.ILayer layer = baseLayers.Next();

            while (layer != null)

            {

                globeLayerProperties = globeDisplayLayers.FindGlobeProperties(layer);

                if (globeLayerProperties.Type != ESRI.ArcGIS.GlobeCore.esriGlobeDataType.esriGlobeDataElevation)

                {

                    DrapedLayers.Add(layer);

                }

                else if (globeLayerProperties.Type == ESRI.ArcGIS.GlobeCore.esriGlobeDataType.esriGlobeDataElevation)

                {

                    ElevationLayers.Add(layer);

                }

               //获得浮动图层

            ESRI.ArcGIS.Carto.ILayer theFloatingLayer = floatingLayers.Next();

            while (theFloatingLayer != null)

            {

                theFloatingLayer = floatingLayers.Next();

            }

        }

 

2.   获得BasicMap

              public ESRI.ArcGIS.Carto.IBasicMap GetBasicMapFromGlobe(ESRI.ArcGIS.GlobeCore.IGlobe globe)

        {

            ESRI.ArcGIS.Carto.IBasicMap basicMap = globe as ESRI.ArcGIS.Carto.IBasicMap;

 

            return basicMap;

        }

 

3.     获得Geographic 坐标

              public ESRI.ArcGIS.Geometry.IPoint GetGeographicCoordinates(System.Int32 xView, System.Int32 yView, ESRI.ArcGIS.GlobeCore.IGlobeDisplay globeDisplay)

        {

            ESRI.ArcGIS.Geometry.IPoint point;

            object ppOwner;

            object ppObject;

            globeDisplay.Locate(globeDisplay.ActiveViewer, xView, yView, false, true, out point, out ppOwner, out ppObject);

            return point;

        }

 

4.   设置Globe Layer 属性

              public void SetGlobeLayerProperties1(ESRI.ArcGIS.GlobeCore.IGlobeDisplay globeDisplay, ESRI.ArcGIS.Carto.ILayer layer)

        {

            ESRI.ArcGIS.GlobeCore.IGlobeDisplayLayers globeDisplayLayers = globeDisplay as ESRI.ArcGIS.GlobeCore.IGlobeDisplayLayers;

 

            ESRI.ArcGIS.GlobeCore.IGlobeLayerProperties globeLayerProps = globeDisplayLayers.FindGlobeProperties(layer);

 

            globeLayerProps.Use16ColorBits = true;

 

            globeDisplayLayers.RefreshLayer(layer);

        }

 

 

 

5.   向ArcGlobe控件中通过类型来添加图层

 

              public void AddGlobeLayerByType(ESRI.ArcGIS.GlobeCore.IGlobe globe,

              ESRI.ArcGIS.GlobeCore.esriGlobeLayerType globeLayerType, ESRI.ArcGIS.Carto.ILayer layer)

        {

            if (globe == null) return;

 

            if (globeLayerType ==ESRI.ArcGIS.GlobeCore.esriGlobeLayerType.esriGlobeLayerTypeElevation)

            {

                if (layer is ESRI.ArcGIS.Carto.IRasterLayer ||

                    layer is ESRI.ArcGIS.Carto.ITinLayer ||

                    layer is ESRI.ArcGIS.Carto.ITerrainLayer)

                {

                    globe.AddLayerType(layer, globeLayerType, true);

                }

                return;

            }

            // else if GlobeLayerType is esriGlobeLayerTypeDraped or esriGlobeLayerTypeFloating

            globe.AddLayerType(layer, globeLayerType, true);

        }

 

6.     向ArcGlobe中添加Graphics Layer

 

              public void AddNewGraphicsLayer(ESRI.ArcGIS.GlobeCore.IGlobe globe, System.String graphicsLayerName)

        {

graphics layer 并添加到//  // 设置相关属性

            simpleMarker3DSymbol.ResolutionQuality = 1;

            ESRI.ArcGIS.Display.IColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();

            rgbColor.RGB = 255;

 

            ESRI.ArcGIS.Display.IMarkerSymbol markerSymbol =(ESRI.ArcGIS.Display.IMarkerSymbol)simpleMarker3DSymbol;   

                     markerSymbol.Color =rgbColor;

            markerSymbol.Size = 100000;

 

           

            ESRI.ArcGIS.Geometry.IPoint point = new ESRI.ArcGIS.Geometry.PointClass();

            point.PutCoords(-47, 44);

            markerElement.Geometry = point;

 

           graphics layer

            ESRI.ArcGIS.Carto.IMarkerElement markerElement_2 =(ESRI.ArcGIS.Carto.IMarkerElement)markerElement;

            markerElement_2.Symbol = markerSymbol;

            globeGraphicsLayer.AddElement(markerElement, 1);

 

           graphics layer添加线元素

            ESRI.ArcGIS.Carto.IElement lineElement = new ESRI.ArcGIS.Carto.LineElementClass();

            ESRI.ArcGIS.Analyst3D.ISimpleLine3DSymbol simpleLineSymbol3D = new              ESRI.ArcGIS.Analyst3D.SimpleLine3DSymbolClass();

            simpleLineSymbol3D.Style =ESRI.ArcGIS.Analyst3D.esriSimple3DLineStyle.esriS3DLSStrip;

 

             // 设置         // 添加到<span lang="EN-US" arial","sans-serif";="" mso-fareast-font-family:宋体;color:#e46c0a;mso-themecolor:accent6;mso-themeshade:="" 191;mso-style-textfill-fill-color:#e46c0a;mso-style-textfill-fill-themecolor:="" accent6;mso-style-textfill-fill-alpha:100.0%;mso-style-textfill-fill-colortransforms:="" lumm="75000;mso-font-kerning:0pt;""> graphics layer

            ESRI.ArcGIS.Carto.ILineElement lineElement_2 =(ESRI.ArcGIS.Carto.ILineElement)lineElement;

            lineElement_2.Symbol = lineSymbol;

            globeGraphicsLayer.AddElement(lineElement, 1);

        }

 

 

7.     向ArcGlobe添加 KML 数据

 

              public void AddKMLData(System.String theKmlFile, ESRI.ArcGIS.GlobeCore.IGlobe globe,System.String kmlLayerName)

        {

            Type kmlType = Type.GetTypeFromProgID("esriGlobeCore.KmlLayer");

            ESRI.ArcGIS.GlobeCore.IKmlLayer kmlLayer = (ESRI.ArcGIS.GlobeCore.IKmlLayer)System.Activator.CreateInstance(kmlType);

            kmlLayer.DataPath = theKmlFile;

            kmlLayer.Name = kmlLayerName;

            ESRI.ArcGIS.Analyst3D.IScene scene = globe as ESRI.ArcGIS.Analyst3D.IScene;   

 

         scene.AddLayer(kmlLayer as ESRI.ArcGIS.Carto.ILayer, true);        

         }

 

8.   向ArcGlobe中添加矢量数据

 

              public void AddVectorData(ESRI.ArcGIS.GlobeCore.IGlobe globe,

 

              ESRI.ArcGIS.GlobeCore.esriGlobeLayerType globeLayerType, ESRI.ArcGIS.Carto.ILayer layer)

        {

            if (globe == null || layer == null ||

                globeLayerType ==ESRI.ArcGIS.GlobeCore.esriGlobeLayerType.esriGlobeLayerTypeElevation ||

                globeLayerType ==ESRI.ArcGIS.GlobeCore.esriGlobeLayerType.esriGlobeLayerTypeUnknown)

                            {

                                   return;

                            }

 

            ESRI.ArcGIS.GlobeCore.IGlobeDisplay globeDisplay = globe.GlobeDisplay;

            ESRI.ArcGIS.GlobeCore.IGlobeDisplay2 globeDisplay2 = globeDisplay as ESRI.ArcGIS.GlobeCore.IGlobeDisplay2;

            globeDisplay2.PauseCaching = true;

            globe.AddLayerType(layer, globeLayerType, true);

            ESRI.ArcGIS.GlobeCore.IGlobeDisplayLayers globeDisplayLayers = globeDisplay as ESRI.ArcGIS.GlobeCore.IGlobeDisplayLayers;

            ESRI.ArcGIS.GlobeCore.IGlobeLayerProperties globeLayerProperties =globeDisplayLayers.FindGlobeProperties(layer);

            globeLayerProperties.IsDynamicallyRasterized = false;

            globeDisplay2.PauseCaching = false;

        }

你可能感兴趣的:(ArcGlobe常用代码)