Skip to main content

Python bindings for liblrs: a library to work with linear referencing systems

Project description

LibLRS Python

Expose liblrs through pyO3.

Usage

Simply add liblrs-python to your dependencies.

import liblrs_python as lrs

plm = lrs.Lrs(open("path_to_your_lrs_file", "rb").read())

# We build a dict mapping for each LRM id to its handle
lrms = {plm.get_lrm_scale_id(i): i for i in range(plm.lrm_len())}

# We find the handle for the Via Aurelia (https://en.wikipedia.org/wiki/Via_Aurelia)
via_aurelia_handle = [v for k,v in lrms.items() if k.startswith("Via Aurelia")][0]

# We define two measures meaning “100 passus after milestone 50”
# (passus = step in latin, could be any measurement unit)
a = lrs.LrmScaleMeasure("50", 100)
b = lrs.LrmScaleMeasure("60", 200)

# Get the coordinates between those two measures
coordinates = [[p.x, p.y] for p in plm.resolve_range(via_aurelia_handle, a, b)]

Developpment

Create your virtualenv and install maturin:

python -m venv venv-liblrs
source venv-liblrs/bin/activate
pip install
maturin develop

Bindings with PyO3 to liblrs

Publishing

We publish the library to PYPI running:

docker run --rm -e MATURIN_PYPI_TOKEN=PYPI_key -w /io/python -v $(pwd)/..:/io ghcr.io/pyo3/maturin publish

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

liblrs_python-0.1.7.tar.gz (51.2 kB view hashes)

Uploaded Source

Built Distribution

liblrs_python-0.1.7-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page