diff --git a/src/pfaedle/osm/OsmBuilder.cpp b/src/pfaedle/osm/OsmBuilder.cpp index 1fe0159..5f31291 100644 --- a/src/pfaedle/osm/OsmBuilder.cpp +++ b/src/pfaedle/osm/OsmBuilder.cpp @@ -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); @@ -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); } @@ -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) { @@ -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); @@ -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(); @@ -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 { diff --git a/src/pfaedle/osm/OsmBuilder.h b/src/pfaedle/osm/OsmBuilder.h index e25de70..60728ed 100644 --- a/src/pfaedle/osm/OsmBuilder.h +++ b/src/pfaedle/osm/OsmBuilder.h @@ -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; diff --git a/src/pfaedle/osm/source/XMLSource.cpp b/src/pfaedle/osm/source/XMLSource.cpp index fc08930..23ade0d 100644 --- a/src/pfaedle/osm/source/XMLSource.cpp +++ b/src/pfaedle/osm/source/XMLSource.cpp @@ -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")) {} } // _____________________________________________________________________________ @@ -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;