Reference¶
ImxCompareMultiRepo
¶
A class for comparing IMX objects across multiple repositories.
TODO: THIS SHOULD ACT MORE LIKE A NORMAL IMX REPO
Attributes:
Name | Type | Description |
---|---|---|
_data |
dict[str, Any]
|
Internal data dictionary for storing comparison results. |
container_order |
Any
|
Order of containers to consider in the comparison. |
diff |
dict[str, list[ChangedImxObject]]
|
Dictionary holding the differences. |
_containers |
list
|
List of containers involved in the comparison. |
get_geojson(object_paths, to_wgs=True)
¶
Generate a GeoJSON feature collection for the specified object paths.
This function creates a list of GeoJSON features from the objects in the specified paths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
object_paths |
list[str]
|
A list of object paths to extract geometry from. |
required |
to_wgs |
bool
|
If True, converts the geometries to WGS84. |
True
|
Returns:
Type | Description |
---|---|
ShapelyGeoJsonFeatureCollection
|
A collection of GeoJSON features. |
create_geojson_files(directory_path, to_wgs=True)
¶
Create GeoJSON files for all objects in the diff dictionary.
This function generates GeoJSON files for each key in the diff dictionary and saves them in the specified directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
directory_path |
str | Path
|
The path to the directory where the files will be saved. |
required |
to_wgs |
bool
|
If True, converts the geometries to WGS84. |
True
|
Change
dataclass
¶
Dataclass for representing any type of change between two dictionaries.
get_object_changes(dict1, dict2)
¶
Compares two dictionaries and returns a dictionary that shows differences, unchanged values, and changes between them.
Utilizes DeepDiff to perform the comparison and includes custom operators to handle specific types like UUIDs and Shapely objects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dict1 |
dict[str, Any]
|
The first dictionary to compare. |
required |
dict2 |
dict[str, Any]
|
The second dictionary to compare. |
required |
Returns:
Type | Description |
---|---|
dict[str, Change]
|
A dictionary where keys represent the paths to changed elements, |
dict[str, Change]
|
and values are |
transform_dict(d)
¶
Transforms a dictionary by grouping list items based on their indexed keys.
This function processes a dictionary where keys may contain indexed parts indicating list items (e.g., 'key.0.subkey'). It transforms the dictionary by consolidating these list items into structured lists under their base paths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
d |
A dictionary with keys that may represent nested structures with indexed list items. |
required |
Returns:
Type | Description |
---|---|
dict[str, Any]
|
A transformed dictionary where indexed list items are grouped under their respective base paths. |
remove_empty_dicts(data)
¶
Recursively removes empty dictionaries from a nested data structure.
This function traverses through a nested dictionary or list and removes
any dictionary where all values are None
. It handles arbitrarily
deep nesting of dictionaries and lists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
dict | list | Any
|
The input data structure, which can be a dictionary, list, or any other type. |
required |
Returns:
Type | Description |
---|---|
dict | Any
|
The cleaned data structure with empty dictionaries removed. |
parse_dict_to_value_objects(input_dict)
¶
Parses GML elements in the input dictionary to Shapely objects or converts string representations of numbers to their respective types.
This function processes each key-value pair in the input dictionary, converting string representations of coordinates into Shapely geometry objects and strings containing numeric values to their respective numeric types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_dict |
dict[str, Any]
|
A dictionary where keys are strings and values can be GML elements, numeric strings, or any other types. |
required |
Returns:
Type | Description |
---|---|
dict[str, Any]
|
A dictionary with GML elements converted to Shapely objects and numeric strings |
dict[str, Any]
|
converted to their respective types (int or float). |
convert_deepdiff_path(deepdiff_path)
¶
Converts a DeepDiff path to a dot-separated path format using regular expressions.
This function takes a DeepDiff path and transforms it into a dot-separated format by removing unnecessary characters and adjusting the path representation for easier use.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deepdiff_path |
str
|
A string representing the path from DeepDiff, typically formatted with brackets and quotes. |
required |
Returns:
Type | Description |
---|---|
str
|
A string representing the converted path in a dot-separated format. |
merge_dict_keep_first_key(d)
¶
Merges a dictionary by keeping the first occurrence of each key (case-insensitive).
This function processes a dictionary and merges keys while preserving the first key's original case. If duplicate keys (case-insensitive) are found, their values are merged based on their types: - Lists are concatenated. - Dictionaries are merged recursively. - Other values are replaced by the most recent occurrence.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
d |
dict
|
The dictionary to be merged, where keys may have different cases. |
required |
Returns:
Type | Description |
---|---|
dict
|
A new dictionary with merged keys and values, maintaining the first key's original case. |