GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Total newbie question - Java connection basics?  XML
Forum Index -> General
Author Message
JCampy



Joined: 14/08/2009 05:23:46
Messages: 2
Location: Colorado, USA
Offline

Hi,

Total newbie to using GeoNames. I have some Java code that looks OK to me, but continually returns a 0 length List< Toponym >, though the same input work via the web site:

Code:
         // Address changed to protect the innocent - because I use MY address
         String address = "100 Fake St Denver, CO"; 
         ToponymSearchResult result;
         try
         {
             ToponymSearchCriteria criteria = new ToponymSearchCriteria();
             String UrlUtf8Address = URLEncoder.encode( address, "UTF8" );
             criteria.setQ( UrlUtf8Address );
  
             WebService.setGeoNamesServer( "ws.geonames.org" );
             result = WebService.search( criteria );
         }
         catch (Exception e)
         {
              e.printStackTrace();
             return null;
         }
         
         List< Toponym > ts = result.getToponyms();
 


By the rime I get to the result, the size of the List is 0.

I must be doing something obviously wrong. Or did I miss a registration requirement for using the free service?

Thanks for any clues.

P.S. Are there any simple Java cookbooks around for GeoNames?
marc



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

The java library already does the utf8 encoding for, no need to do it yourself. If you do it yourself it won't work for non-ascii characters.
The service does not support addresses (street and house number).

Best

Marc

[WWW]
JCampy



Joined: 14/08/2009 05:23:46
Messages: 2
Location: Colorado, USA
Offline

Since your main page DOES support addresses, I had assumed that GeoNames does as well. Looking at it again, I see you mention a redirect to Yahoo Geocoder on the results page. Even seeing that, I would have assumed that this was the GeoNames code doing the redirect. It might be better to require an extra click to use Yahoo to resolve so that it's obvious that GeoNames doesn't automatically support the redirection as part of the service.

I have a business I'm trying to get off the ground ("on the cheap" - no funds to pay for geocoding service during initial development and beta testing) that I would have switched to your pay service had you supported address resolution. Seems like a small step to take to be able to take on a lot more business. I mean, your main page is already doing it. The big guy on the block is obviously Google, but their terms of service require that you use the geocoding result to display a map, and they reserve the right to add advertising to their maps. These terms are unacceptable to my needs. (They also require that you grant free access to the geocoding services on the site, but we intend to do that anyway.)

If you change your model, let me know. Outside of the address lookup failure, you guys seem to offer the right blend of up front low (no) cost leading to good uptime guarantees at a reasonable cost for the long run, as well as a reasonably simple interface. Add to that the international coverage, and you have a long-term growth path for web sites from initial development on up. Just wish this limitation had been made more obvious up front, so I wouldn't have spent so many hours working on a non-solution.

One more thing - the JavaDoc on the Java interface could stand some work. Finding that I needed to do a setQ() to set up my query took quite a bit of web searching. And I did end up seeing that you did the URL and UTF encoding by downloading your source code and walking through it in the debugger. But that should have been made obvious in the JavaDoc. If I had a reason to use your service, I would have helped out in this area when I had a chance. As it stands, I'll just leave you with the suggestion.

Good luck, and thanks for the response.
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team