// 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);
geoFire.setLocation("firebase-hq", new GeoLocation(37.7853889, -122.4056973));
geoFire.setLocation("firebase-hq", new GeoLocation(37.7853889, -122.4056973));
geoFire.setLocation("firebase-hq", new GeoLocation(37.7853889, -122.4056973));
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 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 */ }
private GeoQuery createQuery(Double latitude, Double longitude, String ip) { if (ip == null) { return new GeoQuery(new GeoLocation(latitude, longitude)); } return new GeoQuery(ip); }
ipAddress = request.getRemoteAddr(); GeoLocation gl = new GeoLocation(); gl.GetGeoLocationByIP(ipAddress); String country = gl.Country;
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; } }
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; } }
SimpleQuery query = new SimpleQuery(conditions); query.addProjectionOnField("*"); query.addProjectionOnField("distance:geodist(store," + GeoConverters.GeoLocationToStringConverter.INSTANCE.convert(new GeoLocation(45.15, -93.85)) + ")"); Page<EventDocument> result = template.queryForPage(query, EventDocument.class);
/** * returns a GeoLocation instance if a "geo" element is found. * * @param json JSONObject to be parsed * @return GeoLocation instance * @throws TwitterException when coordinates is not included in geo element (should be an API side issue) */ /*package*/ static GeoLocation createGeoLocation(JSONObject json) throws TwitterException { try { if (!json.isNull("coordinates")) { String coordinates = json.getJSONObject("coordinates") .getString("coordinates"); coordinates = coordinates.substring(1, coordinates.length() - 1); String[] point = coordinates.split(","); return new GeoLocation(Double.parseDouble(point[1]), Double.parseDouble(point[0])); } } catch (JSONException jsone) { throw new TwitterException(jsone); } return null; }
this.latitude = latitude; this.longitude = longitude; this.place = new GeoLocation(latitude, longitude);
/** * Returns the locations that Twitter has trending topic information for, closest to a specified location.<br> * The response is an array of "locations" that encode the location's WOEID and some other human-readable information such as a canonical name and country the location belongs in.<br> * A WOEID is a <a href="http://developer.yahoo.com/geo/geoplanet/">Yahoo! Where On Earth ID</a>. * <br>This method calls http://api.twitter.com/1.1/trends/closest.json * <p/> * {@sample.xml ../../../doc/twitter-connector.xml.sample twitter:getClosestTrends} * * @param latitude The latitude of the location this tweet refers to. This parameter will be ignored unless it is * inside the range -90.0 to +90.0 (North is positive) inclusive. * @param longitude he longitude of the location this tweet refers to. The valid ranges for longitude is -180.0 to * +180.0 (East is positive) inclusive. This parameter will be ignored if outside that range or if there not a * corresponding lat parameter. * @return the locations * @throws TwitterException twitter4j.TwitterException when Twitter service or network is unavailable */ @Processor public ResponseList<Location> getClosestTrends(double latitude, double longitude) throws TwitterException { return getConnectionManagement().getTwitterClient().getClosestTrends(new GeoLocation(latitude, longitude)); }
SimpleQuery query = new SimpleQuery(conditions); query.addProjectionOnField("*"); query.addProjectionOnField("distance:geodist()"); DefaultQueryParser qp = new DefaultQueryParser(); final SolrQuery solrQuery = qp.constructSolrQuery(query); solrQuery.add("sfield", "store"); solrQuery.add("pt", GeoConverters.GeoLocationToStringConverter.INSTANCE.convert(new GeoLocation(45.15, -93.85))); solrQuery.add("d", GeoConverters.DistanceToStringConverter.INSTANCE.convert(new Distance(5))); List<EventDocument> result = template.execute(new SolrCallback<List<EventDocument>>() { @Override public List<EventDocument> doInSolr(SolrServer solrServer) throws SolrServerException, IOException { return template.getConverter().read(solrServer.query(solrQuery).getResults(), EventDocument.class); } });
public static void reply(long inReplyToStatusId,String text,double latitude,double longitude,TwitterFactory factory) throws TwitterException { AccessToken accessToken = loadAccessToken(); Twitter twitter = factory.getInstance(); twitter.setOAuthConsumer(consumerKey, consumerSecrate); twitter.setOAuthAccessToken(accessToken); StatusUpdate stat= new StatusUpdate(text); stat.setInReplyToStatusId(inReplyToStatusId); GeoLocation location= new GeoLocation(latitude, longitude); stat.setLocation(location); twitter.updateStatus(stat); }'
/** * Creates a new place at the given latitude and longitude. * <p/> * {@sample.xml ../../../doc/twitter-connector.xml.sample twitter:createPlace} * * @param placeName The placeName a place is known as. * @param containedWithin The place_id within which the new place can be found. * Try and be as close as possible with the containing place. For * example, for a room in a building, set the contained_within as the * building place_id. * @param token The token found in the response from geo/similar_places. * @param latitude The latitude the place is located at. * @param longitude The longitude the place is located at. * @param streetAddress optional: This parameter searches for places which have * this given street address. There are other well-known, and * application specific attributes available. Custom attributes are * also permitted. Learn more about Place Attributes. * @return a new {@link Place} * @throws TwitterException when Twitter service or network is unavailable */ @Processor public Place createPlace(String placeName, String containedWithin, String token, @Placement(group = "Coordinates") Double latitude, @Placement(group = "Coordinates") Double longitude, @Optional String streetAddress) throws TwitterException { return getConnectionManagement().getTwitterClient().createPlace(placeName, containedWithin, token, new GeoLocation(latitude, longitude), streetAddress); }
static GeoLocation[][] coordinatesAsGeoLocationArray(JSONArray coordinates) throws TwitterException { try { GeoLocation[][] boundingBox = new GeoLocation[coordinates.length()][]; for (int i = 0; i < coordinates.length(); i++) { JSONArray array = coordinates.getJSONArray(i); boundingBox[i] = new GeoLocation[array.length()]; for (int j = 0; j < array.length(); j++) { JSONArray coordinate = array.getJSONArray(j); boundingBox[i][j] = new GeoLocation(coordinate.getDouble(1), coordinate.getDouble(0)); } } return boundingBox; } catch (JSONException jsone) { throw new TwitterException(jsone); } }
&& ObjectHelper.isNotEmpty(endpoint.getProperties().getLongitude()) && 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()));
String placeName, @Optional String containedWithin, @Optional String streetAddress) throws TwitterException { return getConnectionManagement().getTwitterClient().getSimilarPlaces(new GeoLocation(latitude, longitude), placeName, containedWithin, streetAddress);