twitter4j.GeoLocation类的使用及代码示例

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

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

GeoLocation介绍

[英]A data class representing geo location.
[中]

代码示例

代码示例来源:origin: apache/incubator-druid

double lat = status.getGeoLocation().getLatitude();
double lon = status.getGeoLocation().getLongitude();
theMap.put("lat", lat);
theMap.put("lon", lon);

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

// 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);

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

ipAddress = request.getRemoteAddr();
 GeoLocation gl = new GeoLocation();
 gl.GetGeoLocationByIP(ipAddress);

String country = gl.Country;

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

this.latitude = latitude;
this.longitude = longitude;
this.place = new GeoLocation(latitude, longitude);
return place.getLongitude();
return spot.distanceFrom(place);

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

/**
 * 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;
}

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

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

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

@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;
}

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

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

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

/**
 * 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();
}

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

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

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

GpsDirectory gpsDirectory = metadata.getDirectory(GpsDirectory.class);
GeoLocation location = gpsDirectory.getGeoLocation();
double lat = location.getLatitude();
double lng = location.getLongitude();

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

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);
 }

代码示例来源:origin: jcustenborder/kafka-connect-twitter

public static void convert(GeoLocation geoLocation, Struct struct) {
 if (null == geoLocation) {
  return;
 }
 struct.put("Latitude", geoLocation.getLatitude())
   .put("Longitude", geoLocation.getLongitude());
}

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

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 */
}

代码示例来源:origin: P7h/StormTweetsSentimentAnalysis

/**
   * 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;
  }
}

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

private GeoQuery createQuery(Double latitude, Double longitude, String ip) {
  if (ip == null) {
    return new GeoQuery(new GeoLocation(latitude, longitude));
  }
  return new GeoQuery(ip);
}

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

@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()])));
}

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

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;
  }
}

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

@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())));
}

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

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;
  }
}

相关文章