コード例 #1
0
ファイル: Parser.cs プロジェクト: koppzuy/hackathon
        /// <summary>
        /// Finds bus stops matching the area specified by center location and radius.
        /// </summary>
        /// <param name="pos">Position</param>
        /// <param name="radius">Rectangular search "radius" in kilometers</param>
        /// <returns>Array of Stop objects</returns>
        public static async Task <Stop[]> FindStopsByLocationAsync(BasicPosition pos, int radius)
        {
            var box      = MapExtensions.GetBoundingBox(pos, radius);
            var left     = (int)(box.MinPoint.Longitude * 3600000);
            var right    = (int)(box.MaxPoint.Longitude * 3600000);
            var top      = (int)(box.MaxPoint.Latitude * 3600000);
            var bottom   = (int)(box.MinPoint.Latitude * 3600000);
            var content  = new StringContent("left=" + left + "&bottom=" + bottom + "&right=" + right + "&top=" + top);
            var response = await _client.PostAsync(_geoUrl, content);

            var locationInfo = await DeserializeAsync <LocationInfo>(response);

            return(locationInfo.Stops);
        }