Beispiel #1
0
 private void LatLngToPix_Click(object sender, RoutedEventArgs e)
 {
     try {
         Point pMeters = WebMercator.LatLonToMeters(Double.Parse(LatTxt.Text), Double.Parse(LngTxt.Text));
         Point pPixels = WebMercator.MetersToPixels(pMeters, int.Parse(ZoomTxt.Text));
         XPixTxt.Text = pPixels.X.ToString();
         YPixTxt.Text = pPixels.Y.ToString();
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #2
0
    void ParseCSV(string s)
    {
        Nodes = new List <Node>();

        string[] lines = s.Split('\n');

        //header on line 1
        string[] header = lines[0].Split(',');

        Debug.Log(lines[0]);

        foreach (string h in header)
        {
            //Debug.Log(h);
        }
        double lat           = 0;
        double lon           = 0;
        double alt           = 0;
        double deg           = 0;
        double gimbalheading = 0;
        double gimbalpitch   = 0;

        for (int i = 0; i < lines.Length; i++)
        {
            if (i == 0) //header
            {
                continue;
            }

            string line = lines[i];

            if (line.Length < 2)
            {
                continue;
            }

            Node     n     = new Node();
            string[] items = line.Split(',');



            for (int j = 0; j < items.Length; j++)
            {
                if (header[j] == LATITUDE)
                {
                    //n.latitude = float.Parse(items[i]);
                    lat = double.Parse(items[j]);
                }
                if (header[j] == LONGITUDE)
                {
                    //n.longitude = float.Parse(items[i]);
                    lon = double.Parse(items[j]);
                }
                if (header[j] == ALTITUDEFEET)
                {
                    //n.altitude = float.Parse(items[i]);
                    alt = FeetToMeters(double.Parse(items[j]));
                }
                if (header[j] == TIMEMS)
                {
                    n.timems = int.Parse(items[j]);
                }
                if (header[j] == COMPASSDEGREES)
                {
                    deg = double.Parse(items[j]);
                }

                if (header[j] == GIMBALHEADINGDEGREES)
                {
                    double t = double.Parse(items[j]);
                    if (t != 0)
                    {
                        gimbalheading = double.Parse(items[j]);
                    }
                }
                if (header[j] == GIMBALPITCHDEGREES)
                {
                    double t = double.Parse(items[j]);
                    if (t != 0)
                    {
                        gimbalpitch = double.Parse(items[j]);
                    }
                }

                if (header[j] == STARTVIDEO)
                {
                    n.isVideo = int.Parse(items[j]);
                }

                if (header[j] == CAPTUREPHOTO)
                {
                    n.isPhoto = int.Parse(items[j]);
                }

                if (header[j] == FLYSTATE)
                {
                    n.FlyState = items[j];
                }

                if (header[j] == MESSAGE)
                {
                    n.Message = items[j];
                }
            }

            if (i == 1)
            {
                StartPoint    = WebMercator.LatLonToMeters(lat, lon);
                StartAltitude = alt;
            }

            Point p = WebMercator.LatLonToMeters(lat, lon);
            n.DronePosition.x = (float)((p.X - StartPoint.X) * Scale.x);
            n.DronePosition.z = (float)((p.Z - StartPoint.Z) * Scale.z);
            n.DronePosition.y = (float)((alt - StartAltitude) * Scale.y);
            n.DroneRotation   = Quaternion.Euler(0, (float)deg, 0);
            n.GimbalRotation  = Quaternion.Euler((float)-gimbalpitch, (float)(gimbalheading - deg), 0);
            //Debug.Log(n.GimbalRotation.eulerAngles);


            Nodes.Add(n);
            //Debug.Log(line);
        }

        CreatePathFromNodes();
    }