A Python package to generate a random route with a specified length.
Utilizes the openrouteservice API to generate the routing and the Overpass API for picking a random location.
Installation
Random-Route-Generator releases are available as wheel packages for macOS, Windows and Linux on PyPI. Install it using pip:
pip install random-route-generator
Example
This script generates a random route which is maximum 25km long and starts at the coordinate (51.846812, 6.242033). It uses mountain-biking route generation and utilizes 4 random points. The route also avoids ferries and steps and is self-contained.
from randomRouteGenerator.route_generator import RouteGenerator
from randomRouteGenerator.coordinate import Coordinate
generator = RouteGenerator()
#Manually set the openrouteservice API key
generator.api_key = ""
#OR read the API key from a file
#generator.read_api_key("ors_api.key")
#What type of route generation should be used? (See README)
generator.routing_profile = "cycling-mountain"
#How many random points should be generated?"
generator.point_amount = 4
#How should the origin and end point be handled (See RouteGenerator.ROUTE_MODE)?
generator.route_mode = generator.ROUTE_MODE.START_END_ORIGIN
#Which features should be avoided in the route?
generator.avoids = ["ferries", "steps"]
#Generate the route with the given origin point and maximum length
p = generator.generate_route(Coordinate(51.846812, 6.242033), 25000)
length = p.get_length()
duration = p.get_duration()
elevation = p.get_elevation()
#Retrieve information about the road-types in the route i.e. gravel, paved, ...
print(p.get_way_info())
#Print all routing points (all points generated by the routing)
for x in p.routing_points:
print(x)
#Print all way-points (ONLY the random points whose amount is specified in generator.point_amount)
for x in p.points:
print(x)
#Generate a GPX file containing the route
p.generate_gpx_file(filename="out.gpx")
Profiles
- driving-car (Regular car routing)
- driving-hgv (Routing for heavy-trucks)
- cycling-regular (Routing for regular cycling)
- cycling-road (Routing for road bikes)
- cycling-mountain (Routing for mountain bikes, prefers offroad tracks)
- cycling-electric (Routing for E-bikes)
Credits
- openrouteservice - Used to generate the routing between the points
- Overpass-API - Used for picking a random location
- gpxpy - Used for exporting to a GPX file
- overpy - Used for communicating with the Overpass-API
- haversine - Used for coordinate calculations
License
Metadata
Release files for random-route-generator 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| random-route-generator-1.0.3.tar.gz | 20.1 kB | Without provenance | Details for random-route-generator-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| random_route_generator-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for random_route_generator-1.0.3-py3-none-any.whl |
Total release size: 40.7 kB
Release files / random-route-generator-1.0.3.tar.gz
| Download URL | random-route-generator-1.0.3.tar.gz |
|---|---|
| Size | 20.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
209b2d6ed8060b428f656c865b52ccfdd25993e1761cab359118310b62eed44e
|
|
BLAKE2b-256 checksum How to use checksums |
858a6336d8c2592796a070355a4eb7b4be08744da7c8f4c8e7dc50b4f8f43497
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / random_route_generator-1.0.3-py3-none-any.whl
| Download URL | random_route_generator-1.0.3-py3-none-any.whl |
|---|---|
| Size | 20.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2282534fbfcc5b82237f70383d9d167184a6974ca63be720762adb78bd84810f
|
|
BLAKE2b-256 checksum How to use checksums |
3054d073f6bb377f69d7c69e09a65448d3fe9afc07a25d897291ff93f4946b8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for random-route-generator 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.