twitter4j.GeoLocation.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中twitter4j.GeoLocation.<init>()方法的一些代码示例,展示了GeoLocation.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GeoLocation.<init>()方法的具体详情如下:
包路径:twitter4j.GeoLocation
类名称:GeoLocation
方法名:<init>

GeoLocation.<init>介绍

[英]Creates a GeoLocation instance
[中]创建地理位置实例

代码示例

代码示例来源:origin: stackoverflow.com

  1. // creates a new query around [37.7832, -122.4056] with a radius of 0.6 kilometers
  2. GeoQuery geoQuery = geoFire.queryAtLocation(new GeoLocation(37.7832, -122.4056), 0.6);

代码示例来源:origin: stackoverflow.com

  1. geoFire.setLocation("firebase-hq", new GeoLocation(37.7853889, -122.4056973));

代码示例来源:origin: stackoverflow.com

  1. geoFire.setLocation("firebase-hq", new GeoLocation(37.7853889, -122.4056973));

代码示例来源:origin: stackoverflow.com

  1. geoFire.setLocation("firebase-hq", new GeoLocation(37.7853889, -122.4056973));

代码示例来源:origin: stackoverflow.com

  1. public class PlaceInformation {
  2. private String name;
  3. private String tag;
  4. private String address;
  5. private double latitude;
  6. private double longitude;
  7. GeoLocation place = null;
  8. public PlaceInformation(String name, String address, String tag,
  9. double latitude, double longitude) {
  10. this.name = name;
  11. this.address = address;
  12. this.tag = tag;
  13. this.latitude = latitude;
  14. this.longitude = longitude;
  15. place = new GeoLocation(latitude, longitude);
  16. }

代码示例来源:origin: stackoverflow.com

  1. public class PlaceInformation {
  2. private String name;
  3. private String tag;
  4. private String address;
  5. private double latitude;
  6. private double longitude;
  7. GeoLocation place;
  8. public PlaceInformation(String name, String address, String tag,
  9. double latitude, double longitude) {
  10. place = new GeoLocation(latitude, longitude);
  11. this.name = name;
  12. this.address = address;
  13. this.tag = tag;
  14. this.latitude = latitude;
  15. this.longitude = longitude;
  16. }
  17. /* Rest of class omitted */
  18. }

代码示例来源:origin: org.mule.modules/mule-module-twitter

  1. private GeoQuery createQuery(Double latitude, Double longitude, String ip) {
  2. if (ip == null) {
  3. return new GeoQuery(new GeoLocation(latitude, longitude));
  4. }
  5. return new GeoQuery(ip);
  6. }

代码示例来源:origin: stackoverflow.com

  1. ipAddress = request.getRemoteAddr();
  2. GeoLocation gl = new GeoLocation();
  3. gl.GetGeoLocationByIP(ipAddress);
  4. String country = gl.Country;

代码示例来源:origin: openimaj/openimaj

  1. private static List<Query> geoLocQueries(List<Map<String, String>> geolocs) {
  2. final List<Query> ret = new ArrayList<Query>();
  3. for (final Map<String, String> geoloc : geolocs) {
  4. final Query q = new Query();
  5. q.geoCode(
  6. new GeoLocation(
  7. Double.parseDouble(geoloc.get("lat")),
  8. Double.parseDouble(geoloc.get("lon"))
  9. ),
  10. Double.parseDouble(geoloc.get("rad")),
  11. Query.KILOMETERS
  12. );
  13. ret.add(q);
  14. }
  15. return ret;
  16. }
  17. }

代码示例来源:origin: org.openimaj/sandbox

  1. private static List<Query> geoLocQueries(List<Map<String, String>> geolocs) {
  2. final List<Query> ret = new ArrayList<Query>();
  3. for (final Map<String, String> geoloc : geolocs) {
  4. final Query q = new Query();
  5. q.geoCode(
  6. new GeoLocation(
  7. Double.parseDouble(geoloc.get("lat")),
  8. Double.parseDouble(geoloc.get("lon"))
  9. ),
  10. Double.parseDouble(geoloc.get("rad")),
  11. Query.KILOMETERS
  12. );
  13. ret.add(q);
  14. }
  15. return ret;
  16. }
  17. }

