<div dir="ltr">Hi Alex,<div><br></div><div>  If you simply want to find the nearest road to a GPS coordinate, the /nearest service is simpler.  The /match service is specifically designed to match a sequence of GPS coordinates *with error* to the most likely path.</div><div><br></div><div>  The problem with using /nearest is that it has no context - if your GPS position has a large error value (10+ metres), then it may snap you to some nearby road that's not actually where the vehicle is.</div><div><br></div><div>  The /match service fixes this - if you supply, say, the last 60 seconds of coordinates, it will use the prior coordinates to select the most likely path, and snap the final coordinate to what is probably the right location, even if there is some error in the GPS value.</div><div><br></div><div>  For your specific case - the "NoSegment" error means there was no road to snap to within 15m of the coordinates - either the OSM map is bad, or your GPS coordinates have quite a large error in them.  Adding `radiuses=15m` increases the search range out to 45m (the 15m value is 1 standard deviation of expected error, we search out to 3 standard deviations).</div><div><br></div><div>  1.  Yes, OSRM is suitable for this, if you use the /match service as I suggested (provide several previous points for context).</div><div>  2.  No, but see description above.  Supply a trace to /match, and look at the last value in the result for the "current" point.</div><div>  3.  You'll have to test - I'd guess based on your description that the last 6 samples would work pretty well.</div><div>  4.  It could handle 50 req/sec as long as you:</div><div>      1. Give it sufficient CPUs to work with</div><div>      2. Don't supply *too* many coordinate to /matching, and keep the `radiuses=` parameter to the smallest value that works</div><div>      3. Test it to determine throughput.</div><div>      50 req/sec is not out of the question at all.</div><div>  5. See above</div><div>  6. If you can be confident about the routes, then you can reduce the size of your map data (and increase matching performance) by giving OSRM a very limited road network to work with (just your bus routes).  You'd need to figure out how to construct that yourself however, and ensure that all roads are properly connected.  The advantage to using the whole city is that it will properly follow any deviations from the normal route.</div><div>      If you can come up with a road network of just your bus routes, you can increase the `radiuses=` parameter significantly so things would still properly snap even in the case where a bus deviates from a route.</div><div><br></div><div>Hope that helps.</div><div><br></div><div><br></div><div>daniel</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Dec 6, 2019 at 3:16 PM Alex R <<a href="mailto:ralienpp@gmail.com">ralienpp@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="auto"><div dir="ltr"><div dir="ltr">Hi,</div><div dir="ltr"><br></div><div dir="ltr"> I ask for advice in using OSRM with a live stream of data. The examples I've seen relate to tracks that can be passed into OSRM and it will apply "map matching" to snap all points to the roads, in one move.<br></div><div dir="ltr"> </div><div dir="ltr"> My scenario is different, I am trying to understand whether it is feasible with in circumstances:</div><div dir="ltr"> - a fleet of 500 public transport vehicles</div><div dir="ltr"> - each vehicle sends telemetry every 10s</div><div dir="ltr"> - all of this is happening within a 120 km^2 city</div><div dir="ltr"> - the vehicles move on fixed routes that I know in advance</div><div dir="ltr"> </div><div dir="ltr">I followed the Docker guide instructions and downloaded the map data for my country, then I sent a HTTP request to the matching API, with one data-point (note, in the examples below, the order is lon/lat, as mentioned in the FAQ):<br></div><div dir="ltr">curl '<a href="http://127.0.0.1:5000/match/v1/driving/28.8260977,47.0231816" target="_blank">http://127.0.0.1:5000/match/v1/driving/28.8260977,47.0231816</a>'</div><div>OSRM replied with "Number of coordinates needs to be at least two."</div><div dir="ltr"><br></div><div dir="ltr">So I did: curl '<a href="http://127.0.0.1:5000/match/v1/driving/28.8260977,47.0231816;28.8260977,47.0231816" target="_blank">http://127.0.0.1:5000/match/v1/driving/28.8260977,47.0231816;28.8260977,47.0231816</a>'<br>and got {"message":"Could not find a matching segment for any coordinate.","code":"NoSegment"}</div><div dir="ltr"><br></div><div>What worked out in the end was:</div>curl '<a href="http://127.0.0.1:5000/match/v1/driving/28.8260977,47.0231816;28.8260977,47.0231816?radiuses=15;15" target="_blank">http://127.0.0.1:5000/match/v1/driving/28.8260977,47.0231816;28.8260977,47.0231816?radiuses=15;15</a>'</div><div dir="ltr"><br><div dir="ltr"> </div><div dir="ltr"> My questions are:</div><div dir="ltr"> 1. Is OSRM's matching suitable for such scenarios?</div><div> 2. Did I correctly understand and apply the matching API?<br></div><div dir="ltr"> 3. What is the recommended number of points for a match query?</div><div dir="ltr"> 4. In what circumstances would it be able to handle a rate of 50 requests/s?</div><div dir="ltr"> 5. What techniques can I apply to increase throughput? </div><div dir="ltr"> 6. Instead of using the map of an entire country, or even a city - can I tell OSRM to match to a specific route that I know for sure the vehicle is on?</div><div dir="ltr"> </div><div dir="ltr"> </div><div dir="ltr"> I look forward to your to your feedback,</div><div>Alex<br></div></div></div>
</div>
_______________________________________________<br>
OSRM-talk mailing list<br>
<a href="mailto:OSRM-talk@openstreetmap.org" target="_blank">OSRM-talk@openstreetmap.org</a><br>
<a href="https://lists.openstreetmap.org/listinfo/osrm-talk" rel="noreferrer" target="_blank">https://lists.openstreetmap.org/listinfo/osrm-talk</a><br>
</blockquote></div>