示例#1
0
    public void handleRequestResponse(string response)
    {
        NOAAWeathers.PointData pointData = JsonUtility.FromJson <NOAAWeathers.PointData> (response);
        NOAAWeathers.NOAAWeatherRequestBuilder builder = new NOAAWeathers.NOAAWeatherRequestBuilder();

        string gridUrl = builder.getUrlForGridPoint(pointData);

        if (requestToResponseMap.ContainsValue(gridUrl))
        {
            handleGridForecast(requestToResponseMap [gridUrl]);
        }
        else
        {
            StartCoroutine(GetGridForecast(gridUrl));
        }

        string pointDataForecastUrl = builder.getUrlForPointForecast(pointData);

        if (requestToResponseMap.ContainsValue(pointDataForecastUrl))
        {
            handlePointForecast(requestToResponseMap [pointDataForecastUrl]);
        }
        else
        {
            StartCoroutine(GetPointForecast(pointDataForecastUrl));
        }
    }
示例#2
0
    public void GetWeather(Vector2 coord)
    {
        WeatherText.text           = "Weather pending.....";
        CurrentConditionsText.text = "Current Conditions:\nPending.....";
        string url = new NOAAWeathers.NOAAWeatherRequestBuilder().getUrlForPoint(coord.x, coord.y);

        Debug.Log(url);
        if (requestToResponseMap.ContainsValue(url))
        {
            handleRequestResponse(requestToResponseMap [url]);
        }
        else
        {
            StartCoroutine(GetPointData(url));
        }
    }