Skip to content
Merged
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
13 changes: 11 additions & 2 deletions src/OpenStreetMap-esp32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,24 @@ void OpenStreetMap::makeJobList(const tileList &requiredTiles, std::vector<TileJ
if (isTileCached(x, y, zoom, tilePointers)) // isTileCached will push_back a valid ptr if tile is cached
continue;

// Check if this tile is already in the job list
auto existing = std::find_if(jobs.begin(), jobs.end(), [&](const TileJob &job)
{ return job.x == x && job.y == static_cast<uint32_t>(y) && job.z == zoom; });
if (existing != jobs.end())
{
tilePointers.push_back(existing->tile->buffer); // reuse buffer from already queued job
continue;
}

CachedTile *tileToReplace = findUnusedTile(requiredTiles, zoom);
if (!tileToReplace)
{
tilePointers.push_back(nullptr); // again, keep 1:1 aligned
continue;
}

tilePointers.push_back(tileToReplace->buffer); // push_back the still-to-download tile ptr
jobs.push_back({x, static_cast<uint32_t>(y), zoom, tileToReplace}); // push_back tile ptr to the job list
tilePointers.push_back(tileToReplace->buffer); // store buffer for rendering
jobs.push_back({x, static_cast<uint32_t>(y), zoom, tileToReplace}); // queue job
}
}

Expand Down