Skip to content

Commit

Permalink
Merge pull request #124 from johannesWen/main
Browse files Browse the repository at this point in the history
Add file location from XML elements to the issues in checks
  • Loading branch information
andreaskern74 authored Jan 8, 2025
2 parents 7d9e418 + dae5d1f commit ab7485a
Show file tree
Hide file tree
Showing 21 changed files with 400 additions and 8 deletions.
9 changes: 9 additions & 0 deletions qc_opendrive/checks/basic/fileheader_is_present.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,12 @@ def check_rule(checker_data: models.CheckerData) -> None:
xpath=checker_data.input_file_xml_root.getpath(root),
description=f"No child element header",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=root.sourceline,
column=0,
description="No child element header",
)
9 changes: 9 additions & 0 deletions qc_opendrive/checks/basic/root_tag_is_opendrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,12 @@ def check_rule(checker_data: models.CheckerData) -> bool:
xpath=checker_data.input_file_xml_root.getpath(root),
description=f"Root is not OpenDRIVE",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=root.sourceline,
column=0,
description="Root is not OpenDRIVE",
)
9 changes: 9 additions & 0 deletions qc_opendrive/checks/basic/version_is_defined.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,12 @@ def check_rule(checker_data: models.CheckerData) -> bool:
xpath=checker_data.input_file_xml_root.getpath(file_header_tag),
description=f"Header tag has invalid or missing version info",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=file_header_tag.sourceline,
column=0,
description="Header tag has invalid or missing version info",
)
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ def _check_all_roads(checker_data: models.CheckerData) -> None:
description=f"Length does not match the actual curve length. The estimated absolute error from numerical integration is {estimated_error}",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=geometry.sourceline,
column=0,
description=f"Length does not match the actual curve length. The estimated absolute error from numerical integration is {estimated_error}",
)

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

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=geometry.sourceline,
column=0,
description=f"Length does not match the actual curve length. The estimated absolute error from numerical integration is {estimated_error}",
)

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

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=geometry.sourceline,
column=0,
description=f"Length does not match the actual curve length. The estimated absolute error from numerical integration is {estimated_error}",
)

s_coordinate = utils.get_s_from_geometry(geometry)
if s_coordinate is None:
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ def _raise_issue(
description=f"Outer lane border intersects or stays within inner lane border.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=left_lane.sourceline,
column=0,
description=f"Outer lane border intersects or stays within inner lane border.",
)

checker_data.result.add_xml_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
Expand All @@ -140,6 +149,15 @@ def _raise_issue(
description=f"Outer lane border intersects or stays within inner lane border.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=right_lane.sourceline,
column=0,
description=f"Outer lane border intersects or stays within inner lane border.",
)

s_section = utils.get_s_from_lane_section(lane_section_with_length.lane_section)

if s_section is None:
Expand Down
108 changes: 108 additions & 0 deletions qc_opendrive/checks/performance/performance_avoid_redundant_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ def _check_road_superelevations(
description=f"Redundant superelevation declaration.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=current_superelevation.xml_element.sourceline,
column=0,
description=f"Redundant superelevation declaration.",
)

checker_data.result.add_xml_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
Expand All @@ -58,6 +67,15 @@ def _check_road_superelevations(
description=f"Redundant superelevation declaration.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=next_superelevation.xml_element.sourceline,
column=0,
description=f"Redundant superelevation declaration.",
)

inertial_point = utils.get_point_xyz_from_road_reference_line(
road, next_superelevation.s_offset
)
Expand Down Expand Up @@ -99,6 +117,15 @@ def _check_road_elevations(
description=f"Redundant elevation declaration.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=current_elevation.xml_element.sourceline,
column=0,
description=f"Redundant superelevation declaration.",
)

checker_data.result.add_xml_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
Expand All @@ -109,6 +136,15 @@ def _check_road_elevations(
description=f"Redundant elevation declaration.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=next_elevation.xml_element.sourceline,
column=0,
description=f"Redundant elevation declaration.",
)

inertial_point = utils.get_point_xyz_from_road_reference_line(
road, next_elevation.s_offset
)
Expand Down Expand Up @@ -150,6 +186,15 @@ def _check_lane_offsets(
description=f"Redundant lane offset declaration.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=current_lane_offset.xml_element.sourceline,
column=0,
description=f"Redundant lane offset declaration.",
)

