| 110 | } |
| 111 | |
| 112 | bool DeserializeBoundariesTable(std::string const & path, OsmIdToBoundariesTable & table) |
| 113 | { |
| 114 | vector<vector<base::GeoObjectId>> allIds; |
| 115 | vector<vector<CityBoundary>> allBoundaries; |
| 116 | |
| 117 | size_t count = 0; |
| 118 | try |
| 119 | { |
| 120 | FileReader reader(path); |
| 121 | NonOwningReaderSource source(reader); |
| 122 | |
| 123 | double precision; |
| 124 | CitiesBoundariesSerDes::Deserialize(source, allBoundaries, precision); |
| 125 | |
| 126 | count = allBoundaries.size(); |
| 127 | allIds.resize(count); |
| 128 | |
| 129 | for (auto & ids : allIds) |
| 130 | { |
| 131 | auto const m = ReadPrimitiveFromSource<uint64_t>(source); |
| 132 | ids.resize(m); |
| 133 | CHECK(m != 0, ()); |
| 134 | |
| 135 | for (auto & id : ids) |
| 136 | { |
| 137 | auto const encodedId = ReadPrimitiveFromSource<uint64_t>(source); |
| 138 | id = base::GeoObjectId(encodedId); |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | catch (Reader::Exception const & e) |
| 143 | { |
| 144 | LOG(LERROR, ("Can't deserialize boundaries table:", e.what())); |
| 145 | return false; |
| 146 | } |
| 147 | |
| 148 | table.Clear(); |
| 149 | for (size_t i = 0; i < count; ++i) |
| 150 | { |
| 151 | auto const & ids = allIds[i]; |
| 152 | CHECK(!ids.empty(), ()); |
| 153 | auto const & id = ids.front(); |
| 154 | |
| 155 | for (auto & b : allBoundaries[i]) |
| 156 | table.Append(id, std::move(b)); |
| 157 | |
| 158 | for (size_t j = 1; j < ids.size(); ++j) |
| 159 | table.Union(id, ids[j]); |
| 160 | } |
| 161 | |
| 162 | return true; |
| 163 | } |
| 164 | } // namespace generator |