List of usage examples for twitter4j Twitter reverseGeoCode
ResponseList<Place> reverseGeoCode(GeoQuery query) throws TwitterException;
From source file:geo.ReverseGeoCode.java
License:Apache License
/** * Usage: java twitter4j.examples.geo.ReverseGeoCode [latitude] [longitude] * * @param args message/*from w w w . ja v a 2 s . c o m*/ */ public static void main(String[] args) { if (args.length < 2) { System.out.println("Usage: java twitter4j.examples.geo.ReverseGeoCode [latitude] [longitude]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); GeoQuery query = new GeoQuery( new GeoLocation(Double.parseDouble(args[0]), Double.parseDouble(args[1]))); ResponseList<Place> places = twitter.reverseGeoCode(query); if (places.size() == 0) { System.out.println("No location associated with the specified lat/lang"); } else { for (Place place : places) { System.out.println("id: " + place.getId() + " name: " + place.getFullName()); Place[] containedWithinArray = place.getContainedWithIn(); if (containedWithinArray != null && containedWithinArray.length != 0) { System.out.println(" contained within:"); for (Place containedWithinPlace : containedWithinArray) { System.out.println(" id: " + containedWithinPlace.getId() + " name: " + containedWithinPlace.getFullName()); } } } } System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to retrieve places: " + te.getMessage()); System.exit(-1); } }