Skip to content

Commit

Permalink
added lines argument to add_xml_location in checks
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Wenninger <johannes.wenninger@lcm.at>
  • Loading branch information
johannesWen committed Dec 18, 2024
1 parent 7d9e418 commit a1b29b8
Show file tree
Hide file tree
Showing 21 changed files with 54 additions and 8 deletions.
1 change: 1 addition & 0 deletions qc_opendrive/checks/basic/fileheader_is_present.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ def check_rule(checker_data: models.CheckerData) -> None:
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(root),
description=f"No child element header",
lines=root.sourceline,
)
1 change: 1 addition & 0 deletions qc_opendrive/checks/basic/root_tag_is_opendrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ def check_rule(checker_data: models.CheckerData) -> bool:
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(root),
description=f"Root is not OpenDRIVE",
lines=root.sourceline,
)
1 change: 1 addition & 0 deletions qc_opendrive/checks/basic/version_is_defined.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ def check_rule(checker_data: models.CheckerData) -> bool:
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(file_header_tag),
description=f"Header tag has invalid or missing version info",
lines=file_header_tag.sourceline,
)
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def _check_all_roads(checker_data: models.CheckerData) -> None:
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(geometry),
description=f"Length does not match the actual curve length. The estimated absolute error from numerical integration is {estimated_error}",
lines=geometry.sourceline,
)

s_coordinate = utils.get_s_from_geometry(geometry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def _check_all_roads(checker_data: models.CheckerData) -> None:
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(geometry),
description=f"Length does not match the actual curve length. The estimated absolute error from numerical integration is {estimated_error}",
lines=geometry.sourceline,
)

s_coordinate = utils.get_s_from_geometry(geometry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def _check_all_roads(checker_data: models.CheckerData) -> None:
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(geometry),
description=f"Length does not match the actual curve length. The estimated absolute error from numerical integration is {estimated_error}",
lines=geometry.sourceline,
)

