12#ifndef Q_HEX_WALKER_ASTAR_H
13#define Q_HEX_WALKER_ASTAR_H
54 explicit H3AStar(QObject *parent =
nullptr);
95 void newCell(H3Index h3Index);
126 std::size_t
operator()(
const H3Index &index)
const {
return std::hash<uint64_t>()(index); }
170 std::vector<H3Index>
refinePath(
const std::vector<H3Index> &pathRes3, H3Index originalStart, H3Index originalEnd,
171 int startRes,
int endRes);
196 static std::array<H3Index, MAX_NEIGHBORS>
getNeighbors(H3Index cell);
212 static double heuristic(H3Index cell,
const LatLng &targetCoord);
221 static std::vector<H3Index>
reconstructPath(
const std::unordered_map<H3Index, H3Index, H3IndexHash> &previous,
222 H3Index start, H3Index end);
Bidirectional A* pathfinding algorithm for H3 hexagonal cells.
std::vector< H3Index > findShortestPath(H3Index start, H3Index end)
Finds the shortest path between two H3 cells.
static H3Index cellToParentRes3(H3Index index)
Converts any cell to its parent at resolution 3.
std::vector< H3Index > refinePath(const std::vector< H3Index > &pathRes3, H3Index originalStart, H3Index originalEnd, int startRes, int endRes)
Refines entire coarse path to target resolution.
static H3Index findBoundaryCellInDirection(const std::vector< H3Index > &cells, H3Index from, H3Index direction)
Finds boundary cell in a direction for path refinement.
std::vector< H3Index > refineEndSegmentGradual(H3Index prevInPath, H3Index parentEnd, H3Index originalEnd, int endRes)
Refines path segment near the end point to target resolution.
void setBlockedCells(const std::unordered_set< H3Index > &blocked)
Sets cells that cannot be traversed (obstacles).
static double heuristic(H3Index cell, const LatLng &targetCoord)
Heuristic function for A* (distance to target).
static constexpr int MAX_NEIGHBORS
Maximum neighbors for a hexagonal cell (always 6).
~H3AStar() override
Destructor.
static H3Index cellToChildRes3(H3Index index)
Converts resolution 3 cell to child at original resolution.
std::vector< H3Index > findLocalPathAtResolution(H3Index start, H3Index end, H3Index limitParent) const
Finds local path within a parent cell boundary.
static constexpr uint16_t MAX_CELLS_RES_3
Maximum number of cells at resolution 3 (~41K cells globally).
std::vector< H3Index > findPathAtResolution3(H3Index start, H3Index end, const LatLng &endCoord)
Finds path at resolution 3 using bidirectional A*.
static std::array< H3Index, MAX_NEIGHBORS > getNeighbors(H3Index cell)
Gets the 6 neighbors of a hexagonal cell.
std::vector< H3Index > refineStartSegmentGradual(H3Index originalStart, H3Index nextInPath, int startRes) const
Refines path segment near the start point to target resolution.
static std::vector< H3Index > getChildrenAtResolution(H3Index parent, int resolution)
Gets all children of a cell at specified resolution.
std::unordered_set< H3Index > blockedCells
Set of blocked (impassable) cells.
static std::vector< H3Index > reconstructPath(const std::unordered_map< H3Index, H3Index, H3IndexHash > &previous, H3Index start, H3Index end)
Reconstructs path from the visited nodes map.
static double getDistanceBetweenCells(H3Index cell1, H3Index cell2)
Calculates geographic distance between two cells.
Hash function for H3Index in unordered containers.
std::size_t operator()(const H3Index &index) const
Internal node structure for A* priority queue.
double gScore
Cost from start to this node.
bool operator>(const Node &other) const
Comparison operator for priority queue (min-heap).
H3Index cell
The H3 cell index.
double fScore
Estimated total cost (gScore + heuristic).