| 317 | } |
| 318 | |
| 319 | void TransitReadManager::UpdateViewport(ScreenBase const & screen) |
| 320 | { |
| 321 | m_currentModelView = {screen, true /* initialized */}; |
| 322 | |
| 323 | if (!m_isSchemeMode || m_isSchemeModeBlocked) |
| 324 | return; |
| 325 | |
| 326 | if (df::GetDrawTileScale(screen) < kMinSchemeZoomLevel) |
| 327 | { |
| 328 | ChangeState(TransitSchemeState::Enabled); |
| 329 | return; |
| 330 | } |
| 331 | |
| 332 | auto mwms = m_getMwmsByRectFn(screen.ClipRect()); |
| 333 | |
| 334 | m_lastActiveMwms.clear(); |
| 335 | auto const currentTime = steady_clock::now(); |
| 336 | |
| 337 | TransitDisplayInfos newTransitData; |
| 338 | for (auto const & mwmId : mwms) |
| 339 | { |
| 340 | if (!mwmId.IsAlive()) |
| 341 | continue; |
| 342 | m_lastActiveMwms.insert(mwmId); |
| 343 | auto it = m_mwmCache.find(mwmId); |
| 344 | if (it == m_mwmCache.end()) |
| 345 | { |
| 346 | newTransitData[mwmId] = {}; |
| 347 | m_mwmCache.insert(make_pair(mwmId, CacheEntry(currentTime))); |
| 348 | } |
| 349 | else |
| 350 | { |
| 351 | it->second.m_lastActiveTime = currentTime; |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | if (!newTransitData.empty()) |
| 356 | { |
| 357 | GetTransitDisplayInfo(newTransitData); |
| 358 | |
| 359 | TransitDisplayInfos validTransitData; |
| 360 | for (auto & [mwmId, transitInfo] : newTransitData) |
| 361 | { |
| 362 | if (!transitInfo) |
| 363 | continue; |
| 364 | |
| 365 | if (transitInfo->m_transitVersion == ::transit::TransitVersion::OnlySubway && transitInfo->m_linesSubway.empty()) |
| 366 | continue; |
| 367 | |
| 368 | if (transitInfo->m_transitVersion == ::transit::TransitVersion::AllPublicTransport && |
| 369 | transitInfo->m_linesPT.empty()) |
| 370 | continue; |
| 371 | |
| 372 | auto it = m_mwmCache.find(mwmId); |
| 373 | |
| 374 | it->second.m_isLoaded = true; |
| 375 | |
| 376 | auto const dataSize = CalculateCacheSize(*transitInfo); |
nothing calls this directly
no test coverage detected