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

Method VisualizeMwmsBordersInRect

qt/draw_widget.cpp:314–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

312}
313
314void DrawWidget::VisualizeMwmsBordersInRect(m2::RectD const & rect, bool withVertices, bool fromPackedPolygon,
315 bool boundingBox)
316{
317 auto const getRegions = [&](std::string const & mwmName)
318 {
319 if (fromPackedPolygon)
320 {
321 std::vector<storage::CountryDef> countries;
322 FilesContainerR reader(base::JoinPath(GetPlatform().ResourcesDir(), PACKED_POLYGONS_FILE));
323 ReaderSource<ModelReaderPtr> src(reader.GetReader(PACKED_POLYGONS_INFO_TAG));
324 rw::Read(src, countries);
325
326 for (size_t id = 0; id < countries.size(); ++id)
327 {
328 if (countries[id].m_countryId != mwmName)
329 continue;
330
331 src = reader.GetReader(std::to_string(id));
332 return borders::ReadPolygonsOfOneBorder(src);
333 }
334
335 UNREACHABLE();
336 }
337 else
338 {
339 std::string const bordersDir = base::JoinPath(GetPlatform().WritableDir(), BORDERS_DIR);
340 std::string const path = base::JoinPath(bordersDir, mwmName + BORDERS_EXTENSION);
341
342 std::vector<m2::RegionD> polygons;
343 borders::LoadBorders(path, polygons);
344 return polygons;
345 }
346 };
347
348 auto mwmNames = m_framework.GetRegionsCountryIdByRect(rect, false /* rough */);
349
350 for (auto & mwmName : mwmNames)
351 {
352 auto regions = getRegions(mwmName);
353 mwmName += fromPackedPolygon ? ".bin" : ".poly";
354 if (boundingBox)
355 {
356 std::vector<m2::RegionD> boxes;
357 for (auto const & region : regions)
358 {
359 auto const r = region.GetRect();
360 boxes.emplace_back(
361 std::vector<m2::PointD>({r.LeftBottom(), r.LeftTop(), r.RightTop(), r.RightBottom(), r.LeftBottom()}));
362 }
363
364 regions = std::move(boxes);
365 mwmName += ".box";
366 }
367 DrawMwmBorder(m_framework.GetDrapeApi(), mwmName, regions, withVertices);
368 }
369}
370
371void DrawWidget::mouseReleaseEvent(QMouseEvent * e)

Callers

nothing calls this directly

Calls 15

JoinPathFunction · 0.85
to_stringFunction · 0.85
ReadPolygonsOfOneBorderFunction · 0.85
DrawMwmBorderFunction · 0.85
LeftBottomMethod · 0.80
LeftTopMethod · 0.80
RightTopMethod · 0.80
RightBottomMethod · 0.80
ReadFunction · 0.50
LoadBordersFunction · 0.50
GetReaderMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected