double lat = status.getGeoLocation().getLatitude(); double lon = status.getGeoLocation().getLongitude(); theMap.put("lat", lat); theMap.put("lon", lon);
// creates a new query around [37.7832, -122.4056] with a radius of 0.6 kilometers GeoQuery geoQuery = geoFire.queryAtLocation(new GeoLocation(37.7832, -122.4056), 0.6);
ipAddress = request.getRemoteAddr(); GeoLocation gl = new GeoLocation(); gl.GetGeoLocationByIP(ipAddress); String country = gl.Country;
this.latitude = latitude; this.longitude = longitude; this.place = new GeoLocation(latitude, longitude); return place.getLongitude(); return spot.distanceFrom(place);
/** * 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; }
geoFire.setLocation("firebase-hq", new GeoLocation(37.7853889, -122.4056973));
@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; }
geoFire.setLocation("firebase-hq", new GeoLocation(37.7853889, -122.4056973));
/** * 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(); }
geoFire.setLocation("firebase-hq", new GeoLocation(37.7853889, -122.4056973));
GpsDirectory gpsDirectory = metadata.getDirectory(GpsDirectory.class); GeoLocation location = gpsDirectory.getGeoLocation(); double lat = location.getLatitude(); double lng = location.getLongitude();
public class PlaceInformation { private String name; private String tag; private String address; private double latitude; private double longitude; GeoLocation place = null; public PlaceInformation(String name, String address, String tag, double latitude, double longitude) { this.name = name; this.address = address; this.tag = tag; this.latitude = latitude; this.longitude = longitude; place = new GeoLocation(latitude, longitude); }
public static void convert(GeoLocation geoLocation, Struct struct) { if (null == geoLocation) { return; } struct.put("Latitude", geoLocation.getLatitude()) .put("Longitude", geoLocation.getLongitude()); }
public class PlaceInformation { private String name; private String tag; private String address; private double latitude; private double longitude; GeoLocation place; public PlaceInformation(String name, String address, String tag, double latitude, double longitude) { place = new GeoLocation(latitude, longitude); this.name = name; this.address = address; this.tag = tag; this.latitude = latitude; this.longitude = longitude; } /* Rest of class omitted */ }
/** * 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; } }
private GeoQuery createQuery(Double latitude, Double longitude, String ip) { if (ip == null) { return new GeoQuery(new GeoLocation(latitude, longitude)); } return new GeoQuery(ip); }
@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()]))); }
private static List<Query> geoLocQueries(List<Map<String, String>> geolocs) { final List<Query> ret = new ArrayList<Query>(); for (final Map<String, String> geoloc : geolocs) { final Query q = new Query(); q.geoCode( new GeoLocation( Double.parseDouble(geoloc.get("lat")), Double.parseDouble(geoloc.get("lon")) ), Double.parseDouble(geoloc.get("rad")), Query.KILOMETERS ); ret.add(q); } return ret; } }
@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()))); }
private static List<Query> geoLocQueries(List<Map<String, String>> geolocs) { final List<Query> ret = new ArrayList<Query>(); for (final Map<String, String> geoloc : geolocs) { final Query q = new Query(); q.geoCode( new GeoLocation( Double.parseDouble(geoloc.get("lat")), Double.parseDouble(geoloc.get("lon")) ), Double.parseDouble(geoloc.get("rad")), Query.KILOMETERS ); ret.add(q); } return ret; } }