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

Method SearchByFeatureId

libs/search/processor.cpp:388–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

386}
387
388void Processor::SearchByFeatureId()
389{
390 // Create a copy of the query to trim it in-place.
391 string query(m_query.m_query);
392 strings::Trim(query);
393
394 if (strings::EatPrefix(query, "?fid"))
395 {
396 strings::Trim(query);
397 if (strings::EatPrefix(query, "="))
398 strings::Trim(query);
399 }
400 else
401 return;
402
403 vector<shared_ptr<MwmInfo>> infos;
404 m_dataSource.GetMwmsInfo(infos);
405
406 auto const putFeature = [](FeaturesLoaderGuard & guard, uint32_t fid, auto const & fn)
407 {
408 // Feature can be deleted, so always check.
409 auto ft = guard.GetFeatureByIndex(fid);
410 if (ft)
411 fn(std::move(ft));
412 };
413
414 storage::CountryId mwmName;
415 uint32_t version;
416 uint32_t fid;
417
418 // Case 0.
419 {
420 string s = query;
421 if (EatFid(s, fid))
422 {
423 EmitResultsFromMwms(infos, [&putFeature, fid](FeaturesLoaderGuard & guard, auto const & fn)
424 {
425 if (fid < guard.GetNumFeatures())
426 putFeature(guard, fid, fn);
427 });
428 }
429 }
430
431 // Case 1.
432 {
433 string s = query;
434 bool const parenPref = strings::EatPrefix(s, "(");
435 bool const parenSuff = strings::EatSuffix(s, ")");
436 if (parenPref == parenSuff && EatMwmName(m_countriesTrie, s, mwmName) && strings::EatPrefix(s, ",") &&
437 EatFid(s, fid))
438 {
439 EmitResultsFromMwms(infos, [&putFeature, &mwmName, fid](FeaturesLoaderGuard & guard, auto const & fn)
440 {
441 if (guard.GetCountryFileName() == mwmName && fid < guard.GetNumFeatures())
442 putFeature(guard, fid, fn);
443 });
444 }
445 }

Callers

nothing calls this directly

Calls 11

TrimFunction · 0.85
EatPrefixFunction · 0.85
EatFidFunction · 0.85
EatSuffixFunction · 0.85
EatMwmNameFunction · 0.85
EatVersionFunction · 0.85
GetMwmsInfoMethod · 0.80
GetCountryFileNameMethod · 0.80
GetFeatureByIndexMethod · 0.45
GetNumFeaturesMethod · 0.45
GetVersionMethod · 0.45

Tested by

no test coverage detected