Source code for nrel.hive.model.roadnetwork.link

from __future__ import annotations

from typing import NamedTuple, Optional

import h3

from nrel.hive.model.roadnetwork.linktraversal import LinkTraversal
from nrel.hive.util.h3_ops import H3Ops
from nrel.hive.util.typealiases import LinkId, GeoId
from nrel.hive.util.units import (
    Kilometers,
    Kmph,
    Seconds,
    Ratio,
    hours_to_seconds,
)





[docs]def interpolate_between_geoids(a: GeoId, b: GeoId, ratio: Ratio) -> GeoId: """ Interpolate between two geoids given a ratio from a->b :param a: The starting point :param b: The ending point :param ratio: The ratio from a->b :return: An interpolated GeoId """ line = h3.h3_line(a, b) index = int(len(line) * ratio) return line[index]