Exemple #1
0
    IEnumerator Map()
    {
        lat = dataStream.get("latitude");
        lon = dataStream.get("longitude");
        url = "https://maps.googleapis.com/maps/api/staticmap?center=" + lat + "," + lon
              + "&markers=color:blue%7Clabel:A%7C" + lat + "," + lon
              + urlMarkers + "&zoom=" + zoom + urlEnding;
        Debug.Log(url);
        UnityWebRequest www = UnityWebRequestTexture.GetTexture(url);

        yield return(www.SendWebRequest());

        myRenderer = GetComponent <Renderer>();
        myRenderer.material.mainTexture = DownloadHandlerTexture.GetContent(www);
    }
    // Update is called once per frame
    void Update()
    {
        if (dataStream.get("altitude") != "")
        {
            //find intersection between line from true marker location and origin and the sphere surrounding the origin
            var radius            = 10;
            var droneLatitude     = Convert.ToDouble(dataStream.get("latitude"));
            var droneLongitude    = Convert.ToDouble(dataStream.get("longitude"));
            var relativeLatitude  = (latitude < droneLatitude ? -1 : 1) * GetDistanceFromLatLonInKm(droneLatitude, 0, latitude, 0) * 1000;
            var relativeLongitude = (longitude < droneLongitude ? -1 : 1) * GetDistanceFromLatLonInKm(0, droneLongitude, 0, longitude) * 1000;
            var relativeAltitude  = altitude - Convert.ToDouble(dataStream.get("altitude"));
            var t = Math.Sqrt(Math.Pow(radius, 2) / (Math.Pow(relativeLongitude, 2) + Math.Pow(relativeAltitude, 2) + Math.Pow(relativeLatitude, 2)));
            var x = relativeLongitude * t;
            var y = relativeAltitude * t;
            var z = relativeLatitude * t;

            //adjust based on pitch
            var pitch = Convert.ToDouble(dataStream.get("roll"));
            (z, y) = Rotate(z, y, pitch);
            //adjust based on roll
            var roll = Convert.ToDouble(dataStream.get("roll"));
            (x, y) = Rotate(x, y, roll - 360);
            //adjust displayed marker based on heading
            var heading = Convert.ToDouble(dataStream.get("heading"));
            (x, z) = Rotate(x, y, roll - 360);
            //update location
            transform.position = new Vector3((float)x, (float)y, (float)z);
            distanceToMarker   = GetDistanceFromLatLonInKm(droneLatitude, droneLongitude, latitude, longitude);
        }
    }
Exemple #3
0
    public void IntegrationTest()
    {
        PositionARMarker  marker     = new PositionARMarker();
        FlightDataStorage dataStream = new FlightDataStorage();

        dataStream.set("latitude", "5");
        dataStream.set("longitude", "5");
        Debug.Assert(marker.GetDistanceFromLatLonInKm(Convert.ToDouble(dataStream.get("latitude")), Convert.ToDouble(dataStream.get("longitude")), 5, 5) == 0);
    }
Exemple #4
0
 // Update is called once per frame
 void Update()
 {
     text.text = fieldText + ": " + dataStream.get(fieldProperty) + (units == "" ? "" : " (" + units + ")");
 }
Exemple #5
0
 // Update is called once per frame
 void Update()
 {
     compass.transform.eulerAngles = new Vector3(compass.transform.eulerAngles.x, compass.transform.eulerAngles.y, float.Parse(dataStream.get("heading")));
 }
Exemple #6
0
    public void DataStreamGetTest()
    {
        FlightDataStorage dataStream = new FlightDataStorage();

        Debug.Assert(dataStream.get("BLAH") == "DATA NOT FOUND");
    }
Exemple #7
0
 public void Initialize()
 {
     markers[0] = SetupMarker(Convert.ToDouble(dataStream.get("latitude")), Convert.ToDouble(dataStream.get("longitude")), 0, "Home", homeMarker);
     map.Initialize();
     initialized = true;
 }