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

Function ParseLine

generator/address_parser/tiger_parser.cpp:66–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66bool ParseLine(std::string_view line, AddressEntry & e)
67{
68 // from;to;interpolation;street;city;state;postcode;geometry
69
70 // Basic check.
71 if (std::count(line.begin(), line.end(), ';') != 7)
72 return false;
73
74 TokenizeIterator<SimpleDelimiter, std::string_view::const_iterator, true /* KeepEmptyTokens */> it(line.begin(),
75 line.end(), ";");
76
77 e.m_from = *it;
78 ++it;
79 e.m_to = *it;
80 ++it;
81 e.m_interpol = ParseInterpolation(*it);
82 ++it;
83 e.m_street = *it;
84 ++it;
85 ++it;
86 ++it;
87 e.m_postcode = *it;
88 ++it;
89 ParseGeometry(*it, e.m_geom);
90
91 if (e.m_interpol == feature::InterpolType::None || e.m_geom.empty())
92 return false;
93
94 // Check and order house numbers.
95 auto const range = e.GetHNRange();
96 if (range == AddressEntry::kInvalidRange)
97 return false;
98
99 if (range.second < range.first)
100 {
101 std::swap(e.m_from, e.m_to);
102 std::reverse(e.m_geom.begin(), e.m_geom.end());
103 }
104
105 return true;
106}
107
108} // namespace tiger
109

Callers 2

RunMethod · 0.85
UNIT_TESTFunction · 0.85

Calls 8

countFunction · 0.85
ParseInterpolationFunction · 0.85
ParseGeometryFunction · 0.85
GetHNRangeMethod · 0.80
swapFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.68