<p align="center">
<a href="">
<img src="banner.png" alt="Repository Banner">
</a>
</p>
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](https://pypi.org/project/random-route-generator/). Install it using `pip`:
```bash
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**.
```python
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](https://openrouteservice.org/) - Used to generate the routing between the points
* [Overpass-API](http://overpass-api.de/) - Used for picking a random location
* [gpxpy](https://github.com/tkrajina/gpxpy) - Used for exporting to a GPX file
* [overpy](https://pypi.org/project/overpy/) - Used for communicating with the Overpass-API
* [haversine](https://pypi.org/project/haversine/) - Used for coordinate calculations
## License
[GPL v3.0](https://github.com/oskarkraemer/youtubeWordFinder/blob/main/LICENSE)
Raw data
{
"_id": null,
"home_page": "https://github.com/oskarkraemer/randomRouteGenerator",
"name": "random-route-generator",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "geography,route,random,generator,gpx,gps",
"author": "Oskar Kraemer",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/85/8a/6336d8c2592796a070355a4eb7b4be08744da7c8f4c8e7dc50b4f8f43497/random-route-generator-1.0.3.tar.gz",
"platform": null,
"description": "<p align=\"center\">\r\n <a href=\"\">\r\n <img src=\"banner.png\" alt=\"Repository Banner\">\r\n </a>\r\n</p>\r\n\r\nA Python package to generate a random route with a specified length.\r\n\r\nUtilizes the openrouteservice API to generate the routing and the Overpass API for picking a random location. \r\n\r\n## Installation\r\n\r\nRandom-Route-Generator releases are available as wheel packages for macOS, Windows and Linux on [PyPI](https://pypi.org/project/random-route-generator/). Install it using `pip`:\r\n\r\n```bash\r\npip install random-route-generator\r\n```\r\n\r\n## Example\r\n\r\nThis 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**.\r\n\r\n```python\r\nfrom randomRouteGenerator.route_generator import RouteGenerator\r\nfrom randomRouteGenerator.coordinate import Coordinate\r\n\r\ngenerator = RouteGenerator()\r\n\r\n#Manually set the openrouteservice API key\r\ngenerator.api_key = \"\"\r\n\r\n#OR read the API key from a file\r\n#generator.read_api_key(\"ors_api.key\")\r\n\r\n\r\n#What type of route generation should be used? (See README)\r\ngenerator.routing_profile = \"cycling-mountain\"\r\n\r\n#How many random points should be generated?\"\r\ngenerator.point_amount = 4\r\n\r\n#How should the origin and end point be handled (See RouteGenerator.ROUTE_MODE)?\r\ngenerator.route_mode = generator.ROUTE_MODE.START_END_ORIGIN\r\n\r\n#Which features should be avoided in the route?\r\ngenerator.avoids = [\"ferries\", \"steps\"]\r\n\r\n#Generate the route with the given origin point and maximum length\r\np = generator.generate_route(Coordinate(51.846812, 6.242033), 25000)\r\n\r\n\r\nlength = p.get_length()\r\nduration = p.get_duration()\r\nelevation = p.get_elevation()\r\n\r\n#Retrieve information about the road-types in the route i.e. gravel, paved, ...\r\nprint(p.get_way_info())\r\n\r\n#Print all routing points (all points generated by the routing)\r\nfor x in p.routing_points:\r\n\tprint(x)\r\n\r\n\r\n\r\n#Print all way-points (ONLY the random points whose amount is specified in generator.point_amount)\r\nfor x in p.points:\r\n\tprint(x)\r\n\r\n\r\n#Generate a GPX file containing the route\r\np.generate_gpx_file(filename=\"out.gpx\")\r\n```\r\n\r\n\r\n## Profiles\r\n* driving-car (Regular car routing)\r\n* driving-hgv (Routing for heavy-trucks)\r\n* cycling-regular (Routing for regular cycling)\r\n* cycling-road (Routing for road bikes)\r\n* cycling-mountain (Routing for mountain bikes, prefers offroad tracks)\r\n* cycling-electric (Routing for E-bikes)\r\n\r\n## Credits\r\n\r\n* [openrouteservice](https://openrouteservice.org/) - Used to generate the routing between the points\r\n* [Overpass-API](http://overpass-api.de/) - Used for picking a random location\r\n* [gpxpy](https://github.com/tkrajina/gpxpy) - Used for exporting to a GPX file\r\n* [overpy](https://pypi.org/project/overpy/) - Used for communicating with the Overpass-API\r\n* [haversine](https://pypi.org/project/haversine/) - Used for coordinate calculations\r\n\r\n## License\r\n\r\n[GPL v3.0](https://github.com/oskarkraemer/youtubeWordFinder/blob/main/LICENSE)\r\n",
"bugtrack_url": null,
"license": "GPL-3.0",
"summary": "A Python libary to generate a random route with a specified length.",
"version": "1.0.3",
"project_urls": {
"Homepage": "https://github.com/oskarkraemer/randomRouteGenerator"
},
"split_keywords": [
"geography",
"route",
"random",
"generator",
"gpx",
"gps"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3054d073f6bb377f69d7c69e09a65448d3fe9afc07a25d897291ff93f4946b8d",
"md5": "8a0be8bc3f7f4b66c6309d2500ac533f",
"sha256": "2282534fbfcc5b82237f70383d9d167184a6974ca63be720762adb78bd84810f"
},
"downloads": -1,
"filename": "random_route_generator-1.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8a0be8bc3f7f4b66c6309d2500ac533f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 20616,
"upload_time": "2023-08-09T18:16:45",
"upload_time_iso_8601": "2023-08-09T18:16:45.369240Z",
"url": "https://files.pythonhosted.org/packages/30/54/d073f6bb377f69d7c69e09a65448d3fe9afc07a25d897291ff93f4946b8d/random_route_generator-1.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "858a6336d8c2592796a070355a4eb7b4be08744da7c8f4c8e7dc50b4f8f43497",
"md5": "e5236824fc2f70889ec4368ba9b38414",
"sha256": "209b2d6ed8060b428f656c865b52ccfdd25993e1761cab359118310b62eed44e"
},
"downloads": -1,
"filename": "random-route-generator-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "e5236824fc2f70889ec4368ba9b38414",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 20078,
"upload_time": "2023-08-09T18:16:46",
"upload_time_iso_8601": "2023-08-09T18:16:46.989803Z",
"url": "https://files.pythonhosted.org/packages/85/8a/6336d8c2592796a070355a4eb7b4be08744da7c8f4c8e7dc50b4f8f43497/random-route-generator-1.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-09 18:16:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "oskarkraemer",
"github_project": "randomRouteGenerator",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "random-route-generator"
}