checker_data.result.add_xml_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
Expand All @@ -160,6 +205,15 @@ def _check_lane_offsets(
description=f"Redundant lane offset declaration.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=next_lane_offset.xml_element.sourceline,
column=0,
description=f"Redundant lane offset declaration.",
)

s = next_lane_offset.s_offset
t = utils.poly3_to_polynomial(next_lane_offset.poly3)(0.0)

Expand Down Expand Up @@ -214,6 +268,15 @@ def _check_road_plan_view(
description=f"Redundant line geometry declaration.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=current_geometry.sourceline,
column=0,
description=f"Redundant line geometry declaration.",
)

checker_data.result.add_xml_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
Expand All @@ -222,6 +285,15 @@ def _check_road_plan_view(
description=f"Redundant line geometry declaration.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=next_geometry.sourceline,
column=0,
description=f"Redundant line geometry declaration.",
)

s_offset = utils.get_s_from_geometry(next_geometry)
if s_offset is not None:
inertial_point = utils.get_point_xyz_from_road_reference_line(
Expand Down Expand Up @@ -268,6 +340,15 @@ def _check_lane_widths(
description=f"Redundant lane width declaration.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=current_width.xml_element.sourceline,
column=0,
description=f"Redundant lane width declaration.",
)

checker_data.result.add_xml_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
Expand All @@ -276,6 +357,15 @@ def _check_lane_widths(
description=f"Redundant lane width declaration.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=next_width.xml_element.sourceline,
column=0,
description=f"Redundant lane width declaration.",
)

s_section = utils.get_s_from_lane_section(lane_section)

if s_section is None:
Expand Down Expand Up @@ -328,6 +418,15 @@ def _check_lane_borders(
description=f"Redundant lane border declaration.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=current_border.xml_element.sourceline,
column=0,
description=f"Redundant lane border declaration.",
)

checker_data.result.add_xml_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
Expand All @@ -336,6 +435,15 @@ def _check_lane_borders(
description=f"Redundant lane border declaration.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=next_border.xml_element.sourceline,
column=0,
description=f"Redundant lane border declaration.",
)

s_section = utils.get_s_from_lane_section(lane_section)

if s_section is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ def _check_junctions_connection_connect_road_no_incoming_road(
description="Connection with connecting road found as incoming road.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=connection.sourceline,
column=0,
description=f"Connection with connecting road found as incoming road.",
)

successor_junction_id = utils.get_linked_junction_id(
incoming_road, models.LinkageTag.SUCCESSOR
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ def _raise_issue(
description=f"Contact point 'end' not used on successor road connection.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=connection.sourceline,
column=0,
description=f"Contact point 'end' not used on successor road connection.",
)

inertial_point = utils.get_end_point_xyz_from_road_reference_line(connection_road)
if inertial_point is not None:
checker_data.result.add_inertial_location(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ def _check_junctions_connection_one_connection_element(
description="Connection with reused connecting road id.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=connection.sourceline,
column=0,
description=f"Connection with reused connecting road id.",
)

connecting_road = road_id_map.get(connecting_road_id)
if connecting_road is not None:
inertial_point = utils.get_middle_point_xyz_from_road_reference_line(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ def _raise_lane_linkage_issue(
description=f"Lane link in opposite direction.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=lane_link.sourceline,
column=0,
description=f"Lane link in opposite direction.",
)

s = None
if connecting_contact_point == models.ContactPoint.START:
s = 0
Expand Down Expand Up @@ -564,6 +573,15 @@ def _check_junctions_connection_one_link_to_incoming(
description=f"Connection with reused (incoming_road_id, connecting_road_id) = ({incoming_road_id}, {connecting_road_id}) pair.",
)

checker_data.result.add_file_location(
checker_bundle_name=constants.BUNDLE_NAME,
checker_id=CHECKER_ID,
issue_id=issue_id,
row=connection.sourceline,
column=0,
description=f"Connection with reused (incoming_road_id, connecting_road_id) = ({incoming_road_id}, {connecting_road_id}) pair.",
)

has_start_contact_point = False
has_end_contact_point = False
for connection in connections:
Expand Down
Loading

0 comments on commit ab7485a

Please sign in to comment.