public void DisplayInfo(GeolocationInfo _geolocationInfo) { ipAddressTMP.text = "IP Address: " + _geolocationInfo.query; inputField.text = _geolocationInfo.query; geolocationInfooTMP1.text = $"status: {_geolocationInfo.status}\n" + $"continent: {_geolocationInfo.continent}\n" + $"continentCode: {_geolocationInfo.continentCode}\n" + $"country: {_geolocationInfo.country}\n" + $"countryCode: {_geolocationInfo.countryCode}\n" + $"region: {_geolocationInfo.region}\n" + $"regionName: {_geolocationInfo.regionName}\n" + $"city: {_geolocationInfo.city}\n" + $"district: {_geolocationInfo.district}\n" + $"zip: {_geolocationInfo.zip}\n" + $"lat: {_geolocationInfo.lat}\n" + $"lon: {_geolocationInfo.lon}"; geolocationInfooTMP2.text = $"timezone: {_geolocationInfo.timezone}\n" + $"currency: {_geolocationInfo.currency}\n" + $"isp: {_geolocationInfo.isp}\n" + $"org: {_geolocationInfo.org}\n" + $"as: {_geolocationInfo.@as}\n" + $"asname: {_geolocationInfo.asname}\n" + $"reverse: {_geolocationInfo.reverse}\n" + $"mobile: {_geolocationInfo.mobile}\n" + $"proxy: {_geolocationInfo.proxy}\n" + $"hosting: {_geolocationInfo.hosting}\n" + $"query: {_geolocationInfo.query}"; }
public IEnumerator GetGeolocation(string ipAddress) { geolocationInfooTMP1.text = "Loading. . . ."; geolocationInfooTMP2.text = "Loading. . . ."; ipAddressTMP.text = "IP Address: . . ."; inputField.text = ""; if (viewMoreDetail) { ipAddress += "?fields=status,message,continent,continentCode,country,countryCode,region,regionName,city,district,zip,lat,lon,timezone,currency,isp,org,as,asname,reverse,mobile,proxy,hosting,query"; } ipAddress += (viewMoreDetail ? "&" : "?") + "lang=" + LocalizationString(localization); var www = new UnityWebRequest("http://ip-api.com/json/" + ipAddress) { downloadHandler = new DownloadHandlerBuffer() }; Debug.Log("http://ip-api.com/json/" + ipAddress); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { //error yield break; } geolocationInfo = JsonUtility.FromJson <GeolocationInfo>(www.downloadHandler.text); DisplayInfo(geolocationInfo); }
private void AddGeolocationIfNotLast(GeolocationInfo geolocationInfo) { var lastLocation = _locations.LastOrDefault(x => geolocationInfo.Device == x.Device); if (lastLocation != null && lastLocation.Geolocation.Equals(geolocationInfo.Geolocation) && !lastLocation.DateTime.Equals(geolocationInfo.DateTime)) { lastLocation.DateTime = geolocationInfo.DateTime; } else if (lastLocation == null || !lastLocation.Geolocation.Equals(geolocationInfo.Geolocation)) { _locations.Add(geolocationInfo); } }
private async Task HandleAddress() { var latlon = GeolocationInfo.GetLatLong(address.address, "REDACTED"); address.lat = latlon.lat; address.lon = latlon.lon; var sunTime = await GeolocationInfo.GetDayLengthSeconds(address.lat, address.lon, address.date.ToShortDateString()); address.timeSeconds = sunTime.day_length; List <IBuildingModel> iBuildings = buildings.ToList <IBuildingModel>(); iBuildings = SolarTimeCalculator.CalculateSunTime(iBuildings, address.timeSeconds); buildings.Clear(); barData.Clear(); foreach (var iBuild in iBuildings) { buildings.Add(new DisplayBuildingModel { label = iBuild.label, height = iBuild.height, width = iBuild.width, riseLocation = iBuild.riseLocation, setLocation = iBuild.setLocation, seeSunRise = iBuild.seeSunRise, seeSunSet = iBuild.seeSunSet, afternoonSunTime = iBuild.afternoonSunTime, morningSunTime = iBuild.morningSunTime }); barData.Add(new BarChartModel { label = iBuild.label, morningSun = iBuild.morningSunTime, afternoonSun = iBuild.afternoonSunTime }); } await barObj.RefreshLiveData(); }
public void UpdateLocation(GeolocationInfo geolocationInfo) => AddGeolocationIfNotLast(geolocationInfo);