Ejemplo n.º 1
0
        public void ExecuteRectangeSearch()
        {
            var baiduClient   = ClientCreator.Create();
            var rectangeModel = new PlaceRectangeModel
            {
                Query  = "银行",
                Bounds = "39.915,116.404,39.975,116.414"
            };
            var req = new PlaceSearchRequest <PlaceRectangeModel>(rectangeModel);
            PlaceSearchResponse resp = baiduClient.Execute(req);

            resp.Status.ShouldBe(0);
            resp.Message.ShouldBe("ok");
        }
Ejemplo n.º 2
0
        public void ExecuteCircumSearch()
        {
            var baiduClient = ClientCreator.Create();
            var circumModel = new PlaceCircumModel
            {
                Query    = "银行",
                Location = "39.915,116.404",
                Radius   = "2000"
            };
            var req = new PlaceSearchRequest <PlaceCircumModel>(circumModel);
            PlaceSearchResponse resp = baiduClient.Execute(req);

            resp.Status.ShouldBe(0);
            resp.Message.ShouldBe("ok");
        }
Ejemplo n.º 3
0
        public void ExecuteRegionSearch()
        {
            var baiduClient = ClientCreator.Create();
            var regionModel = new PlaceRegionModel
            {
                Query  = "ATM机",
                Tag    = "银行",
                Region = "杭州"
            };
            var req = new PlaceSearchRequest <PlaceRegionModel>(regionModel);
            PlaceSearchResponse resp = baiduClient.Execute(req);

            resp.Status.ShouldBe(0);
            resp.Message.ShouldBe("ok");
            resp.Results.Count.ShouldBe(10);
        }
Ejemplo n.º 4
0
        /**
         * Method that makes call to Google Places API and
         * retrieves list of places given specific parameters
         * <param name="keyword">Term to match against all content Google has indexed
         * including but not limited to name, type, and address</param>
         * <param name="type">Used to indicate status.</param>
         */
        public PlaceSearchResponse GetPlaces(string keyword, string type, GeometryLocation location)
        {
            // Initialize API request with URL and API key
            RestRequest request = new RestRequest("/nearbysearch/json?", Method.GET);

            request.AddQueryParameter("key", _apiKey);

            // Add parameters to API request, these will need to be changed
            request.AddQueryParameter("keyword", keyword);
            request.AddQueryParameter("location", $"{location.Latitude}, {location.Longitude}");
            request.AddQueryParameter("radius", "10000");
            request.AddQueryParameter("type", type);

            // Get respones from API using above request
            IRestResponse response = _client.Execute(request);

            // Convert JSON response to model and return response
            PlaceSearchResponse apiResponse = JsonConvert.DeserializeObject <PlaceSearchResponse>(response.Content);

            return(apiResponse);
        }
Ejemplo n.º 5
0
        /**
         * Check Google API for different sports venues
         */
        public List <PlaceSearchResult> GetVenues()
        {
            List <GeometryLocation> cities = new List <GeometryLocation>();

            // Salem
            cities.Add(new GeometryLocation {
                Latitude = 44.9429, Longitude = -123.0351
            });

            // Independence
            cities.Add(new GeometryLocation {
                Latitude = 44.8512, Longitude = -123.1868
            });

            //Monmouth
            cities.Add(new GeometryLocation {
                Latitude = 44.8485, Longitude = -123.2340
            });

            // Initialize list to store all venue results
            List <PlaceSearchResult> results = new List <PlaceSearchResult>();

            foreach (var city in cities)
            {
                // Get basketball venues
                PlaceSearchResponse basketballVenues = GetPlaces("basketball", "park", city);
                foreach (var venue in basketballVenues.Results)
                {
                    results.Add(venue);
                }

                // Get football venues
                PlaceSearchResponse footballVenues = GetPlaces("football", "school", city);
                foreach (var venue in footballVenues.Results)
                {
                    results.Add(venue);
                }

                // Get tennis venues
                PlaceSearchResponse tennisVenues = GetPlaces("tennis", "park", city);
                foreach (var venue in tennisVenues.Results)
                {
                    results.Add(venue);
                }

                // Get baseball venues
                PlaceSearchResponse baseballVenues = GetPlaces("baseball", "park", city);
                foreach (var venue in baseballVenues.Results)
                {
                    results.Add(venue);
                }

                // Get softball venues
                PlaceSearchResponse softballVenues = GetPlaces("softball", "park", city);
                foreach (var venue in softballVenues.Results)
                {
                    results.Add(venue);
                }

                // Get golf venues
                PlaceSearchResponse golfVenues = GetPlaces("golf", "park", city);
                foreach (var venue in golfVenues.Results)
                {
                    results.Add(venue);
                }

                // Get volleyball venues
                PlaceSearchResponse volleyballVenues = GetPlaces("volleyball", "park", city);
                foreach (var venue in volleyballVenues.Results)
                {
                    results.Add(venue);
                }
            }

            return(results);
        }