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

Function ForEachFeatureAtPoint

libs/indexer/data_source_helpers.cpp:20–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18using namespace std;
19
20void ForEachFeatureAtPoint(DataSource const & dataSource, function<void(FeatureType &)> && fn,
21 m2::PointD const & mercator, double toleranceInMeters)
22{
23 double constexpr kSelectRectWidthInMeters = 1.1;
24 double constexpr kMetersToLinearFeature = 3;
25 int constexpr kScale = scales::GetUpperScale();
26 m2::RectD const rect = mercator::RectByCenterXYAndSizeInMeters(mercator, kSelectRectWidthInMeters);
27
28 auto const emitter = [&fn, &rect, &mercator, toleranceInMeters](FeatureType & ft)
29 {
30 switch (ft.GetGeomType())
31 {
32 case feature::GeomType::Point:
33 if (rect.IsPointInside(ft.GetCenter()))
34 fn(ft);
35 break;
36 case feature::GeomType::Line:
37 if (feature::GetMinDistanceMeters(ft, mercator) < kMetersToLinearFeature)
38 fn(ft);
39 break;
40 case feature::GeomType::Area:
41 {
42 auto limitRect = ft.GetLimitRect(kScale);
43 // Be a little more tolerant. When used by editor mercator is given
44 // with some error, so we must extend limit rect a bit.
45 limitRect.Inflate(kMwmPointAccuracy, kMwmPointAccuracy);
46 if (limitRect.IsPointInside(mercator) && feature::GetMinDistanceMeters(ft, mercator) <= toleranceInMeters)
47 fn(ft);
48 }
49 break;
50 case feature::GeomType::Undefined: ASSERT(false, ("case feature::GeomType::Undefined")); break;
51 }
52 };
53
54 dataSource.ForEachInRect(emitter, rect, kScale);
55}
56} // namespace indexer

Callers 5

GetCandidatePointsMethod · 0.85
ForEachFeatureAtPointMethod · 0.85
ForEachFeatureAtPointMethod · 0.85
GetFeatureAtPointMethod · 0.85

Calls 10

GetUpperScaleFunction · 0.85
GetMinDistanceMetersFunction · 0.85
ASSERTFunction · 0.85
GetGeomTypeMethod · 0.45
IsPointInsideMethod · 0.45
GetCenterMethod · 0.45
GetLimitRectMethod · 0.45
InflateMethod · 0.45
ForEachInRectMethod · 0.45

Tested by

no test coverage detected