Skip to content

feat: Several changes to libosmscout - #1760

Merged
Framstag merged 2 commits into
masterfrom
updates-to-general-libosmscout-code
Aug 21, 2026
Merged

feat: Several changes to libosmscout#1760
Framstag merged 2 commits into
masterfrom
updates-to-general-libosmscout-code

Conversation

@Framstag

Copy link
Copy Markdown
Owner
  • KI infused change in context of Java-based client development in context of...
  • basemap support
  • Dynamic map loading/removing in client
  • routing implementation, improvement
  • Error handling

- KI infused change in context of Java-based client development in context of...
- basemap support
- Dynamic map loading/removing in client
- routing implementation, improvement
- Error handling
@Framstag

Copy link
Copy Markdown
Owner Author

Hi @Karry, please check the changes if they are OK for you

@Karry Karry left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, just few nitpicks :-)

Async<bool>([this](const Breaker& /*breaker*/) {
WriteLock locker(latch);

if (basemapDatabase) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lines below are duplicate, I would love to have them in separate private method...


if (lastPosition &&
(gpsUpdateMsg->timestamp-lastPosition.time) >= seconds(1)){
// --- Prefer GPS-reported speed over position-difference computation ---

@Karry Karry Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

well, with my experience, speed reported by the device GPS module is nonsense usually. This is the reason why it is computed as average movement in few seconds... I will test this change. We may introduce some configuration option what speed value to prefer...

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I'll merge this part but note, that I currently also have effect with GPS signal handling, so I'm also sure that like GPS signal handling will change...

}),
databaseLookupDirs.end());
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should not be LookupDatabases(); called here?

- Move duplicated basemap close/open logic from OnDatabaseListChanged and
  ReloadBasemap into private DBThread::LoadBasemap() method
- MapManager::RemoveLookupDirectory now triggers LookupDatabases() so maps
  from removed directory disappear from database list and
  databaseListChanged signal is emitted
- Add test verifying RemoveLookupDirectory rescans and emits signal
@Framstag

Copy link
Copy Markdown
Owner Author

Feedback form AI:

Done. All three comments handled.

Summary

Comment 1 — DBThread dedup (libosmscout-client/src/osmscoutclient/DBThread.cpp, DBThread.h)

  • Extracted basemap close+open logic into private DBThread::LoadBasemap()
  • OnDatabaseListChanged and ReloadBasemap now both call it
  • Preserved ordering: LoadBasemap() still called after mmap-quota computation in OnDatabaseListChanged (32-bit
    mmap flags must apply before open)
  • Unified log message ("Basemap loaded from...")

Comment 2 — SpeedAgent — ignored per instruction.

Comment 3 — MapManager (MapManager.cpp, MapManager.h)

  • Analysis: RemoveLookupDirectory removed dir from databaseLookupDirs but never re-scanned. Result:
    databaseDirectories still held maps from removed dir, databaseListChanged never emitted → DBThread kept removed
    databases open. Karry right.
  • Fix: added LookupDatabases() call, mirroring AddLookupDirectory
  • Header doc updated

Test (Tests/src/MapDownloadServiceTest.cpp)

  • New MapManager::RemoveLookupDirectory triggers database rescan:
    • Creates valid map dir (all 18 mandatory files)
    • AddLookupDirectory → map visible in GetDatabaseDirectories()
    • RemoveLookupDirectory → map gone, lookup dirs empty, databaseListChanged emitted with empty list
    • Polls async worker with deadline

Verification

  • Full build clean
  • 68/68 non-PerformanceTest tests pass (PerformanceTest failures pre-existing — UI lib leak on exit, documented in
    AGENTS.md)
  • New test: 12 test cases, 77 assertions, all pass

Changes uncommitted on branch updates-to-general-libosmscout-code. Want commit?

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
9.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@Framstag
Framstag merged commit f302f3c into master Aug 21, 2026
20 of 21 checks passed
@Framstag
Framstag deleted the updates-to-general-libosmscout-code branch August 21, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants