/** * returns tweets by users located within a given radius of the given latitude/longitude, where the user's location is taken from their Twitter profile * * @param location geo location * @param radius radius * @param unit Query.MILES or Query.KILOMETERS * @return the instance * @since Twitter4J 4.0.7 */ public Query geoCode(GeoLocation location, double radius , Unit unit) { setGeoCode(location, radius, unit); return this; }
/** * returns tweets by users located within a given radius of the given latitude/longitude, where the user's location is taken from their Twitter profile * * @param location geo location * @param radius radius * @param unit Use "mi" for miles or "km" for kilometers * @return the instance * @since Twitter4J 2.1.0 * @deprecated use {@link #geoCode(GeoLocation, double, twitter4j.Query.Unit)} instead */ public Query geoCode(GeoLocation location, double radius , String unit) { setGeoCode(location, radius, unit); return this; }
try { Query query = new Query(keyword); // GeoLocation location = new GeoLocation(latitude, longitude); String unit = Query.KILOMETERS; // or Query.MILES; query.setGeoCode(location, radius, unit); QueryResult result; do { result = twitter.search(query); List<Status> tweets = result.getTweets(); for (Status tweet : tweets) { System.out.println("@" + tweet.getUser().getScreenName() + " - " + tweet.getText()); } } while ((query = result.nextQuery()) != null); } catch (TwitterException te) { System.out.println("Failed to search tweets: " + te.getMessage()); System.exit(-1); }
throw new IllegalArgumentException("unrecognized geocode radius: "+radiusstr); query.setGeoCode(new GeoLocation(latitude, longitude), radius, unit);
final double latitude = Double.parseDouble(StringUtils.replace(geocodeSplit[0], " ", "")); final double longitude = Double.parseDouble(StringUtils.replace(geocodeSplit[1], " ", "")); q.setGeoCode(new GeoLocation(latitude, longitude), Double.parseDouble(radius), unit);
&& ObjectHelper.isNotEmpty(endpoint.getProperties().getRadius())) { GeoLocation location = new GeoLocation(endpoint.getProperties().getLatitude(), endpoint.getProperties().getLongitude()); query.setGeoCode(location, endpoint.getProperties().getRadius(), Unit.valueOf(endpoint.getProperties().getDistanceMetric()));