• 雨后春笋


    今天,帮一个同事写了一段测试小程序,刚好外面在下雨,就叫它“雨后春笋”吧!

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.IO;
    using System.Text;
    using TerraExplorerX;
    
    namespace ShowPoints
    {
        public partial class Form1 : Form
        {
            public SGWorld66 sg;
    
            public Form1()
            {
                InitializeComponent();
    
                sg = new SGWorld66();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                Read(Application.StartupPath + "/testdata.txt");
            }
    
            //从txt中读取经纬度坐标,创建三维对象
            public void Read(string path)
            {
                StreamReader sr = new StreamReader(path, Encoding.Default);
                String line;
                int i = 0;
                string gid = CreateGroup("Cones");
                while ((line = sr.ReadLine()) != null)
                {
                    if (i % 2 == 0)
                    {
                        string gStr = line.ToString();
                        string[] aStr = gStr.Split(new string[] { " " }, StringSplitOptions.None);
                        string Lat = line.Substring(21, 7).Trim();
                        string Long = line.Substring(28, 7).Trim();
                        if (Lat == string.Empty) continue;
                        //if (Long == string.Empty) continue;  
                        IPosition66 pos = sg.Creator.CreatePosition(Convert.ToDouble(Long), Convert.ToDouble(Lat), 0); ;
                        ITerrain3DRegBase66 obj = sg.Creator.CreateCone(pos, 5000,5000);
                        sg.ProjectTree.SetParent(obj.ID, gid);
                    }
                    i++;
                }
                sg.Navigate.FlyTo(sg.ProjectTree.GetNextItem(gid, ItemCode.CHILD), ActionCode.AC_JUMP); ;
            }
            private string CreateGroup(string gname)
            {
                return sg.ProjectTree.CreateGroup(gname);
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                this.timer1.Enabled = true;
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
                this.timer1.Enabled = false;
            }
    
            private void timer1_Tick(object sender, EventArgs e)
            {
                try
                {
                    string oid = sg.ProjectTree.FindItem("Cones");
                    oid = sg.ProjectTree.GetNextItem(oid, ItemCode.CHILD);
                    int a = 0;
                    // 遍历一个组
                    while (oid != sg.ProjectTree.RootID)
                    {
                        ITerrain3DRegBase66 obj = sg.ProjectTree.GetObject(oid) as ITerrain3DRegBase66;
                        obj.Height = obj.Height + 100 + a*10;
                        oid = sg.ProjectTree.GetNextItem(oid, ItemCode.NEXT);
                        a++;
                    }
                }
                catch (Exception ex)
                { }
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                // 初始化加载一个三维地形,@"C:UsersAdministratorDesktopa.FLY"可以换成本地的fly或者mpt文件
                sg.Open(@"C:UsersAdministratorDesktopa.FLY");
            }
    
        }
    }
    

      

     未到清明雨纷纷,一朝天子一朝臣。快马加鞭莫等闲,再统天下平百川。

  • 相关阅读:
    自动重连脚本
    自动输入用户名密码脚本
    idea 安装及配置
    manjaro安装anaconda
    hive 常用命令
    python built-in zip()
    isinstance(),issubclass()
    python built-in delattr()
    字符串匹配算法
    贪心,分治,回溯,动态规划 4大核心算法思想
  • 原文地址:https://www.cnblogs.com/yitianhe/p/6606316.html
Copyright © 2020-2023  润新知