Skip to content

Table of Contents

georouting.utils

convert_to_list

1
def convert_to_list(data)

This function converts the data to a list.

get_batch_od_pairs

1
def get_batch_od_pairs(orgins, destinations, max_batch_size=25)

This function returns a list of dataframes containing the origin-destination pairs to avoid the repeated requests to the travel distance API.

build_geofabrik_region_index

1
2
3
4
5
6
7
def build_geofabrik_region_index(cache_path=DEFAULT_GEOFABRIK_CACHE,
                                 refresh=False,
                                 include_sizes=False,
                                 regions=None,
                                 verbose=False,
                                 size_timeout=10,
                                 prefer_html=False)

Build a mapping of region slug -> {url, size_bytes?, size_gb?} using Geofabrik index-v1.json. Saves to cache_path (JSON) for reuse unless refresh=True.

build_geofabrik_catalog

1
2
3
4
5
6
7
def build_geofabrik_catalog(cache_path=DEFAULT_GEOFABRIK_CATALOG,
                            refresh=False,
                            include_sizes=True,
                            regions=None,
                            size_timeout=10,
                            verbose=False,
                            prefer_html=True)

Return a list of all Geofabrik PBF datasets with URLs (and sizes if requested). Caches the result to JSON for reuse.

resolve_geofabrik_pbf

1
def resolve_geofabrik_pbf(region, refresh=True, include_size=False)

Resolve a region string to a Geofabrik PBF URL using the catalog; fallback to slug/path.

render_osrm_dockerfile

1
2
3
4
5
6
7
def render_osrm_dockerfile(region="north-america/us/massachusetts",
                           port=DEFAULT_OSRM_PORT,
                           base_image=DEFAULT_OSRM_BASE_IMAGE,
                           auto_fetch=True,
                           prefer_html=True,
                           size_timeout=10,
                           profile="car")

Render a Dockerfile string for an OSRM backend for the given region/profile.

Parameters

region : str Geofabrik region slug/path (e.g., "north-america/us/massachusetts"). port : int Port to expose in the container. base_image : str OSRM base image to use. auto_fetch : bool If True, refresh Geofabrik index when resolving region. prefer_html : bool Unused here; kept for parity with resolver options. size_timeout : int Timeout (seconds) for size resolution (currently unused in rendering). profile : str OSRM profile name or path (e.g., "car", "foot", "bicycle" or a lua path).

write_osrm_dockerfile

1
def write_osrm_dockerfile(path="Dockerfile", **kwargs)

Write the rendered OSRM Dockerfile to disk and print a preview.

build_osrm_image

1
2
3
def build_osrm_image(tag="osrm-backend",
                     dockerfile_path="Dockerfile",
                     context=".")

Build the OSRM Docker image using the given Dockerfile and context.

run_osrm_container

1
2
3
4
def run_osrm_container(tag="osrm-backend",
                       port=DEFAULT_OSRM_PORT,
                       detach=True,
                       extra_args=None)

Run the OSRM container exposing the selected port.

build_and_run_osrm

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
def build_and_run_osrm(region="north-america/us/massachusetts",
                       port=DEFAULT_OSRM_PORT,
                       tag="osrm-backend",
                       dockerfile_path=None,
                       context=None,
                       auto_fetch=True,
                       prefer_html=True,
                       size_timeout=10,
                       detach=True,
                       extra_run_args=None,
                       base_image=DEFAULT_OSRM_BASE_IMAGE,
                       profile="car")

One-shot: write Dockerfile, build image, run container for the given region.