[traffic] Make traffic initialization work with LoadMapsAsync()

Signed-off-by: mvglasow <michael -at- vonglasow.com>
This commit is contained in:
mvglasow
2025-07-27 01:24:34 +03:00
parent 958be3dee6
commit 871cd73592
2 changed files with 54 additions and 10 deletions

View File

@@ -230,7 +230,34 @@ public:
/// \note It works for group and leaf node.
bool HasUnsavedEdits(storage::CountryId const & countryId);
/**
* @brief Loads maps synchronously.
*
* Maps are loaded on the calling thread.
*
* This function also performs certain initialization operations which depend on map data being
* available, such as search, traffic and the download queue.
*
* @note This function is not suitable for use on platforms which enforce restrictions on
* time-consuming or potentially blocking operations on the UI thread (as Android does). On such
* platforms, `LoadMapsAsync()` should be used instead.
*/
void LoadMapsSync();
/**
* @brief Loads maps asynchronously.
*
* Maps are loaded on a new thread. Some operations are executed as part of a separate task which
* is posted to the GUI thread.
*
* This function also performs certain initialization operations which depend on map data being
* available, such as search, traffic and the download queue.
*
* After finishing initialization, the caller-supplied callback function is called. This function
* also runs on the GUI thread and should therefore not perform any time-consuming operations.
*
* @param callback A callback function to run at the end of initialization.
*/
void LoadMapsAsync(std::function<void()> && callback);
/// Registers all local map files in internal indexes.
@@ -389,6 +416,16 @@ private:
private:
std::vector<m2::TriangleD> GetSelectedFeatureTriangles() const;
/**
* @brief Initializes the traffic manager.
*
* This enables the traffic manager if defined in settings. If the traffic manager is not in test
* mode, all cunfigured sources are also added here.
*
* Maps must be loaded prior to calling this method.
*/
void InitializeTraffic();
public:
/// @name GPS location updates routine.
void OnLocationError(location::TLocationError error);