aviroez / osmbonuspack

Automatically exported from code.google.com/p/osmbonuspack
0 stars 0 forks source link

Route showing as a straight line and not along any road #63

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Trying to add route overlay
2. Trying to add polyline along a road
3. invalidating the mapview

What is the expected output? What do you see instead?
I see a straight line from the starting geo point to the ending geo point, but 
the line does not run along any roads. 

What version of the products are you using (Android SDK, osmdroid,
OSMBonusPack)?

osmdroid-android-4.1.jar
osmbonuspack_v4.4.jar
eclipse android sdk

Please provide any additional information below.

I want the line from start to end point to run along a specific road, not a 
straight one.

The method I am using:

public void addRouteOverlay(GeoPoint startPoint, GeoPoint endPoint) {
            // road manager
            RoadManager roadManager = new OSRMRoadManager();

            // start and end points
            ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
            waypoints.add(startPoint);
            // GeoPoint endPoint = new GeoPoint(48.4, -1.9);
            waypoints.add(endPoint);
            // roadManager.addRequestOption("routeType=bicycle");
            // retreive the road between those points
            Road road = roadManager.getRoad(waypoints);
            if (road.mStatus != Road.STATUS_OK){
                  Log.d("Road Status", ""+road.mStatus);
                }
            // Polyline with the route shape
            org.osmdroid.bonuspack.overlays.Polyline roadOverlay = RoadManager
                    .buildRoadOverlay(road, this);
            // Polyline to the overlays of your map
            mapView.getOverlays().add(roadOverlay);
            // Refresh the map
            mapView.invalidate();  
}

The way I am calling the method:

//to display route between current location and destination
                addRouteOverlay(new GeoPoint(location.getLatitude(),
                        location.getLongitude()), new GeoPoint(22.566039700000000000,
                                88.349356700000040000));

Original issue reported on code.google.com by androabh...@gmail.com on 29 Apr 2014 at 12:16

Attachments:

GoogleCodeExporter commented 9 years ago
First, refer to this Stackoverflow answer:
http://stackoverflow.com/questions/21213224/roadmanager-for-osmdroid-error-help-
please/21894178#21894178

Then, if you think you encounter a really new issue, then provide the logcat 
stacktrace. 

Original comment by mathieu....@gmail.com on 30 Apr 2014 at 8:04

GoogleCodeExporter commented 9 years ago
If I copy/paste this full url in a browser, the browser is returning a json 
file. The first lines of the json says:

"status":0,"status_message": "Found route between 
points","route_geometry":"blah blah blah"

I am also getting "OSRMRoadManager::getRoad: request failed" error in the logcat

Original comment by androabh...@gmail.com on 1 May 2014 at 5:16

GoogleCodeExporter commented 9 years ago
Logcat output

Original comment by androabh...@gmail.com on 1 May 2014 at 5:21

Attachments:

GoogleCodeExporter commented 9 years ago
The logcat shows that you have a NetworkOnMainThreadException. 
This is the very first case explained in the Stackoverflow answer. 
Refer to Tutorial_0 "Important note about network calls". 

Original comment by mathieu....@gmail.com on 1 May 2014 at 11:37