代码示例来源:origin: stackoverflow.com

  1. SimpleQuery query = new SimpleQuery(conditions);
  2. query.addProjectionOnField("*");
  3. query.addProjectionOnField("distance:geodist(store," + GeoConverters.GeoLocationToStringConverter.INSTANCE.convert(new GeoLocation(45.15, -93.85)) + ")");
  4. Page<EventDocument> result = template.queryForPage(query, EventDocument.class);

代码示例来源:origin: org.twitter4j/twitter4j-core

  1. /**
  2. * returns a GeoLocation instance if a "geo" element is found.
  3. *
  4. * @param json JSONObject to be parsed
  5. * @return GeoLocation instance
  6. * @throws TwitterException when coordinates is not included in geo element (should be an API side issue)
  7. */
  8. /*package*/
  9. static GeoLocation createGeoLocation(JSONObject json) throws TwitterException {
  10. try {
  11. if (!json.isNull("coordinates")) {
  12. String coordinates = json.getJSONObject("coordinates")
  13. .getString("coordinates");
  14. coordinates = coordinates.substring(1, coordinates.length() - 1);
  15. String[] point = coordinates.split(",");
  16. return new GeoLocation(Double.parseDouble(point[1]),
  17. Double.parseDouble(point[0]));
  18. }
  19. } catch (JSONException jsone) {
  20. throw new TwitterException(jsone);
  21. }
  22. return null;
  23. }

代码示例来源:origin: stackoverflow.com

  1. this.latitude = latitude;
  2. this.longitude = longitude;
  3. this.place = new GeoLocation(latitude, longitude);

代码示例来源:origin: org.mule.modules/mule-module-twitter

  1. /**
  2. * Returns the locations that Twitter has trending topic information for, closest to a specified location.<br>
  3. * 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>
  4. * A WOEID is a <a href="http://developer.yahoo.com/geo/geoplanet/">Yahoo! Where On Earth ID</a>.
  5. * <br>This method calls http://api.twitter.com/1.1/trends/closest.json
  6. * <p/>
  7. * {@sample.xml ../../../doc/twitter-connector.xml.sample twitter:getClosestTrends}
  8. *
  9. * @param latitude The latitude of the location this tweet refers to. This parameter will be ignored unless it is
  10. * inside the range -90.0 to +90.0 (North is positive) inclusive.
  11. * @param longitude he longitude of the location this tweet refers to. The valid ranges for longitude is -180.0 to
  12. * +180.0 (East is positive) inclusive. This parameter will be ignored if outside that range or if there not a
  13. * corresponding lat parameter.
  14. * @return the locations
  15. * @throws TwitterException twitter4j.TwitterException when Twitter service or network is unavailable
  16. */
  17. @Processor
  18. public ResponseList<Location> getClosestTrends(double latitude, double longitude) throws TwitterException {
  19. return getConnectionManagement().getTwitterClient().getClosestTrends(new GeoLocation(latitude, longitude));
  20. }

代码示例来源:origin: stackoverflow.com

  1. SimpleQuery query = new SimpleQuery(conditions);
  2. query.addProjectionOnField("*");
  3. query.addProjectionOnField("distance:geodist()");
  4. DefaultQueryParser qp = new DefaultQueryParser();
  5. final SolrQuery solrQuery = qp.constructSolrQuery(query);
  6. solrQuery.add("sfield", "store");
  7. solrQuery.add("pt", GeoConverters.GeoLocationToStringConverter.INSTANCE.convert(new GeoLocation(45.15, -93.85)));
  8. solrQuery.add("d", GeoConverters.DistanceToStringConverter.INSTANCE.convert(new Distance(5)));
  9. List<EventDocument> result = template.execute(new SolrCallback<List<EventDocument>>() {
  10. @Override
  11. public List<EventDocument> doInSolr(SolrServer solrServer) throws SolrServerException, IOException {
  12. return template.getConverter().read(solrServer.query(solrQuery).getResults(), EventDocument.class);
  13. }
  14. });

