Skip to main content

Low level Python library for handling BSSD data within Lanelet2 maps

Project description

BSSD Core

IMPORTANT NOTE This repository is part of the Behavior-Semantic Scenery Description (BSSD) framework. Check out our BSSD documentation and overview repository in your git of choice: GitLab GitHub

This is a low-level Python library for creating and managing the BSSD elements within the BSSD extension for Lanelet2 maps. The BSSD Core is based on PyOsmium, a module that provides access to some features of the C++ library Osmium from Python code. It offers various functions for processing OpenStreetMap (OSM) data - that means also Lanelet2 data - quickly and flexibly. PyOsmium or Osmium specializes in processing the ways, nodes and relations elements available in OSM. The BSSD Core builds on this library and provides functions that are adapted for BSSD elements. Classes are provided for the BSSD elements of the BSSD extension for Lanelet2. These classes already offer integrated attributes according to the data structure of the BSSD extension for Lanelet2. The BSSD core therefore makes it possible to create instances of BSSD elements and set their attributes. In addition, members can be added using simple methods without knowing the correct syntax of the member elements in OSM. Since the instances of BSSD elements created in this way are translated internally into relations from OSM, it is possible to save them in an OSM file using the write functions of PyOsmium.

Installation

Using pip

pip install bssd-core

This will install the latest version of the BSSD Core library available in PyPI to your environment.

Manual Installation

Clone the source code to a directory of your choice (path/to/bssd-core-src/).

If you are using virtual environments, make sure to activate the correct environment to install the library into e.g:

source /<path-to-my-project>/.venv/bin/activate

Install the library:

pip install -e path/to/bssd-core-src/

Usage

The package is build as an extension of PyOsmium. Following is a simple example on how to use the library. The referenced objects from the handler are only temporary. If data is wished to be stored it must be copied out.

import osmium
from bssd.core import BSSDHandler, Reservation
from bssd.core import mutable


class Handler(BSSDHandler):
    def __init__(self):
        super().__init__()
        self.writer = osmium.SimpleWriter("out.osm")

    # callback function for reservations
    def reservation(self, r: Reservation):
        # r is readonly, to change r it must be converted
        r: mutable.Reservation = r.make_mutable()
        r.bicycle = True
        # write the changed reservation to the output file
        self.writer.add_relation(r.get_osmium())


if __name__ == "__main__":
    h = Handler()
    h.apply_file("in.osm")

NOTE For a more application-oriented example, take also a look at the integration of the BSSD Core in the tool Lanelet2 BSSD Converter using a git of your choice: GitLab GitHub

BSSDHandler Callback Functions

These callback functions need to be implemented in the inheriting class to be used. The function will receive the specified objects after calling apply_file(). The relation callback can be used to read non BSSD elements.

  • behavior_space(core.BehaviorSpace)
  • behavior(core.Behavior)
  • boundary_lat(core.BoundaryLat)
  • boundary_long(core.BoundaryLong)
  • reservation(core.Reservation)
  • relation(osm.Relation)

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

bssd_core-2025.1.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bssd_core-2025.1-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file bssd_core-2025.1.tar.gz.

File metadata

  • Download URL: bssd_core-2025.1.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.10

File hashes

Hashes for bssd_core-2025.1.tar.gz
Algorithm Hash digest
SHA256 26d57df56058cbdb12371a536c6156225c87e7fc13678060e79f56e9f56eea0b
MD5 128c618dda0546a980d6e71130c3b3d2
BLAKE2b-256 d262fe317589975844dfaa7f95d29e0f0acb5bbfd74870e257c36bbf7881f8a0

See more details on using hashes here.

File details

Details for the file bssd_core-2025.1-py3-none-any.whl.

File metadata

  • Download URL: bssd_core-2025.1-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.10

File hashes

Hashes for bssd_core-2025.1-py3-none-any.whl
Algorithm Hash digest
SHA256 93e5a66474632c513f5a304a395bc09330a1b492a523c7e0715194a401828b43
MD5 92d60156fd9f555fd4413e4abef281cb
BLAKE2b-256 49cdd8d35b066ea6d76c3db81638173b76805aaeb5fbc7e90697b9e82988ea86

See more details on using hashes here.

Supported by

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