velorail API Documentation
gpxviewer
Created on 2025-01-17
@author: wf
GPXViewer
display a given gpx file
Source code in velorail/gpxviewer.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
__init__(args=None)
constructor
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args(argparse.Namespace) |
command line arguments |
required |
Source code in velorail/gpxviewer.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
add_leg(start_point, end_point, leg_type, add_end_point=False, url=None)
Add a leg to the tour
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_point |
GPX point for start of leg |
required | |
end_point |
GPX point for end of leg |
required | |
leg_type |
str
|
Type of leg (e.g., "bike", "train", "car") |
required |
add_end_point |
bool
|
Whether to add the end point (True for last leg) |
False
|
url |
Optional[str]
|
Optional URL associated with the leg |
None
|
Source code in velorail/gpxviewer.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
get_points(gpx, way_points_fallback=False)
Extract waypoints and legs from the GPX object and create a tour
Source code in velorail/gpxviewer.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
load_gpx(gpx_url)
load the given gpx file
Source code in velorail/gpxviewer.py
59 60 61 62 63 64 65 66 | |
parse_lines(lines)
Parse the 'lines' parameter into route segments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lines |
str
|
The input string containing routes in the format: "By bike: 51.243931° N, 6.520022° E, 51.269222° N, 6.625467° E:" |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Tour |
Created tour from the parsed coordinates |
Source code in velorail/gpxviewer.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
parse_lines_and_show(lines, zoom=None)
Parse lines and display them on the map
Source code in velorail/gpxviewer.py
225 226 227 228 229 230 | |
set_center()
Calculate and set the center and bounding box based on tour legs
Source code in velorail/gpxviewer.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
show(zoom=None, center=None)
Show tour with styled paths
Source code in velorail/gpxviewer.py
232 233 234 235 236 237 238 239 240 241 242 243 | |
gpxviewer_server
Created on 2025-01-18
@author: wf
clean_smw_artifacts(input_str)
Remove SMW artifacts ([[SMW::on]] and [[SMW::off]]) from the input string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_str |
str
|
Input string containing SMW artifacts. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Cleaned string without SMW markers. |
Source code in velorail/gpxviewer_server.py
27 28 29 30 31 32 33 34 35 36 37 38 | |
gpx(gpx=None, auth_token=None, zoom=GPXViewer.default_zoom)
GPX viewer page with optional gpx_url and auth_token.
Source code in velorail/gpxviewer_server.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
initialize_viewer()
Initialize the GPXViewer with parsed arguments.
Source code in velorail/gpxviewer_server.py
17 18 19 20 21 22 23 24 | |
lines_page(lines=None, auth_token=None, zoom=GPXViewer.default_zoom)
Endpoint to display routes based on 'lines' parameter.
Source code in velorail/gpxviewer_server.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
main()
Entry point for gpxviewer.
Source code in velorail/gpxviewer_server.py
95 96 97 98 99 100 | |
locfind
Created on 2025-02-01
@author: th
LocFinder
Set of methods to lookup different location types
Source code in velorail/locfind.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
__init__()
constructor
Source code in velorail/locfind.py
105 106 107 108 109 110 111 112 113 114 115 116 | |
get_train_stations_by_coordinates(latitude, longitude, radius)
Get all train stations within the given radius around the given latitude and longitude
Source code in velorail/locfind.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
get_wikidata_geo(qid)
Get geographical coordinates and metadata for a Wikidata item
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qid |
str
|
Wikidata QID of the item |
required |
Returns:
| Type | Description |
|---|---|
WikidataGeoItem
|
WikidataGeoItem with location data and metadata |
Source code in velorail/locfind.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
query(query_name, param_dict={}, endpoint='wikidata-qlever')
get the result of the given query
Source code in velorail/locfind.py
118 119 120 121 122 123 124 125 126 | |
WikidataGeoItem
Dataclass for storing Wikidata geographical location data with labels
Source code in velorail/locfind.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
osm_url: str
property
Get OpenStreetMap URL for this location
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zoom |
Zoom level (default=15) |
required |
Returns:
| Type | Description |
|---|---|
str
|
OpenStreetMap URL for the location |
from_record(record)
classmethod
Create WikidataGeoItem from a dictionary record
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record |
dict
|
Dictionary containing lat, lon, label and description |
required |
Returns:
| Type | Description |
|---|---|
WikidataGeoItem
|
WikidataGeoRecord instance |
Source code in velorail/locfind.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
get_map_links(leg_styles=None, zoom=14)
Get HTML markup with icons grouped by map type
Source code in velorail/locfind.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
tour
Created on 2025-01-19
@author: wf
Tour definition as Legs connecting Locs Styling of Legs
Leg
A segment of a trip between two locations
Source code in velorail/tour.py
31 32 33 34 35 36 37 38 39 40 | |
LegStyle
Style configuration for a transport leg
Source code in velorail/tour.py
81 82 83 84 85 86 87 88 89 90 91 92 93 | |
LegStyles
Collection of predefined styles for different leg types
Source code in velorail/tour.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
default()
classmethod
Get default leg styles
Source code in velorail/tour.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
get_style(leg_type)
Get style for given leg type
Source code in velorail/tour.py
104 105 106 107 108 109 | |
Loc
A location in a trip or tour
Source code in velorail/tour.py
17 18 19 20 21 22 23 24 25 26 27 28 | |
Tour
A sequence of legs connecting waypoints that form a complete journey
Source code in velorail/tour.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
dump(limit=10, leg_styles=None)
Print a detailed dump of the tour for debugging
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit |
int
|
Maximum number of legs to show |
10
|
Source code in velorail/tour.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
velorail_cmd
Created on 2025-02-01
@author: wf
VeloRailCmd
Bases: WebserverCmd
command line handling for velorail
Source code in velorail/velorail_cmd.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
__init__()
constructor
Source code in velorail/velorail_cmd.py
22 23 24 25 26 27 28 | |
getArgParser(description, version_msg)
override the default argparser call
Source code in velorail/velorail_cmd.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
main(argv=None)
main call
Source code in velorail/velorail_cmd.py
73 74 75 76 77 78 79 | |
version
Created on 2025-02-01
@author: wf
Version
dataclass
Version handling for velorail
Source code in velorail/version.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
wditem_search
Created on 2024-01-03
@author: wf
WikidataItemSearch
wikidata item search
Source code in velorail/wditem_search.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
__init__(solution, record_filter=None, lang='en')
Initialize the WikidataItemSearch with the given solution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solution |
WebSolution
|
The solution to attach the search UI. |
required |
record_filter(Callable) |
callback for displayed found records |
required |
Source code in velorail/wditem_search.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
debounced_search()
async
Waits for a period of inactivity and then performs the search.
Source code in velorail/wditem_search.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
get_selection_view_lod(wd_search_result)
Convert the Wikidata search result list of dict to a selection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wd_search_result |
List[Dict[str, Any]]
|
The search results from Wikidata. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
List[Dict[str, Any]]: The list of dictionaries formatted for view. |
Source code in velorail/wditem_search.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
on_search_change(_args)
async
react on changes in the search input
Source code in velorail/wditem_search.py
69 70 71 72 73 74 75 76 77 78 | |
setup()
setup the user interface
Source code in velorail/wditem_search.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
webserver
Created on 2025-02-01
@author: wf
VeloRailSolution
Bases: InputWebSolution
the VeloRail solution
Source code in velorail/webserver.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
__init__(webserver, client)
Initialize the solution
Calls the constructor of the base solution Args: webserver (VeloRailWebServer): The webserver instance associated with this context. client (Client): The client instance this context is associated with.
Source code in velorail/webserver.py
25 26 27 28 29 30 31 32 33 34 35 36 | |
clean_smw_artifacts(input_str)
Remove SMW artifacts ([[SMW::on]] and [[SMW::off]]) from the input string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_str |
str
|
Input string containing SMW artifacts. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Cleaned string without SMW markers. |
Source code in velorail/webserver.py
38 39 40 41 42 43 44 45 46 47 48 49 | |
home()
async
provide the main content page
Source code in velorail/webserver.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
prepare_ui()
overrideable configuration
Source code in velorail/webserver.py
134 135 136 137 138 139 | |
show_gpx(gpx=None, auth_token=None, zoom=GPXViewer.default_zoom)
async
GPX viewer page with optional gpx_url and auth_token.
Source code in velorail/webserver.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
show_lines(lines=None, auth_token=None, zoom=GPXViewer.default_zoom)
async
Endpoint to display routes based on 'lines' parameter.
Source code in velorail/webserver.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
show_wikidata_item(qid=None)
async
show the given wikidata item on the map Args: qid(str): the Wikidata id of the item to analyze
Source code in velorail/webserver.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
VeloRailWebServer
Bases: InputWebserver
WebServer class that manages the server for velorail
Source code in velorail/webserver.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
__init__()
Constructs all the necessary attributes for the WebServer object.
Source code in velorail/webserver.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |