1
2
3
4
5
6
7
8
9
10
11
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
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
"""
Type stubs for pysochrone — the compiled Rust extension.
All GeoJSON return values are strings. Parse them with ``json.loads``.
"""
# ---------------------------------------------------------------------------
# Graph object
# ---------------------------------------------------------------------------
"""
A road-network graph loaded from OpenStreetMap.
Obtain via :func:`build_graph`. Reuse across multiple queries to avoid
redundant cache lookups.
Attributes are read-only; all mutations happen inside Rust.
"""
"""Number of nodes in the graph."""
...
"""Number of directed edges in the graph."""
...
"""
Return ``(osm_id, lat, lon)`` for the node nearest to ``(lat, lon)``.
Uses the internal R-tree spatial index — O(log n).
Returns ``None`` if the graph is empty.
"""
...
"""
Compute isochrones from ``(lat, lon)`` using this graph.
Parameters
----------
lat, lon:
Origin coordinates.
time_limits:
Travel-time thresholds in **seconds**.
hull_type:
``"Convex"`` | ``"FastConcave"`` | ``"Concave"``
Returns
-------
list[str]
One GeoJSON geometry string per time limit, in the same order
as ``time_limits``.
"""
...
"""
Find the fastest route between two coordinates using A*.
The network type (drive/walk/bike) is inherited from the ``Graph``.
Returns
-------
str
GeoJSON ``Feature`` (LineString) with properties:
- ``distance_m`` (float) — total route distance in metres
- ``duration_s`` (float) — total travel time in seconds
- ``cumulative_times_s`` (list[float]) — elapsed time at each waypoint
"""
...
"""
Fetch OSM points of interest within a given isochrone polygon.
Parameters
----------
isochrone_geojson:
A GeoJSON geometry string, e.g. from :meth:`isochrones`.
Returns
-------
str
GeoJSON ``FeatureCollection``; each feature is a POI ``Point``
with raw OSM tags as properties.
"""
...
"""
All graph nodes as a GeoJSON ``FeatureCollection`` of ``Point`` features.
Properties per feature: ``id``, ``lat``, ``lon``.
"""
...
"""
All graph edges as a GeoJSON ``FeatureCollection`` of ``LineString`` features.
Properties per feature: ``highway``, ``length_m``, ``speed_kph``,
``drive_time_s``, ``walk_time_s``, ``bike_time_s``.
"""
...
...
# ---------------------------------------------------------------------------
# Module-level functions
# ---------------------------------------------------------------------------
"""
Build and return a road-network :class:`Graph` for the area around ``(lat, lon)``.
The graph is cached — repeated calls for the same area and network type
return the in-memory graph with no network I/O.
Parameters
----------
lat, lon:
Centre of the query area.
network_type:
``"Drive"`` | ``"DriveService"`` | ``"Walk"`` | ``"Bike"`` |
``"All"`` | ``"AllPrivate"``
max_dist:
Bounding-box radius in metres. Default: 5 000 m.
retain_all:
Skip topological simplification. Preserves every OSM node and edge;
slower for downstream computation.
"""
...
"""
Compute isochrones from a single origin point.
Parameters
----------
lat, lon:
Origin coordinates.
time_limits:
Travel-time thresholds in **seconds**.
network_type:
``"Drive"`` | ``"DriveService"`` | ``"Walk"`` | ``"Bike"`` |
``"All"`` | ``"AllPrivate"``
hull_type:
``"Convex"`` | ``"FastConcave"`` | ``"Concave"``
max_dist:
Bounding-box radius in metres. When ``None``, auto-sized from the
largest time limit.
retain_all:
Skip topological simplification.
Returns
-------
list[str]
One GeoJSON geometry string per time limit, in the same order as
``time_limits``.
"""
...
"""
Find the fastest route between two coordinates using A*.
Parameters
----------
origin_lat, origin_lon:
Origin coordinates.
dest_lat, dest_lon:
Destination coordinates.
network_type:
``"Drive"`` | ``"DriveService"`` | ``"Walk"`` | ``"Bike"`` |
``"All"`` | ``"AllPrivate"``
max_dist:
Bounding-box radius. When ``None``, uses
``max(5000, 1.5 × straight-line distance)``.
retain_all:
Skip topological simplification.
Returns
-------
str
GeoJSON ``Feature`` (LineString) with properties:
- ``distance_m`` (float) — total route distance in metres
- ``duration_s`` (float) — total travel time in seconds
- ``cumulative_times_s`` (list[float]) — elapsed time at each waypoint,
starting at ``0.0`` and ending at ``duration_s``
"""
...
"""
Convert a place name to ``(lat, lon)`` via the Nominatim API.
Parameters
----------
place:
Any Nominatim-supported query string (e.g. ``"Marienplatz, Munich, Germany"``).
Returns
-------
tuple[float, float]
``(latitude, longitude)``
"""
...
"""
Fetch OSM points of interest that fall within a given isochrone polygon.
Parameters
----------
isochrone_geojson:
A GeoJSON geometry string, e.g. from :func:`calc_isochrones`.
Returns
-------
str
GeoJSON ``FeatureCollection``; each feature is a POI ``Point`` with
raw OSM tags as properties.
"""
...
"""
Return the path to the on-disk XML cache directory.
Override the default by setting the ``OSM_GRAPH_CACHE_DIR`` environment variable.
"""
...
"""
Clear both the in-memory (graph and XML) caches and the on-disk XML cache.
"""
...