Geonames database works fine for me when to query via WEB. However, there are java packages org.geonames
with classes WebService
, Toponym
and other ones, which seem to do the same from within java application. So, I try to use org.geonames
for creating a query like
https://secure.geonames.org/countrySubdivision?lat=47.03&lng=30.2&username=myUserName
which, when sending via WEB, returns xml nwith countryName
and adminName1
tags. However, I cannot find appropriate method (methods) in org.geonames
returning object with countryName
and adminName1
by given latitude and longitude.
How do I solve the problem?
The methods are in the class Toponym
, not in the package.
Here is the javadoc with all the methods.
And here is an example from their website.
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(toponym.getName()+" "+ toponym.getCountryName());
}