| 91 | } |
| 92 | |
| 93 | bool CamerasInfoCollector::ParseIntermediateInfo(std::string const & camerasInfoPath, |
| 94 | routing::OsmIdToFeatureIds const & osmIdToFeatureIds) |
| 95 | { |
| 96 | FileReader reader(camerasInfoPath); |
| 97 | ReaderSource<FileReader> src(reader); |
| 98 | |
| 99 | uint32_t maxSpeedKmPH = 0; |
| 100 | uint32_t relatedWaysNumber = 0; |
| 101 | |
| 102 | uint32_t latInt = 0; |
| 103 | double lat = 0; |
| 104 | |
| 105 | uint32_t lonInt = 0; |
| 106 | double lon = 0; |
| 107 | m2::PointD center; |
| 108 | |
| 109 | while (src.Size() > 0) |
| 110 | { |
| 111 | /// @todo Take out intermediate camera info serialization code. |
| 112 | /// Should be equal with CameraCollector::CameraInfo::Read. |
| 113 | |
| 114 | ReadPrimitiveFromSource(src, latInt); |
| 115 | ReadPrimitiveFromSource(src, lonInt); |
| 116 | lat = Uint32ToDouble(latInt, ms::LatLon::kMinLat, ms::LatLon::kMaxLat, kPointCoordBits); |
| 117 | lon = Uint32ToDouble(lonInt, ms::LatLon::kMinLon, ms::LatLon::kMaxLon, kPointCoordBits); |
| 118 | |
| 119 | ReadPrimitiveFromSource(src, maxSpeedKmPH); |
| 120 | ReadPrimitiveFromSource(src, relatedWaysNumber); |
| 121 | |
| 122 | center = mercator::FromLatLon(lat, lon); |
| 123 | |
| 124 | if (maxSpeedKmPH >= routing::kMaxCameraSpeedKmpH) |
| 125 | { |
| 126 | LOG(LINFO, ("Bad SpeedCamera max speed:", maxSpeedKmPH)); |
| 127 | maxSpeedKmPH = 0; |
| 128 | } |
| 129 | |
| 130 | bool badCamera = false; |
| 131 | if (relatedWaysNumber > std::numeric_limits<uint8_t>::max()) |
| 132 | { |
| 133 | badCamera = true; |
| 134 | LOG(LERROR, |
| 135 | ("Number of related to camera ways should be interval from 0 to 255.", "lat(", lat, "), lon(", lon, ")")); |
| 136 | } |
| 137 | |
| 138 | std::vector<routing::SpeedCameraMwmPosition> ways; |
| 139 | uint64_t wayOsmId = 0; |
| 140 | for (uint32_t i = 0; i < relatedWaysNumber; ++i) |
| 141 | { |
| 142 | ReadPrimitiveFromSource(src, wayOsmId); |
| 143 | |
| 144 | auto const it = osmIdToFeatureIds.find(base::MakeOsmWay(wayOsmId)); |
| 145 | if (it != osmIdToFeatureIds.cend()) |
| 146 | { |
| 147 | auto const & featureIdsVec = it->second; |
| 148 | // Note. One |wayOsmId| may correspond several feature ids. |
| 149 | for (auto const featureId : featureIdsVec) |
| 150 | ways.emplace_back(featureId, 0 /* segmentId */, 0 /* coef */); |
nothing calls this directly
no test coverage detected