Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ projects, please consider donating a small amount so that I may continue to devo
* [Place Searches](#place-searches)
* [Nearby Search](#nearby-search-requests)
* [Text Search](#text-search-requests)
* [Radar Search](#radar-search-requests)
* [Adding extra URL parameters](#additional-url-parameters)
* [Place Details](#place-details)
* [Icons](#icons)
Expand Down Expand Up @@ -105,14 +104,6 @@ You can also search for locations by search query. This is the same backend syst
List<Place> places = client.getPlacesByQuery("Empire State Building", GooglePlaces.MAXIMUM_RESULTS);
```

### Radar Search Requests

You can also use the ["radar"](https://developers.google.com/places/documentation/search#RadarSearchRequests) method of finding locations.

```java
List<Place> places = client.getPlacesByRadar(lat, lng, radius, GooglePlaces.MAXIMUM_RESULTS);
```

### Additional Url Parameters

If you need to add additional URL parameters to the request URL you can append as many `Param` objects as you want to any request method.
Expand Down
48 changes: 0 additions & 48 deletions src/main/java/se/walkercrou/places/GooglePlaces.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,6 @@ public static String parse(GooglePlaces client, List<Place> places, String str,

return json.optString(STRING_NEXT_PAGE_TOKEN, null);
}

/**
* Parses the specified Radar raw json String into a list of places.
*
* @param places to parse into
* @param str Radar raw json
* @param limit the maximum amount of places to return
*/
public static void parseRadar(GooglePlaces client, List<Place> places, String str, int limit) {
// parse json
JSONObject json = new JSONObject(str);

// check root elements
String statusCode = json.getString(STRING_STATUS);
checkStatus(statusCode, json.optString(STRING_ERROR_MESSAGE));
if (statusCode.equals(STATUS_ZERO_RESULTS))
return;

JSONArray results = json.getJSONArray(ARRAY_RESULTS);
parseResults(client, places, results, Math.min(limit, MAXIMUM_RADAR_RESULTS));
}

private static void parseResults(GooglePlaces client, List<Place> places, JSONArray results, int limit) {
for (int i = 0; i < limit; i++) {
Expand Down Expand Up @@ -262,22 +241,6 @@ public List<Place> getPlacesByQuery(String query, Param... extraParams) {
return getPlacesByQuery(query, DEFAULT_RESULTS, extraParams);
}

@Override
public List<Place> getPlacesByRadar(double lat, double lng, double radius, int limit, Param... extraParams) {
try {
String uri = buildUrl(METHOD_RADAR_SEARCH, String.format(Locale.ENGLISH, "key=%s&location=%f,%f&radius=%f",
apiKey, lat, lng, radius), extraParams);
return getRadarPlaces(uri, METHOD_RADAR_SEARCH, limit);
} catch (Exception e) {
throw new GooglePlacesException(e);
}
}

@Override
public List<Place> getPlacesByRadar(double lat, double lng, double radius, Param... extraParams) {
return getPlacesByRadar(lat, lng, radius, MAXIMUM_RESULTS, extraParams);
}

@Override
public Place getPlaceById(String placeId, Param... extraParams) {
try {
Expand Down Expand Up @@ -435,17 +398,6 @@ private List<Place> getPlaces(String uri, String method, int limit) throws IOExc
return places;
}

private List<Place> getRadarPlaces(String uri, String method, int limit) throws IOException {
limit = Math.min(limit, MAXIMUM_RADAR_RESULTS); // max of 200 results possible

List<Place> places = new ArrayList<>();
String raw = requestHandler.get(uri);
debug(raw);
parseRadar(this, places, raw, limit);

return places;
}

private void sleep(long millis) {
try {
Thread.sleep(millis);
Expand Down
33 changes: 0 additions & 33 deletions src/main/java/se/walkercrou/places/GooglePlacesInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ public interface GooglePlacesInterface extends Types, Statuses {
* The maximum results that can be returned.
*/
int MAXIMUM_RESULTS = 60;

/**
* The maximum radar results that can be returned.
*/
int MAXIMUM_RADAR_RESULTS = 200;

/**
* The maximum search radius for places.
Expand All @@ -43,7 +38,6 @@ public interface GooglePlacesInterface extends Types, Statuses {
// METHODS
String METHOD_NEARBY_SEARCH = "nearbysearch";
String METHOD_TEXT_SEARCH = "textsearch";
String METHOD_RADAR_SEARCH = "radarsearch";
String METHOD_DETAILS = "details";
String METHOD_ADD = "add";
String METHOD_DELETE = "delete";
Expand Down Expand Up @@ -453,33 +447,6 @@ List<Place> getNearbyPlacesRankedByDistance(double lat, double lng, Param... par
*/
List<Place> getPlacesByQuery(String query, Param... extraParams);

/**
* Returns the places at the specified latitude and longitude according to the "radar" method specified by Google
* Places API. If the specified limit is greater than {@link #MAXIMUM_PAGE_RESULTS}, multiple HTTP GET requests
* may be made if necessary.
*
* @param lat latitude
* @param lng longitude
* @param radius radius
* @param limit the maximum amount of places to return
* @param extraParams any extra parameters to include in the request URL
* @return a list of places that were found
*/
List<Place> getPlacesByRadar(double lat, double lng, double radius, int limit, Param... extraParams);

/**
* Returns the places at the specified latitude and longitude according to the "radar" method specified by Google
* Places API. No more than {@link #DEFAULT_RESULTS} will be returned and no more than one HTTP GET request will
* be sent.
*
* @param lat latitude
* @param lng longitude
* @param radius radius
* @param extraParams any extra parameters to include in the request URL
* @return a list of places that were found
*/
List<Place> getPlacesByRadar(double lat, double lng, double radius, Param... extraParams);

/**
* Returns the place specified by the 'placeid'.
*
Expand Down
14 changes: 0 additions & 14 deletions src/test/java/se/walkercrou/places/GooglePlacesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,6 @@ public void testGetPlacesByQuery() {
System.out.println("******************** getPlacesByQuery ********************");
if (!findPlace(google.getPlacesByQuery(TEST_PLACE_NAME, MAXIMUM_RESULTS), TEST_PLACE_NAME))
fail("Test place could not be found by name");
testGetPlacesByRadar();
}

public void testGetPlacesByRadar() {
System.out.println("******************** getPlacesByRadar ********************");
List<Place> places = google.getPlacesByRadar(TEST_PLACE_LAT, TEST_PLACE_LNG, MAXIMUM_RADIUS,
MAXIMUM_RESULTS, Param.name("name").value(TEST_PLACE_NAME));
boolean found = false;
for (Place place : places) {
if (place.getDetails().getName().equals(TEST_PLACE_NAME))
found = true;
}
if (!found)
fail("Test place could not be found using the radar method.");
}

private boolean findPlace(List<Place> places, String name) {
Expand Down