utils.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * @Description:
  3. * @Version: 1.0
  4. * @Autor: Sun Yalun
  5. * @Date: 2024-11-04 15:38:06
  6. * @LastEditors: Sun Yalun
  7. * @LastEditTime: 2024-11-08 14:39:18
  8. */
  9. // lib/utils.h
  10. #ifndef UTILS_H
  11. #define UTILS_H
  12. #include "engine.h"
  13. #include <string>
  14. #include <vector>
  15. struct BoundingBox {
  16. double min_x, max_x;
  17. double min_y, max_y;
  18. };
  19. BoundingBox createBoundingBox(const Point& p1, const Point& p2);
  20. bool isPointInBoundingBox(const Point& p, const BoundingBox& box);
  21. std::vector<int> parseRef(const std::string& ref_str);
  22. std::vector<Point> parseCoords(const std::string& coords_str);
  23. std::vector<InterInfo> readIntersectionsFromCSV(const std::string& csvPath);
  24. std::vector<CrosswalkInfo> readCrosswalksFromCSV(const std::string& csvPath);
  25. std::vector<TrafficlightInfo> readTrafficlightsFromCSV(const std::string& csvPath);
  26. std::vector<RoadInfo> readRoadsFromCSV(const std::string& csvPath);
  27. std::vector<LaneInfo> readLanesFromCSV(const std::string& csvPath);
  28. std::vector<SignalInfo> readSignalsFromCSV(const std::string& csvPath);
  29. std::vector<StoplineInfo> readStopLinesFromCSV(const std::string& csvPath);
  30. std::vector<ArrowInfo> readArrowsFromCSV(const std::string& csvPath);
  31. double calculateDistance(double x1, double y1, double x2, double y2);
  32. double pointToSegmentDistance(const Point& p, const Point& p1, const Point& p2);
  33. double computeMinDistanceToCurve(const Point& queryPoint, const std::vector<Point>& curve, size_t window_size=10);
  34. double computeBazierDistanceToCurve(const Point& queryPoint, const std::vector<Point>& coords);
  35. Point calculateCentroid(const std::vector<Point>& coords);
  36. #endif // UTILS_H