s_coordinate = utils.get_s_from_geometry(geometry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def _raise_issue(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(left_lane),
description=f"Outer lane border intersects or stays within inner lane border.",
lines=left_lane.sourceline,
)

checker_data.result.add_xml_location(
Expand All @@ -138,6 +139,7 @@ def _raise_issue(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(right_lane),
description=f"Outer lane border intersects or stays within inner lane border.",
lines=right_lane.sourceline,
)

s_section = utils.get_s_from_lane_section(lane_section_with_length.lane_section)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def _check_road_superelevations(
current_superelevation.xml_element
),
description=f"Redundant superelevation declaration.",
lines=current_superelevation.xml_element.sourceline,
)

checker_data.result.add_xml_location(
Expand All @@ -56,6 +57,7 @@ def _check_road_superelevations(
next_superelevation.xml_element
),
description=f"Redundant superelevation declaration.",
lines=next_superelevation.xml_element.sourceline,
)

inertial_point = utils.get_point_xyz_from_road_reference_line(
Expand Down Expand Up @@ -97,6 +99,7 @@ def _check_road_elevations(
current_elevation.xml_element
),
description=f"Redundant elevation declaration.",
lines=current_elevation.xml_element.sourceline,
)

checker_data.result.add_xml_location(
Expand All @@ -107,6 +110,7 @@ def _check_road_elevations(
next_elevation.xml_element
),
description=f"Redundant elevation declaration.",
lines=next_elevation.xml_element.sourceline,
)

inertial_point = utils.get_point_xyz_from_road_reference_line(
Expand Down Expand Up @@ -148,6 +152,7 @@ def _check_lane_offsets(
current_lane_offset.xml_element
),
description=f"Redundant lane offset declaration.",
lines=current_lane_offset.xml_element.sourceline,
)

checker_data.result.add_xml_location(
Expand All @@ -158,6 +163,7 @@ def _check_lane_offsets(
next_lane_offset.xml_element
),
description=f"Redundant lane offset declaration.",
lines=next_lane_offset.xml_element.sourceline,
)

s = next_lane_offset.s_offset
Expand Down Expand Up @@ -212,6 +218,7 @@ def _check_road_plan_view(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(current_geometry),
description=f"Redundant line geometry declaration.",
lines=current_geometry.sourceline,
)

checker_data.result.add_xml_location(
Expand All @@ -220,6 +227,7 @@ def _check_road_plan_view(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(next_geometry),
description=f"Redundant line geometry declaration.",
lines=next_geometry.sourceline,
)

s_offset = utils.get_s_from_geometry(next_geometry)
Expand Down Expand Up @@ -266,6 +274,7 @@ def _check_lane_widths(
current_width.xml_element
),
description=f"Redundant lane width declaration.",
lines=current_width.xml_element.sourceline,
)

checker_data.result.add_xml_location(
Expand All @@ -274,6 +283,7 @@ def _check_lane_widths(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(next_width.xml_element),
description=f"Redundant lane width declaration.",
lines=next_width.xml_element.sourceline,
)

s_section = utils.get_s_from_lane_section(lane_section)
Expand Down Expand Up @@ -326,6 +336,7 @@ def _check_lane_borders(
current_border.xml_element
),
description=f"Redundant lane border declaration.",
lines=current_border.xml_element.sourceline,
)

checker_data.result.add_xml_location(
Expand All @@ -334,6 +345,7 @@ def _check_lane_borders(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(next_border.xml_element),
description=f"Redundant lane border declaration.",
lines=next_border.xml_element.sourceline,
)

s_section = utils.get_s_from_lane_section(lane_section)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def _check_junctions_connection_connect_road_no_incoming_road(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(connection),
description="Connection with connecting road found as incoming road.",
lines=connection.sourceline,
)

successor_junction_id = utils.get_linked_junction_id(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def _raise_issue(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(connection),
description=f"Contact point 'end' not used on successor road connection.",
lines=connection.sourceline,
)

inertial_point = utils.get_end_point_xyz_from_road_reference_line(connection_road)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def _check_junctions_connection_one_connection_element(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(connection),
description="Connection with reused connecting road id.",
lines=connection.sourceline,
)

connecting_road = road_id_map.get(connecting_road_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def _raise_lane_linkage_issue(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(lane_link),
description=f"Lane link in opposite direction.",
lines=lane_link.sourceline,
)

s = None
Expand Down Expand Up @@ -562,6 +563,7 @@ def _check_junctions_connection_one_link_to_incoming(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(connection),
description=f"Connection with reused (incoming_road_id, connecting_road_id) = ({incoming_road_id}, {connecting_road_id}) pair.",
lines=connection.sourceline,
)

has_start_contact_point = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def _raise_issue(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(connection),
description=f"Contact point 'start' not used on predecessor road connection.",
lines=connection.sourceline,
)

inertial_point = utils.get_start_point_xyz_from_road_reference_line(connection_road)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def _check_all_roads(checker_data: models.CheckerData) -> None:
issue_id=issue_id,
xpath=path,
description=f"First encounter of {current_rule} having {previous_rule} before.",
lines=access.sourceline,
)

if s_section is None:
Expand Down
25 changes: 17 additions & 8 deletions qc_opendrive/checks/semantic/road_lane_level_true_one_side.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def _check_true_level_on_side(
issue_id=issue_id,
xpath=path,
description=f"Lane id {index} @level=False where previous lane id @level=True.",
lines=lane.sourceline,
)

s_section = utils.get_s_from_lane_section(
Expand Down Expand Up @@ -95,7 +96,8 @@ def _get_linkage_level_warnings(
target_lane_section: etree._ElementTree,
linkage_tag: models.LinkageTag,
):
warnings: Set[str] = set()
warnings: List[str] = []
warnings_linenr: List[int] = []

for lane in utils.get_left_and_right_lanes_from_lane_section(current_lane_section):
lane_level = utils.get_lane_level_from_lane(lane)
Expand All @@ -114,9 +116,10 @@ def _get_linkage_level_warnings(
linkage_level = utils.get_lane_level_from_lane(linkage_lane)

if linkage_level != lane_level:
warnings.add(root.getpath(lane))
warnings.append(root.getpath(lane))
warnings_linenr.append(lane.sourceline)

return warnings
return warnings, warnings_linenr


def _check_level_change_between_lane_sections(
Expand All @@ -136,23 +139,24 @@ def _check_level_change_between_lane_sections(
function will register the issue twice, one for each linkage.
"""

predecessor_warnings = _get_linkage_level_warnings(
predecessor_warnings, predecessor_warnings_linenr = _get_linkage_level_warnings(
root=root,
current_lane_section=current_lane_section,
target_lane_section=previous_lane_section,
linkage_tag=models.LinkageTag.PREDECESSOR,
)
successor_warnings = _get_linkage_level_warnings(
successor_warnings, successor_warnings_linenr = _get_linkage_level_warnings(
root=root,
current_lane_section=previous_lane_section,
target_lane_section=current_lane_section,
linkage_tag=models.LinkageTag.SUCCESSOR,
)

warnings = predecessor_warnings | successor_warnings
warnings = sorted(list(warnings))
warnings = predecessor_warnings + successor_warnings
warnings_linenr = predecessor_warnings_linenr + successor_warnings_linenr
warnings_sorted = sorted(zip(warnings, warnings_linenr), key=lambda x: x[1])

for warning in warnings:
for warning, warning_linenr in warnings_sorted:
issue_id = result.register_issue(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
Expand All @@ -166,6 +170,7 @@ def _check_level_change_between_lane_sections(
issue_id=issue_id,
xpath=warning,
description="Lane levels are not the same in two consecutive lane sections",
lines=warning_linenr,
)


Expand Down Expand Up @@ -230,6 +235,7 @@ def _check_level_change_linkage_roads(
issue_id=issue_id,
xpath=root.getpath(lane),
description="Lane levels are not the same between two connected roads.",
lines=lane.sourceline,
)

result.add_xml_location(
Expand All @@ -238,6 +244,7 @@ def _check_level_change_linkage_roads(
issue_id=issue_id,
xpath=root.getpath(other_lane),
description="Lane levels are not the same between two connected roads.",
lines=other_lane.sourceline,
)

s = None
Expand Down Expand Up @@ -407,6 +414,7 @@ def _check_level_among_junctions(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(incoming_lane),
description="Lane levels are not the same between incoming road and junction.",
lines=incoming_lane.sourceline,
)

checker_data.result.add_xml_location(
Expand All @@ -415,6 +423,7 @@ def _check_level_among_junctions(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(connection_lane),
description="Lane levels are not the same between incoming road and junction.",
lines=connection_lane.sourceline,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def _check_two_lane_sections_one_direction(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(connecting_lane),
description="Missing lane link.",
lines=connecting_lane.sourceline,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def _raise_issue(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(lane),
description=f"Lane with {linkage_tag.value} with width zero.",
lines=lane.sourceline,
)

checker_data.result.add_xml_location(
Expand All @@ -52,6 +53,7 @@ def _raise_issue(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(width_zero_lane),
description=f"{linkage_tag.value.capitalize()} lane with width zero.",
lines=width_zero_lane.sourceline,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def _raise_issue(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(lane),
description="Lane with width zero and successors.",
lines=lane.sourceline,
)

s_section = utils.get_s_from_lane_section(lane_section_with_length.lane_section)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def _raise_issue(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(lane),
description="Lane with width zero and predecessors.",
lines=lane.sourceline,
)

s = utils.get_s_from_lane_section(lane_section)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def _raise_road_linkage_is_junction_needed_issue(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(element),
description=f"Road cannot have ambiguous {linkage_tag.value}, a junction is needed.",
lines=element.sourceline,
)

if problematic_road is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ def _raise_geometry_gap_issue(
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(previous_geometry),
description=f"First geometry element",
lines=previous_geometry.sourceline,
)
checker_data.result.add_xml_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
xpath=checker_data.input_file_xml_root.getpath(geometry),
description=f"Second geometry element",
lines=geometry.sourceline,
)

if inertial_point is not None:
Expand Down Expand Up @@ -120,13 +122,15 @@ def _raise_lane_linkage_gap_issue(
issue_id=issue_id,
xpath=issue_xpaths[0],
description=f"First lane element",
lines=previous_lane.sourceline,
)
checker_data.result.add_xml_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
xpath=issue_xpaths[1],
description=f"Next lane element",
lines=current_lane.sourceline,
)

if inertial_point is not None:
Expand Down

0 comments on commit a1b29b8

Please sign in to comment.