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

Method PreSerialize

generator/feature_builder.cpp:174–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174bool FeatureBuilder::PreSerialize()
175{
176 /// @todo Seems like we should put CHECK(IsValid()) here.
177 if (!m_params.IsValid())
178 return false;
179
180 auto const checkHouseNumber = [this]()
181 {
182 if (!m_params.house.IsEmpty())
183 {
184 // Hack/Patch here. Convert non-number into default name for the search index.
185 // Happens with building-address: https://github.com/organicmaps/organicmaps/issues/4994
186 /// @todo Refactor to store raw name: and addr: values in FeatureBuilderParams and make one
187 /// _finalization_ function here.
188 auto const & hn = m_params.house.Get();
189 if (FeatureParams::LooksLikeHouseNumber(hn) || !m_params.SetDefaultNameIfEmpty(hn))
190 return true;
191 else
192 m_params.house.Clear();
193 }
194 return false;
195 };
196
197 // Conform serialization logic (see HeaderMask::HEADER_MASK_HAS_ADDINFO):
198 // - rank (city) is stored only for Point
199 // - ref (road number, address range) is stored only for Line
200 // - house is stored for PointEx and Area
201 switch (m_params.GetGeomType())
202 {
203 case GeomType::Point:
204 if (checkHouseNumber())
205 {
206 // Store house number like HeaderGeomType::PointEx.
207 m_params.SetGeomTypePointEx();
208 m_params.rank = 0;
209 }
210
211 if (!m_params.ref.empty())
212 {
213 auto const & types = GetTypes();
214 if (ftypes::IsMotorwayJunctionChecker::Instance()(types) ||
215 (!m_params.name.HasString(localisation::kDefaultNameIndex) &&
216 (ftypes::IsPostPoiChecker::Instance()(types) || ftypes::IsRailwaySubwayEntranceChecker::Instance()(types) ||
217 ftypes::IsEntranceChecker::Instance()(types) || ftypes::IsAerowayGateChecker::Instance()(types) ||
218 ftypes::IsPlatformChecker::Instance()(types))))
219 {
220 m_params.name.AddString(localisation::kDefaultNameIndex, m_params.ref);
221 }
222 else if (!m_params.name.IsEmpty() && ftypes::IsRailwaySubwayEntranceChecker::Instance()(types))
223 {
224 StringUtf8Multilang nameWithRef;
225 m_params.name.ForEach([&nameWithRef, this](int8_t code, std::string_view name)
226 { nameWithRef.AddString(code, std::string(name) + " (" + m_params.ref + ")"); });
227 m_params.name = std::move(nameWithRef);
228 }
229 else if (ftypes::IsEmergencyAccessPointChecker::Instance()(types))
230 {
231 m_params.name.Clear();

Callers

nothing calls this directly

Calls 15

LooksLikeHouseNumberFunction · 0.85
GetTypesFunction · 0.85
IsRoadFunction · 0.85
SetDefaultNameIfEmptyMethod · 0.80
SetGeomTypePointExMethod · 0.80
IsValidMethod · 0.45
IsEmptyMethod · 0.45
GetMethod · 0.45
ClearMethod · 0.45
GetGeomTypeMethod · 0.45
emptyMethod · 0.45
HasStringMethod · 0.45

Tested by

no test coverage detected