代码示例来源:origin: stackoverflow.com

  1. public static void reply(long inReplyToStatusId,String text,double latitude,double longitude,TwitterFactory factory) throws TwitterException
  2. { AccessToken accessToken = loadAccessToken();
  3. Twitter twitter = factory.getInstance();
  4. twitter.setOAuthConsumer(consumerKey, consumerSecrate);
  5. twitter.setOAuthAccessToken(accessToken);
  6. StatusUpdate stat= new StatusUpdate(text);
  7. stat.setInReplyToStatusId(inReplyToStatusId);
  8. GeoLocation location= new GeoLocation(latitude, longitude);
  9. stat.setLocation(location);
  10. twitter.updateStatus(stat);
  11. }'

代码示例来源:origin: org.mule.modules/mule-module-twitter

  1. /**
  2. * Creates a new place at the given latitude and longitude.
  3. * <p/>
  4. * {@sample.xml ../../../doc/twitter-connector.xml.sample twitter:createPlace}
  5. *
  6. * @param placeName The placeName a place is known as.
  7. * @param containedWithin The place_id within which the new place can be found.
  8. * Try and be as close as possible with the containing place. For
  9. * example, for a room in a building, set the contained_within as the
  10. * building place_id.
  11. * @param token The token found in the response from geo/similar_places.
  12. * @param latitude The latitude the place is located at.
  13. * @param longitude The longitude the place is located at.
  14. * @param streetAddress optional: This parameter searches for places which have
  15. * this given street address. There are other well-known, and
  16. * application specific attributes available. Custom attributes are
  17. * also permitted. Learn more about Place Attributes.
  18. * @return a new {@link Place}
  19. * @throws TwitterException when Twitter service or network is unavailable
  20. */
  21. @Processor
  22. public Place createPlace(String placeName,
  23. String containedWithin,
  24. String token,
  25. @Placement(group = "Coordinates") Double latitude,
  26. @Placement(group = "Coordinates") Double longitude,
  27. @Optional String streetAddress) throws TwitterException {
  28. return getConnectionManagement().getTwitterClient().createPlace(placeName, containedWithin, token, new GeoLocation(latitude, longitude),
  29. streetAddress);
  30. }

代码示例来源:origin: org.twitter4j/twitter4j-core

  1. static GeoLocation[][] coordinatesAsGeoLocationArray(JSONArray coordinates) throws TwitterException {
  2. try {
  3. GeoLocation[][] boundingBox = new GeoLocation[coordinates.length()][];
  4. for (int i = 0; i < coordinates.length(); i++) {
  5. JSONArray array = coordinates.getJSONArray(i);
  6. boundingBox[i] = new GeoLocation[array.length()];
  7. for (int j = 0; j < array.length(); j++) {
  8. JSONArray coordinate = array.getJSONArray(j);
  9. boundingBox[i][j] = new GeoLocation(coordinate.getDouble(1), coordinate.getDouble(0));
  10. }
  11. }
  12. return boundingBox;
  13. } catch (JSONException jsone) {
  14. throw new TwitterException(jsone);
  15. }
  16. }

代码示例来源:origin: org.apache.camel/camel-twitter

  1. && ObjectHelper.isNotEmpty(endpoint.getProperties().getLongitude())
  2. && ObjectHelper.isNotEmpty(endpoint.getProperties().getRadius())) {
  3. GeoLocation location = new GeoLocation(endpoint.getProperties().getLatitude(), endpoint.getProperties().getLongitude());
  4. query.setGeoCode(location, endpoint.getProperties().getRadius(), Unit.valueOf(endpoint.getProperties().getDistanceMetric()));

代码示例来源:origin: org.mule.modules/mule-module-twitter

  1. String placeName, @Optional String containedWithin,
  2. @Optional String streetAddress) throws TwitterException {
  3. return getConnectionManagement().getTwitterClient().getSimilarPlaces(new GeoLocation(latitude, longitude),
  4. placeName, containedWithin, streetAddress);

相关文章