ustroetz / python-osrm

A Python wrapper around the OSRM API
MIT License
133 stars 55 forks source link

Bad Request for table with more than 100 coordinates #45

Closed Rougree closed 4 years ago

Rougree commented 4 years ago

Hi Guys,

Is there a limit for the amount of coordinates in one request? The table function works fine for 100 coordinates (100x100 =10.000 ) If want to request the distances for 101 coordinates I have the following error:

time_matrix = osrm.table(list_coordinates, coords_dest=coords_destinations, output='dataframe')

File "C:\Users\RSale\Anaconda3\lib\site-packages\osrm\core.py", line 348, in table rep = urlopen(req)

File "C:\Users\RSale\Anaconda3\lib\urllib\request.py", line 223, in urlopen return opener.open(url, data, timeout)

File "C:\Users\RSale\Anaconda3\lib\urllib\request.py", line 532, in open response = meth(req, response)

File "C:\Users\RSale\Anaconda3\lib\urllib\request.py", line 642, in http_response 'http', request, response, code, msg, hdrs)

File "C:\Users\RSale\Anaconda3\lib\urllib\request.py", line 570, in error return self._call_chain(*args)

File "C:\Users\RSale\Anaconda3\lib\urllib\request.py", line 504, in _call_chain result = func(*args)

File "C:\Users\RSale\Anaconda3\lib\urllib\request.py", line 650, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp)

HTTPError: Bad Request

So, I think there is some limit of requests? Can I change that limit somewhere? OSRM for c++ does not have this limit.

zifeo commented 4 years ago

Hello @RamySalem1993, The error is likely to come from the underlying OSRM server as 100 is the default value for the table requests. Please update that number and retry.

Rougree commented 4 years ago

Thanks for your quick response @zifeo ! Where can I find this file, since I use OSRM with python. As far as I know this file is not on my computer, since it is a C++ file.

zifeo commented 4 years ago

@RamySalem1993, what OSRM url you use? Using the demo server is only for testing/demo and the option are limited. Consider running it with docker and you will be able to customize the launching flag --max-table-size.

Rougree commented 4 years ago

I'm using the following url:

osrm.RequestConfig.host = "router.project-osrm.org"

Is this URL a demo server? I never used docker before. So, your are saying that the only way to work this good is with docker? @zifeo

If it is only good with docker I don't understand why it is implemented on Python...

zifeo commented 4 years ago

@RamySalem1993 Please have a look on https://github.com/Project-OSRM/osrm-backend/wiki/Demo-server. AFAIK there is no free and open server to use, you have to host you own.

Rougree commented 4 years ago

Sorry for all my questions, but it looks like you are familiar with OSRM. I thought that OSRM was a open source (and free) route machine which provides distances and durations between coordinates, while using the real road network. But you imply that this is a demo and the original one is not free and I have to host my own. What do you mean with host my own? Since I read a lot in the "OSRM c++ github" and there I see people talking about updating values (distances etc.) and requesting matrices of 10000x10000. I have never read about paying for this service. So, at the moment I don't understand the service of OSRM, is it free or do you have to pay for it? And what do you recommend to use OSRM in the best and fastest way? @zifeo

zifeo commented 4 years ago

@RamySalem1993 open source != free runtime, it means that the code source is publicly available but it does not guarantee that the resources needed for running this system are also offered. It should be easy to run it on your computer, for instance here and here.

Rougree commented 4 years ago

Thanks @zifeo. So, using this --> osrm.RequestConfig.host = "router.project-osrm.org" <-- in Python is a demo and it doesn't work as I want. And it is better to use ubuntu or docker instead (to have the best features)?

zifeo commented 4 years ago

@RamySalem1993 yes.