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

Method Update

generator/addresses_collector.cpp:89–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89bool AddressesHolder::Update(feature::FeatureBuilder & fb) const
90{
91 uint64_t const id = GetOsmID(fb);
92 auto const i = m_addresses.find(id);
93 if (i == m_addresses.end())
94 return false;
95
96 // Get existing params (street, postcode).
97 auto const info = FromFB(fb);
98 auto & params = fb.GetParams();
99
100 // Force update ref as house's range.
101 if (!params.ref.empty())
102 LogWarning("Ref is not empty", id);
103
104 params.ref = i->second.FormatRange();
105 if (params.ref.empty())
106 {
107 LogWarning("Invalid range", id);
108 return false;
109 }
110
111 // Update from saved params if needed (prefer existing).
112 if (!i->second.m_street.empty() && i->second.m_street != info.m_street)
113 {
114 if (!info.m_street.empty())
115 LogWarning("Different streets", id);
116 else
117 params.SetStreet(i->second.m_street);
118 }
119
120 /// @todo I suspect that we should skip these features because of possible valid 3party addresses.
121 /// 28561 entries for now.
122 if (params.GetStreet().empty())
123 LogWarning("Empty street", id);
124
125 if (!i->second.m_postcode.empty() && i->second.m_postcode != info.m_postcode)
126 {
127 if (!info.m_postcode.empty())
128 LogWarning("Different postcodes", id);
129 else
130 params.SetPostcode(i->second.m_postcode);
131 }
132
133 return true;
134}
135
136void AddressesHolder::MergeInto(AddressesHolder & holder) const
137{

Callers 1

ProcessRoundaboutsMethod · 0.45

Calls 11

GetOsmIDFunction · 0.85
FromFBFunction · 0.85
LogWarningFunction · 0.85
GetParamsMethod · 0.80
FormatRangeMethod · 0.80
findMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
SetStreetMethod · 0.45
GetStreetMethod · 0.45
SetPostcodeMethod · 0.45

Tested by

no test coverage detected