GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
InsufficientStyleException on getPopulation() in Java  XML
Forum Index -> General
Author Message
bradamant



Joined: 03/11/2011 16:07:26
Messages: 6
Offline

I'm getting an error when trying to check the population using the Java API. I did find the documentation for this error but it's not detailed enough for me to understand how to fix it.

I search for a place by name:
Code:
ToponymSearchCriteria searchCriteria = new ToponymSearchCriteria();
 searchCriteria.setName(candidatePlace);
 List<Toponym> hits = check.getToponyms();


Then I loop through the hits list, checking whether each one is an exact name match...
Code:
if (testing.getName().equals(candidatePlace)) {...


And whether it's in a hashset of acceptable feature codes that I created...
Code:
if (acceptableClasses.contains(testing.getFeatureCode())) {...


And that all works fine. But when I want to check whether the population is big enough, seemingly in a very similar way, it doesn't work.
Code:
if (testing.getPopulation() > 10000) {...


This throws
Code:
org.geonames.InsufficientStyleException: population not supported by style MEDIUM


What is "style MEDIUM" in this context? Is there something wrong with the way I've retrieved the list of candidate Toponyms?
marc



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

The api is using the xml webservice:
http://www.geonames.org/export/geonames-search.html

The xml response only includes population data for style 'FULL' or 'LONG'. You therefore have to set the style to be able to retrieve the population for the search.

Best Regards

Marc

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