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

Function GetCrossBorderPoints

generator/world_roads_builder/world_roads_builder.cpp:120–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118using CrossBorderIndexes = std::vector<size_t>;
119
120std::pair<NodePoints, CrossBorderIndexes> GetCrossBorderPoints(
121 std::vector<uint64_t> const & nodeIds, ankerl::unordered_dense::map<uint64_t, ms::LatLon> const & nodes,
122 feature::CountriesFilesAffiliation const & mwmMatcher,
123 ankerl::unordered_dense::map<std::string, NumMwmId> const & regionToIdMap)
124{
125 NodePoints nodePoints;
126 CrossBorderIndexes crossBorderIndexes;
127
128 std::string prevRegion;
129 m2::PointD prevPoint;
130
131 for (auto const & nodeId : nodeIds)
132 {
133 auto const itNodes = nodes.find(nodeId);
134 CHECK(itNodes != nodes.end(), (nodeId));
135
136 m2::PointD const & curPoint = mercator::FromLatLon(itNodes->second);
137 auto const & regions = mwmMatcher.GetAffiliations(curPoint);
138
139 if (regions.size() > 1)
140 {
141 LOG(LWARNING, ("Point", itNodes->second, "belongs to multiple mwms:", regions));
142 continue;
143 }
144
145 if (regions.empty())
146 {
147 LOG(LWARNING, ("Point", itNodes->second, "doesn't belong to any mwm."));
148 continue;
149 }
150
151 auto const & curRegion = regions[0];
152 auto const & curMwmId = regionToIdMap.at(curRegion);
153 nodePoints.emplace_back(curPoint, curMwmId);
154
155 if (curRegion != prevRegion)
156 {
157 if (!prevRegion.empty())
158 {
159 CHECK_GREATER(nodePoints.size(), 1, ());
160 // We add index of the previous point.
161 crossBorderIndexes.push_back(nodePoints.size() - 2);
162 }
163
164 prevRegion = curRegion;
165 }
166
167 prevPoint = curPoint;
168 }
169
170 return std::make_pair(nodePoints, crossBorderIndexes);
171}
172
173std::optional<std::pair<m2::PointD, double>> GetPointInMwm(NodePoints const & points, size_t index, bool forward)
174{

Callers 1

FillCrossBorderGraphFunction · 0.85

Calls 9

atMethod · 0.80
FromLatLonFunction · 0.50
findMethod · 0.45
endMethod · 0.45
GetAffiliationsMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
emplace_backMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected