MCPcopy Create free account
hub / github.com/comaps/comaps / RunGenerateIsolinesTasks

Function RunGenerateIsolinesTasks

tools/topography_generator/generator.cpp:408–446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406
407template <typename ParamsType>
408void RunGenerateIsolinesTasks(int left, int bottom, int right, int top, std::string const & srtmPath,
409 ParamsType const & params, long threadsCount, long maxCachedTilesPerThread,
410 bool forceRegenerate)
411{
412 std::vector<std::unique_ptr<TileIsolinesTask>> tasks;
413
414 CHECK_GREATER(right, left, ());
415 CHECK_GREATER(top, bottom, ());
416
417 int tilesRowPerTask = top - bottom;
418 int tilesColPerTask = right - left;
419
420 if (tilesRowPerTask * tilesColPerTask <= static_cast<long>(threadsCount))
421 {
422 tilesRowPerTask = 1;
423 tilesColPerTask = 1;
424 }
425 else
426 {
427 while (tilesRowPerTask * tilesColPerTask > static_cast<long>(maxCachedTilesPerThread))
428 if (tilesRowPerTask > tilesColPerTask)
429 tilesRowPerTask = (tilesRowPerTask + 1) / 2;
430 else
431 tilesColPerTask = (tilesColPerTask + 1) / 2;
432 }
433
434 base::ComputationalThreadPool threadPool(threadsCount);
435
436 for (int lat = bottom; lat < top; lat += tilesRowPerTask)
437 {
438 int const topLat = std::min(lat + tilesRowPerTask - 1, top - 1);
439 for (int lon = left; lon < right; lon += tilesColPerTask)
440 {
441 int const rightLon = std::min(lon + tilesColPerTask - 1, right - 1);
442 auto task = std::make_unique<TileIsolinesTask>(lon, lat, rightLon, topLat, srtmPath, &params, forceRegenerate);
443 threadPool.SubmitWork([task = std::move(task)]() { task->Do(); });
444 }
445 }
446}
447} // namespace
448
449Generator::Generator(std::string const & srtmPath, long threadsCount, long maxCachedTilesPerThread,

Callers 1

GenerateIsolinesMethod · 0.85

Calls 2

SubmitWorkMethod · 0.80
DoMethod · 0.45

Tested by

no test coverage detected