Fast OpenLR location reference decoder for Python. Decodes HERE-encoded OpenLR onto OSM-based road networks using a Rust backend.
pip install openlr-decoderfrom openlr_decoder import RoadNetwork, Decoder
# Load road network from Parquet file
network = RoadNetwork.from_parquet("network.parquet")
decoder = Decoder(network)
# Decode a single OpenLR code
result = decoder.decode("CwRbWyNG9RpsCQCb/jsboAD/6/+E")
print(result.edge_ids, result.length)
# Batch decode (parallel, returns Arrow RecordBatch)
codes = ["CwRbWyNG9RpsCQCb/jsboAD/6/+E", "C7yVyRun2SOPAAAD/94jDw=="]
batch = decoder.decode_batch(codes)
# Convert to Polars
import polars as pl
df = pl.from_arrow(batch)Load networks from Polars DataFrames or PyArrow Tables with no serialization overhead:
import polars as pl
from openlr_decoder import RoadNetwork
df = pl.read_parquet("network.parquet")
network = RoadNetwork.from_arrow(df) # zero-copyThe road network Parquet file must contain these columns:
| Column | Type | Required | Description |
|---|---|---|---|
stableEdgeId |
uint64 | Yes | Unique edge identifier |
startVertex |
int64 | Yes | Start node ID |
endVertex |
int64 | Yes | End node ID |
startLat |
float64 | Yes | Start point latitude |
startLon |
float64 | Yes | Start point longitude |
endLat |
float64 | Yes | End point latitude |
endLon |
float64 | Yes | End point longitude |
highway |
string | Yes | OSM highway tag |
lanes |
int64 | No | Lane count (for FOW inference) |
geometry |
binary (WKB) | No | LineString geometry |
from openlr_decoder import DecoderConfig
config = DecoderConfig(
search_radius_m=100.0, # meters, default 100
max_candidates=10, # per LRP, default 10
length_tolerance=0.35, # fraction, default 0.35
frc_tolerance=2, # FRC class difference, default 2
max_candidate_distance_m=35.0, # meters, default 35
)
decoder = Decoder(network, config)See the Configuration Guide for all 14 parameters.
MIT