Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the category key when loading proto files #332

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions xml_converter/integration_tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def rebuild_xml_converter_binary() -> None:
################################################################################
line_patterns_to_ignore = [
r"^Loading taco pack .*$",
r"^Loading waypoint pack .*$",
r"^The taco parse function took [0-9]+ milliseconds to run$",
r"^The xml write function took [0-9]+ milliseconds to run$",
r"^The protobuf read function took [0-9]+ milliseconds to run$",
Expand Down Expand Up @@ -170,6 +171,7 @@ def main() -> bool:

rawstdout, rawstderr, returncode = run_xml_converter(
input_xml=testcase.xml_input_paths,
input_proto=testcase.proto_input_paths,
output_xml=[xml_output_dir_path],
output_proto=[proto_output_dir_path],
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" Name="mycategory"></MarkerCategory>

<MarkerCategory DisplayName="Nested Level One" Name="NestedLevel1">
<MarkerCategory DisplayName="Nested Level Two" Name="NestedLevel2">
<MarkerCategory DisplayName="Nested Level Three" Name="NestedLevel3"></MarkerCategory>
</MarkerCategory>
</MarkerCategory>

<POIs>
<POI Type="mycategory" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" />
<POI Type="nestedlevel1" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" />
<POI Type="nestedlevel1.nestedlevel2" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" />
<POI Type="nestedlevel1.nestedlevel2.nestedlevel3" XPos="169.81" YPos="210.65" ZPos="215.83" MapID="50" />
</POIs>
</OverlayData>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/display_name_valid/output_proto/markers.bin.textproto._old	2024-08-18 04:11:07.024577588 +0000
+++ xml_converter/integration_tests/test_cases/display_name_valid/output_proto/markers.bin.textproto._new	2024-08-18 04:11:07.032577619 +0000
@@ -0,0 +1,48 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}
+category {
+  name: "Nested Level One"
+  children {
+    name: "Nested Level Two"
+    children {
+      name: "Nested Level Three"
+      icon {
+        map_id: 50
+        position {
+          x: 169.81
+          y: 210.65
+          z: 215.83
+        }
+      }
+      id: "p,T\324\205\337\210\244"
+    }
+    icon {
+      map_id: 50
+      position {
+        x: 169.81
+        y: 210.65
+        z: 215.83
+      }
+    }
+    id: "\270\232\334\270\267xj\317"
+  }
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: ",\222\247\355j@\016:"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/display_name_valid/output_proto/markers.bin.textproto._old	2024-08-18 21:26:25.288712905 +0000
+++ xml_converter/integration_tests/test_cases/display_name_valid/output_proto/markers.bin.textproto._new	2024-08-18 21:26:25.296712852 +0000
@@ -0,0 +1,48 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}
+category {
+  name: "Nested Level One"
+  children {
+    name: "Nested Level Two"
+    children {
+      name: "Nested Level Three"
+      icon {
+        map_id: 50
+        position {
+          x: 169.81
+          y: 210.65
+          z: 215.83
+        }
+      }
+      id: "p,T\324\205\337\210\244"
+    }
+    icon {
+      map_id: 50
+      position {
+        x: 169.81
+        y: 210.65
+        z: 215.83
+      }
+    }
+    id: "\270\232\334\270\267xj\317"
+  }
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: ",\222\247\355j@\016:"
+}

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

,
My Category 2B\Ï)Cf¦RC{ÔWCB(èÌ“^–
™
Nested Level Onef
Nested Level Two3
Nested Level Three 2B\Ï)Cf¦RC{ÔWCBp,Tԅ߈¤ 2B\Ï)Cf¦RC{ÔWCB¸šÜ¸·xjÏ 2B\Ï)Cf¦RC{ÔWCB,’§íj@:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory">
</MarkerCategory>

<MarkerCategory DisplayName="Nested Level One" ID="LJKn7WpADjo=" Name="NestedLevel1">
<MarkerCategory DisplayName="Nested Level Two" ID="uJrcuLd4as8=" Name="NestedLevel2">
<MarkerCategory DisplayName="Nested Level Three" ID="cCxU1IXfiKQ=" Name="NestedLevel3">
</MarkerCategory>
</MarkerCategory>
</MarkerCategory>

<POIs>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="nestedlevel1" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="nestedlevel1.nestedlevel2" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="nestedlevel1.nestedlevel2.nestedlevel3" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
</POIs>
</OverlayData>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
input_paths:
"pack": "xml"
expected_stdout: |
expected_stderr: |
expected_returncode: 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/proto_type_valid/input/pack/markers.bin.textproto._old	2024-08-18 04:11:07.076577796 +0000
+++ xml_converter/integration_tests/test_cases/proto_type_valid/input/pack/markers.bin.textproto._new	2024-08-18 04:11:07.084577829 +0000
@@ -0,0 +1,48 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}
+category {
+  name: "Nested Level One"
+  children {
+    name: "Nested Level Two"
+    children {
+      name: "Nested Level Three"
+      icon {
+        map_id: 50
+        position {
+          x: 169.81
+          y: 210.65
+          z: 215.83
+        }
+      }
+      id: "p,T\324\205\337\210\244"
+    }
+    icon {
+      map_id: 50
+      position {
+        x: 169.81
+        y: 210.65
+        z: 215.83
+      }
+    }
+    id: "\270\232\334\270\267xj\317"
+  }
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: ",\222\247\355j@\016:"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/proto_type_valid/input/pack/markers.bin.textproto._old	2024-08-18 21:26:25.304712800 +0000
+++ xml_converter/integration_tests/test_cases/proto_type_valid/input/pack/markers.bin.textproto._new	2024-08-18 21:26:25.312712750 +0000
@@ -0,0 +1,48 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}
+category {
+  name: "Nested Level One"
+  children {
+    name: "Nested Level Two"
+    children {
+      name: "Nested Level Three"
+      icon {
+        map_id: 50
+        position {
+          x: 169.81
+          y: 210.65
+          z: 215.83
+        }
+      }
+      id: "p,T\324\205\337\210\244"
+    }
+    icon {
+      map_id: 50
+      position {
+        x: 169.81
+        y: 210.65
+        z: 215.83
+      }
+    }
+    id: "\270\232\334\270\267xj\317"
+  }
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: ",\222\247\355j@\016:"
+}

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

,
My Category 2B\Ï)Cf¦RC{ÔWCB(èÌ“^–
™
Nested Level Onef
Nested Level Two3
Nested Level Three 2B\Ï)Cf¦RC{ÔWCBp,Tԅ߈¤ 2B\Ï)Cf¦RC{ÔWCB¸šÜ¸·xjÏ 2B\Ï)Cf¦RC{ÔWCB,’§íj@:
Expand Down

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/proto_type_valid/output_proto/markers.bin.textproto._old	2024-08-18 04:11:07.092577861 +0000
+++ xml_converter/integration_tests/test_cases/proto_type_valid/output_proto/markers.bin.textproto._new	2024-08-18 04:11:07.100577892 +0000
@@ -0,0 +1,48 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}
+category {
+  name: "Nested Level One"
+  children {
+    name: "Nested Level Two"
+    children {
+      name: "Nested Level Three"
+      icon {
+        map_id: 50
+        position {
+          x: 169.81
+          y: 210.65
+          z: 215.83
+        }
+      }
+      id: "p,T\324\205\337\210\244"
+    }
+    icon {
+      map_id: 50
+      position {
+        x: 169.81
+        y: 210.65
+        z: 215.83
+      }
+    }
+    id: "\270\232\334\270\267xj\317"
+  }
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: ",\222\247\355j@\016:"
+}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full Diff
--- xml_converter/integration_tests/test_cases/proto_type_valid/output_proto/markers.bin.textproto._old	2024-08-18 21:26:25.320712697 +0000
+++ xml_converter/integration_tests/test_cases/proto_type_valid/output_proto/markers.bin.textproto._new	2024-08-18 21:26:25.328712645 +0000
@@ -0,0 +1,48 @@
+category {
+  name: "My Category"
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: "(\350\314\006\302\223^\226"
+}
+category {
+  name: "Nested Level One"
+  children {
+    name: "Nested Level Two"
+    children {
+      name: "Nested Level Three"
+      icon {
+        map_id: 50
+        position {
+          x: 169.81
+          y: 210.65
+          z: 215.83
+        }
+      }
+      id: "p,T\324\205\337\210\244"
+    }
+    icon {
+      map_id: 50
+      position {
+        x: 169.81
+        y: 210.65
+        z: 215.83
+      }
+    }
+    id: "\270\232\334\270\267xj\317"
+  }
+  icon {
+    map_id: 50
+    position {
+      x: 169.81
+      y: 210.65
+      z: 215.83
+    }
+  }
+  id: ",\222\247\355j@\016:"
+}

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

,
My Category 2B\Ï)Cf¦RC{ÔWCB(èÌ“^–
™
Nested Level Onef
Nested Level Two3
Nested Level Three 2B\Ï)Cf¦RC{ÔWCBp,Tԅ߈¤ 2B\Ï)Cf¦RC{ÔWCB¸šÜ¸·xjÏ 2B\Ï)Cf¦RC{ÔWCB,’§íj@:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<OverlayData>
<MarkerCategory DisplayName="My Category" ID="KOjMBsKTXpY=" Name="mycategory">
</MarkerCategory>

<MarkerCategory DisplayName="Nested Level One" ID="LJKn7WpADjo=" Name="nestedlevelone">
<MarkerCategory DisplayName="Nested Level Two" ID="uJrcuLd4as8=" Name="nestedleveltwo">
<MarkerCategory DisplayName="Nested Level Three" ID="cCxU1IXfiKQ=" Name="nestedlevelthree">
</MarkerCategory>
</MarkerCategory>
</MarkerCategory>

<POIs>
<POI Type="mycategory" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="nestedlevelone" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="nestedlevelone.nestedleveltwo" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
<POI Type="nestedlevelone.nestedleveltwo.nestedlevelthree" MapID="50" XPos="169.809998" YPos="210.649994" ZPos="215.830002"/>
</POIs>
</OverlayData>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
input_paths:
"pack": "proto"
expected_stdout: |
expected_stderr: |
expected_returncode: 0
9 changes: 7 additions & 2 deletions xml_converter/src/packaging_protobin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ void parse_waypoint_categories(
map<string, Category>* marker_categories,
vector<Parseable*>* parsed_pois,
ProtoReaderState* state) {
full_category_name += proto_category.name();
Category* this_category = &(*marker_categories)[full_category_name];
string category_name = normalize(proto_category.name());
full_category_name += category_name;
Category* this_category = &(*marker_categories)[category_name];

this_category->parse_protobuf(proto_category, state);

Expand All @@ -40,6 +41,7 @@ void parse_waypoint_categories(
// TODO: The field category in Icon is being deprciated
// This overwrites any icon.category with its position in the heirarchy
icon->category.category = full_category_name;
icon->category_is_set = true;
parsed_pois->push_back(icon);
}
for (int i = 0; i < proto_category.trail_size(); i++) {
Expand All @@ -48,6 +50,7 @@ void parse_waypoint_categories(
// TODO: The field category in Trail is being deprciated
// This overwrites any trail.category with its position in the heirarchy
trail->category.category = full_category_name;
trail->category_is_set = true;
parsed_pois->push_back(trail);
}

Expand Down Expand Up @@ -216,10 +219,12 @@ void write_protobuf_file(
Parseable* parsed_poi = (*parsed_pois)[i];
if (parsed_poi->classname() == "POI") {
Icon* icon = dynamic_cast<Icon*>(parsed_poi);
// TODO(331): This is the wrong place to lowercase() the category and is hiding some crimes elsewhere
category_to_pois[lowercase(icon->category.category)].push_back(parsed_poi);
}
else if (parsed_poi->classname() == "Trail") {
Trail* trail = dynamic_cast<Trail*>(parsed_poi);
// TODO(331): This is the wrong place to lowercase() the category and is hiding some crimes elsewhere
category_to_pois[lowercase(trail->category.category)].push_back(parsed_poi);
}
else {
Expand Down
Loading