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

Method ParseRestrictions

generator/restriction_collector.cpp:77–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77bool RestrictionCollector::ParseRestrictions(std::string const & path)
78{
79 std::ifstream stream(path);
80 if (stream.fail())
81 return false;
82
83 std::string line;
84 while (std::getline(stream, line))
85 {
86 strings::SimpleTokenizer iter(line, ", \t\r\n");
87 if (!iter) // the line is empty
88 return false;
89
90 Restriction::Type restrictionType;
91 auto viaType = RestrictionWriter::ViaType::Count;
92 FromString(*iter, restrictionType);
93 ++iter;
94
95 FromString(*iter, viaType);
96 ++iter;
97
98 m2::PointD coords = kNoCoords;
99 if (viaType == RestrictionWriter::ViaType::Node)
100 {
101 FromString(*iter, coords.x);
102 ++iter;
103 FromString(*iter, coords.y);
104 ++iter;
105 }
106
107 std::vector<base::GeoObjectId> osmIds;
108 if (!ParseLineOfWayIds(iter, osmIds))
109 {
110 LOG(LWARNING, ("Cannot parse osm ids from", path));
111 return false;
112 }
113
114 if (viaType == RestrictionWriter::ViaType::Node)
115 CHECK_EQUAL(osmIds.size(), 2, ("Only |from| and |to| osmId."));
116
117 CHECK_NOT_EQUAL(viaType, RestrictionWriter::ViaType::Count, ());
118 AddRestriction(coords, restrictionType, osmIds);
119 }
120 return true;
121}
122
123Joint::Id RestrictionCollector::GetFirstCommonJoint(uint32_t firstFeatureId, uint32_t secondFeatureId) const
124{

Callers

nothing calls this directly

Calls 3

ParseLineOfWayIdsFunction · 0.85
FromStringFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected