Skip to content

Reference

ImxContainer

Bases: ImxRepo

Represents an IMX container.

Parameters:

Name Type Description Default
imx_file_path Path | str

Path to the IMX container.

required

Attributes:

Name Type Description
files

The IMX files inside the container.

imx_version

Version of the IMX files.

project_metadata

Metadata associated with the project.

dataframes

Pandas dataframes generated from the IMX container.

get_all()

Retrieves all objects in the tree.

Returns:

Type Description
Iterable[ImxObject]

Iterable[ImxObject]: An iterable of all ImxObjects.

find(key)

Finds an object in the tree by its key or ImxObject.

Parameters:

Name Type Description Default
key str | ImxObject

The key or ImxObject to find.

required

Returns:

Type Description
ImxObject | None

ImxObject | None: The found ImxObject, or None if not found.

get_types()

Retrieves all unique object types in the tree.

Returns:

Type Description
list[str]

list[str]: A list of all unique object types.

get_by_types(object_types)

Retrieves objects of specified types from the tree.

Parameters:

Name Type Description Default
object_types list[str]

The list of object types to retrieve.

required

Returns:

Type Description
list[ImxObject]

list[ImxObject]: The list of matching ImxObjects.

get_all_paths()

Retrieves all unique object paths in the tree.

Returns:

Type Description
list[str]

list[str]: A list of all unique object paths.

get_by_paths(object_paths)

Retrieves objects of specified paths from the tree.

Parameters:

Name Type Description Default
object_paths list[str]

The list of object paths to retrieve.

required

Returns:

Type Description
list[ImxObject]

list[ImxObject]: The list of matching ImxObjects.

get_keys()

Returns the set of keys currently in the tree dictionary.

Returns:

Type Description
list[str]

frozenset[str]: The set of keys in the tree dictionary.

get_build_exceptions()

Retrieve build exceptions from the tree structure.

This method returns any build exceptions that occurred during the build process. The result is a dictionary where the keys are strings representing different build steps or processes, and the values are lists of ImxException instances.

Returns:

Type Description
defaultdict[str, list[ImxException]]

A dictionary where the keys represent the build processes step, and the values are lists of ImxException that were raised.

get_pandas_df(object_type_or_path=None, puic_as_index=True)

Get Pandas dataframe of one value object type or limited view of all objects.

When using an object type or path, all properties will be flattened. When getting a dataframe of all objects, most attributes will be stripped except for some metadata. In both cases, it will include parent puic, path.

Parameters:

Name Type Description Default
object_type_or_path str | None

path or imx type to get df of

None
puic_as_index bool

if true puic value will be the index

True

Returns:

Type Description
DataFrame

pd.DataFrame: pandas dataframe of the object properties

get_pandas_df_dict(key_based_on_type=False)

Get a dictionary of Pandas dataframe of all type bases on keys or path.

Parameters:

Name Type Description Default
key_based_on_type bool

if true key based on type, else on path

False

Returns: dictionary of pandas dataframe

get_geojson(object_path, to_wgs=True, extension_properties=False)

Generate a GeoJSON feature collection from a list of object types or paths.

Parameters:

Name Type Description Default
object_path list[str]

A list of object paths used to fetch the corresponding data.

required
to_wgs bool

convert to WGS84

True
extension_properties bool

add extension properties to geojson

False

Returns:

Name Type Description
ShapelyGeoJsonFeatureCollection ShapelyGeoJsonFeatureCollection

A GeoJSON feature collection containing the geographical features.

create_geojson_files(directory_path, to_wgs=True, extension_properties=False)

Create GeoJSON files for the specified object types or paths and save them to the given directory.

Parameters:

Name Type Description Default
directory_path str | Path

The directory where the GeoJSON files will be created.

required
to_wgs bool

convert to WGS84

True
extension_properties bool

add extension properties to geojson

False

ImxContainerMetadata dataclass

from_element(element) staticmethod

Creates an ImxContainerMetadata instance from an XML element.

Parameters:

Name Type Description Default
element Optional[Union[_Element, _ElementTree]]

The XML element containing project metadata.

required

Returns:

Type Description
Optional[ImxContainerMetadata]

Optional[ImxContainerMetadata]: An instance of ImxContainerMetadata or None if the element is None.

ImxContainerFiles

A data class representing a collection of IMX container files.

Info

This class holds references to various IMX design files and additional files that might be included in an IMX container.

Attributes:

Name Type Description
manifest ImxFile | None

The manifest file.

signaling_design ImxDesignCoreFile | None

The signaling design file.

furniture ImxDesignPetalFile | None

The furniture file.

train_control ImxDesignPetalFile | None

The train control file.

management_areas ImxDesignPetalFile | None

The management areas file.

installation_design ImxDesignPetalFile | None

The installation design file.

network_configuration ImxDesignPetalFile | None

The network configuration file.

schema_layout ImxDesignPetalFile | None

The schema layout file.

railway_electrification ImxDesignPetalFile | None

The railway electrification file.

bgt ImxDesignPetalFile | None

The BGT file.

observations ImxDesignPetalFile | None

The observations file.

additional_files list[Any]

Additional files.

ImxDesignCoreFile

Bases: ImxContainerFile

Represents an IMX design core file, extending ImxContainerFile.

Parameters:

Name Type Description Default
imx_file_path Path

The path to the IMX file.

required
file_id str | None

Optional file ID.

required

previous_versions: list[ImxContainerFileReference] property

Gets the previous version file references, if present.

Returns:

Type Description
list[ImxContainerFileReference]

The previous versions.

reference_date: datetime.datetime | None property

Gets the reference date attribute from the XML root element.

Returns:

Type Description
datetime | None

The reference date if found, else None.

perspective_date: datetime.datetime | None property

Gets the perspective date attribute from the XML root element.

Returns:

Type Description
datetime | None

The perspective date if found, else None.

ImxDesignPetalFile

Bases: ImxContainerFile

Represents an IMX design petal file, should extend a ImxDesignCoreFile repo.

Parameters:

Name Type Description Default
imx_file_path Path

The path to the IMX file.

required
file_id str | None

Optional file ID.

required

previous_versions: list[ImxContainerFileReference] property

Gets the previous version file references, if present.

Returns:

Type Description
list[ImxContainerFileReference]

The previous versions.

base_reference: ImxContainerFileReference | None property

Gets the base reference file reference, if available.

Returns:

Type Description
ImxContainerFileReference | None

The BaseReference of the petal file.

ImxContainerFile

Bases: ImxFile

Represents a base class for IMX container files.

Parameters:

Name Type Description Default
imx_file_path Path

The path to the IMX file.

required
file_id str | None

Optional file ID.

None

previous_versions: list[ImxContainerFileReference] property

Gets the previous version file references, if present.

Returns:

Type Description
list[ImxContainerFileReference]

The previous versions.