コード例 #1
0
ファイル: Service.cs プロジェクト: jcanez2/CSE445Project3V1
    public static async Task <SunIntensityModel> LoadSunIntensityModel(double lat, double longitude)
    {
        string url            = "";
        double localLatitude  = lat;
        double localLongitude = longitude;

        // base url
        url =
            "https://developer.nrel.gov/api/solar/solar_resource/v1.json?api_key=af9Pr6H2WleNc0oL3KolePr1ic5WCKospWH7cVXa&lat=33.4484&lon=-112.0740";
        // url for input
        string checkURL = String.Format("https://developer.nrel.gov/api/solar/solar_resource/v1.json?api_key=af9Pr6H2WleNc0oL3KolePr1ic5WCKospWH7cVXa&lat={0}&lon={1}", localLatitude, localLongitude);

        using (HttpResponseMessage response = await ApiClientApiHelper.MyApiClient.GetAsync(checkURL)) // create a "browser" for our request
        {
            if (response.IsSuccessStatusCode)                                                          // is the response message from our request is successful
            {
                // convert the received JSON to the object model
                SunIntensityModel intensityModel = await response.Content.ReadAsAsync <SunIntensityModel>();

                // add the url to the model for debugging
                intensityModel.checkValue = checkURL;
                // return the model
                return(intensityModel);
            }
            // if our request fails
            throw new Exception(response.ReasonPhrase);
        }
    }
コード例 #2
0
ファイル: Service.cs プロジェクト: jcanez2/CSE445Project3V1
 private async Task loadSunIntensityModelTask(double lat, double longitude)
 {
     currentSunIntensityModel = await SunIntensityProcessor.LoadSunIntensityModel(lat, longitude);
 }