-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathGooglePlacesInterface.java
More file actions
567 lines (478 loc) · 17.6 KB
/
GooglePlacesInterface.java
File metadata and controls
567 lines (478 loc) · 17.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
package se.walkercrou.places;
import se.walkercrou.places.exception.GooglePlacesException;
import java.util.List;
/**
* A Java binding for the Google Places API:
* <a href="https://developers.google.com/places/">https://developers.google.com/places/</a>
*/
public interface GooglePlacesInterface extends Types, Statuses {
/**
* The URL of which Google Places API is located.
*/
String API_URL = "https://maps.googleapis.com/maps/api/place/";
/**
* The maximum amount of results that can be on one single page.
*/
int MAXIMUM_PAGE_RESULTS = 20;
/**
* The default amount of results that will be returned in a single request.
*/
int DEFAULT_RESULTS = MAXIMUM_PAGE_RESULTS;
/**
* The maximum results that can be returned.
*/
int MAXIMUM_RESULTS = 60;
/**
* The maximum search radius for places.
*/
double MAXIMUM_RADIUS = 50000;
// METHODS
String METHOD_NEARBY_SEARCH = "nearbysearch";
String METHOD_TEXT_SEARCH = "textsearch";
String METHOD_DETAILS = "details";
String METHOD_ADD = "add";
String METHOD_DELETE = "delete";
String METHOD_AUTOCOMPLETE = "autocomplete";
String METHOD_QUERY_AUTOCOMPLETE = "queryautocomplete";
int MAX_PHOTO_SIZE = 1600;
/**
* Types of place
*/
String ARRAY_TYPES = "types";
/**
* Array for results
*/
String ARRAY_RESULTS = "results";
/**
* Signifies the hours of operation of a place
*/
String ARRAY_PERIODS = "periods";
/**
* Array containing photo information
*/
String ARRAY_PHOTOS = "photos";
/**
* An array containing each element in a places full address
*/
String ARRAY_ADDRESS_COMPONENTS = "address_components";
/**
* Array of reviews of a Place
*/
String ARRAY_REVIEWS = "reviews";
/**
* Array of aspects of a review
*/
String ARRAY_ASPECTS = "aspects";
/**
* Array of autocomplete predictions
*/
String ARRAY_PREDICTIONS = "predictions";
/**
* Array of terms describing a autocomplete prediction description
*/
String ARRAY_TERMS = "terms";
/**
* Used for matching matched substrings for autocompletion
*/
String ARRAY_MATCHED_SUBSTRINGS = "matched_substrings";
/**
* Defines alternate entries for a specified place.
*/
String ARRAY_ALT_IDS = "alt_ids";
/**
* If the place is opened now
*/
String BOOLEAN_OPENED = "open_now";
/**
* Latitude of place
*/
String DOUBLE_LATITUDE = "lat";
/**
* Longitude of place
*/
String DOUBLE_LONGITUDE = "lng";
/**
* The "rating" of the place
*/
String DOUBLE_RATING = "rating";
/**
* How expensive the place is
*/
String INTEGER_PRICE_LEVEL = "price_level";
/**
* Day represented by an int 0-6, starting with Sunday
*/
String INTEGER_DAY = "day";
/**
* Used for describing a photo's width
*/
String INTEGER_WIDTH = "width";
/**
* Used for describing a photo's height
*/
String INTEGER_HEIGHT = "height";
/**
* Reviews use integer ratings
*/
String INTEGER_RATING = "rating";
/**
* Minutes that a location is of from UTC
*/
String INTEGER_UTC_OFFSET = "utc_offset";
/**
* Accuracy of location, in meters
*/
String INTEGER_ACCURACY = "accuracy";
/**
* Used for autocomplete predictions
*/
String INTEGER_OFFSET = "offset";
/**
* Used for autocomplete substring length
*/
String INTEGER_LENGTH = "length";
/**
* Used for the date of a review
*/
String LONG_TIME = "time";
/**
* Used for responses with single results
*/
String OBJECT_RESULT = "result";
/**
* Geographic information
*/
String OBJECT_GEOMETRY = "geometry";
/**
* Contains latitude and longitude coordinates
*/
String OBJECT_LOCATION = "location";
/**
* Contains open_now
*/
String OBJECT_HOURS = "opening_hours";
/**
* The beginning of a period
*/
String OBJECT_OPEN = "open";
/**
* The end of a period
*/
String OBJECT_CLOSE = "close";
/**
* The unique, stable, identifier for this place
*/
String STRING_PLACE_ID = "place_id";
/**
* Url to the icon to represent this place
*/
String STRING_ICON = "icon";
/**
* The name of the place
*/
String STRING_NAME = "name";
/**
* The address of the place
*/
String STRING_ADDRESS = "formatted_address";
/**
* The vicinity of which the place can be found (sometimes replaces formatted_address)
*/
String STRING_VICINITY = "vicinity";
/**
* The url for an event at a place
*/
String STRING_URL = "url";
/**
* A root element to indicate the status of the query.
*/
String STRING_STATUS = "status";
/**
* A message that may or may not be present when an error occurs.
*/
String STRING_ERROR_MESSAGE = "error_message";
/**
* A token used for getting the next page of results
*/
String STRING_NEXT_PAGE_TOKEN = "next_page_token";
/**
* The phone number of the place
*/
String STRING_PHONE_NUMBER = "formatted_phone_number";
/**
* The phone number of the place with an international country code
*/
String STRING_INTERNATIONAL_PHONE_NUMBER = "international_phone_number";
/**
* The website associated with a place
*/
String STRING_WEBSITE = "website";
/**
* A time represented by an hhmm format
*/
String STRING_TIME = "time";
/**
* A reference to an actual photo
*/
String STRING_PHOTO_REFERENCE = "photo_reference";
/**
* Represents an address component's long name
*/
String STRING_LONG_NAME = "long_name";
/**
* Represents an address component's short name
*/
String STRING_SHORT_NAME = "short_name";
/**
* Name of a review author
*/
String STRING_AUTHOR_NAME = "author_name";
/**
* Url of author
*/
String STRING_AUTHOR_URL = "author_url";
/**
* Language for review localization
*/
String STRING_LANGUAGE = "language";
/**
* Review content
*/
String STRING_TEXT = "text";
/**
* Description of autocomplete prediction
*/
String STRING_DESCRIPTION = "description";
/**
* Used for autocomplete terms
*/
String STRING_VALUE = "value";
/**
* Used for singular types in review aspects
*/
String STRING_TYPE = "type";
/**
* Restricts the results to places matching at least one of the specified types.
*/
String STRING_TYPES = "types";
/**
* Defines what scope a location resides in.
*
* @see se.walkercrou.places.Scope
*/
String STRING_SCOPE = "scope";
/**
* Returns true if the client is running in debug mode.
*
* @return true if debug mode
*/
boolean isDebugModeEnabled();
/**
* Sets if the client should run in debug mode.
*
* @param debugModeEnabled true if in debug mode
*/
void setDebugModeEnabled(boolean debugModeEnabled);
/**
* Returns the API key associated with this GooglePlaces object.
*
* @return api key
*/
String getApiKey();
/**
* Sets the API key associated with this GooglePlaces object.
*
* @param apiKey to set
*/
void setApiKey(String apiKey);
/**
* Returns the interface that handles HTTP requests to Google's server.
*
* @return request handler for HTTP traffic
*/
RequestHandler getRequestHandler();
/**
* Sets the request handler to delegate HTTP traffic.
*
* @param requestHandler to handle HTTP traffic
*/
void setRequestHandler(RequestHandler requestHandler);
/**
* Returns the places at the specified latitude and longitude within the specified radius. 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> getNearbyPlaces(double lat, double lng, double radius, int limit, Param... extraParams);
/**
* Returns the places at the specified latitude and longitude within the specified radius. 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> getNearbyPlaces(double lat, double lng, double radius, Param... extraParams);
/**
* Returns the places at the specified latitude and longitude in order of proximity to the specified location. If
* the specified limit is greater than {@link #MAXIMUM_PAGE_RESULTS}, multiple HTTP GET requests may be made if
* necessary. One or more of the parameters 'keyword', 'name', or 'types' is required or else a
* {@link se.walkercrou.places.exception.GooglePlacesException} will be thrown.
*
* @param lat latitude
* @param lng longitude
* @param limit the maximum amount of places to return
* @param params parameters to append to url, one or more being 'keyword', 'name', or 'types'
* @return list of places in order of proximity to the specified location
* @throws se.walkercrou.places.exception.GooglePlacesException if 'keyword', 'name' or 'types' is not included.
*/
List<Place> getNearbyPlacesRankedByDistance(double lat, double lng, int limit, Param... params)
throws GooglePlacesException;
/**
* Returns the places at the specified latitude and longitude in order of proximity to the specified location. No
* more than {@link #DEFAULT_RESULTS} will be returned and no more than one HTTP GET request will be sent. One or
* more of the parameters 'keyword', 'name', or 'types' is required or else a
* {@link se.walkercrou.places.exception.GooglePlacesException} will be thrown.
*
* @param lat latitude
* @param lng longitude
* @param params parameters to append to url, one or more being 'keyword', 'name', or 'types'
* @return list of places in order of proximity to the specified location
* @throws se.walkercrou.places.exception.GooglePlacesException if 'keyword', 'name' or 'types' is not included.
*/
List<Place> getNearbyPlacesRankedByDistance(double lat, double lng, Param... params)
throws GooglePlacesException;
/**
* Returns the places that match the specified search query. If the specified limit
* is greater than {@link #MAXIMUM_PAGE_RESULTS}, multiple HTTP GET requests may be made if necessary.
*
* @param query search query
* @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> getPlacesByQuery(String query, int limit, Param... extraParams);
/**
* Returns the places that match the specified search query. No more than {@link #DEFAULT_RESULTS} will be returned
* and no more than one HTTP GET request will be sent. The 'sensor' parameter defaults to false.
*
* @param query search query
* @param extraParams any extra parameters to include in the request URL
* @return a list of places that were found
*/
List<Place> getPlacesByQuery(String query, Param... extraParams);
/**
* Returns the place specified by the 'placeid'.
*
* @param placeId to get
* @param extraParams params to append to url
* @return place
*/
Place getPlaceById(String placeId, Param... extraParams);
/**
* Adds a new place to the Places API and gets the newly created place if returnPlace is set to true.
*
* @param builder to get place details from
* @param returnPlace true if the newly created place should be returned
* @param extraParams to append to request url
* @return newly created place
*/
Place addPlace(PlaceBuilder builder, boolean returnPlace, Param... extraParams);
/**
* Deletes the place of the specified placeId.
*
* @param placeId place id
* @param extraParams params to append to url
*/
void deletePlaceById(String placeId, Param... extraParams);
/**
* Deletes the specified place.
*
* @param place to delete
*/
void deletePlace(Place place, Param... extraParams);
/**
* Returns a list of auto-complete predictions for searching for a specific place. The 'offset' is the position, in
* the input term, of the last character that the service uses to match predictions. For example, if the input is
* 'Google' and the offset is 3, the service will match on 'Goo'. The string determined by the offset is matched
* against the first word in the input term only. For example, if the input term is 'Google abc' and the offset is
* 3, the service will attempt to match against 'Goo abc'. If no offset is supplied, the service will use the whole
* term. The offset should generally be set to the position of the text caret. The lat, lng, and radius parameter
* specify and area in which you would like to search.
*
* @param input user input
* @param offset offset of text caret
* @param lat latitude
* @param lng longitude
* @param radius radius
* @param extraParams to append to request url
* @return list of predictions
*/
List<Prediction> getPlacePredictions(String input, int offset, int lat, int lng, int radius,
Param... extraParams);
/**
* Returns a list of auto-complete predictions for searching for a specific place. The 'offset' is the position, in
* the input term, of the last character that the service uses to match predictions. For example, if the input is
* 'Google' and the offset is 3, the service will match on 'Goo'. The string determined by the offset is matched
* against the first word in the input term only. For example, if the input term is 'Google abc' and the offset is
* 3, the service will attempt to match against 'Goo abc'. If no offset is supplied, the service will use the whole
* term. The offset should generally be set to the position of the text caret.
*
* @param input user input
* @param offset offset of text caret
* @return list of predictions
*/
List<Prediction> getPlacePredictions(String input, int offset, Param... extraParams);
/**
* Returns a list of auto-complete predictions for searching for a specific place.
*
* @param input user input
* @param extraParams extra params to include in url
* @return list of predictions
*/
List<Prediction> getPlacePredictions(String input, Param... extraParams);
/**
* Returns a list of auto-complete predictions for searching for a place by a query. The 'offset' is the position,
* in the input term, of the last character that the service uses to match predictions. For example, if the input is
* 'Google' and the offset is 3, the service will match on 'Goo'. The string determined by the offset is matched
* against the first word in the input term only. For example, if the input term is 'Google abc' and the offset is
* 3, the service will attempt to match against 'Goo abc'. If no offset is supplied, the service will use the whole
* term. The offset should generally be set to the position of the text caret. The lat, lng, and radius parameter
* specify and area in which you would like to search.
*
* @param input user input
* @param extraParams to append to request url
* @return list of predictions
*/
List<Prediction> getQueryPredictions(String input, int offset, int lat, int lng, int radius,
Param... extraParams);
/**
* Returns a list of auto-complete predictions for searching for a place by a query. The 'offset' is the position,
* in the input term, of the last character that the service uses to match predictions. For example, if the input is
* 'Google' and the offset is 3, the service will match on 'Goo'. The string determined by the offset is matched
* against the first word in the input term only. For example, if the input term is 'Google abc' and the offset is
* 3, the service will attempt to match against 'Goo abc'. If no offset is supplied, the service will use the whole
* term. The offset should generally be set to the position of the text caret.
*
* @param input user input
* @param offset offset of text caret
* @param extraParams extra params to append to url
* @return list of predictions
*/
List<Prediction> getQueryPredictions(String input, int offset, Param... extraParams);
/**
* Returns a list of auto-complete predictions for searching for a place by a query.
*
* @param input user input
* @param extraParams extra parameters to append to url
* @return list of predictions
*/
List<Prediction> getQueryPredictions(String input, Param... extraParams);
}