Skip to content

Commit

Permalink
fix some remaining bugs with XMLSource
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickbr committed Nov 11, 2024
1 parent 4ffa3da commit ffd478d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
14 changes: 0 additions & 14 deletions src/pfaedle/osm/OsmBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,12 @@ void OsmBuilder::read(const std::string& path, const OsmReadOpts& opts,
// * have been used in a way in pass 3

LOG(DEBUG) << "Reading bounding box nodes...";
skipUntil(&xml, "node");
pfxml::parser_state nodeBeg = xml.state();
// pfxml::parser_state edgesBeg =
// readBBoxNds(source, &bboxNodes, &noHupNodes, filter, bbox);
readBBoxNds(source, &bboxNodes, &noHupNodes, filter, bbox);

LOG(DEBUG) << "Reading relations...";
// skipUntil(&xml, "relation");
readRels(source, &intmRels, &nodeRels, &wayRels, filter, attrKeys[2],
&rawRests);

Expand All @@ -125,7 +123,6 @@ void OsmBuilder::read(const std::string& path, const OsmReadOpts& opts,
opts);

LOG(DEBUG) << "Reading kept nodes...";
xml.set_state(nodeBeg);
readNodes(source, g, intmRels, nodeRels, filter, bboxNodes, &nodes,
&multNodes, &orphanStations, attrKeys[0], intmRels.flat, opts);
}
Expand Down Expand Up @@ -343,8 +340,6 @@ void OsmBuilder::filterWrite(const std::string& in, const std::string& out,
BBoxIdx latLngBox = box;

if (latLngBox.size() == 0) {
skipUntil(&xml, "bounds");

const pfxml::tag& cur = xml.get();

if (strcmp(cur.name, "bounds") != 0) {
Expand Down Expand Up @@ -408,8 +403,6 @@ void OsmBuilder::filterWrite(const std::string& in, const std::string& out,
filter = filter.merge(OsmFilter(o.keepFilter, o.dropFilter));
}

skipUntil(&xml, "node");
pfxml::parser_state nodeBeg = xml.state();
readBBoxNds(source, &bboxNodes, &noHupNodes, filter, latLngBox);

readRels(source, &rels, &nodeRels, &wayRels, filter, attrKeys[2], &rests);
Expand All @@ -422,7 +415,6 @@ void OsmBuilder::filterWrite(const std::string& in, const std::string& out,
readWriteWays(source, &wr, &ways, attrKeys[1]);

std::sort(ways.begin(), ways.end());
// skipUntil(&xml, "relation");
readWriteRels(source, &wr, &ways, &nodes, filter, attrKeys[2]);

wr.closeTags();
Expand Down Expand Up @@ -602,12 +594,6 @@ OsmWay OsmBuilder::nextWayWithId(OsmSource* source, osmid wid,
return OsmWay();
}

// _____________________________________________________________________________
void OsmBuilder::skipUntil(pfxml::file* xml, const std::string& s) const {
while (xml->next() && strcmp(xml->get().name, s.c_str())) {
}
}

// _____________________________________________________________________________
bool OsmBuilder::relKeep(osmid id, const RelMap& rels,
const FlatRels& fl) const {
Expand Down
2 changes: 0 additions & 2 deletions src/pfaedle/osm/OsmBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ class OsmBuilder {

void getKeptAttrKeys(const OsmReadOpts& opts, AttrKeySet sets[3]) const;

void skipUntil(pfxml::file* xml, const std::string& s) const;

void processRestr(osmid nid, osmid wid, const Restrictions& rawRests, Edge* e,
Node* n, Restrictor* restor) const;

Expand Down
8 changes: 6 additions & 2 deletions src/pfaedle/osm/source/XMLSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,19 @@ const OsmSourceNode* XMLSource::nextNode() {
// _____________________________________________________________________________
void XMLSource::seekNodes() {
_xml.reset();
while (_xml.next() && strcmp(_xml.get().name, "node")) {}
}

// _____________________________________________________________________________
void XMLSource::seekWays() {
_xml.reset();
while (_xml.next() && strcmp(_xml.get().name, "way")) {}
}

// _____________________________________________________________________________
void XMLSource::seekRels() {
_xml.reset();
while (_xml.next() && strcmp(_xml.get().name, "relation")) {}
}

// _____________________________________________________________________________
Expand Down Expand Up @@ -92,9 +95,10 @@ const OsmSourceRelationMember* XMLSource::nextMember() {
if (strcmp(cur.name, "member") == 0) {
_curMember.id = util::atoul(cur.attr("ref"));
_curMember.type = 0;
if (strcmp(cur.attr("ref"), "way") == 0) _curMember.type = 1;
else if (strcmp(cur.attr("ref"), "relation") == 0) _curMember.type = 2;
if (strcmp(cur.attr("type"), "way") == 0) _curMember.type = 1;
else if (strcmp(cur.attr("type"), "relation") == 0) _curMember.type = 2;
_curMember.role = cur.attr("role");
if (!_curMember.role) _curMember.role = "";
return &_curMember;
} else {
return 0;
Expand Down

0 comments on commit ffd478d

Please sign in to comment.