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

Function GenerateFinalFeatures

generator/feature_sorter.cpp:362–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360};
361
362bool GenerateFinalFeatures(feature::GenerateInfo const & info, std::string const & name,
363 feature::DataHeader::MapType mapType)
364{
365 std::string const srcFilePath = info.GetTmpFileName(name);
366 std::string const dataFilePath = info.GetTargetFileName(name);
367
368 LOG(LINFO, ("Calculating middle points"));
369 // Store cellIds for middle points.
370 CalculateMidPoints midPoints;
371 ForEachFeatureRawFormat(srcFilePath, [&midPoints](FeatureBuilder const & fb, uint64_t pos) { midPoints(fb, pos); });
372
373 // Sort features by their middle point.
374 midPoints.Sort();
375
376 // Store sorted features.
377 {
378 FileReader reader(srcFilePath);
379 // Fill mwm header.
380 DataHeader header;
381
382 bool const isWorldOrWorldCoasts = (mapType != DataHeader::MapType::Country);
383 uint8_t coordBits = kFeatureSorterPointCoordBits;
384 if (isWorldOrWorldCoasts)
385 coordBits -= ((scales::GetUpperScale() - scales::GetUpperWorldScale()) / 2);
386
387 header.SetType(static_cast<DataHeader::MapType>(mapType));
388 header.SetGeometryCodingParams(serial::GeometryCodingParams(coordBits, midPoints.GetCenter()));
389 if (isWorldOrWorldCoasts)
390 header.SetScales(g_arrWorldScales);
391 else
392 header.SetScales(g_arrCountryScales);
393
394 RegionData regionData;
395 if (!ReadRegionData(name, regionData))
396 LOG(LWARNING, ("No extra data for country:", name));
397
398 // Transform features from raw format to optimized format.
399 try
400 {
401 // FeaturesCollector2 will create temporary file `dataFilePath + FEATURES_FILE_TAG`.
402 // Can't remove file in ~FeaturesCollector2() because of using it in base class dtor logic.
403 SCOPE_GUARD(_, [&]() { Platform::RemoveFileIfExists(info.GetTargetFileName(name, FEATURES_FILE_TAG)); });
404 LOG(LINFO, ("Simplifying and filtering geometry for all geom levels"));
405
406 FeaturesCollector2 collector(name, info, header, regionData, info.m_versionDate);
407 for (auto const & point : midPoints.GetVector())
408 {
409 ReaderSource<FileReader> src(reader);
410 src.Skip(point.second);
411
412 FeatureBuilder fb;
413 ReadFromSourceRawFormat(src, fb);
414 collector(fb);
415 }
416
417 LOG(LINFO, ("Writing features' data to", dataFilePath));
418
419 // Update bounds with the limit rect corresponding to region borders.

Callers 3

generator_tool.cppFile · 0.85
BuildFeaturesMethod · 0.85
FinishMethod · 0.85

Calls 15

ForEachFeatureRawFormatFunction · 0.85
GetUpperScaleFunction · 0.85
GetUpperWorldScaleFunction · 0.85
ReadRegionDataFunction · 0.85
ReadFromSourceRawFormatFunction · 0.85
GetBordersRectFunction · 0.85
GetTmpFileNameMethod · 0.80
GetTargetFileNameMethod · 0.80
SetScalesMethod · 0.80
SortMethod · 0.45

Tested by 2

BuildFeaturesMethod · 0.68
FinishMethod · 0.68