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

Function BuildTransit

generator/transit_generator_experimental.cpp:156–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156EdgeIdToFeatureId BuildTransit(std::string const & mwmDir, CountryId const & countryId,
157 std::string const & osmIdToFeatureIdsPath, std::string const & transitDir)
158{
159 LOG(LINFO, ("Building experimental transit section for", countryId, "mwmDir:", mwmDir));
160 std::string const mwmPath = GetMwmPath(mwmDir, countryId);
161
162 OsmIdToFeatureIdsMap mapping;
163 FillOsmIdToFeatureIdsMap(osmIdToFeatureIdsPath, mapping);
164
165 std::string const transitPath = base::JoinPath(transitDir, countryId);
166 if (!Platform::IsFileExistsByFullPath(transitPath))
167 {
168 LOG(LWARNING, ("Path to experimental transit files doesn't exist:", transitPath));
169 return {};
170 }
171
172 TransitData data;
173 DeserializeFromJson(mapping, transitPath, data);
174
175 // Transit section can be empty.
176 if (data.IsEmpty())
177 {
178 LOG(LWARNING, ("Experimental transit data deserialized from jsons is empty:", transitPath));
179 return {};
180 }
181
182 CalculateBestPedestrianSegments(mwmPath, countryId, data);
183
184 data.Sort();
185
186 data.CheckSorted();
187 data.CheckValid();
188 data.CheckUnique();
189
190 // Transit graph numerates features according to their orderto their order..
191 EdgeIdToFeatureId edgeToFeature;
192 for (uint32_t i = 0; i < data.GetEdges().size(); ++i)
193 {
194 auto const & e = data.GetEdges()[i];
195 EdgeId id(e.GetStop1Id(), e.GetStop2Id(), e.GetLineId());
196 edgeToFeature[id] = i;
197 }
198
199 FilesContainerW container(mwmPath, FileWriter::OP_WRITE_EXISTING);
200 auto writer = container.GetWriter(TRANSIT_FILE_TAG);
201 data.Serialize(*writer);
202 return edgeToFeature;
203}
204} // namespace experimental
205} // namespace transit

Callers

nothing calls this directly

Calls 15

JoinPathFunction · 0.85
CheckSortedMethod · 0.80
CheckValidMethod · 0.80
CheckUniqueMethod · 0.80
GetStop1IdMethod · 0.80
GetStop2IdMethod · 0.80
GetLineIdMethod · 0.80
GetWriterMethod · 0.80
GetMwmPathFunction · 0.70
FillOsmIdToFeatureIdsMapFunction · 0.70
DeserializeFromJsonFunction · 0.70

Tested by

no test coverage detected