only fail if not sort-in succeeded at all

This commit is contained in:
Patrick Brosi 2019-01-14 19:37:50 +01:00 committed by Patrick Brosi
parent 7835242cb8
commit 8fb21919f3

View file

@ -168,10 +168,11 @@ void OsmBuilder::read(const std::string& path, const OsmReadOpts& opts,
std::vector<const Stop*> notSnapped; std::vector<const Stop*> notSnapped;
for (size_t i = 0; i < opts.maxSnapDistances.size(); i++) { for (auto& s : *fs) {
double d = opts.maxSnapDistances[i]; bool snapped = false;
for (auto& s : *fs) { auto pl = plFromGtfs(s.first, opts);
auto pl = plFromGtfs(s.first, opts); for (size_t i = 0; i < opts.maxSnapDistances.size(); i++) {
double d = opts.maxSnapDistances[i];
StatGroup* group = groupStats( StatGroup* group = groupStats(
snapStation(g, &pl, &eg, &sng, opts, res, snapStation(g, &pl, &eg, &sng, opts, res,
@ -180,14 +181,16 @@ void OsmBuilder::read(const std::string& path, const OsmReadOpts& opts,
if (group) { if (group) {
group->addStop(s.first); group->addStop(s.first);
(*fs)[s.first] = *group->getNodes().begin(); (*fs)[s.first] = *group->getNodes().begin();
} else if (i == opts.maxSnapDistances.size() - 1) { snapped = true;
LOG(VDEBUG) << "Could not snap station "
<< "(" << pl.getSI()->getName() << ")"
<< " (" << s.first->getLat() << "," << s.first->getLng()
<< ") in normal run, trying again later in orphan mode.";
notSnapped.push_back(s.first);
} }
} }
if (!snapped) {
LOG(VDEBUG) << "Could not snap station "
<< "(" << pl.getSI()->getName() << ")"
<< " (" << s.first->getLat() << "," << s.first->getLng()
<< ") in normal run, trying again later in orphan mode.";
notSnapped.push_back(s.first);
}
} }
if (notSnapped.size()) if (notSnapped.size())
@ -197,10 +200,11 @@ void OsmBuilder::read(const std::string& path, const OsmReadOpts& opts,
// try again, but aggressively snap to orphan OSM stations which have // try again, but aggressively snap to orphan OSM stations which have
// not been assigned to any GTFS stop yet // not been assigned to any GTFS stop yet
for (size_t i = 0; i < opts.maxSnapDistances.size(); i++) { for (auto& s : notSnapped) {
double d = opts.maxSnapDistances[i]; bool snapped = false;
for (auto& s : notSnapped) { auto pl = plFromGtfs(s, opts);
auto pl = plFromGtfs(s, opts); for (size_t i = 0; i < opts.maxSnapDistances.size(); i++) {
double d = opts.maxSnapDistances[i];
StatGroup* group = groupStats( StatGroup* group = groupStats(
snapStation(g, &pl, &eg, &sng, opts, res, snapStation(g, &pl, &eg, &sng, opts, res,
@ -215,23 +219,24 @@ void OsmBuilder::read(const std::string& path, const OsmReadOpts& opts,
n->pl().getSI()->addAltName(pl.getSI()->getName()); n->pl().getSI()->addAltName(pl.getSI()->getName());
} }
(*fs)[s] = *group->getNodes().begin(); (*fs)[s] = *group->getNodes().begin();
} else if (i == snapped = true;
opts.maxSnapDistances.size() - 1) { // only fail on last
// finally give up
// add a group with only this stop in it
StatGroup* dummyGroup = new StatGroup();
Node* dummyNode = g->addNd(pl);
dummyNode->pl().getSI()->setGroup(dummyGroup);
dummyGroup->addNode(dummyNode);
dummyGroup->addStop(s);
(*fs)[s] = dummyNode;
LOG(WARN) << "Could not snap station "
<< "(" << pl.getSI()->getName() << ")"
<< " (" << s->getLat() << "," << s->getLng() << ")";
} }
} }
if (!snapped) {
// finally give up
// add a group with only this stop in it
StatGroup* dummyGroup = new StatGroup();
Node* dummyNode = g->addNd(pl);
dummyNode->pl().getSI()->setGroup(dummyGroup);
dummyGroup->addNode(dummyNode);
dummyGroup->addStop(s);
(*fs)[s] = dummyNode;
LOG(WARN) << "Could not snap station "
<< "(" << pl.getSI()->getName() << ")"
<< " (" << s->getLat() << "," << s->getLng() << ")";
}
} }
} }
@ -299,7 +304,7 @@ void OsmBuilder::overpassQryWrite(std::ostream* out,
wr.writeText(" - written by pfaedle -"); wr.writeText(" - written by pfaedle -");
wr.closeTag(); wr.closeTag();
wr.openTag("osm-script", wr.openTag("osm-script",
{{"timeout", "99999"}, {"element-limit", "1073741824"}}); {{"timeout", "99999"}, {"element-limit", "2073741824"}});
OsmFilter filter; OsmFilter filter;