[Openstreetmap-dev] Using osmServerClient ?

Magne Mæhre magne at samfundet.no
Sun May 29 16:38:35 BST 2005


I've been trying to extract data from OSM by using osmServerClient,
but with little luck.  What I do is that is I create an
instance of osmServerClient() and calls getNodes (..) on it.
No matter what LatLonPoints I feed it, I get 0 nodes back.
The applet works as it should (even when I start it locally from
dist/applet.sh), so it must be a really stupid mistake I do somewhere :)

I have tried both with and without calling login() first.  Login seems
to work as it should, since I get an error when I give an invalid
username/password.   Since getNodes() doesn't require a login, the 
test program below is without it.

The short example program below tries to extract the points from
an area around my home town:


OpenStreetTest.java
> import org.openstreetmap.client.*;
> import com.bbn.openmap.LatLonPoint;
> import java.util.*;
> 
> public class OpenStreetTest
> {
>     public static void main (String[] args) throws Exception {
>         osmServerClient client = new osmServerClient();
>         // retrieve data set for Trondheim, Norway
>         // 63.42216N  010.39334E 
>         LatLonPoint a = new LatLonPoint(64.0, 10.0);
>         LatLonPoint b = new LatLonPoint(63.0, 11.0);
> 
>         Hashtable h = client.getNodes (a, b);
>         Vector v    = client.getLines (h);
>         System.out.println("Got " + h.size() + " nodes and "  + 
>                             v.size() + " lines");
>     }
> }

Output from the program is:
> % java OpenStreetTest
> grabbing nodes...
> result = []
> Spent 1519 in request
> Calling getNodes took 1703.0ms
> reading Lines...
> result = []
> Spent 217 in request
> Calling getLines took 220.0ms
> done getting lines!
> Got 0 nodes, and 0 lines



Any clues on what I do wrong?

--Magne





More information about the dev mailing list