if (null != geoLocation) { double lat = status.getGeoLocation().getLatitude(); double lon = status.getGeoLocation().getLongitude(); theMap.put("lat", lat); theMap.put("lon", lon);
/** * 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 * @deprecated use {@link #setGeoCode(GeoLocation, double, twitter4j.Query.Unit)} instead */ public void setGeoCode(GeoLocation location, double radius , String unit) { this.geocode = location.getLatitude() + "," + location.getLongitude() + "," + radius + unit; }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof GeoLocation)) return false; GeoLocation that = (GeoLocation) o; if (Double.compare(that.getLatitude(), latitude) != 0) return false; if (Double.compare(that.getLongitude(), longitude) != 0) return false; return true; }
/** * 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 * @since Twitter4J 4.0.1 */ public void setGeoCode(GeoLocation location, double radius , Unit unit) { this.geocode = location.getLatitude() + "," + location.getLongitude() + "," + radius + unit.name(); }
GpsDirectory gpsDirectory = metadata.getDirectory(GpsDirectory.class); GeoLocation location = gpsDirectory.getGeoLocation(); double lat = location.getLatitude(); double lng = location.getLongitude();
/** * Retrieves the State from GeoLocation Object of the Tweet. * This is considered as the primary and correct value for the State of the tweet. * * @param status -- Status Object. * @return State of tweet. */ private final String getStateFromTweetGeoLocation(final Status status) { String state = null; final double latitude; final double longitude; final GeoLocation geoLocation = status.getGeoLocation(); if (null != geoLocation) { latitude = geoLocation.getLatitude(); longitude = geoLocation.getLongitude(); LOGGER.debug("LatLng for BingMaps:{} and {}", latitude, longitude); final Optional<String> stateGeoOptional = BingMapsLookup.reverseGeocodeFromLatLong(latitude, longitude); if(stateGeoOptional.isPresent()){ final String stateFromGeoLocation = stateGeoOptional.get(); LOGGER.debug("State from BingMaps:{}", stateFromGeoLocation); state = (2 == stateFromGeoLocation.length())? stateFromGeoLocation.toUpperCase(): null; } } return state; } }
@Override public ResponseList<Place> getSimilarPlaces(GeoLocation location, String name, String containedWithin, String streetAddress) throws TwitterException { List<HttpParameter> params = new ArrayList<HttpParameter>(3); params.add(new HttpParameter("lat", location.getLatitude())); params.add(new HttpParameter("long", location.getLongitude())); params.add(new HttpParameter("name", name)); if (containedWithin != null) { params.add(new HttpParameter("contained_within", containedWithin)); } if (streetAddress != null) { params.add(new HttpParameter("attribute:street_address", streetAddress)); } return factory.createPlaceList(get(conf.getRestBaseURL() + "geo/similar_places.json", params.toArray(new HttpParameter[params.size()]))); }
public static void convert(GeoLocation geoLocation, Struct struct) { if (null == geoLocation) { return; } struct.put("Latitude", geoLocation.getLatitude()) .put("Longitude", geoLocation.getLongitude()); }
return place.getLongitude();
/*package*/ HttpParameter[] asHttpParameterArray() { ArrayList<HttpParameter> params = new ArrayList<HttpParameter>(); if (location != null) { appendParameter("lat", location.getLatitude(), params); appendParameter("long", location.getLongitude(), params); } if (ip != null) { appendParameter("ip", ip, params); } appendParameter("accuracy", accuracy, params); appendParameter("query", query, params); appendParameter("granularity", granularity, params); appendParameter("max_results", maxResults, params); HttpParameter[] paramArray = new HttpParameter[params.size()]; return params.toArray(paramArray); }
coordinate = new Coordinate(geoLocation.getLongitude(), geoLocation.getLatitude());
/*package*/ HttpParameter[] asHttpParameterArray() { ArrayList<HttpParameter> params = new ArrayList<HttpParameter>(); appendParameter("status", status, params); if (-1 != inReplyToStatusId) { appendParameter("in_reply_to_status_id", inReplyToStatusId, params); } if (location != null) { appendParameter("lat", location.getLatitude(), params); appendParameter("long", location.getLongitude(), params); } appendParameter("place_id", placeId, params); if (!displayCoordinates) { appendParameter("display_coordinates", "false", params); } if (null != mediaFile) { params.add(new HttpParameter("media[]", mediaFile)); params.add(new HttpParameter("possibly_sensitive", possiblySensitive)); } else if (mediaName != null && mediaBody != null) { params.add(new HttpParameter("media[]", mediaName, mediaBody)); params.add(new HttpParameter("possibly_sensitive", possiblySensitive)); } else if (mediaIds != null && mediaIds.length >= 1) { params.add(new HttpParameter("media_ids", StringUtil.join(mediaIds))); } if(autoPopulateReplyMetadata){ appendParameter("auto_populate_reply_metadata", "true", params); } appendParameter("attachment_url", attachmentUrl, params); HttpParameter[] paramArray = new HttpParameter[params.size()]; return params.toArray(paramArray); }
@Override public ResponseList<Location> getClosestTrends(GeoLocation location) throws TwitterException { return factory.createLocationList(get(conf.getRestBaseURL() + "trends/closest.json", new HttpParameter("lat", location.getLatitude()) , new HttpParameter("long", location.getLongitude()))); }
if (null != geoLocation) { double lat = status.getGeoLocation().getLatitude(); double lon = status.getGeoLocation().getLongitude(); theMap.put("lat", lat); theMap.put("lon", lon);
tl.UpdateStatus(statusText, (float) location.getLatitude(), (float) location.getLongitude(), ""); log.info(String.format("@%s - %s sent with geo locations.", name, statusText)); } else {
@Override public void onStatus(Status status) { Document tweet = new Document(); tweet.put("_id", status.getId()); tweet.put("createdAt", status.getCreatedAt()); tweet.put("favoriteCount", status.getFavoriteCount()); tweet.put("retweetCount", status.getRetweetCount()); if (status.getGeoLocation() != null) { tweet.put("lat", status.getGeoLocation().getLatitude()); tweet.put("long", status.getGeoLocation().getLongitude()); } tweet.put("screenName", status.getUser().getScreenName()); if (status.getRetweetedStatus() != null) { tweet.put("retweetedStatus", status.getRetweetedStatus().getText()); } tweet.put("text", status.getText()); Document query = new Document(); query.put("_id", status.getId()); collection.replaceOne(query, tweet, new UpdateOptions().upsert(true)); }
coords[1] = geloc.getLongitude(); status.geo = coords;
coords[1] = geloc.getLongitude(); status.geo = coords;