Skip to content

Fix invalid tile messages #10

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

Merged
merged 3 commits into from
Mar 24, 2025
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
9 changes: 9 additions & 0 deletions src/OpenStreetMap-esp32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ void OpenStreetMap::updateCache(const tileList &requiredTiles, uint8_t zoom)
{
for (const auto &[x, y] : requiredTiles)
{
if (y < 0 || y >= (1 << zoom))
continue;

if (!isTileCached(x, y, zoom))
{
const unsigned long startMs = millis();
Expand Down Expand Up @@ -218,6 +221,12 @@ bool OpenStreetMap::composeMap(LGFX_Sprite &mapSprite, const tileList &requiredT
int tileIndex = 0;
for (const auto &[tileX, tileY] : requiredTiles)
{
if (tileY < 0 || tileY >= (1 << zoom))
{
tileIndex++;
continue;
}

int drawX = startOffsetX + (tileIndex % numberOfColums) * OSM_TILESIZE;
int drawY = startOffsetY + (tileIndex / numberOfColums) * OSM_TILESIZE;

Expand Down
2 changes: 1 addition & 1 deletion src/OpenStreetMap-esp32.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ constexpr uint16_t OSM_TILE_TIMEOUT_MS = 500;
constexpr uint16_t OSM_DEFAULT_CACHE_ITEMS = 10;
constexpr uint16_t OSM_MAX_ZOOM = 18;

using tileList = std::vector<std::pair<uint32_t, uint32_t>>;
using tileList = std::vector<std::pair<uint32_t, int32_t>>;

class OpenStreetMap
{
Expand Down