Android - PointOutOfBoundsException on a sample project

Hi,
I followed all the instructions in documentation for Android.
I downloaded the sample project and build it,everything is good,but when i want to draw a route between two points it returns PointOutOfBoundsException.
I downloaded Kosovo map.
My doinBackground code looks like:

protected PathWrapper doInBackground(Void… v) {

        try
        {

        StopWatch sw = new StopWatch().start();
        GHRequest req = new GHRequest(fromLat, fromLon, toLat, toLon).
                setAlgorithm(Algorithms.DIJKSTRA_BI);
        req.getHints().
                put(Routing.INSTRUCTIONS, "false");

            hopper.setGraphHopperStorage(graphHopperStorage);
        GHResponse resp = hopper.route(req);
        time = sw.stop().getSeconds();
        return resp.getBest();

        }
        catch (Exception e)
        {
            return  null;
        }
    }

Can anybody help ?

This error indicates that the request is out of the area that is available. So your graph is potentially too small. Can you print: graphHopperStorage.getBounds() and fromLat+lon and toLat+lon?

Thanks for reply.

fromLat = 42.215615
fromLon = 20.748334

toLat = 42.217279
toLon = 20.743751

BBox:

minLon = 1.7976931348623157E308
maxLon = -1.7976931348623157E308

minLat = 1.7976931348623157E308
maxLat = -1.7976931348623157E308

elevation = false

maxEle = NaN
minEle = NaN

I downloaded Kosovo map.

And you created also a graph for that map?

I followed the steps from https://github.com/graphhopper/graphhopper/blob/master/docs/android/index.md
can you tell me how to create a graph ?

In that guide see the Maps section for how to create a graph and put it in the device.

Yes i did those 4 steps, are the step 5 and 6 required ?

Step 5 is optional, but in step 6 you transferred the folder with the map + graph in the device right?

And on start does the sample informs via toast messages that it loaded the graph correctly?

I only transfered kosovo.map. the path looks like sdcard/graphhopper/maps/kosovo-gh/kosovo.map

On start of application i got the toast “Finished loading graph. Press long to define where to start and end the route.”

You need step 4 (copy map into graph folder) and then copy the folder with all files in device.

That shouldn’t be normal if the graph is missing… :thinking:

I did step 4 and copied the .map file into sdcard/graphhopper/maps/kosovo-gh/

I dont understand this, where should I copy the folder in device ?

Can i download the kosovo map like the other cities in sample project ? like hamburg,berlin ?
without putting a file manually in device

Build the graph in pc, copy the .map in graph folder and then copy the folder in device, so final path would be like /storage/emulated/0/download/graphhopper/maps/kosovo-gh/.

@karussell something seems wrong with latest GraphHopper.
I test Berlin, it downloads and when it opens it tries to re-create the graph again.
Can you confirm?

How can i build the graph, can you explain me lil bit with a steps

See my comment above, it’s mentioned in Maps section at the guide.

That would be ugly. Will try.

Forgot to mention the log:

com.graphhopper.android I/*ContractionHierarchies: 0, updates:0, nodes: 59 276, shortcuts:0, dijkstras:477 306, t(dijk):1.45, t(period):0.0, t(lazy):0.0, t(neighbor):0.0, meanDegree:2, algo:0MB, totalMB:21, usedMB:19
com.graphhopper.android I/*ContractionHierarchies: 11 840, updates:0, nodes: 47 436, shortcuts:66, dijkstras:485 762, t(dijk):1.57, t(period):0.0, t(lazy):0.0, t(neighbor):0.14, meanDegree:0, algo:0MB, totalMB:21, usedMB:20
com.graphhopper.android I/*ContractionHierarchies: 23 680, updates:1, nodes: 35 596, shortcuts:5 441, dijkstras:977 091, t(dijk):6.45, t(period):1.98, t(lazy):0.0, t(neighbor):3.26, meanDegree:1, algo:0MB, totalMB:22, usedMB:20
...

Ah, I know. We changed prepare.xy to prepare.ch.xy when introducing prepare.lm.xy in the landmark issue. And now the ‘done’ was not found for CH and it is redoing the work here as the files on the server have not recreated. So should I recreate the files (and add some protection) or should I parse the old prepare.xy for the done state?

Update: have fixed it here: https://github.com/graphhopper/graphhopper/commit/b065b4f3cc13fd4f0e16c060c7ad68e19df375e4 please try :slight_smile:

Hmm still seeing same behavior…

Sorry for the confusion, forgot to change Gradle repositories to use the local fix. :slight_smile:

I can confirm that it works properly now!

Ah, puh - thanks! Created an issue for this as this might reappear when we remove it later: https://github.com/graphhopper/graphhopper/issues/967

1 Like