Esempio n. 1
0
        private async Task <List <AltitudeResponse> > SendRequest(AltitudeRequest request)
        {
            HttpClient httpClient = new HttpClient();

            string      json        = JsonConvert.SerializeObject(request, jsonConverterSettings);
            HttpContent httpContent = new StringContent(json);

            httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
            HttpResponseMessage htppResponse = await httpClient.PostAsync(RequestUri, httpContent);

            List <AltitudeResponse> altitudeResponse = null;

            if (htppResponse.StatusCode == System.Net.HttpStatusCode.OK)
            {
                string rawData = await htppResponse.Content.ReadAsStringAsync();

                altitudeResponse = JsonConvert.DeserializeObject <List <AltitudeResponse> >(rawData);
            }

            return(altitudeResponse);
        }
Esempio n. 2
0
        private async Task <List <List <AltitudeResponse> > > GrabAltitude()
        {
            List <List <AltitudeResponse> > data = new List <List <AltitudeResponse> >();

            int stepsCount = (int)Math.Ceiling(Math.Abs(TopLeft.Lng - BottomRight.Lng) / GeoPointStep);

            for (var i = 0; i < stepsCount; i++)
            {
                GeoPoint startPoint = new GeoPoint {
                    Lat = TopLeft.Lat, Lng = TopLeft.Lng + i * GeoPointStep
                };
                GeoPoint endPoint = new GeoPoint {
                    Lat = BottomRight.Lat, Lng = TopLeft.Lng + i * GeoPointStep
                };

                AltitudeRequest         request  = MakeRequest(startPoint, endPoint);
                List <AltitudeResponse> response = await SendRequest(request);

                data.Add(response);
            }
            return(data);
        }