GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
getting continent code with java webservice  XML
Forum Index -> General
Author Message
kris


[Avatar]

Joined: 06/05/2012 18:01:14
Messages: 1
Offline

hello,

let me quickly explain what I want to do:

I have a java project that uses the twitter4j library to get all the twitter followers of a specific twitter account. I now want to count, how many followers of that account com from each continent. To do tha, I want to find out, from which continent the twitter user come from. with the help of the twitter4j library I can get the information the user added in his twitter profile, which is often very sketchy and not complete or even the same for different users that come from the same country. so for example one writes briatin and the next writes UK or just london. to get the continet I hope that the GeoNames webservice for java can help. so far I used this example with mixed results:
Code:
 WebService.setUserName("demo"); // add your username here
 		 
 		  ToponymSearchCriteria searchCriteria = new ToponymSearchCriteria();
 		  searchCriteria.setQ("zurich");
 		  
 		  ToponymSearchResult searchResult = WebService.search(searchCriteria);
 		  for (Toponym toponym : searchResult.getToponyms()) {
 		     System.out.println("Country: " + toponym.getCountryCode() + " Continent: " + toponym.getContinentCode() );
 		  }
 


I do get the results but the continet is null. I´m also wondering why there are so many resutls for one query. Even if I search for britain or germany I get a lot of different results and the continent is always null. Can somebody help?

thanks

k.
marc



Joined: 08/12/2005 07:39:47
Messages: 4501
Offline

Hi Kris

The continentCode is not included in the default xml result. You have to set the style to FULL to retrieve the attribute.
It is a bug in the client code to not throw an exception when the continent code is retrieved without setting the proper style.

Best Regards

Marc

[WWW]
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team