skyline_x
skyline_x
2019-07-26 10:43

基于c#的skyline二次开发时,用帮助文档的例子,创建圆的时候 try catch捕捉到的一下问题:

图片说明图片说明

基于c#的skyline二次开发时,用帮助文档的例子,创建圆的时候 try catch捕捉到的一下问题:代码如下,出现的问题如图

  private void btnCircle_Click(object sender, EventArgs e)
        {
            //Creating a Circle 
            //This example demonstrates how to create a circle, set its properties, and then fly to it. This
            //example uses the ICreator61 (CreatePosition, CreateColor, CreateCircle, CreateMessage),
            //INavigate61 (FlyTo), IPosition61 (Copy, Pitch), IColor61, ITerrainRegularPolygon61 (Radius, Message),
            //IFillStyle61 (Color) and ITerraExplorerMessage61 (ID) interfaces.
            string tMsg = String.Empty;
            IPosition61 cPos = null;    
            IColor61 cFillColor = null;
            ITerrainRegularPolygon61 cCircle = null;
            ITerraExplorerMessage61 cMessage = null;
            try
            {
                // A. Instantiate Terra Explorer Globe

                SGWorld61 sgworld = new SGWorld61();
                // B. Create position for circle
                // B1. Set position input parameters (San Fransico shore)
                double dXCoord = -122.49460;
                double dYCoord = 37.78816;
                double dAltitude = 100.0;

                AltitudeTypeCode eAltitudeTypeCode = AltitudeTypeCode.ATC_TERRAIN_RELATIVE;
                double dYaw = 0.0;  //yaw 偏航
                double dPitch = 0.0;  //pitch 倾斜
                double dRoll = 0.0; //roll 滚动
                double dDistance = 5000; //距离
                // B2. Create Position  

                cPos = sgworld.Creator.CreatePosition(dXCoord, dYCoord, dAltitude, eAltitudeTypeCode, dYaw, dPitch, dRoll, dDistance);
                // C. create FillColor for circle
                // C1. Set fill color input params - RGB and Alpha
                int nRed = 0;
                int nGreen = 255;
                int nBlue = 0;
                int nAlpha = 0x7F; // 50% opacity
                // C2. Create fill color
                cFillColor = sgworld.Creator.CreateColor(nRed, nGreen, nBlue, nAlpha);
                // D. Create circle using created position and fill color (for line color use Abgr uint value)
                // D1. Set circle input params
                uint nLineColor = 0xFFFF0000; // Abgr value - Solid blue   纯蓝色
                double dCircleRadius = 200; // in meters  半径
                // C2. Create circle

                cCircle = sgworld.Creator.CreateCircle(cPos, dCircleRadius, nLineColor, cFillColor, 0, "Circle");
                // E. Get and change circle properties
                // E1. Get & Set circle radius
                double dNewCircleRadius = 300;
                double dCurrentCircleRadius = cCircle.Radius; // Get circle radius
                cCircle.Radius = dNewCircleRadius; // Set new circle radius
                // E2. Get fill style and change its properties
                uint nRGB_Red = 0xFF0000; // uing Rgb - Red color
                double dAlpha = 0.2; // 80% transparent
                IFillStyle61 cFillStyle = cCircle.FillStyle;
                cFillStyle.Color.FromRGBColor(nRGB_Red);
                cFillStyle.Color.SetAlpha(dAlpha);
                // F. Add Message to created circle
                // F1. Set message input parameters

                MsgTargetPosition eMsgTarget = MsgTargetPosition.MTP_POPUP;
                string tMessage = "Hello Circle";

                MsgType eMsgType = MsgType.TYPE_TEXT;
                bool bIsBringToFront = true;
                // F2. Create message and add to circle

                cMessage = sgworld.Creator.CreateMessage(eMsgTarget, tMessage, eMsgType, bIsBringToFront);
                cCircle.Message.MessageID = cMessage.ID;
                // G. FlyTo created circle
                IPosition61 cFlyToPos = cPos.Copy();
                cFlyToPos.Pitch = -89.0; // Set camera to look downward on circle

                sgworld.Navigate.FlyTo(cFlyToPos, ActionCode.AC_FLYTO);
            }
            catch (Exception ex)
            {
                tMsg = String.Format("CreateCircleButton_Click Exception: {0}", ex.Message);
                MessageBox.Show(tMsg);
            }
        }

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

为你推荐