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

Method CreateFromMapObject

libs/indexer/feature.cpp:204–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204std::unique_ptr<FeatureType> FeatureType::CreateFromMapObject(osm::MapObject const & emo)
205{
206 auto ft = std::unique_ptr<FeatureType>(new FeatureType());
207
208 HeaderGeomType headerGeomType = HeaderGeomType::Point;
209 ft->m_limitRect.MakeEmpty();
210
211 switch (emo.GetGeomType())
212 {
213 case feature::GeomType::Undefined:
214 // It is not possible because of FeatureType::GetGeomType() never returns GeomType::Undefined.
215 UNREACHABLE();
216 case feature::GeomType::Point:
217 headerGeomType = HeaderGeomType::Point;
218 ft->m_center = emo.GetMercator();
219 ft->m_limitRect.Add(ft->m_center);
220 break;
221 case feature::GeomType::Line:
222 headerGeomType = HeaderGeomType::Line;
223 assign_range(ft->m_points, emo.GetPoints());
224 for (auto const & p : ft->m_points)
225 ft->m_limitRect.Add(p);
226 break;
227 case feature::GeomType::Area:
228 headerGeomType = HeaderGeomType::Area;
229 assign_range(ft->m_triangles, emo.GetTriangesAsPoints());
230 for (auto const & p : ft->m_triangles)
231 ft->m_limitRect.Add(p);
232 break;
233 }
234
235 ft->m_parsed.m_points = ft->m_parsed.m_triangles = true;
236
237 ft->m_params.name = emo.GetNameMultilang();
238 string const & house = emo.GetHouseNumber();
239 if (house.empty())
240 ft->m_params.house.Clear();
241 else
242 ft->m_params.house.Set(house);
243 ft->m_parsed.m_common = true;
244
245 emo.AssignMetadata(ft->m_metadata);
246 ft->m_parsed.m_metadata = true;
247 ft->m_parsed.m_metaIds = true;
248
249 CHECK_LESS_OR_EQUAL(emo.GetTypes().Size(), feature::kMaxTypesCount, ());
250 copy(emo.GetTypes().begin(), emo.GetTypes().end(), ft->m_types.begin());
251
252 ft->m_parsed.m_types = true;
253 ft->m_header = CalculateHeader(emo.GetTypes().Size(), headerGeomType, ft->m_params);
254 ft->m_parsed.m_header2 = true;
255 ft->m_parsed.m_relations = true;
256
257 ft->m_id = emo.GetID();
258 return ft;
259}
260
261feature::GeomType FeatureType::GetGeomType() const

Callers

nothing calls this directly

Calls 15

assign_rangeFunction · 0.85
CalculateHeaderFunction · 0.85
MakeEmptyMethod · 0.80
GetHouseNumberMethod · 0.80
AssignMetadataMethod · 0.80
GetGeomTypeMethod · 0.45
AddMethod · 0.45
emptyMethod · 0.45
ClearMethod · 0.45
SetMethod · 0.45
SizeMethod · 0.45
GetTypesMethod · 0.45

Tested by

no test coverage detected