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

Function DeserializeBoundariesTable

generator/cities_boundaries_builder.cpp:112–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112bool 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

Callers 2

generator_tool.cppFile · 0.85
BuildSearchMethod · 0.85

Calls 9

frontMethod · 0.80
GeoObjectIdClass · 0.70
sizeMethod · 0.45
resizeMethod · 0.45
whatMethod · 0.45
ClearMethod · 0.45
emptyMethod · 0.45
AppendMethod · 0.45
UnionMethod · 0.45

Tested by 1

BuildSearchMethod · 0.68