/**<summary> Get location from image </summary>*/ public static async Task <Tuple <bool, LocationData> > LocationFineDummy(string buildingID, byte[] image) { if (App.config.debug) { Debug.Log("Starting dummy location/fine request for buildingID: " + buildingID); } await Task.Delay(100); LocationData locationData = new LocationData(new Vector3(-30, 1.6f, 20), Vector3.forward, Quaternion.identity); OnLocationResponse?.Invoke(true, locationData); return(new Tuple <bool, LocationData>(true, locationData)); }
/**<summary> Get location from image </summary>*/ public static async Task <Tuple <bool, LocationData> > LocationFine(string buildingID, byte[] image) { #if UNITY_EDITOR //return await LocationFineDummy(buildingID, image); #endif if (App.config.debug) { Debug.Log("Starting location/fine request for buildingID: " + buildingID); } WWWForm formData = new WWWForm(); formData.AddField("buildingID", buildingID); formData.AddField("useVise", "true"); formData.AddBinaryData("image", image); UnityWebRequest www = UnityWebRequest.Post(App.config.apiURL + "/location/fine", formData); www.downloadHandler = new DownloadHandlerBuffer(); www.SendWebRequest(); while (!www.isDone) { await Task.Delay(100); } if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); Debug.Log(www.downloadHandler.text); OnLocationResponse?.Invoke(false, new LocationData()); return(new Tuple <bool, LocationData>(false, new LocationData())); } else { Debug.Log(www.downloadHandler.text); LocationData locationData = ParseLocation(www.downloadHandler.text); OnLocationResponse?.Invoke(true, locationData); return(new Tuple <bool, LocationData>(true, locationData)); } }