| 154 | } |
| 155 | |
| 156 | EdgeIdToFeatureId 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 |
nothing calls this directly
no test coverage detected