Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process the requests in my server #140

Closed
andrewcarlos opened this issue Jul 29, 2015 · 12 comments
Closed

Process the requests in my server #140

andrewcarlos opened this issue Jul 29, 2015 · 12 comments

Comments

@andrewcarlos
Copy link

Hi, awesome work with this plugin, but I have a issue. I need to send a lot of coordinates, but I get this error from your server since you only support the GET request, "414 Request-URI Too Large", so my question is: Can I use my server to process the request instead of yours, so I can change it to POST? If so, what do I have to change to make this happen? Thanks in advance.

@SamSalman
Copy link

Hello,

Would you please suggest how did you manage to resolve this issue? I am also facing same error saying "414 Request-URI Too Large" since I am trying draw route with lot of coordinates.

Thank you

@perliedman
Copy link
Owner

If you already have a lot of coordinates, you most likely don't want to route between them, and OSRM will fail since the URI is too large. (A side note: OSRM is not my server, it's hosted by the OSRM project.)

If you just want to draw a line, use a polyline in Leaflet, or maybe use L.Routing.Line, if you like the styling.

OSRM is great if you want to find the route between a couple of waypoints, not if you already have tens or hundreds of coordinates!

@SamSalman
Copy link

Hello Perliedman,

Thank you for your quick response.

Currently, we are using polyline of leaflet. But the challenge we are having with it is that due to some reasons if we miss some GPS coordinates from GPS device, polyline draw straight line into the map, it doesn't follow the actual road/route on the map. The purpose of using this plugin is that, its follow the proper route path on the map. Would you suggest any possible solution in this regards.

Edit: this is a project requirement to draw the route on lots coordinates since we tracking locations of vehicles having GPS device.

Thank you

@perliedman
Copy link
Owner

@SamSalman I think what you want is OSRM's map matching functionality, that can be used to clean up a GPS trace. It's suited for pushing a lot of vertices, compared to the routing functionality.

@SamSalman
Copy link

I really appreciate your quick response.

I looked into the OSRM map matching algorithm. It says " Large jumps in the timestamps (>60s) or improbable transitions lead to trace splits if a complete matching could not be found". Since we fully rely on GPS device to sends GPS coordinates to our server, we have faced issue that device doesn't send any GPS coordinates for hour(s). In this scenario service match algorithm will not work and it will break the route.

Any suggestions, thank you in advance.

@perliedman
Copy link
Owner

@SamSalman I assume you could break this into multiple operations: use matching for parts where gps positions are frequent, and use routing, two waypoints at a time or so, for the parts where the device has been offline.

@SamSalman
Copy link

Thank you for your response.
I followed the same idea to break the request into multiple operations and its works quite fine. Now another challenge that I am having is to remove already generated routes. I have already tried your suggestion in another thread : routeControl.getPlan().setWaypoints([]); but it gives me following error: http://router.project-osrm.org/viaroute?instructions=true&alt=true&&checksum=3879459955 400 (Bad Request) and routes keep adding to the map.

is there any other way to clear route completely? Thank you in advance.

@perliedman
Copy link
Owner

That is weird. Could you post some sample code, or ideally make a jsfiddle that reproduces the problem?

@SamSalman
Copy link

@perliedman Now after some amendment, route is getting clear successfully. But in console I received many Bad requests error:
GET http://router.project-osrm.org/viaroute?instructions=true&alt=true& 400 (Bad Request)
GET http://router.project-osrm.org/viaroute?instructions=true&alt=true&&checksum=3879459955 400 (Bad Request)

Here is my implementation:

clearRoute: function(){
for(let a = 0; a < routingArray.length; a++){
routingArray[a].getPlan().setWaypoints([]);
}
routingArray = [];
}

mainRoute: function(route){
let coordinates = [];
if (route !== undefined) {
this.clearRoute();
}
for (let entry of route) {
coordinates.push({latLng: L.latLng(entry.coordinates)});
this.drawRoute(coordinates) ;
}
}

drawRoute: function(coordinates){
let routeControl= window.L.Routing.control({
waypoints: coordinates,
routeWhileDragging: false,
addWaypoints: false,
draggableWaypoints: false,
waypointMode: 'connect',
fitSelectedRoutes: false,
lineOptions: {
styles: [{color: 'black', opacity: 0.15, weight: 9},
{color: 'white',opacity: 0.8, weight: 6},
{color: 'orange', opacity: 1, weight: 2}]}
}).addTo(window.map);
routingArray.push(routeControl);
}

Thank you

@perliedman
Copy link
Owner

Hard to tell without being able to step through the code, but I would check what the coordinates array that you're passing in as waypoints looks like. From looking at the request URL, it looks like LRM doesn't add any coordinates to it, which makes me suspect the waypoints are somehow invalid.

@SamSalman
Copy link

@perliedman Thank you for your response.

So as I said: routingArray[a].getPlan().setWaypoints([]); does clear the route but simultaneously it generates bad requests console errors. However, I finally figured out clean way to clear route without any bad request error with this command:
routingArray[a].getPlan().setWaypoints({latLng: L.latLng([0, 0])});

@perliedman
Copy link
Owner

@SamSalman ok, added a new issue, #153, for this. Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants