Download the PHP package dmgctrlr/lara-osrm without Composer
On this page you can find all versions of the php package dmgctrlr/lara-osrm. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package lara-osrm
Wrapper around OSRM for Laravel
This package is a simple wrapper for querying OSRM. It assumes you have an OSRM v5.x server available. It supports route, nearest, table, match, and trip services. Driving is the only profile currently supported.
Installation
You can install the package via composer:
Publish the config file (config/lara-osrm.config)
You can overwrite the defaults in your .env
file too:
Usage
Getting the Request Service
There are a few ways to get the request service, depending on your preferences and situation.
Direct Creation
You can create them directly - passing an array (including 'host' and 'port' keys if you want to overwrite reading from config()
Dependency Injection
LaraOSRM registers with Laravel's dependency injector - so if you're using LaraOSRM in a controller, job or similar
you can simply add it as a requirement. It will be setup using the config settings defined in config/lara-osrm.php
and/or .env
Route Calculation
See: http://project-osrm.org/docs/v5.22.0/api/#route-service
Match Service
See: http://project-osrm.org/docs/v5.22.0/api/#match-service
SendChunk - sending huge RouteServiceRequests
Note: This is an experimental feature, your contributions are welcome
If you want to a route request with more than a few hundred waypoints you'll run into URI length limits when the library sends a GET request to OSRM.
To workaround that you can use sendChunk()
- which is an experimental and incomplete
attempt at breaking your huge request into smaller requests and combining them.
To use sendChunk()
:
- Read the SendChunk inline documentation (
src/BaseServiceRequest.php
) - Confirm that sendChunk processes and returns the information you want (it doesn't process everything)
- Simply swap
send()
withsendChunk()
on your RouteRequest object. - Test to check that the return from
sendChunk()
is accurate enough for you.
Known Limitations of sendChunk()
(and how to help out)
This is actually a list of things known to (probably) work. The crux of the complexity of sendChunk is in re-combining and stitching together the multiple requests we make.
Ultimately we want to be able to perform a send()
and a sendChunk()
and get exactly
the same result. We can do this by using a test list of Waypoints which is small enough
for send()
and use really small (e.g. 10 instead of 100) chunk sizes.
The tests are currently all in: RouteServiceTest::testSendChunkReturnsSameAsSend
and
towards the bottom there are a bunch of commented out asserts. The next step
is to make those asserts work, and then declare another bit of the result OK!.
- sendChunk only works with RouteServiceRequests
- sendChunk only works when 'geometries' is set to 'geojson'
- sendChunk only works for the 'waypoints' return value
- any other returned data shouldn't be trusted (it's probably only partial).
- sendChunk may not throw an error if you try and mis-use it. Please add error reporting.
Testing
If you get errors like Failed asserting that 429 matches expected 400.
or other mentions of
code 429 then the server you're using is probably busy (or rate limiting you).
By default the tests will use the OSRM demo server, to use your own or another
server cp phpunit.xml.dist phpunit.xml
and edit the environment variables.
If you're getting errors about a route not having a distance, and you're using your own server - check the server is properly configured and is not returning non-zero distances. For these tests you must have the "berlin" area installed.
or (better on Windows):
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Daniel
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.
All versions of lara-osrm with dependencies
guzzlehttp/guzzle Version ^6.3||^7
illuminate/support Version 5.7.*||^6||^7||^8