Exemplo n.º 1
0
        //全天日照时间
        private void button3_Click(object sender, EventArgs e)
        {
            double  Lon = Convert.ToDouble(lon.Text);
            double  Lat = Convert.ToDouble(lat.Text);
            int     Y   = Convert.ToInt32(TimeY.Text);
            int     M   = Convert.ToInt32(TimeM.Text);
            int     D   = Convert.ToInt32(TimeD.Text);
            Vertex3 Obp = new Vertex3(posX, posZ, posY);

            //获取日出、日落时间
            double[] SUN = CountSun.SunRaiseSetTime(Y, M, D, Lon, Lat);
            if (listBox1.Items.Count > 0)
            {
                listBox1.Items.Clear();
            }
            listBox1.Items.Add("日出时间:" + (int)SUN[0] + ":" + (int)((SUN[0] - (int)SUN[0]) * 60));
            listBox1.Items.Add("日落时间:" + (int)SUN[1] + ":" + (int)((SUN[1] - (int)SUN[1]) * 60));

            //计算日照时间
            List <string> ShadowTime = CalculateTools.SinglePointTime(Obp, gl.model.model, Y, M, D, Lon, Lat);

            for (int i = 0; i < ShadowTime.Count - 1; i++)
            {
                listBox1.Items.Add("被遮挡时间:" + ShadowTime[i]);
            }
            listBox1.Items.Add("全天总日照时间:" + Convert.ToString(Math.Round((SUN[1] - SUN[0] - ShadowTime.Count * 10.0 / 60.0), 2)) + "小时");
            //listBox1.Items.Add("全天总日照时间:" + ShadowTime[ShadowTime.Count - 1] + "小时");
        }
Exemplo n.º 2
0
        //计算单点日照时间
        public static List <string> SinglePointTime(Vertex3 ObP, t3DModel model, int Y, int M, int D, double Lon, double Lat)
        {
            double         Tr         = CountSun.SunRaiseSetTime(Y, M, D, Lon, Lat)[0]; //日出时间
            double         Ts         = CountSun.SunRaiseSetTime(Y, M, D, Lon, Lat)[1]; //日落时间
            double         t          = 0;                                              //遮挡时间
            List <string>  ShadowTime = new List <string>();
            List <Vector3> dn         = new List <Vector3>();
            Vector3        Dn         = null;

            //每隔10分钟判读一次观测被遮挡情况
            for (double T = Tr; T <= Ts; T += 10.0 / 60.0)
            {
                int H   = (int)T;
                int Min = (int)((T - H) * 60);
                H   = H + Min / 60;
                Min = Min % 60;
                double[] sun = CountSun.CalculateSun(Y, M, D, H, Min, Lon, Lat);//计算太阳因子
                Dn = CalculateDirectionVector(sun[2], sun[3]);
                dn.Add(Dn);
                //Vector3 Dn = CalculateDirectionVector(ObP.z,sun[0], sun[1]);//计算太阳单位方向向量
                //Dn.x += ObP.x;
                //Dn.y -= ObP.y;
                //Dn.z += ObP.z;
                bool shelter = SinglePointShelter(ObP, model, Dn);//判断是否被遮挡
                if (shelter)
                {
                    t += 10;
                    if (Min < 10)
                    {
                        ShadowTime.Add(H + ":0" + Min + "--" + H + ":" + (Min + 10));
                    }
                    else
                    {
                        ShadowTime.Add(H + ":" + Min + "--" + H + ":" + (Min + 10));
                    }
                }
            }
            t = t / 60;                                                     //被遮挡时间
            ShadowTime.Add(Convert.ToString(Math.Round((Ts - Tr - t), 2))); //日照时间
            return(ShadowTime);
        }